RUM-3836 Provide the DatadogContextStorage for Opentelemetry#1970
Conversation
3083360 to
b51edc9
Compare
fead880 to
141ad20
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## feature/otel-support #1970 +/- ##
========================================================
+ Coverage 60.16% 60.26% +0.10%
========================================================
Files 804 807 +3
Lines 30141 30184 +43
Branches 4933 4945 +12
========================================================
+ Hits 18133 18188 +55
+ Misses 10801 10776 -25
- Partials 1207 1220 +13
|
ca00753 to
a2fcd1b
Compare
| import java.util.concurrent.TimeUnit; | ||
| import java.util.logging.Logger; | ||
|
|
||
| public class OtelSpanBuilder implements SpanBuilder { |
There was a problem hiding this comment.
these diffs are mostly from new format applied because this was copied from the Java agent project.
a2fcd1b to
2e65dda
Compare
8f4c236 to
b8617c3
Compare
0xnm
left a comment
There was a problem hiding this comment.
overall lgtm, I left some comments/suggestions
| - "io.opentelemetry.api.trace.Span.getInvalid()" | ||
| - "io.opentelemetry.api.trace.TracerBuilder.build()" | ||
| - "io.opentelemetry.api.trace.SpanBuilder.setAttribute(kotlin.String?, kotlin.String?)" | ||
| - "io.opentelemetry.api.trace.TracerBuilder.setInstrumentationVersion(kotlin.String?)" |
There was a problem hiding this comment.
very minor: need to fix ordering here
| private val emailKey: ContextKey<String> = ContextKey.named("email") | ||
| private val usernameKey: ContextKey<String> = ContextKey.named("username") | ||
| private val context: Context = | ||
| Context.current().with(emailKey, email).with(usernameKey, username) | ||
| val startSpan: Span = tracer | ||
| .spanBuilder("submitForm") | ||
| .setParent(context) | ||
| .startSpan() | ||
| val scope: Scope = startSpan.makeCurrent() | ||
|
|
||
| @Suppress("CheckInternal") | ||
| private val logger: Logger by lazy { |
There was a problem hiding this comment.
minor: why do we explicitly specify types everywhere here? I believe in majority of the lines they can be removed?
There was a problem hiding this comment.
actually I need to do that because the Java code under the hood uses generics and it complains if it hasn't a type to inferre from
There was a problem hiding this comment.
for some lines - yes, but some lines for sure don't need an explicit type
b8617c3 to
ca283f6
Compare
| internal const val OTEL_CONTEXT_SPAN_KEY = "opentelemetry-trace-span-key" | ||
| internal const val OTEL_CONTEXT_ROOT_SPAN_KEY = "opentelemetry-traces-local-root-span" |
There was a problem hiding this comment.
btw, are these some official keys? Or just made up by us? they have some difference: trace vs traces and also there is a key word in the former, but not in the latter.
There was a problem hiding this comment.
official ones, that code in OtelContext is pretty much the one in Java Agent implementation. But it is a good observation and will double check with them also.
ca283f6 to
70acea8
Compare
What does this PR do?
In this PR we are providing our own implementation of https://github.com/open-telemetry/opentelemetryjava/blob/main/context/src/main/java/io/opentelemetry/context/ContextStorage.java
interface which wraps inside the default one in order to be able to provide our own implementation of
Context->OtelContext.The main reason for this update was to be able to tight the Opentelemetry Scopes to the
CoreTracerones.See more here how you can create a
Scopein Opentelemetry:https://github.com/open-telemetry/opentelemetry-java/blob/main/context/src/main/java/io/opentelemetry/context/ContextStorage.java
Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)