-
Notifications
You must be signed in to change notification settings - Fork 1k
Populate Zipkin remoteEndpoint #4933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
5855a24
cddd6a6
53b04a1
9eb08c2
505a7da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,9 @@ | |
| import static io.opentelemetry.exporter.zipkin.ZipkinTestUtil.spanBuilder; | ||
| import static io.opentelemetry.exporter.zipkin.ZipkinTestUtil.zipkinSpan; | ||
| import static io.opentelemetry.exporter.zipkin.ZipkinTestUtil.zipkinSpanBuilder; | ||
| import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_PEER_PORT; | ||
| import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_SOCK_PEER_ADDR; | ||
| import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.PEER_SERVICE; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.mockito.Mockito.mock; | ||
|
|
||
|
|
@@ -135,11 +138,11 @@ void generateSpan_ResourceServiceNameMapping() { | |
| Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, "super-zipkin-service")); | ||
| SpanData data = spanBuilder().setResource(resource).build(); | ||
|
|
||
| Endpoint expectedEndpoint = | ||
| Endpoint expectedLocalEndpoint = | ||
| Endpoint.newBuilder().serviceName("super-zipkin-service").ip(localIp).build(); | ||
| Span expectedZipkinSpan = | ||
| zipkinSpan(Span.Kind.SERVER, localIp).toBuilder() | ||
| .localEndpoint(expectedEndpoint) | ||
| .localEndpoint(expectedLocalEndpoint) | ||
| .putTag(OtelToZipkinSpanTransformer.OTEL_STATUS_CODE, "OK") | ||
| .build(); | ||
| assertThat(transformer.generateSpan(data)).isEqualTo(expectedZipkinSpan); | ||
|
|
@@ -149,19 +152,112 @@ void generateSpan_ResourceServiceNameMapping() { | |
| void generateSpan_defaultResourceServiceName() { | ||
| SpanData data = spanBuilder().setResource(Resource.empty()).build(); | ||
|
|
||
| Endpoint expectedEndpoint = | ||
| Endpoint expectedLocalEndpoint = | ||
| Endpoint.newBuilder() | ||
| .serviceName(Resource.getDefault().getAttribute(ResourceAttributes.SERVICE_NAME)) | ||
| .ip(localIp) | ||
| .build(); | ||
| Span expectedZipkinSpan = | ||
| zipkinSpan(Span.Kind.SERVER, localIp).toBuilder() | ||
| .localEndpoint(expectedEndpoint) | ||
| .localEndpoint(expectedLocalEndpoint) | ||
| .putTag(OtelToZipkinSpanTransformer.OTEL_STATUS_CODE, "OK") | ||
| .build(); | ||
| assertThat(transformer.generateSpan(data)).isEqualTo(expectedZipkinSpan); | ||
| } | ||
|
|
||
| @Test | ||
|
jonatan-ivanov marked this conversation as resolved.
Outdated
|
||
| void generateSpan_RemoteEndpointMapping() { | ||
| Attributes attributes = | ||
| Attributes.builder() | ||
| .put(PEER_SERVICE, "remote-test-service") | ||
| .put(NET_SOCK_PEER_ADDR, "8.8.8.8") | ||
| .put(NET_PEER_PORT, 42L) | ||
| .build(); | ||
|
|
||
| SpanData spanData = | ||
| spanBuilder().setResource(Resource.empty()).setAttributes(attributes).build(); | ||
|
|
||
| Endpoint expectedLocalEndpoint = | ||
| Endpoint.newBuilder() | ||
| .serviceName(Resource.getDefault().getAttribute(ResourceAttributes.SERVICE_NAME)) | ||
| .ip(localIp) | ||
| .build(); | ||
|
|
||
| Endpoint expectedRemoteEndpoint = | ||
| Endpoint.newBuilder().serviceName("remote-test-service").ip("8.8.8.8").port(42).build(); | ||
|
|
||
| Span expectedSpan = | ||
| zipkinSpan(Span.Kind.SERVER, localIp).toBuilder() | ||
| .localEndpoint(expectedLocalEndpoint) | ||
| .remoteEndpoint(expectedRemoteEndpoint) | ||
| .putTag(PEER_SERVICE.getKey(), "remote-test-service") | ||
| .putTag(NET_SOCK_PEER_ADDR.getKey(), "8.8.8.8") | ||
| .putTag(NET_PEER_PORT.getKey(), "42") | ||
|
Comment on lines
+202
to
+205
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bummer that these are kinda redundant (duplicated) now -- they exist both in the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fyi: there will be lots of things to filter out: https://opentelemetry.io/docs/reference/specification/trace/sdk_exporters/zipkin/#otlp---zipkin What happens in this class seems wrong to me (but I guess now it's too late for that); I think the span ( Also, just an fyi: as a user of OTel, I would consider this as a breaking change (a tag will be removed from the span). I'm not sure if doing such a change is even allowed here (maybe it is since semconv is unstable so deleting/renaming attributes and breaking users that way is possible at this point here). Because of these, I think deleting (filtering out) those attributes should happen in a separate issue/pr.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I assume the decision to model fields in map-like structure instead of in top level fields is because it affords more ability to experiment without the consequences of adding a top level field we later wish to remove / rename / or change. This relieves bikeshedding (to some extent anyway 😄). Additionally, since spans can potentially be used to model many many domains, the top level fields could easily get bogged down as more and more top level fields were added.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think I see the intent but doing this will also give a false sense of not introducing a breaking change when this happens. Indeed, source and binary compatibility are kept but unfortunately it is still a breaking change since behavioral compatibility is not. I totally agree with not adding fields for everything (that's what attributes are for) but I also think that this is such a fundamental field that it should be there (like the name of the span or the localEndpoint). I just wanted to call these out, they don't really belong to the scope of this PR.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a "fundamental" field for one type of span, but certainly not universally applicable, which is why it shouldn't be a top level field on the Span, or the SpanData.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess that's why it should be optional/
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're arguing with the wrong crowd here... this would be something that would need to be added in the specification, and not something we would or could unilaterally add to the java APIs.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yepp, that's why I wrote that I think now it's too late for that. |
||
| .putTag(OtelToZipkinSpanTransformer.OTEL_STATUS_CODE, "OK") | ||
| .build(); | ||
|
|
||
| assertThat(transformer.generateSpan(spanData)).isEqualTo(expectedSpan); | ||
| } | ||
|
|
||
| @Test | ||
|
jonatan-ivanov marked this conversation as resolved.
Outdated
|
||
| void generateSpan_RemoteEndpointMappingWhenPortIsMissing() { | ||
| Attributes attributes = | ||
| Attributes.builder() | ||
| .put(PEER_SERVICE, "remote-test-service") | ||
| .put(NET_SOCK_PEER_ADDR, "8.8.8.8") | ||
| .build(); | ||
|
|
||
| SpanData spanData = | ||
| spanBuilder().setResource(Resource.empty()).setAttributes(attributes).build(); | ||
|
|
||
| Endpoint expectedLocalEndpoint = | ||
| Endpoint.newBuilder() | ||
| .serviceName(Resource.getDefault().getAttribute(ResourceAttributes.SERVICE_NAME)) | ||
| .ip(localIp) | ||
| .build(); | ||
|
|
||
| Endpoint expectedRemoteEndpoint = | ||
| Endpoint.newBuilder().serviceName("remote-test-service").ip("8.8.8.8").build(); | ||
|
|
||
| Span expectedSpan = | ||
| zipkinSpan(Span.Kind.SERVER, localIp).toBuilder() | ||
| .localEndpoint(expectedLocalEndpoint) | ||
| .remoteEndpoint(expectedRemoteEndpoint) | ||
| .putTag(PEER_SERVICE.getKey(), "remote-test-service") | ||
| .putTag(NET_SOCK_PEER_ADDR.getKey(), "8.8.8.8") | ||
| .putTag(OtelToZipkinSpanTransformer.OTEL_STATUS_CODE, "OK") | ||
| .build(); | ||
|
|
||
| assertThat(transformer.generateSpan(spanData)).isEqualTo(expectedSpan); | ||
| } | ||
|
|
||
| @Test | ||
| void generateSpan_RemoteEndpointMappingWhenIpAndPortAreMissing() { | ||
| Attributes attributes = Attributes.builder().put(PEER_SERVICE, "remote-test-service").build(); | ||
|
|
||
| SpanData spanData = | ||
| spanBuilder().setResource(Resource.empty()).setAttributes(attributes).build(); | ||
|
|
||
| Endpoint expectedLocalEndpoint = | ||
| Endpoint.newBuilder() | ||
| .serviceName(Resource.getDefault().getAttribute(ResourceAttributes.SERVICE_NAME)) | ||
| .ip(localIp) | ||
| .build(); | ||
|
|
||
| Endpoint expectedRemoteEndpoint = | ||
| Endpoint.newBuilder().serviceName("remote-test-service").build(); | ||
|
|
||
| Span expectedSpan = | ||
| zipkinSpan(Span.Kind.SERVER, localIp).toBuilder() | ||
| .localEndpoint(expectedLocalEndpoint) | ||
| .remoteEndpoint(expectedRemoteEndpoint) | ||
| .putTag(PEER_SERVICE.getKey(), "remote-test-service") | ||
| .putTag(OtelToZipkinSpanTransformer.OTEL_STATUS_CODE, "OK") | ||
| .build(); | ||
|
|
||
| assertThat(transformer.generateSpan(spanData)).isEqualTo(expectedSpan); | ||
| } | ||
|
|
||
| @Test | ||
| void generateSpan_WithAttributes() { | ||
| Attributes attributes = | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.