-
Notifications
You must be signed in to change notification settings - Fork 71
[RUM-9899]: TracingInterceptor migration #2708
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
base: feature/v3
Are you sure you want to change the base?
Conversation
...-sdk-android-trace-internal/src/main/java/com/datadog/trace/api/interceptor/MutableSpan.java
Show resolved
Hide resolved
@@ -223,6 +223,14 @@ void registerSpan(final DDSpan span) { | |||
} | |||
} | |||
|
|||
public void unregisterSpan(final DDSpan span){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important
Another point that I want to pay attention to: Dropping span wasn't supported in CoreTracer
and I am not sure that removing span from ROOT_SPAN
is the right thing here. Please let me know if I missing something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm...not sure it's ok here, I am thinking about the case where you have a parent span already and you only want to create the Okhttp span for the ids. In this case dropping the OkHttp span will completely drop all the trace ?
...tions/dd-sdk-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/DatadogInterceptor.kt
Outdated
Show resolved
Hide resolved
...k-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/internal/otel/TraceContextExt.kt
Outdated
Show resolved
Hide resolved
...dd-sdk-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/trace/TracingInterceptor.kt
Show resolved
Hide resolved
...oid-okhttp/src/test/kotlin/com/datadog/android/okhttp/DatadogInterceptorWithoutTracesTest.kt
Outdated
Show resolved
Hide resolved
...dd-sdk-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/trace/TracingInterceptor.kt
Outdated
Show resolved
Hide resolved
...dd-sdk-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/trace/TracingInterceptor.kt
Outdated
Show resolved
Hide resolved
...dd-sdk-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/trace/TracingInterceptor.kt
Outdated
Show resolved
Hide resolved
...tions/dd-sdk-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/DatadogInterceptor.kt
Outdated
Show resolved
Hide resolved
features/dd-sdk-android-trace-internal/src/main/java/com/datadog/trace/core/CoreTracer.java
Show resolved
Hide resolved
...dd-sdk-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/trace/TracingInterceptor.kt
Outdated
Show resolved
Hide resolved
...dd-sdk-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/trace/TracingInterceptor.kt
Show resolved
Hide resolved
...dd-sdk-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/trace/TracingInterceptor.kt
Outdated
Show resolved
Hide resolved
...k-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/internal/otel/TraceContextExt.kt
Outdated
Show resolved
Hide resolved
...-sdk-android-trace-internal/src/main/java/com/datadog/trace/api/interceptor/MutableSpan.java
Show resolved
Hide resolved
features/dd-sdk-android-trace-internal/src/main/java/com/datadog/trace/core/DDSpan.java
Show resolved
Hide resolved
@@ -223,6 +223,14 @@ void registerSpan(final DDSpan span) { | |||
} | |||
} | |||
|
|||
public void unregisterSpan(final DDSpan span){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm...not sure it's ok here, I am thinking about the case where you have a parent span already and you only want to create the Okhttp span for the ids. In this case dropping the OkHttp span will completely drop all the trace ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general. We're missing the part where we are able to inject our own tracer into the DatadogInterceptor#builder
, see the Slack thread but I guess this can still be added into this PR.
...ions/dd-sdk-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/trace/OtelMigration.kt
Outdated
Show resolved
Hide resolved
caa0454
to
253eace
Compare
dd-sdk-android-internal/src/main/java/com/datadog/android/internal/utils/CastExt.kt
Outdated
Show resolved
Hide resolved
186412e
to
4897596
Compare
… resolution during one of last commit squashing procedure
…xtension implementations
…eTracer and related classes for customers. The only publicity available ways for tracing feature usage: - okhttp instrumentation - manual instrumentation with Otel so it's okay that TracerContext is the only way to set the parent span (otherwise AgentSpan will be exposed)
20dc422
to
4f14507
Compare
ef02f2f
to
e60b523
Compare
…/RUM-9899_2 # Conflicts: # features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/internal/domain/event/CoreTracerSpanToSpanEventMapper.kt # features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/internal/domain/event/DdSpanToSpanEventMapper.kt
lgtm but better wait also for @mariusc83 approval |
implementation(project(":dd-sdk-android-internal")) | ||
// TODO RUM-9902 This is temporary for compilation. Gonna change to implementation after removing opentracing code | ||
api(project(":features:dd-sdk-android-trace-internal")) | ||
implementation(project(":features:dd-sdk-android-trace-internal")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason why this is exposed through implementation
dependency now ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module contains adapters mapping api interfaces into dd-trace-java implementation.
:features:dd-sdk-android-trace-internal
added as implementation
dependency in order to make it visible to current module, but hide from others.
Not sure that I've got the question right, please correct me if you meant something else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I see it now, you need these APIs later in module like dd-sdk-android-trace-otel
to delegate to ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me put bit more context here:
:features:dd-sdk-android-trace-internal
- is basically dd-trace-java implementation:features:dd-sdk-android-trace-api
- module that's being used everywhere ( in other modules like-okhttp
,-otel
and so on) to interact with tracing feature. But it only contain interfaces, without implementation.
*:features:dd-sdk-android-trace
- bounds-api
to-internal
.
So -trace
module is aware about -api
and -internal
but don't expose -internal
for descendants that's why it is included as implementation
...trace-internal/src/main/java/com/datadog/trace/bootstrap/instrumentation/api/TagContext.java
Show resolved
Hide resolved
@@ -44,6 +50,7 @@ public final class TracerConfig { | |||
public static final String TRACE_SAMPLING_OPERATION_RULES = "trace.sampling.operation.rules"; | |||
// JSON rules | |||
public static final String TRACE_SAMPLING_RULES = "trace.sampling.rules"; | |||
public static final String SDK_V2_COMPATIBILITY_FLAG = "v2.compatibility.enabled"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this flag needed for ? I see that for now it is not set from anywhere in the sdk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Context: AndroidTracer
user SAMPLER_KEEP and SAMPLER_DROP constant for sampling priority. CoreTracer
uses USER_KEEP and USER_DROP for sampling priority.
- If we change all SAMPLER_KEEP/SAMPLER_DROP to USER_KEEP/USER_DROP everywhere - it could affect manual traces.
- If we change all USER_KEEP/USER_DROP to SAMPLER_KEEP/SAMPLER_DROP it could affect manual traces made with otel (because otel implementation already in public and implemented with
CoreTracer
).
To keep Sample
object JSON looks same as before migration, but keep Otel implementation working same way as it was before v3 we need to add this flag, which set to true
if tracer created from otel provider.
@@ -221,6 +195,16 @@ class SampleApplication : Application() { | |||
} | |||
}.build() | |||
Trace.enable(tracesConfig) | |||
|
|||
GlobalDatadogTracer.registerIfAbsent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we keeping this only for the OkHttp instrumentation ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is the case this will look very weird. IMO the tracing feature in the new state should do 2 things:
- initialise with a configuration
- provide otel implementation by using the dd-sdk-android-otel module on top
- provide the
DatadogInterceptor
from thedd-sdk-android-okhttp
mdule and in case this requires theDatadogTracer
to create/open spans it should register this under the hood.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we keeping this only for the OkHttp instrumentation ?
Nope, we have bunch of places where global instance is being used:
SqliteDatabaseExt, SpanExt, CoroutineExt and so on.
if this is the case this will look very weird. IMO the tracing feature in the new state should do 2 things:
- initialise with a configuration
- provide otel implementation by using the dd-sdk-android-otel module on top
- provide the DatadogInterceptor from the dd-sdk-android-okhttp mdule and in case this requires the DatadogTracer to create/open spans it should register this under the hood.
That would be our best scenario, but we have few limitation here:
- If we force customers using
Otel
version - they would have to add desugaring support. To make it possible avoid otel dependencies we needDatadogTracer
itself. - If we remove
GlobalDatadogTracer
we would have to migrate our integration modules (like okhttp, sqldelight, etc) to useOtel
instead and they gonna require desugaring as well. Otherwise all of those integrations will have to create it's own instance locally and could miss some specific parameters that customer wants (and will only provide on configuration side).
TL;DR We need to wait until minSdk = 26 for the SDK to get rid from `GlobalDatadogTracer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not saying to have these module depending on Otel. I am suggesting that you keep the GlobalDatadogTracer
but you register yourself this instance under the hood and you do not expose this API to the users. Correct me if I am wrong but the intent for this instance is to be used internally by all our instrumentations that require spans/traces right now as as OkHttp. ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with that approach is that we need some place where DatadogTracer
is being configured by the customer before we could put it into GlobalDatadogTracer
. We cannot create it by ourselves because customer should provide some specific parameters (like tracingHeadersTypes for example).
Technically we could put registering logic inside build()
method of a DatadogTracerBuilder
implementation, but it could lead to issues, because it's not expected from developer side that creating builder makes them globally accessible, and I personally don't like such side effects of a functions. But I am open to discuss any other possible solution if you know some
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's discuss this also tomorrow when @0xnm will be in the office, I want to hear also his opinion on this matter before going forward.
… to meta, reverting _dd object back to log
c33379f
to
c32340a
Compare
What does this PR do?
This PR contains major change for tracer migration.
I tried to reduce amount of changes with some tricks with kotlin's
typealias
but it still huge. Maybe some of you will find it easier to review by commits.Main changes:
AndroidTracer
toCoreTracer
inTracingInterceptor
and it descendants.Please pay attention to:
Despite the fact that the APIs of CoreTracer and AndroidTracer are similar, some methods were either not supported or supported at a different level of abstraction. In such cases, I implemented the closest and simplest solution and added comments so you could spot them.
Known issues
GlobalTracer
, butTracingInterceptor
relies on some globally storedCoreTracer
instance. Going to discuss this with the team and provide solution with separate PR.Review checklist (to be filled by reviewers)