@Test public void testEndpointWithNullServiceName() { Endpoint.Builder serverEndpointBuilder = Endpoint.newBuilder().port(80); Endpoint serverEndpoint = serverEndpointBuilder.build(); Span serverSpan = Span.newBuilder() .kind(Kind.SERVER) .traceId("4") .name("test-span") .id("5") .localEndpoint(serverEndpoint) .build(); AttributesExtractor extractor = new AttributesExtractor(Collections.emptyMap()); Map<String, AttributeValue> serverLabels = extractor.extract(serverSpan).getAttributeMapMap(); assertThat(serverLabels).doesNotContainKey("endpoint.serviceName"); }
Attributes extract(Span zipkinSpan) { Attributes.Builder attributes = Attributes.newBuilder(); if (zipkinSpan.kind() != null) { attributes.putAttributeMap(kKindLabelKey, toAttributeValue(kindLabel(zipkinSpan.kind()))); } for (Map.Entry<String, String> tag : zipkinSpan.tags().entrySet()) { attributes.putAttributeMap(getLabelName(tag.getKey()), toAttributeValue(tag.getValue())); } if (zipkinSpan.localEndpoint() != null && zipkinSpan.kind() == Span.Kind.SERVER) { if (zipkinSpan.localEndpoint().ipv4() != null) { attributes.putAttributeMap( getLabelName("endpoint.ipv4"), toAttributeValue(zipkinSpan.localEndpoint().ipv4())); } if (zipkinSpan.localEndpoint().ipv6() != null) { attributes.putAttributeMap( getLabelName("endpoint.ipv6"), toAttributeValue(zipkinSpan.localEndpoint().ipv6())); } } if (zipkinSpan.localEndpoint() != null && zipkinSpan.localEndpoint().serviceName() != null && !zipkinSpan.localEndpoint().serviceName().isEmpty()) { attributes.putAttributeMap( kComponentLabelKey, toAttributeValue(zipkinSpan.localEndpoint().serviceName())); } if (zipkinSpan.parentId() == null) { String agentName = System.getProperty("stackdriver.trace.zipkin.agent", "zipkin-java"); attributes.putAttributeMap(kAgentLabelKey, toAttributeValue(agentName)); } return attributes.build(); }
AttributesExtractor { Attributes extract(Span zipkinSpan) { Attributes.Builder attributes = Attributes.newBuilder(); if (zipkinSpan.kind() != null) { attributes.putAttributeMap(kKindLabelKey, toAttributeValue(kindLabel(zipkinSpan.kind()))); } for (Map.Entry<String, String> tag : zipkinSpan.tags().entrySet()) { attributes.putAttributeMap(getLabelName(tag.getKey()), toAttributeValue(tag.getValue())); } if (zipkinSpan.localEndpoint() != null && zipkinSpan.kind() == Span.Kind.SERVER) { if (zipkinSpan.localEndpoint().ipv4() != null) { attributes.putAttributeMap( getLabelName("endpoint.ipv4"), toAttributeValue(zipkinSpan.localEndpoint().ipv4())); } if (zipkinSpan.localEndpoint().ipv6() != null) { attributes.putAttributeMap( getLabelName("endpoint.ipv6"), toAttributeValue(zipkinSpan.localEndpoint().ipv6())); } } if (zipkinSpan.localEndpoint() != null && zipkinSpan.localEndpoint().serviceName() != null && !zipkinSpan.localEndpoint().serviceName().isEmpty()) { attributes.putAttributeMap( kComponentLabelKey, toAttributeValue(zipkinSpan.localEndpoint().serviceName())); } if (zipkinSpan.parentId() == null) { String agentName = System.getProperty("stackdriver.trace.zipkin.agent", "zipkin-java"); attributes.putAttributeMap(kAgentLabelKey, toAttributeValue(agentName)); } return attributes.build(); } }
AttributesExtractor { Attributes extract(Span zipkinSpan) { Attributes.Builder attributes = Attributes.newBuilder(); if (zipkinSpan.kind() != null) { attributes.putAttributeMap(kKindLabelKey, toAttributeValue(kindLabel(zipkinSpan.kind()))); } for (Map.Entry<String, String> tag : zipkinSpan.tags().entrySet()) { attributes.putAttributeMap(getLabelName(tag.getKey()), toAttributeValue(tag.getValue())); } if (zipkinSpan.localEndpoint() != null && zipkinSpan.kind() == Span.Kind.SERVER) { if (zipkinSpan.localEndpoint().ipv4() != null) { attributes.putAttributeMap( getLabelName("endpoint.ipv4"), toAttributeValue(zipkinSpan.localEndpoint().ipv4())); } if (zipkinSpan.localEndpoint().ipv6() != null) { attributes.putAttributeMap( getLabelName("endpoint.ipv6"), toAttributeValue(zipkinSpan.localEndpoint().ipv6())); } } if (zipkinSpan.localEndpoint() != null && zipkinSpan.localEndpoint().serviceName() != null && !zipkinSpan.localEndpoint().serviceName().isEmpty()) { attributes.putAttributeMap( kComponentLabelKey, toAttributeValue(zipkinSpan.localEndpoint().serviceName())); } if (zipkinSpan.parentId() == null) { String agentName = System.getProperty("stackdriver.trace.zipkin.agent", "zipkin-java"); attributes.putAttributeMap(kAgentLabelKey, toAttributeValue(agentName)); } return attributes.build(); } AttributesExtractor(Map<String, String> renamedLabels); }
AttributesExtractor { Attributes extract(Span zipkinSpan) { Attributes.Builder attributes = Attributes.newBuilder(); if (zipkinSpan.kind() != null) { attributes.putAttributeMap(kKindLabelKey, toAttributeValue(kindLabel(zipkinSpan.kind()))); } for (Map.Entry<String, String> tag : zipkinSpan.tags().entrySet()) { attributes.putAttributeMap(getLabelName(tag.getKey()), toAttributeValue(tag.getValue())); } if (zipkinSpan.localEndpoint() != null && zipkinSpan.kind() == Span.Kind.SERVER) { if (zipkinSpan.localEndpoint().ipv4() != null) { attributes.putAttributeMap( getLabelName("endpoint.ipv4"), toAttributeValue(zipkinSpan.localEndpoint().ipv4())); } if (zipkinSpan.localEndpoint().ipv6() != null) { attributes.putAttributeMap( getLabelName("endpoint.ipv6"), toAttributeValue(zipkinSpan.localEndpoint().ipv6())); } } if (zipkinSpan.localEndpoint() != null && zipkinSpan.localEndpoint().serviceName() != null && !zipkinSpan.localEndpoint().serviceName().isEmpty()) { attributes.putAttributeMap( kComponentLabelKey, toAttributeValue(zipkinSpan.localEndpoint().serviceName())); } if (zipkinSpan.parentId() == null) { String agentName = System.getProperty("stackdriver.trace.zipkin.agent", "zipkin-java"); attributes.putAttributeMap(kAgentLabelKey, toAttributeValue(agentName)); } return attributes.build(); } AttributesExtractor(Map<String, String> renamedLabels);  }
AttributesExtractor { Attributes extract(Span zipkinSpan) { Attributes.Builder attributes = Attributes.newBuilder(); if (zipkinSpan.kind() != null) { attributes.putAttributeMap(kKindLabelKey, toAttributeValue(kindLabel(zipkinSpan.kind()))); } for (Map.Entry<String, String> tag : zipkinSpan.tags().entrySet()) { attributes.putAttributeMap(getLabelName(tag.getKey()), toAttributeValue(tag.getValue())); } if (zipkinSpan.localEndpoint() != null && zipkinSpan.kind() == Span.Kind.SERVER) { if (zipkinSpan.localEndpoint().ipv4() != null) { attributes.putAttributeMap( getLabelName("endpoint.ipv4"), toAttributeValue(zipkinSpan.localEndpoint().ipv4())); } if (zipkinSpan.localEndpoint().ipv6() != null) { attributes.putAttributeMap( getLabelName("endpoint.ipv6"), toAttributeValue(zipkinSpan.localEndpoint().ipv6())); } } if (zipkinSpan.localEndpoint() != null && zipkinSpan.localEndpoint().serviceName() != null && !zipkinSpan.localEndpoint().serviceName().isEmpty()) { attributes.putAttributeMap( kComponentLabelKey, toAttributeValue(zipkinSpan.localEndpoint().serviceName())); } if (zipkinSpan.parentId() == null) { String agentName = System.getProperty("stackdriver.trace.zipkin.agent", "zipkin-java"); attributes.putAttributeMap(kAgentLabelKey, toAttributeValue(agentName)); } return attributes.build(); } AttributesExtractor(Map<String, String> renamedLabels);   }