Skip to content

Commit 9373552

Browse files
committed
RUM-9899: making
fun activateSpan(span: DatadogSpan, asyncPropagating: Boolean): DatadogScope? internal
1 parent afc8869 commit 9373552

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

features/dd-sdk-android-trace-api/src/main/kotlin/com/datadog/android/trace/api/tracer/DatadogTracer.kt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,6 @@ interface DatadogTracer {
4242
*/
4343
fun activateSpan(span: DatadogSpan): DatadogScope?
4444

45-
/**
46-
* Activates the provided span within the current context of the tracer.
47-
* If `asyncPropagating` is set to true, the span is propagated asynchronously.
48-
* Once activated, the span becomes the currently active span until it is explicitly deactivated.
49-
*
50-
* @param span The span to be activated. Represents the logical unit of work being traced.
51-
* @param asyncPropagating If true, this context will propagate across async boundaries.
52-
* @return An instance of [DatadogScope] representing the activated scope.
53-
*/
54-
fun activateSpan(span: DatadogSpan, asyncPropagating: Boolean): DatadogScope?
55-
5645
/**
5746
* Creates a new span builder instance with the specified span name.
5847
*

features/dd-sdk-android-trace-otel/src/main/java/com/datadog/opentelemetry/trace/OtelSpan.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public boolean isRecording() {
153153
}
154154

155155
public DatadogScope activate() {
156-
return agentTracer.activateSpan(this.delegate, DEFAULT_ASYNC_PROPAGATING);
156+
return DatadogTracingToolkit.activateSpan(agentTracer, this.delegate, DEFAULT_ASYNC_PROPAGATING);
157157
}
158158

159159
public DatadogSpan getDatadogSpan() {

features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/internal/DatadogTracerAdapter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ internal class DatadogTracerAdapter(
6767
)
6868
}
6969

70-
override fun activateSpan(span: DatadogSpan, asyncPropagating: Boolean): DatadogScope? {
70+
override fun propagate(): DatadogPropagation = DatadogPropagationAdapter(internalLogger, delegate.propagate())
71+
72+
internal fun activateSpan(span: DatadogSpan, asyncPropagating: Boolean): DatadogScope? {
7173
return (span as? DatadogSpanAdapter)?.let {
7274
DatadogScopeAdapter(
7375
delegate.activateSpan(span.delegate, ScopeSource.INSTRUMENTATION, asyncPropagating) ?: return null
7476
)
7577
}
7678
}
77-
78-
override fun propagate(): DatadogPropagation = DatadogPropagationAdapter(internalLogger, delegate.propagate())
7979
}

features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/internal/DatadogTracingToolkit.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
package com.datadog.android.trace.internal
77

88
import com.datadog.android.lint.InternalApi
9+
import com.datadog.android.trace.api.scope.DatadogScope
910
import com.datadog.android.trace.api.span.DatadogSpan
1011
import com.datadog.android.trace.api.span.DatadogSpanContext
12+
import com.datadog.android.trace.api.tracer.DatadogTracer
1113
import com.datadog.android.trace.api.tracer.DatadogTracerBuilder
1214

1315
/**
@@ -71,4 +73,19 @@ object DatadogTracingToolkit {
7173
fun addThrowable(span: DatadogSpan, throwable: Throwable, errorPriority: Byte) {
7274
(span as? DatadogSpanAdapter)?.addThrowable(throwable, errorPriority)
7375
}
76+
77+
/**
78+
* Activates the provided span within the current context of the tracer.
79+
* If `asyncPropagating` is set to true, the span is propagated asynchronously.
80+
* Once activated, the span becomes the currently active span until it is explicitly deactivated.
81+
*
82+
* @param tracer The tracer instance to be used for activation.
83+
* @param span The span to be activated. Represents the logical unit of work being traced.
84+
* @param asyncPropagating If true, this context will propagate across async boundaries.
85+
* @return An instance of [DatadogScope] representing the activated scope.
86+
*/
87+
@JvmStatic // this method is called from OTel code, written in java
88+
fun activateSpan(tracer: DatadogTracer, span: DatadogSpan, asyncPropagating: Boolean): DatadogScope? {
89+
return (tracer as? DatadogTracerAdapter)?.activateSpan(span, asyncPropagating)
90+
}
7491
}

0 commit comments

Comments
 (0)