Skip to content

Commit 85637ab

Browse files
authored
Merge pull request #2505 from DataDog/tvaleev/RUM-8098/inv-tns-configurations-support
[RUM-8098] Support for configuration schema updates for time based strategy of TNS and INV metrics
2 parents dcb1457 + 3a55504 commit 85637ab

File tree

21 files changed

+279
-90
lines changed

21 files changed

+279
-90
lines changed

dd-sdk-android-core/api/apiSurface

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,13 @@ interface com.datadog.android.core.internal.attributes.LocalAttribute
261261
- CREATION_SAMPLING_RATE
262262
- REPORTING_SAMPLING_RATE
263263
- VIEW_SCOPE_INSTRUMENTATION_TYPE
264+
override fun toString(): String
264265
interface Constant
265266
val key: Key
266-
val value: Any
267267
fun MutableMap<String, Any?>.enrichWithConstantAttribute(LocalAttribute.Constant)
268268
fun MutableMap<String, Any?>.enrichWithNonNullAttribute(LocalAttribute.Key, Any?)
269269
fun MutableMap<String, Any?>.enrichWithLocalAttribute(LocalAttribute.Key, Any?)
270270
enum com.datadog.android.core.internal.attributes.ViewScopeInstrumentationType : LocalAttribute.Constant
271-
constructor(String)
272271
- MANUAL
273272
- COMPOSE
274273
- ACTIVITY

dd-sdk-android-core/api/dd-sdk-android-core.api

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,14 +721,13 @@ public abstract interface class com/datadog/android/core/internal/attributes/Loc
721721

722722
public abstract interface class com/datadog/android/core/internal/attributes/LocalAttribute$Constant {
723723
public abstract fun getKey ()Lcom/datadog/android/core/internal/attributes/LocalAttribute$Key;
724-
public abstract fun getValue ()Ljava/lang/Object;
725724
}
726725

727726
public final class com/datadog/android/core/internal/attributes/LocalAttribute$Key : java/lang/Enum {
728727
public static final field CREATION_SAMPLING_RATE Lcom/datadog/android/core/internal/attributes/LocalAttribute$Key;
729728
public static final field REPORTING_SAMPLING_RATE Lcom/datadog/android/core/internal/attributes/LocalAttribute$Key;
730729
public static final field VIEW_SCOPE_INSTRUMENTATION_TYPE Lcom/datadog/android/core/internal/attributes/LocalAttribute$Key;
731-
public final fun getString ()Ljava/lang/String;
730+
public fun toString ()Ljava/lang/String;
732731
public static fun valueOf (Ljava/lang/String;)Lcom/datadog/android/core/internal/attributes/LocalAttribute$Key;
733732
public static fun values ()[Lcom/datadog/android/core/internal/attributes/LocalAttribute$Key;
734733
}
@@ -745,8 +744,6 @@ public final class com/datadog/android/core/internal/attributes/ViewScopeInstrum
745744
public static final field FRAGMENT Lcom/datadog/android/core/internal/attributes/ViewScopeInstrumentationType;
746745
public static final field MANUAL Lcom/datadog/android/core/internal/attributes/ViewScopeInstrumentationType;
747746
public fun getKey ()Lcom/datadog/android/core/internal/attributes/LocalAttribute$Key;
748-
public synthetic fun getValue ()Ljava/lang/Object;
749-
public fun getValue ()Ljava/lang/String;
750747
public static fun valueOf (Ljava/lang/String;)Lcom/datadog/android/core/internal/attributes/ViewScopeInstrumentationType;
751748
public static fun values ()[Lcom/datadog/android/core/internal/attributes/ViewScopeInstrumentationType;
752749
}

dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/attributes/LocalAttribute.kt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,23 @@ interface LocalAttribute {
1818
* Enumeration of all local attributes keys used in the application.
1919
* Made via **enum** to make sure that all such attributes will be removed before sending the event to the backend.
2020
*
21-
* @property string - Unique string value for a local attribute key.
21+
* @param string - Unique string value for a local attribute key.
2222
*/
2323
@InternalApi
2424
enum class Key(
25-
val string: String
25+
private val string: String
2626
) {
27-
/* Some of the metrics like [PerformanceMetric] being sampled on the
28-
* metric creation place and then reported with 100% probability.
29-
* In such cases we need to use *creationSampleRate* to compute effectiveSampleRate correctlyThe sampling
30-
* rate is used when creating metrics.
31-
* Creation(head) sampling rate exist only for long-lived metrics like method performance.
32-
* Created metric still could not be sent it depends on [REPORTING_SAMPLING_RATE] sampling rate
27+
/*
28+
* Some of the metrics such as [PerformanceMetric] are sampled at the point of
29+
* metric creation and then reported with 100% probability.
30+
* In such cases we need to use *creationSampleRate* to correctly calculate effectiveSampleRate.
31+
* The creation(head) sample rate only exists for long-lived metrics such as method performance.
32+
* Created metric still could not be sent, it depends on the [REPORTING_SAMPLING_RATE] sample rate.
3333
*/
3434
CREATION_SAMPLING_RATE("_dd.local.head_sampling_rate_key"),
3535

36-
/* Sampling rate that is used to decide to send or not to send the metric.
36+
/*
37+
* Sampling rate that is used to decide to send or not to send the metric.
3738
* Each metric should have reporting(tail) sampling rate.
3839
* It's possible that metric has only reporting(tail) sampling rate.
3940
*/
@@ -43,7 +44,11 @@ interface LocalAttribute {
4344
* Indicates which instrumentation was used to track the view scope.
4445
* See [ViewScopeInstrumentationType] for possible values.
4546
*/
46-
VIEW_SCOPE_INSTRUMENTATION_TYPE("_dd.local.view_instrumentation_type_key")
47+
VIEW_SCOPE_INSTRUMENTATION_TYPE("_dd.local.view_instrumentation_type_key");
48+
49+
override fun toString(): String {
50+
return string
51+
}
4752
}
4853

4954
/**
@@ -56,9 +61,6 @@ interface LocalAttribute {
5661
interface Constant {
5762
/** Constant attribute key. For enum constants will be same for all values. */
5863
val key: Key
59-
60-
/** Constant attribute value. One item from set of possible finite values for a given constant attribute.*/
61-
val value: Any
6264
}
6365
}
6466

@@ -99,5 +101,5 @@ fun MutableMap<String, Any?>.enrichWithLocalAttribute(
99101
key: LocalAttribute.Key,
100102
value: Any?
101103
) = apply {
102-
this[key.string] = value
104+
this[key.toString()] = value
103105
}

dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/attributes/ViewScopeInstrumentationType.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,18 @@ import com.datadog.android.lint.InternalApi
1111
* A set of constants describing the instrumentation that were used to define the view scope.
1212
*/
1313
@InternalApi
14-
enum class ViewScopeInstrumentationType(
15-
override val value: String
16-
) : LocalAttribute.Constant {
14+
enum class ViewScopeInstrumentationType : LocalAttribute.Constant {
1715
/** Tracked manually through the RUMMonitor API. */
18-
MANUAL("manual"),
16+
MANUAL,
1917

2018
/** Tracked through ComposeNavigationObserver instrumentation. */
21-
COMPOSE("compose"),
19+
COMPOSE,
2220

2321
/** Tracked through ActivityViewTrackingStrategy instrumentation. */
24-
ACTIVITY("activity"),
22+
ACTIVITY,
2523

2624
/** Tracked through FragmentViewTrackingStrategy instrumentation. */
27-
FRAGMENT("fragment");
25+
FRAGMENT;
2826

2927
/** @inheritdoc */
3028
override val key: LocalAttribute.Key = LocalAttribute.Key.VIEW_SCOPE_INSTRUMENTATION_TYPE

dd-sdk-android-core/src/test/kotlin/com/datadog/android/core/internal/logger/SdkInternalLoggerTest.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ internal class SdkInternalLoggerTest {
453453
// Given
454454
val samplingRate = 100.0f
455455
val fakeAdditionalProperties = forge.exhaustiveAttributes().also {
456-
it[LocalAttribute.Key.REPORTING_SAMPLING_RATE.string] = samplingRate
456+
it[LocalAttribute.Key.REPORTING_SAMPLING_RATE.toString()] = samplingRate
457457
}
458458
val mockLambda: () -> String = mock()
459459
whenever(mockLambda.invoke()) doReturn fakeMessage
@@ -505,13 +505,13 @@ internal class SdkInternalLoggerTest {
505505
val metricEvent = firstValue as InternalTelemetryEvent.Metric
506506

507507
assertThat(
508-
metricEvent.additionalProperties?.get(LocalAttribute.Key.CREATION_SAMPLING_RATE.string)
508+
metricEvent.additionalProperties?.get(LocalAttribute.Key.CREATION_SAMPLING_RATE.toString())
509509
).isEqualTo(
510510
expectedCreationSampleRate
511511
)
512512

513513
assertThat(
514-
metricEvent.additionalProperties?.get(LocalAttribute.Key.REPORTING_SAMPLING_RATE.string)
514+
metricEvent.additionalProperties?.get(LocalAttribute.Key.REPORTING_SAMPLING_RATE.toString())
515515
).isEqualTo(
516516
samplingRate
517517
)
@@ -544,11 +544,11 @@ internal class SdkInternalLoggerTest {
544544
assertThat(
545545
apiUsageEvent.additionalProperties
546546
).doesNotContainKeys(
547-
LocalAttribute.Key.CREATION_SAMPLING_RATE.string
547+
LocalAttribute.Key.CREATION_SAMPLING_RATE.toString()
548548
)
549549

550550
assertThat(
551-
apiUsageEvent.additionalProperties[LocalAttribute.Key.REPORTING_SAMPLING_RATE.string]
551+
apiUsageEvent.additionalProperties[LocalAttribute.Key.REPORTING_SAMPLING_RATE.toString()]
552552
).isEqualTo(
553553
samplingRate
554554
)
@@ -569,7 +569,7 @@ internal class SdkInternalLoggerTest {
569569
),
570570
target = InternalLogger.Target.TELEMETRY,
571571
messageBuilder = { forge.aString() },
572-
additionalProperties = mapOf(LocalAttribute.Key.REPORTING_SAMPLING_RATE.string to samplingRate)
572+
additionalProperties = mapOf(LocalAttribute.Key.REPORTING_SAMPLING_RATE.toString() to samplingRate)
573573
)
574574

575575
// Then
@@ -581,11 +581,11 @@ internal class SdkInternalLoggerTest {
581581
assertThat(
582582
debugEvent.additionalProperties
583583
).doesNotContainKeys(
584-
LocalAttribute.Key.CREATION_SAMPLING_RATE.string
584+
LocalAttribute.Key.CREATION_SAMPLING_RATE.toString()
585585
)
586586

587587
assertThat(
588-
debugEvent.additionalProperties?.get(LocalAttribute.Key.REPORTING_SAMPLING_RATE.string)
588+
debugEvent.additionalProperties?.get(LocalAttribute.Key.REPORTING_SAMPLING_RATE.toString())
589589
).isEqualTo(
590590
samplingRate
591591
)
@@ -604,7 +604,7 @@ internal class SdkInternalLoggerTest {
604604
target = InternalLogger.Target.TELEMETRY,
605605
throwable = forge.aThrowable(),
606606
messageBuilder = { forge.aString() },
607-
additionalProperties = mapOf(LocalAttribute.Key.REPORTING_SAMPLING_RATE.string to samplingRate)
607+
additionalProperties = mapOf(LocalAttribute.Key.REPORTING_SAMPLING_RATE.toString() to samplingRate)
608608
)
609609

610610
// Then
@@ -616,11 +616,11 @@ internal class SdkInternalLoggerTest {
616616
assertThat(
617617
debugEvent.additionalProperties
618618
).doesNotContainKeys(
619-
LocalAttribute.Key.CREATION_SAMPLING_RATE.string
619+
LocalAttribute.Key.CREATION_SAMPLING_RATE.toString()
620620
)
621621

622622
assertThat(
623-
debugEvent.additionalProperties?.get(LocalAttribute.Key.REPORTING_SAMPLING_RATE.string)
623+
debugEvent.additionalProperties?.get(LocalAttribute.Key.REPORTING_SAMPLING_RATE.toString())
624624
).isEqualTo(
625625
samplingRate
626626
)

features/dd-sdk-android-rum/api/apiSurface

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2174,7 +2174,7 @@ data class com.datadog.android.telemetry.model.TelemetryConfigurationEvent
21742174
fun fromJson(kotlin.String): Os
21752175
fun fromJsonObject(com.google.gson.JsonObject): Os
21762176
data class Configuration
2177-
constructor(kotlin.Long? = null, kotlin.Long? = null, kotlin.Long? = null, kotlin.Long? = null, kotlin.Long? = null, TraceContextInjection? = null, kotlin.Long? = null, kotlin.Long? = null, kotlin.Long? = null, TrackingConsent? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, SessionPersistence? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.String? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.collections.List<SelectedTracingPropagator>? = null, kotlin.String? = null, kotlin.String? = null, kotlin.String? = null, kotlin.String? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.collections.List<kotlin.String>? = null, kotlin.collections.List<kotlin.String>? = null, kotlin.Boolean? = null, ViewTrackingStrategy? = null, kotlin.Boolean? = null, kotlin.Long? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.String? = null, kotlin.Boolean? = null, kotlin.Long? = null, kotlin.Long? = null, kotlin.Long? = null, kotlin.Boolean? = null, kotlin.String? = null, kotlin.String? = null, kotlin.String? = null, kotlin.String? = null, kotlin.Long? = null, kotlin.Boolean? = null, kotlin.String? = null, kotlin.String? = null, kotlin.Boolean? = null, kotlin.collections.List<Plugin>? = null, kotlin.Boolean? = null, kotlin.collections.List<TrackFeatureFlagsForEvent>? = null, kotlin.Boolean? = true)
2177+
constructor(kotlin.Long? = null, kotlin.Long? = null, kotlin.Long? = null, kotlin.Long? = null, kotlin.Long? = null, TraceContextInjection? = null, kotlin.Long? = null, kotlin.Long? = null, kotlin.Long? = null, TrackingConsent? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, SessionPersistence? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.String? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.collections.List<SelectedTracingPropagator>? = null, kotlin.String? = null, kotlin.String? = null, kotlin.String? = null, kotlin.String? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.collections.List<kotlin.String>? = null, kotlin.collections.List<kotlin.String>? = null, kotlin.Boolean? = null, ViewTrackingStrategy? = null, kotlin.Boolean? = null, kotlin.Long? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.Boolean? = null, kotlin.String? = null, kotlin.Boolean? = null, kotlin.Long? = null, kotlin.Long? = null, kotlin.Long? = null, kotlin.Boolean? = null, kotlin.String? = null, kotlin.String? = null, kotlin.String? = null, kotlin.String? = null, kotlin.Long? = null, kotlin.Boolean? = null, kotlin.String? = null, kotlin.String? = null, kotlin.Boolean? = null, kotlin.collections.List<Plugin>? = null, kotlin.Boolean? = null, kotlin.Long? = null, kotlin.Long? = null, kotlin.collections.List<TrackFeatureFlagsForEvent>? = null, kotlin.Boolean? = true)
21782178
fun toJson(): com.google.gson.JsonElement
21792179
companion object
21802180
fun fromJson(kotlin.String): Configuration
@@ -2467,6 +2467,30 @@ data class com.datadog.android.telemetry.model.TelemetryUsageEvent
24672467
companion object
24682468
fun fromJson(kotlin.String): StartView
24692469
fun fromJsonObject(com.google.gson.JsonObject): StartView
2470+
class SetViewContext : Usage
2471+
val feature: kotlin.String
2472+
override fun toJson(): com.google.gson.JsonElement
2473+
companion object
2474+
fun fromJson(kotlin.String): SetViewContext
2475+
fun fromJsonObject(com.google.gson.JsonObject): SetViewContext
2476+
class SetViewContextProperty : Usage
2477+
val feature: kotlin.String
2478+
override fun toJson(): com.google.gson.JsonElement
2479+
companion object
2480+
fun fromJson(kotlin.String): SetViewContextProperty
2481+
fun fromJsonObject(com.google.gson.JsonObject): SetViewContextProperty
2482+
class SetViewName : Usage
2483+
val feature: kotlin.String
2484+
override fun toJson(): com.google.gson.JsonElement
2485+
companion object
2486+
fun fromJson(kotlin.String): SetViewName
2487+
fun fromJsonObject(com.google.gson.JsonObject): SetViewName
2488+
class GetViewContext : Usage
2489+
val feature: kotlin.String
2490+
override fun toJson(): com.google.gson.JsonElement
2491+
companion object
2492+
fun fromJson(kotlin.String): GetViewContext
2493+
fun fromJsonObject(com.google.gson.JsonObject): GetViewContext
24702494
class AddAction : Usage
24712495
val feature: kotlin.String
24722496
override fun toJson(): com.google.gson.JsonElement

0 commit comments

Comments
 (0)