Skip to content

Commit f2b505a

Browse files
authored
Merge pull request #2542 from DataDog/xgouchet/RUM-7745/update_default_tracing_config
RUM-7745 update defaults in Tracing configuration
2 parents 4bcd7dd + 561ac6f commit f2b505a

16 files changed

+95
-62
lines changed

integrations/dd-sdk-android-okhttp/api/apiSurface

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ open class com.datadog.android.okhttp.DatadogInterceptor : com.datadog.android.o
3131
data class com.datadog.android.okhttp.TraceContext
3232
constructor(String, String, Int)
3333
enum com.datadog.android.okhttp.TraceContextInjection
34-
- All
35-
- Sampled
34+
- ALL
35+
- SAMPLED
3636
open class com.datadog.android.okhttp.trace.DeterministicTraceSampler : com.datadog.android.core.sampling.DeterministicSampler<io.opentracing.Span>
3737
constructor(() -> Float)
3838
constructor(Float)

integrations/dd-sdk-android-okhttp/api/dd-sdk-android-okhttp.api

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public final class com/datadog/android/okhttp/TraceContext {
6969
}
7070

7171
public final class com/datadog/android/okhttp/TraceContextInjection : java/lang/Enum {
72-
public static final field All Lcom/datadog/android/okhttp/TraceContextInjection;
73-
public static final field Sampled Lcom/datadog/android/okhttp/TraceContextInjection;
72+
public static final field ALL Lcom/datadog/android/okhttp/TraceContextInjection;
73+
public static final field SAMPLED Lcom/datadog/android/okhttp/TraceContextInjection;
7474
public static fun valueOf (Ljava/lang/String;)Lcom/datadog/android/okhttp/TraceContextInjection;
7575
public static fun values ()[Lcom/datadog/android/okhttp/TraceContextInjection;
7676
}

integrations/dd-sdk-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/DatadogInterceptor.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ open class DatadogInterceptor internal constructor(
115115
* auto-instrumented requests. By default it is [DeterministicTraceSampler], which either can accept
116116
* fixed sample rate or can get it dynamically from the provider. Value between `0.0` and
117117
* `100.0`. A value of `0.0` means no trace will be kept, `100.0` means all traces will
118-
* be kept (default value is `20.0`).
118+
* be kept (default value is `100.0`).
119119
*/
120120
@JvmOverloads
121121
@Deprecated(
@@ -136,7 +136,7 @@ open class DatadogInterceptor internal constructor(
136136
tracedRequestListener = tracedRequestListener,
137137
rumResourceAttributesProvider = rumResourceAttributesProvider,
138138
traceSampler = traceSampler,
139-
traceContextInjection = TraceContextInjection.All,
139+
traceContextInjection = TraceContextInjection.SAMPLED,
140140
redacted404ResourceName = true,
141141
localTracerFactory = { sdkCore, tracingHeaderTypes ->
142142
AndroidTracer.Builder(sdkCore).setTracingHeaderTypes(tracingHeaderTypes).build()
@@ -165,7 +165,7 @@ open class DatadogInterceptor internal constructor(
165165
* auto-instrumented requests. By default it is [DeterministicTraceSampler], which either can accept
166166
* fixed sample rate or can get it dynamically from the provider. Value between `0.0` and
167167
* `100.0`. A value of `0.0` means no trace will be kept, `100.0` means all traces will
168-
* be kept (default value is `20.0`).
168+
* be kept (default value is `100.0`).
169169
*/
170170
@JvmOverloads
171171
@Deprecated(
@@ -191,7 +191,7 @@ open class DatadogInterceptor internal constructor(
191191
tracedRequestListener = tracedRequestListener,
192192
rumResourceAttributesProvider = rumResourceAttributesProvider,
193193
traceSampler = traceSampler,
194-
traceContextInjection = TraceContextInjection.All,
194+
traceContextInjection = TraceContextInjection.SAMPLED,
195195
redacted404ResourceName = true,
196196
localTracerFactory = { sdkCore, tracingHeaderTypes ->
197197
AndroidTracer.Builder(sdkCore).setTracingHeaderTypes(tracingHeaderTypes).build()
@@ -212,7 +212,7 @@ open class DatadogInterceptor internal constructor(
212212
* auto-instrumented requests. By default it is [DeterministicTraceSampler], which either can accept
213213
* fixed sample rate or can get it dynamically from the provider. Value between `0.0` and
214214
* `100.0`. A value of `0.0` means no trace will be kept, `100.0` means all traces will
215-
* be kept (default value is `20.0`).
215+
* be kept (default value is `100.0`).
216216
*/
217217
@JvmOverloads
218218
@Deprecated(
@@ -232,7 +232,7 @@ open class DatadogInterceptor internal constructor(
232232
tracedRequestListener = tracedRequestListener,
233233
rumResourceAttributesProvider = rumResourceAttributesProvider,
234234
traceSampler = traceSampler,
235-
traceContextInjection = TraceContextInjection.All,
235+
traceContextInjection = TraceContextInjection.SAMPLED,
236236
redacted404ResourceName = true,
237237
localTracerFactory = { sdkCore, tracingHeaderTypes ->
238238
AndroidTracer.Builder(sdkCore).setTracingHeaderTypes(tracingHeaderTypes).build()

integrations/dd-sdk-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/TraceContextInjection.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ enum class TraceContextInjection {
1616
* headers but the sampling priority will be `0`. This will mean that the client will dictate the sampling priority
1717
* on the server side and no trace will be created no matter the sampling rate at the server side.
1818
*/
19-
All,
19+
ALL,
2020

2121
/**
2222
* Injects trace context only into sampled requests.
@@ -25,5 +25,5 @@ enum class TraceContextInjection {
2525
* This will mean that if the server side sampling rate is higher than the client side sampling rate there will
2626
* be a chance that a trace will be created down the stream.
2727
*/
28-
Sampled
28+
SAMPLED
2929
}

integrations/dd-sdk-android-okhttp/src/main/kotlin/com/datadog/android/okhttp/trace/TracingInterceptor.kt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ internal constructor(
116116
* auto-instrumented requests. By default it is [DeterministicTraceSampler], which either can accept
117117
* fixed sample rate or can get it dynamically from the provider. Value between `0.0` and
118118
* `100.0`. A value of `0.0` means no trace will be kept, `100.0` means all traces will
119-
* be kept (default value is `20.0`). If there is a parent trace attached to the network span created, then its
119+
* be kept (default value is `100.0`). If there is a parent trace attached to the network span created, then its
120120
* sampling decision will be used instead.
121121
*/
122122
@JvmOverloads
@@ -141,7 +141,7 @@ internal constructor(
141141
tracedRequestListener = tracedRequestListener,
142142
traceOrigin = null,
143143
traceSampler = traceSampler,
144-
traceContextInjection = TraceContextInjection.All,
144+
traceContextInjection = TraceContextInjection.SAMPLED,
145145
redacted404ResourceName = true,
146146
localTracerFactory = DEFAULT_LOCAL_TRACER_FACTORY
147147
)
@@ -162,7 +162,7 @@ internal constructor(
162162
* auto-instrumented requests. By default it is [DeterministicTraceSampler], which either can accept
163163
* fixed sample rate or can get it dynamically from the provider. Value between `0.0` and
164164
* `100.0`. A value of `0.0` means no trace will be kept, `100.0` means all traces will
165-
* be kept (default value is `20.0`). If there is a parent trace attached to the network span created, then its
165+
* be kept (default value is `100.0`). If there is a parent trace attached to the network span created, then its
166166
* sampling decision will be used instead.
167167
*/
168168
@JvmOverloads
@@ -182,7 +182,7 @@ internal constructor(
182182
tracedRequestListener = tracedRequestListener,
183183
traceOrigin = null,
184184
traceSampler = traceSampler,
185-
traceContextInjection = TraceContextInjection.All,
185+
traceContextInjection = TraceContextInjection.SAMPLED,
186186
redacted404ResourceName = true,
187187
localTracerFactory = DEFAULT_LOCAL_TRACER_FACTORY
188188
)
@@ -197,7 +197,7 @@ internal constructor(
197197
* auto-instrumented requests. By default it is [DeterministicTraceSampler], which either can accept
198198
* fixed sample rate or can get it dynamically from the provider. Value between `0.0` and
199199
* `100.0`. A value of `0.0` means no trace will be kept, `100.0` means all traces will
200-
* be kept (default value is `20.0`). If there is a parent trace attached to the network span created, then its
200+
* be kept (default value is `100.0`). If there is a parent trace attached to the network span created, then its
201201
* sampling decision will be used instead.
202202
*/
203203
@JvmOverloads
@@ -216,7 +216,7 @@ internal constructor(
216216
tracedRequestListener = tracedRequestListener,
217217
traceOrigin = null,
218218
traceSampler = traceSampler,
219-
traceContextInjection = TraceContextInjection.All,
219+
traceContextInjection = TraceContextInjection.SAMPLED,
220220
redacted404ResourceName = true,
221221
localTracerFactory = DEFAULT_LOCAL_TRACER_FACTORY
222222
)
@@ -561,7 +561,7 @@ internal constructor(
561561
}
562562

563563
private fun handleDatadogSampledOutHeaders(requestBuilder: Request.Builder, span: Span, tracer: Tracer) {
564-
if (traceContextInjection == TraceContextInjection.All) {
564+
if (traceContextInjection == TraceContextInjection.ALL) {
565565
tracer.inject(
566566
span.context(),
567567
Format.Builtin.TEXT_MAP_INJECT,
@@ -583,19 +583,19 @@ internal constructor(
583583
}
584584

585585
private fun handleB3SampledOutHeaders(requestBuilder: Request.Builder) {
586-
if (traceContextInjection == TraceContextInjection.All) {
586+
if (traceContextInjection == TraceContextInjection.ALL) {
587587
requestBuilder.addHeader(B3_HEADER_KEY, B3_DROP_SAMPLING_DECISION)
588588
}
589589
}
590590

591591
private fun handleB3MultiNotSampledHeaders(requestBuilder: Request.Builder) {
592-
if (traceContextInjection == TraceContextInjection.All) {
592+
if (traceContextInjection == TraceContextInjection.ALL) {
593593
requestBuilder.addHeader(B3M_SAMPLING_PRIORITY_KEY, B3M_DROP_SAMPLING_DECISION)
594594
}
595595
}
596596

597597
private fun handleW3CNotSampledHeaders(span: Span, requestBuilder: Request.Builder) {
598-
if (traceContextInjection == TraceContextInjection.All) {
598+
if (traceContextInjection == TraceContextInjection.ALL) {
599599
val traceId = span.context().traceIdAsHexString()
600600
val spanId = span.context().toSpanId()
601601
requestBuilder.addHeader(
@@ -828,7 +828,7 @@ internal constructor(
828828
internal var traceOrigin: String? = null
829829
internal var traceSampler: Sampler<Span> = DeterministicTraceSampler(DEFAULT_TRACE_SAMPLE_RATE)
830830
internal var localTracerFactory = DEFAULT_LOCAL_TRACER_FACTORY
831-
internal var traceContextInjection = TraceContextInjection.All
831+
internal var traceContextInjection = TraceContextInjection.SAMPLED
832832

833833
internal var redacted404ResourceName = true
834834

@@ -855,7 +855,7 @@ internal constructor(
855855
* Set the trace sample rate controlling the sampling of APM traces created for
856856
* auto-instrumented requests. If there is a parent trace attached to the network span created, then its
857857
* sampling decision will be used instead.
858-
* @param sampleRate the sample rate to use (percentage between 0f and 100f, default is 20f).
858+
* @param sampleRate the sample rate to use (percentage between 0f and 100f, default is 100f).
859859
*/
860860
fun setTraceSampleRate(@FloatRange(from = 0.0, to = 100.0) sampleRate: Float): R {
861861
this.traceSampler = DeterministicTraceSampler(sampleRate)
@@ -867,7 +867,7 @@ internal constructor(
867867
* auto-instrumented requests. If there is a parent trace attached to the network span created, then its
868868
* sampling decision will be used instead.
869869
* @param traceSampler the trace sampler controlling the sampling of APM traces.
870-
* By default it is a sampler accepting 20% of the traces.
870+
* By default it is a sampler accepting 100% of the traces.
871871
*/
872872
fun setTraceSampler(traceSampler: Sampler<Span>): R {
873873
this.traceSampler = traceSampler
@@ -876,13 +876,13 @@ internal constructor(
876876

877877
/**
878878
* Set the trace context injection behavior for this interceptor in the intercepted requests.
879-
* By default this is set to [TraceContextInjection.All] meaning that all the trace context
879+
* By default this is set to [TraceContextInjection.SAMPLED], meaning that only the sampled request will
880+
* propagate the trace context. In case of [TraceContextInjection.ALL] all the trace context
880881
* will be propagated in the intercepted requests no matter if the span created around the request
881-
* is sampled or not. In case of [TraceContextInjection.Sampled] only the sampled request will propagate
882-
* the trace context.
882+
* is sampled or not.
883883
* @param traceContextInjection the trace context injection option.
884-
* @see TraceContextInjection.All
885-
* @see TraceContextInjection.Sampled
884+
* @see TraceContextInjection.ALL
885+
* @see TraceContextInjection.SAMPLED
886886
*/
887887
fun setTraceContextInjection(traceContextInjection: TraceContextInjection): R {
888888
this.traceContextInjection = traceContextInjection
@@ -942,7 +942,7 @@ internal constructor(
942942
internal const val NETWORK_REQUESTS_TRACKING_FEATURE_NAME = "Network Requests"
943943
internal const val ALL_IN_SAMPLE_RATE: Double = 100.0
944944
internal const val ZERO_SAMPLE_RATE: Float = 0f
945-
internal const val DEFAULT_TRACE_SAMPLE_RATE: Float = 20f
945+
internal const val DEFAULT_TRACE_SAMPLE_RATE: Float = 100f
946946

947947
// taken from DatadogHttpCodec
948948
internal const val DATADOG_LEAST_SIGNIFICANT_64_BITS_TRACE_ID_HEADER = "x-datadog-trace-id"

integrations/dd-sdk-android-okhttp/src/test/kotlin/com/datadog/android/okhttp/DatadogInterceptorBuilderTest.kt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,14 @@ internal class DatadogInterceptorBuilderTest {
7777

7878
// Then
7979
assertThat(interceptor.tracedHosts).isEqualTo(fakeTracedHostsWithHeaderType)
80-
assertThat(interceptor.traceContextInjection).isEqualTo(TraceContextInjection.All)
80+
assertThat(interceptor.traceContextInjection).isEqualTo(TraceContextInjection.SAMPLED)
8181
assertThat(interceptor.sdkInstanceName).isNull()
8282
assertThat(
8383
interceptor.rumResourceAttributesProvider
8484
).isInstanceOf(NoOpRumResourceAttributesProvider::class.java)
8585
assertThat(interceptor.tracedRequestListener).isInstanceOf(NoOpTracedRequestListener::class.java)
8686
assertThat(interceptor.traceSampler).isInstanceOf(DeterministicTraceSampler::class.java)
87+
assertThat(interceptor.traceSampler.getSampleRate()).isEqualTo(100f)
8788
assertThat(interceptor.traceOrigin).isEqualTo(DatadogInterceptor.ORIGIN_RUM)
8889
assertThat(interceptor.localTracerFactory).isNotNull()
8990
}
@@ -102,13 +103,14 @@ internal class DatadogInterceptorBuilderTest {
102103
setOf(TracingHeaderType.DATADOG, TracingHeaderType.TRACECONTEXT)
103104
}
104105
)
105-
assertThat(interceptor.traceContextInjection).isEqualTo(TraceContextInjection.All)
106+
assertThat(interceptor.traceContextInjection).isEqualTo(TraceContextInjection.SAMPLED)
106107
assertThat(interceptor.sdkInstanceName).isNull()
107108
assertThat(
108109
interceptor.rumResourceAttributesProvider
109110
).isInstanceOf(NoOpRumResourceAttributesProvider::class.java)
110111
assertThat(interceptor.tracedRequestListener).isInstanceOf(NoOpTracedRequestListener::class.java)
111112
assertThat(interceptor.traceSampler).isInstanceOf(DeterministicTraceSampler::class.java)
113+
assertThat(interceptor.traceSampler.getSampleRate()).isEqualTo(100f)
112114
assertThat(interceptor.traceOrigin).isEqualTo(DatadogInterceptor.ORIGIN_RUM)
113115
assertThat(interceptor.localTracerFactory).isNotNull()
114116
}
@@ -122,13 +124,14 @@ internal class DatadogInterceptorBuilderTest {
122124

123125
// Then
124126
assertThat(interceptor.tracedHosts).isEqualTo(fakeTracedHostsWithHeaderType)
125-
assertThat(interceptor.traceContextInjection).isEqualTo(TraceContextInjection.All)
127+
assertThat(interceptor.traceContextInjection).isEqualTo(TraceContextInjection.SAMPLED)
126128
assertThat(interceptor.sdkInstanceName).isEqualTo(fakeSdkInstaceName)
127129
assertThat(
128130
interceptor.rumResourceAttributesProvider
129131
).isInstanceOf(NoOpRumResourceAttributesProvider::class.java)
130132
assertThat(interceptor.tracedRequestListener).isInstanceOf(NoOpTracedRequestListener::class.java)
131133
assertThat(interceptor.traceSampler).isInstanceOf(DeterministicTraceSampler::class.java)
134+
assertThat(interceptor.traceSampler.getSampleRate()).isEqualTo(100f)
132135
assertThat(interceptor.traceOrigin).isEqualTo(DatadogInterceptor.ORIGIN_RUM)
133136
assertThat(interceptor.localTracerFactory).isNotNull()
134137
}
@@ -149,6 +152,7 @@ internal class DatadogInterceptorBuilderTest {
149152
).isInstanceOf(NoOpRumResourceAttributesProvider::class.java)
150153
assertThat(interceptor.tracedRequestListener).isInstanceOf(NoOpTracedRequestListener::class.java)
151154
assertThat(interceptor.traceSampler).isInstanceOf(DeterministicTraceSampler::class.java)
155+
assertThat(interceptor.traceSampler.getSampleRate()).isEqualTo(100f)
152156
assertThat(interceptor.traceOrigin).isEqualTo(DatadogInterceptor.ORIGIN_RUM)
153157
assertThat(interceptor.localTracerFactory).isNotNull()
154158
}
@@ -162,13 +166,14 @@ internal class DatadogInterceptorBuilderTest {
162166

163167
// Then
164168
assertThat(interceptor.tracedHosts).isEqualTo(fakeTracedHostsWithHeaderType)
165-
assertThat(interceptor.traceContextInjection).isEqualTo(TraceContextInjection.All)
169+
assertThat(interceptor.traceContextInjection).isEqualTo(TraceContextInjection.SAMPLED)
166170
assertThat(interceptor.sdkInstanceName).isNull()
167171
assertThat(
168172
interceptor.rumResourceAttributesProvider
169173
).isInstanceOf(NoOpRumResourceAttributesProvider::class.java)
170174
assertThat(interceptor.tracedRequestListener).isSameAs(mockTracedRequestListener)
171175
assertThat(interceptor.traceSampler).isInstanceOf(DeterministicTraceSampler::class.java)
176+
assertThat(interceptor.traceSampler.getSampleRate()).isEqualTo(100f)
172177
assertThat(interceptor.traceOrigin).isEqualTo(DatadogInterceptor.ORIGIN_RUM)
173178
assertThat(interceptor.localTracerFactory).isNotNull()
174179
}
@@ -182,11 +187,12 @@ internal class DatadogInterceptorBuilderTest {
182187

183188
// Then
184189
assertThat(interceptor.tracedHosts).isEqualTo(fakeTracedHostsWithHeaderType)
185-
assertThat(interceptor.traceContextInjection).isEqualTo(TraceContextInjection.All)
190+
assertThat(interceptor.traceContextInjection).isEqualTo(TraceContextInjection.SAMPLED)
186191
assertThat(interceptor.sdkInstanceName).isNull()
187192
assertThat(interceptor.rumResourceAttributesProvider).isSameAs(mockRumResourceAttributesProvider)
188193
assertThat(interceptor.tracedRequestListener).isInstanceOf(NoOpTracedRequestListener::class.java)
189194
assertThat(interceptor.traceSampler).isInstanceOf(DeterministicTraceSampler::class.java)
195+
assertThat(interceptor.traceSampler.getSampleRate()).isEqualTo(100f)
190196
assertThat(interceptor.traceOrigin).isEqualTo(DatadogInterceptor.ORIGIN_RUM)
191197
assertThat(interceptor.localTracerFactory).isNotNull()
192198
}
@@ -202,7 +208,7 @@ internal class DatadogInterceptorBuilderTest {
202208

203209
// Then
204210
assertThat(interceptor.tracedHosts).isEqualTo(fakeTracedHostsWithHeaderType)
205-
assertThat(interceptor.traceContextInjection).isEqualTo(TraceContextInjection.All)
211+
assertThat(interceptor.traceContextInjection).isEqualTo(TraceContextInjection.SAMPLED)
206212
assertThat(interceptor.sdkInstanceName).isNull()
207213
assertThat(
208214
interceptor.rumResourceAttributesProvider
@@ -223,7 +229,7 @@ internal class DatadogInterceptorBuilderTest {
223229

224230
// Then
225231
assertThat(interceptor.tracedHosts).isEqualTo(fakeTracedHostsWithHeaderType)
226-
assertThat(interceptor.traceContextInjection).isEqualTo(TraceContextInjection.All)
232+
assertThat(interceptor.traceContextInjection).isEqualTo(TraceContextInjection.SAMPLED)
227233
assertThat(interceptor.sdkInstanceName).isNull()
228234
assertThat(
229235
interceptor.rumResourceAttributesProvider

integrations/dd-sdk-android-okhttp/src/test/kotlin/com/datadog/android/okhttp/DatadogInterceptorTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ internal class DatadogInterceptorTest : TracingInterceptorNotSendingSpanTest() {
9494
tracedRequestListener = mockRequestListener,
9595
rumResourceAttributesProvider = mockRumAttributesProvider,
9696
traceSampler = mockTraceSampler,
97-
traceContextInjection = TraceContextInjection.All,
97+
traceContextInjection = TraceContextInjection.ALL,
9898
redacted404ResourceName = fakeRedacted404Resources,
9999
localTracerFactory = factory
100100
)

0 commit comments

Comments
 (0)