You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This instrumentation module weaves parts of the OpenTelemetry SDK to incorporate bits of OpenTelemetry functionality into the New Relic Java agent.
3
+
This instrumentation module weaves parts of the OpenTelemetry SDK to incorporate bits of OpenTelemetry functionality into the New Relic Java agent.
4
4
5
-
Specifically it can:
6
-
* Detect OpenTelemetry Spans and include them in New Relic Java agent traces.
5
+
Specifically, it can:
6
+
7
+
* Detect OpenTelemetry Spans and add them to New Relic Java agent traces as New Relic Spans.
8
+
* Detect OpenTelemetry LogRecords and report them as New Relic LogEvents.
7
9
* Detect OpenTelemetry dimensional metrics and report them to the APM entity being monitored by the Java agent.
8
10
* Autoconfigure the OpenTelemetry SDK so that OpenTelemetry data is sent to New Relic and properly associated with an APM entity guid.
9
11
12
+
## OpenTelemetry Configuration
13
+
14
+
To use the OpenTelemetry functionality incorporated into the New Relic Java agent you must enable the following config options:
15
+
16
+
```commandline
17
+
-Dotel.java.global-autoconfigure.enabled=true
18
+
```
19
+
10
20
## New Relic Java Agent Configuration
11
21
12
22
To use the OpenTelemetry Span and dimensional metric functionality incorporated into the New Relic Java agent you must enable the following config options:
OpenTelemetry APIs can be used to create dimensional metrics which will be detected by the New Relic Java agent and reported to the APM entity being monitored by the New Relic Java agent.
66
+
OpenTelemetry APIs can be used to create dimensional metrics which will be detected by the New Relic Java agent and reported to the APM entity being monitored
67
+
by the New Relic Java agent.
39
68
40
69
To use this functionality, enable the feature as documented above, add the required `opentelemetry` dependencies to your application:
Any recorded dimensional metrics can be found in the Metrics Explorer for the associated APM entity and can be used to build custom dashboards.
@@ -58,36 +91,125 @@ Documented below are several approaches for incorporating OpenTelemetry Spans in
58
91
59
92
### `@WithSpan` Annotation
60
93
61
-
The New Relic Java agent will detect usage of the OpenTelemetry [@WithSpan](https://opentelemetry.io/docs/zero-code/java/agent/annotations/) annotation. The `@WithSpan` annotation can be used as an alternative to the `@Trace` annotation.
94
+
The New Relic Java agent will detect usage of the OpenTelemetry [@WithSpan](https://opentelemetry.io/docs/zero-code/java/agent/annotations/) annotation. The
95
+
`@WithSpan` annotation can be used as an alternative to the `@Trace` annotation.
62
96
63
97
This does not currently support the following config options:
*[Creating spans around methods with otel.instrumentation.methods.include](https://opentelemetry.io/docs/zero-code/java/agent/annotations/#creating-spans-around-methods-with-otelinstrumentationmethodsinclude)
66
101
67
-
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.
102
+
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
103
+
our existing OpenTelemetry instrumentation model to get access to the normalized version of the instrumentation settings to include and exclude methods and pass
104
+
those to the core agent through the bridge.
68
105
69
106
See `ClassTransformerConfigImpl.java` for implementation details of the `@WithSpan` annotation.
70
107
71
108
### Spans Emitted From OpenTelemetry Instrumentation
72
109
73
-
The New Relic Java agent will detect Spans emitted by [OpenTelemetry instrumentation](https://opentelemetry.io/docs/languages/java/instrumentation/). It does this by weaving the `io.opentelemetry.sdk.trace.SdkTracerProvider` so that it will create a New Relic Tracer each time an OpenTelemetry Span is started and weaving the `io.opentelemetry.context.Context` to propagate context between New Relic and OpenTelemetry Spans.
110
+
The New Relic Java agent will detect Spans emitted by [OpenTelemetry instrumentation](https://opentelemetry.io/docs/languages/java/instrumentation/). It does
111
+
this by weaving the `io.opentelemetry.sdk.trace.SdkTracerProvider` so that it will create a New Relic Tracer each time an OpenTelemetry Span is started and
112
+
weaving the `io.opentelemetry.context.Context` to propagate context between New Relic and OpenTelemetry Spans.
74
113
75
-
Currently, the New Relic Java agent does not load any OpenTelemetry instrumentation it simply detects Spans emitted by OpenTelemetry manual instrumentation, native instrumentation, library instrumentation, or zero code instrumentation (i.e. bytecode instrumentation that would also require running the OpenTelemetry Java agent).
114
+
Currently, the New Relic Java agent does not load any OpenTelemetry instrumentation it simply detects Spans emitted by OpenTelemetry manual instrumentation,
115
+
native instrumentation, library instrumentation, or zero code instrumentation (i.e. bytecode instrumentation that would also require running the OpenTelemetry
116
+
Java agent).
76
117
77
118
Depending on the OpenTelemetry Span `SpanKind`, it may result in the New Relic Java agent starting a transaction (when one doesn't already exist).
78
119
79
120
*`SpanKind.INTERNAL`
80
-
* Creating a span with no `SpanKind`, which defaults to `SpanKind.INTERNAL`, will not start a transaction
81
-
* If `SpanKind.INTERNAL` spans occur within an already existing New Relic transaction they will be included in the trace
121
+
* Creating a span with no `SpanKind`, which defaults to `SpanKind.INTERNAL`, will not start a transaction
122
+
* If `SpanKind.INTERNAL` spans occur within an already existing New Relic transaction they will be included in the trace
82
123
*`SpanKind.CLIENT`
83
-
* Creating a span with `SpanKind.CLIENT` will not start a transaction. If a `CLIENT` span has certain db attributes it will be treated as a DB span, and other specific attributes will cause it to be treated as an external span
84
-
* If `SpanKind.CLIENT` spans occur within an already existing New Relic transaction they will be included in the trace
124
+
* Creating a span with `SpanKind.CLIENT` will not start a transaction. If a `CLIENT` span has certain db attributes it will be treated as a DB span, and
125
+
other specific attributes will cause it to be treated as an external span
126
+
* If `SpanKind.CLIENT` spans occur within an already existing New Relic transaction they will be included in the trace
85
127
*`SpanKind.SERVER`
86
-
* Creating a span with `SpanKind.SERVER` will start a `WebTransaction/Uri/*` transaction.
87
-
* If `SpanKind.SERVER` spans occur within an already existing New Relic transaction they will be included in the trace
128
+
* Creating a span with `SpanKind.SERVER` will start a `WebTransaction/Uri/*` transaction.
129
+
* If `SpanKind.SERVER` spans occur within an already existing New Relic transaction they will be included in the trace
88
130
*`SpanKind.CONSUMER`
89
-
* Creating a span with `SpanKind.CONSUMER` will start a `OtherTransaction/*` transaction.
90
-
* If `SpanKind.CONSUMER` spans occur within an already existing New Relic transaction they will be included in the trace
131
+
* Creating a span with `SpanKind.CONSUMER` will start a `OtherTransaction/*` transaction.
132
+
* If `SpanKind.CONSUMER` spans occur within an already existing New Relic transaction they will be included in the trace
91
133
*`SpanKind.PRODUCER`
92
-
* Creating a span with `SpanKind.PRODUCER` will not start a transaction. There is no explicit processing for `PRODUCER` spans currently.
93
-
* If `SpanKind.PRODUCER` spans occur within an already existing New Relic transaction they will be included in the trace (though it's effectively no different from a `SpanKind.INTERNAL` span)
134
+
* Creating a span with `SpanKind.PRODUCER` will not start a transaction. There is no explicit processing for `PRODUCER` spans currently.
135
+
* If `SpanKind.PRODUCER` spans occur within an already existing New Relic transaction they will be included in the trace (though it's effectively no
136
+
different from a `SpanKind.INTERNAL` span)
137
+
138
+
## OpenTelemetry Logs
139
+
140
+
OpenTelemetry APIs can be used to create log records which will be detected by the New Relic Java agent and reported to the APM entity being monitored by the
141
+
New Relic Java agent. The log records will be reported as log events in New Relic, which will be associated with a transaction if the logging occurred within
142
+
one.
143
+
144
+
To use this functionality, enable the feature as documented above, add the required `opentelemetry` dependencies to your application:
Copy file name to clipboardExpand all lines: instrumentation/opentelemetry-sdk-extension-autoconfigure-1.28.0/src/main/java/com/nr/agent/instrumentation/utils/AttributesHelper.java
Copy file name to clipboardExpand all lines: instrumentation/opentelemetry-sdk-extension-autoconfigure-1.28.0/src/main/java/com/nr/agent/instrumentation/utils/header/HeaderType.java
Copy file name to clipboardExpand all lines: instrumentation/opentelemetry-sdk-extension-autoconfigure-1.28.0/src/main/java/com/nr/agent/instrumentation/utils/header/W3CTraceParentHeader.java
Copy file name to clipboardExpand all lines: instrumentation/opentelemetry-sdk-extension-autoconfigure-1.28.0/src/main/java/com/nr/agent/instrumentation/utils/header/W3CTraceParentValidator.java
0 commit comments