-
Notifications
You must be signed in to change notification settings - Fork 157
Span link support #2623
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
Open
jasonjkeller
wants to merge
16
commits into
saxon/replace-otel-spans2
Choose a base branch
from
span-link-support
base: saxon/replace-otel-spans2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Span link support #2623
+1,291
−108
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #2426
Adds support for OpenTelemetry SpanLinks.
Test suite run: https://github.com/newrelic/newrelic-java-agent/actions/runs/20048117460
Result Of PR
The end result of this PR is that the
span_event_datacollector payload will now consist of events oftype: Spanandtype: SpanLink. The backend processing pipeline will synthesizeSpanandSpanLinkNRDB events from this data, both of which play a part in the distributed tracing experience.Backward link to upstream trace:

Forward link to downstream traces:

How It Works
There are two new methods added to the bridge version of the
TracedMethodinterface (these aren't available via the public API). These APIs will be implemented on variousTracers (e.g.DefaultTracer). The general idea is that when we intercept an OTel span it triggers the creation of aTracer, which we now can save allSpanLinkson. When the transaction finishes, allTracers will be converted into New RelicSpans with any links stored on them. When we harvest all of theSpans that have been sampled, we then separate theSpans andSpanLinks in the JSON wire format.Example Collector Payload
Example
span_event_datapayload withSpanandSpanLinkevents:[ "BR2dwSrqzp...", { "reservoir_size": 2000, "events_seen": 112 }, [ [ { "traceId": "ff45b399d2cc2e6a7a21eb2aec22876a", "type": "Span", "priority": 1.554158, "transactionId": "6b7749a155ded6f3", "nr.entryPoint": true, "duration": 1.0056225, "name": "Java\/org.example.otel.apis.TraceAPI\/upstreamSpan", "guid": "2a798d1cc2a6f5c9", "transaction.name": "OtherTransaction\/Custom\/org.example.otel.apis.TraceAPI\/upstreamSpan", "category": "generic", "sampled": true, "thread.id": 1, "timestamp": 1765215786794 }, {}, { "code.namespace": "org.example.otel.apis.TraceAPI", "jvm.thread_name": "main", "code.function": "upstreamSpan", "parent.transportType": "Unknown" } ], [ { "traceId": "ff45b399d2cc2e6a7a21eb2aec22876a", "duration": 1.0053169, "name": "Span\/upstreamSpan", "guid": "d31fdbc473f24309", "type": "Span", "category": "generic", "priority": 1.554158, "sampled": true, "thread.id": 1, "parentId": "2a798d1cc2a6f5c9", "transactionId": "6b7749a155ded6f3", "timestamp": 1765215786794 }, { "otel.library.name": "opentelemetry-trace-api-demo", "telemetry.sdk.language": "java", "otel.scope.name": "opentelemetry-trace-api-demo", "service.instance.id": "39296d81-39f0-4ab0-a2e4-e32c474b35f4", "service.name": "opentelemetry-api-bridge", "entity.guid": "OTk4...", "otel.library.version": "1.0.0", "otel.scope.version": "1.0.0", "telemetry.sdk.version": "1.54.1", "telemetry.sdk.name": "opentelemetry" }, {} ], [ { "traceId": "aded5822728fa2222c42617e88963c41", "type": "Span", "priority": 1.00045, "transactionId": "63c01b231342b7be", "nr.entryPoint": true, "duration": 1.0031127, "name": "Java\/org.example.otel.apis.TraceAPI\/downstreamSpan", "guid": "f512c29191b11bf8", "transaction.name": "OtherTransaction\/Custom\/org.example.otel.apis.TraceAPI\/downstreamSpan", "category": "generic", "sampled": true, "thread.id": 1, "timestamp": 1765215798899 }, {}, { "code.namespace": "org.example.otel.apis.TraceAPI", "jvm.thread_name": "main", "code.function": "downstreamSpan", "parent.transportType": "Unknown" } ], [ { "traceId": "aded5822728fa2222c42617e88963c41", "duration": 1.002681, "name": "Span\/downstreamSpan", "guid": "fbdea73443823fec", "type": "Span", "category": "generic", "priority": 1.00045, "sampled": true, "thread.id": 1, "parentId": "f512c29191b11bf8", "transactionId": "63c01b231342b7be", "timestamp": 1765215798899 }, { "otel.library.name": "opentelemetry-trace-api-demo", "telemetry.sdk.language": "java", "otel.scope.name": "opentelemetry-trace-api-demo", "service.instance.id": "39296d81-39f0-4ab0-a2e4-e32c474b35f4", "service.name": "opentelemetry-api-bridge", "entity.guid": "OTk4...", "otel.library.version": "1.0.0", "otel.scope.version": "1.0.0", "telemetry.sdk.version": "1.54.1", "telemetry.sdk.name": "opentelemetry" }, {} ], [ { "trace.id": "aded5822728fa2222c42617e88963c41", "linkedSpanId": "d31fdbc473f24309", "id": "fbdea73443823fec", "type": "SpanLink", "linkedTraceId": "ff45b399d2cc2e6a7a21eb2aec22876a", "timestamp": 1765215798899 }, { "customLinkAttribute": "someValue", "iteration": 11 }, {} ] ] ]