Merged
Conversation
sdaubin
commented
May 7, 2024
|
|
||
| ExitTracer createScalaTxnTracer(); | ||
|
|
||
| default ExitTracer createTracer(String metricName, int flags) { |
Contributor
Author
There was a problem hiding this comment.
The createSegment API still generates an asynchronous tracer, which is not what we want. And from the bridge there's no easy way to register a signature to get a signatureId. This was the easiest way to get a normal, synchronous tracer.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1886 +/- ##
============================================
- Coverage 70.83% 70.33% -0.50%
+ Complexity 10838 10197 -641
============================================
Files 866 863 -3
Lines 43863 41437 -2426
Branches 6910 6276 -634
============================================
- Hits 31069 29144 -1925
+ Misses 9862 9439 -423
+ Partials 2932 2854 -78 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jasonjkeller
previously approved these changes
Jul 2, 2024
This comment was marked as outdated.
This comment was marked as outdated.
This was referenced Sep 23, 2024
…axon/replace-otel-spans2
…axon/replace-otel-spans2
Span link support
…axon/replace-otel-spans2
Span event support
…axon/replace-otel-spans2
Attribute mappings refactored to a String constant
jasonjkeller
approved these changes
Jan 20, 2026
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.
OpenTelemetry Instrumentation
This instrumentation module instruments parts of the OpenTelemetry SDK in order to incorporate signals (metrics, logs, and traces) emitted by OpenTelemetry APIs into the New Relic Java agent.
The following functionality is supported:
OpenTelemetry Traces Signals
Spans are emitted by OpenTelemetry APIs and incorporate them to New Relic Java agent traces.SpanLinkevents.SpanEventevents.OpenTelemetry Dimensional Metrics Signals
OpenTelemetry Logs Signals
LogRecords are emitted by OpenTelemetry APIs report them to the APM entity being monitored by the Java agent as New Relic LogEvents.OpenTelemetry Requirements
The opentelemetry-sdk-extension-autoconfigure dependency (version 1.28.0 or later) must be present in the application being monitored for this instrumentation module to apply. The opentelemetry-exporter-otlp dependency (version 1.28.0 or later) must also be present for dimensional metrics to be exported to New Relic.
Additionally, automatic configuration of the OpenTelemetry SDK must be enabled by one of the following options:
System property:
Environment variable:
Programmatic:
New Relic Java Agent Configuration
Telemetry signals (Logs, Metrics, and Traces) emitted by OpenTelemetry APIs can be incorporated into the Java agent and controlled by the following config options.
Configuration via YAML:
Configuration via system property:
Configuration via environment variable:
Deprecated Config
The following deprecated config option should no longer be used and is only kept for backwards compatibility.
This config was originally used to enable/disable metrics signals and has been replaced by
opentelemetry.metrics.enabled:OpenTelemetry Dimensional Metrics Signals
The OpenTelemetry Metrics API can be used to create dimensional metrics which will be exported by the OpenTelemetry SDK to New Relic over OTLP. The dimensional metrics will be decorated with the
entity.guidof the APM entity being monitored by the New Relic Java agent.Example of OpenTelemetry APIs being used to record dimensional metrics:
Any recorded dimensional metrics can be found in the Metrics Explorer for the associated APM entity and can be used to build custom dashboards.
OpenTelemetry Traces Signals
Documented below are several approaches for incorporating OpenTelemetry Traces (aka Spans) into New Relic Java agent traces.
@WithSpanAnnotationThe New Relic Java agent will detect usage of the OpenTelemetry @WithSpan annotation. The
@WithSpanannotation can be used as an alternative to the@Traceannotation.This does not currently support the following config options:
Note that OpenTelemetry config properties can be set through environment or system properties, like our agent, and eventually through a config file. We can use
our existing OpenTelemetry instrumentation model to get access to the normalized version of the instrumentation settings to include and exclude methods and pass
those to the core agent through the bridge.
See
ClassTransformerConfigImpl.javafor implementation details of the@WithSpanannotation.Spans Emitted From OpenTelemetry Tracing API
The New Relic Java agent will detect Spans emitted by the OpenTelemetry Tracing API for most manual, library, and native instrumentation types and incorporate them into New Relic traces.
It does this by weaving the
io.opentelemetry.sdk.trace.SdkTracerProviderso that it will create a New Relic Tracer each time an OpenTelemetry Span is started andweaving the
io.opentelemetry.context.Contextto propagate context between New Relic and OpenTelemetry Spans.Translating OpenTelemetry SpanKinds To The New Relic Span Data Model
Depending on the OpenTelemetry Span
SpanKind, it may result in the New Relic Java agent starting a transaction (when one doesn't already exist). Also see attribute-mappings.json for the complete attribute mapping rules.SpanKind.INTERNALSpanKind, which defaults toSpanKind.INTERNAL, will not start a transactionSpanKind.INTERNALspans occur within an already existing New Relic transaction they will be included in the traceSpanKind.CLIENTSpanKind.CLIENTwill not start a transaction. If aCLIENTspan has certain db attributes it will be treated as a DB span, andother specific attributes will cause it to be treated as an external span
SpanKind.CLIENTspans occur within an already existing New Relic transaction they will be included in the traceSpanKind.SERVERSpanKind.SERVERwill start aWebTransaction/Uri/*transaction.SpanKind.SERVERspans occur within an already existing New Relic transaction they will be included in the traceSpanKind.CONSUMERSpanKind.CONSUMERwill start aOtherTransaction/*transaction.SpanKind.CONSUMERspans occur within an already existing New Relic transaction they will be included in the traceSpanKind.PRODUCERSpanKind.PRODUCERwill not start a transaction. There is no explicit processing forPRODUCERspans currently.SpanKind.PRODUCERspans occur within an already existing New Relic transaction they will be included in the trace (though it's effectively nodifferent from a
SpanKind.INTERNALspan)Span Links From OpenTelemetry Tracing API
When processing OpenTelemetry Spans, any Links associated with Spans will be captured and reported to New Relic as
SpanLinkevents, which enhance the distributed tracing experience by providing backwards and forwards links between Spans from different traces.SpanLinkevents are included in thespan_event_datacollector payload and do not have their own event sampling reservoir.Example of adding
Links via the OpenTelemetry Traces APIs:Span Events From OpenTelemetry Tracing API
When processing OpenTelemetry Spans, any Events associated with Spans will be captured and reported to New Relic as
SpanEventevents, which enhance the distributed tracing experience by providing log-like records that add extra details about what happened within a Span's execution.SpanEventevents are included in thespan_event_datacollector payload and do not have their own event sampling reservoir.Example of adding
Events via the OpenTelemetry Traces APIs. Note thatrecordExceptionis a specialized variant ofaddEventfor recording exception events:OpenTelemetry Logs Signals
The New Relic Java agent will detect LogRecords emitted by the OpenTelemetry Logs API and incorporate them into New Relic log events associated with the APM entity being monitored. The logs will be associated with a New Relic transaction if the logging occurred within one.
Note: It is recommended that OpenTelemetry instrumentation for a particular logging framework (e.g. Logback, Log4j) should not be used alongside New Relic Java agent instrumentation for the same logging framework. Doing so could result in duplicate log events being reported to New Relic.
Example usage of OpenTelemetry Logs APIs: