Skip to content

Commit

Permalink
Merge pull request #2505 from DataDog/tvaleev/RUM-8098/inv-tns-config…
Browse files Browse the repository at this point in the history
…urations-support

[RUM-8098] Support for configuration schema updates for time based strategy of TNS and INV metrics
  • Loading branch information
satween authored Feb 14, 2025
2 parents dcb1457 + 3a55504 commit 85637ab
Show file tree
Hide file tree
Showing 21 changed files with 279 additions and 90 deletions.
3 changes: 1 addition & 2 deletions dd-sdk-android-core/api/apiSurface
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,13 @@ interface com.datadog.android.core.internal.attributes.LocalAttribute
- CREATION_SAMPLING_RATE
- REPORTING_SAMPLING_RATE
- VIEW_SCOPE_INSTRUMENTATION_TYPE
override fun toString(): String
interface Constant
val key: Key
val value: Any
fun MutableMap<String, Any?>.enrichWithConstantAttribute(LocalAttribute.Constant)
fun MutableMap<String, Any?>.enrichWithNonNullAttribute(LocalAttribute.Key, Any?)
fun MutableMap<String, Any?>.enrichWithLocalAttribute(LocalAttribute.Key, Any?)
enum com.datadog.android.core.internal.attributes.ViewScopeInstrumentationType : LocalAttribute.Constant
constructor(String)
- MANUAL
- COMPOSE
- ACTIVITY
Expand Down
5 changes: 1 addition & 4 deletions dd-sdk-android-core/api/dd-sdk-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -721,14 +721,13 @@ public abstract interface class com/datadog/android/core/internal/attributes/Loc

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

public final class com/datadog/android/core/internal/attributes/LocalAttribute$Key : java/lang/Enum {
public static final field CREATION_SAMPLING_RATE Lcom/datadog/android/core/internal/attributes/LocalAttribute$Key;
public static final field REPORTING_SAMPLING_RATE Lcom/datadog/android/core/internal/attributes/LocalAttribute$Key;
public static final field VIEW_SCOPE_INSTRUMENTATION_TYPE Lcom/datadog/android/core/internal/attributes/LocalAttribute$Key;
public final fun getString ()Ljava/lang/String;
public fun toString ()Ljava/lang/String;
public static fun valueOf (Ljava/lang/String;)Lcom/datadog/android/core/internal/attributes/LocalAttribute$Key;
public static fun values ()[Lcom/datadog/android/core/internal/attributes/LocalAttribute$Key;
}
Expand All @@ -745,8 +744,6 @@ public final class com/datadog/android/core/internal/attributes/ViewScopeInstrum
public static final field FRAGMENT Lcom/datadog/android/core/internal/attributes/ViewScopeInstrumentationType;
public static final field MANUAL Lcom/datadog/android/core/internal/attributes/ViewScopeInstrumentationType;
public fun getKey ()Lcom/datadog/android/core/internal/attributes/LocalAttribute$Key;
public synthetic fun getValue ()Ljava/lang/Object;
public fun getValue ()Ljava/lang/String;
public static fun valueOf (Ljava/lang/String;)Lcom/datadog/android/core/internal/attributes/ViewScopeInstrumentationType;
public static fun values ()[Lcom/datadog/android/core/internal/attributes/ViewScopeInstrumentationType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,23 @@ interface LocalAttribute {
* Enumeration of all local attributes keys used in the application.
* Made via **enum** to make sure that all such attributes will be removed before sending the event to the backend.
*
* @property string - Unique string value for a local attribute key.
* @param string - Unique string value for a local attribute key.
*/
@InternalApi
enum class Key(
val string: String
private val string: String
) {
/* Some of the metrics like [PerformanceMetric] being sampled on the
* metric creation place and then reported with 100% probability.
* In such cases we need to use *creationSampleRate* to compute effectiveSampleRate correctlyThe sampling
* rate is used when creating metrics.
* Creation(head) sampling rate exist only for long-lived metrics like method performance.
* Created metric still could not be sent it depends on [REPORTING_SAMPLING_RATE] sampling rate
/*
* Some of the metrics such as [PerformanceMetric] are sampled at the point of
* metric creation and then reported with 100% probability.
* In such cases we need to use *creationSampleRate* to correctly calculate effectiveSampleRate.
* The creation(head) sample rate only exists for long-lived metrics such as method performance.
* Created metric still could not be sent, it depends on the [REPORTING_SAMPLING_RATE] sample rate.
*/
CREATION_SAMPLING_RATE("_dd.local.head_sampling_rate_key"),

/* Sampling rate that is used to decide to send or not to send the metric.
/*
* Sampling rate that is used to decide to send or not to send the metric.
* Each metric should have reporting(tail) sampling rate.
* It's possible that metric has only reporting(tail) sampling rate.
*/
Expand All @@ -43,7 +44,11 @@ interface LocalAttribute {
* Indicates which instrumentation was used to track the view scope.
* See [ViewScopeInstrumentationType] for possible values.
*/
VIEW_SCOPE_INSTRUMENTATION_TYPE("_dd.local.view_instrumentation_type_key")
VIEW_SCOPE_INSTRUMENTATION_TYPE("_dd.local.view_instrumentation_type_key");

override fun toString(): String {
return string
}
}

/**
Expand All @@ -56,9 +61,6 @@ interface LocalAttribute {
interface Constant {
/** Constant attribute key. For enum constants will be same for all values. */
val key: Key

/** Constant attribute value. One item from set of possible finite values for a given constant attribute.*/
val value: Any
}
}

Expand Down Expand Up @@ -99,5 +101,5 @@ fun MutableMap<String, Any?>.enrichWithLocalAttribute(
key: LocalAttribute.Key,
value: Any?
) = apply {
this[key.string] = value
this[key.toString()] = value
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@ import com.datadog.android.lint.InternalApi
* A set of constants describing the instrumentation that were used to define the view scope.
*/
@InternalApi
enum class ViewScopeInstrumentationType(
override val value: String
) : LocalAttribute.Constant {
enum class ViewScopeInstrumentationType : LocalAttribute.Constant {
/** Tracked manually through the RUMMonitor API. */
MANUAL("manual"),
MANUAL,

/** Tracked through ComposeNavigationObserver instrumentation. */
COMPOSE("compose"),
COMPOSE,

/** Tracked through ActivityViewTrackingStrategy instrumentation. */
ACTIVITY("activity"),
ACTIVITY,

/** Tracked through FragmentViewTrackingStrategy instrumentation. */
FRAGMENT("fragment");
FRAGMENT;

/** @inheritdoc */
override val key: LocalAttribute.Key = LocalAttribute.Key.VIEW_SCOPE_INSTRUMENTATION_TYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ internal class SdkInternalLoggerTest {
// Given
val samplingRate = 100.0f
val fakeAdditionalProperties = forge.exhaustiveAttributes().also {
it[LocalAttribute.Key.REPORTING_SAMPLING_RATE.string] = samplingRate
it[LocalAttribute.Key.REPORTING_SAMPLING_RATE.toString()] = samplingRate
}
val mockLambda: () -> String = mock()
whenever(mockLambda.invoke()) doReturn fakeMessage
Expand Down Expand Up @@ -505,13 +505,13 @@ internal class SdkInternalLoggerTest {
val metricEvent = firstValue as InternalTelemetryEvent.Metric

assertThat(
metricEvent.additionalProperties?.get(LocalAttribute.Key.CREATION_SAMPLING_RATE.string)
metricEvent.additionalProperties?.get(LocalAttribute.Key.CREATION_SAMPLING_RATE.toString())
).isEqualTo(
expectedCreationSampleRate
)

assertThat(
metricEvent.additionalProperties?.get(LocalAttribute.Key.REPORTING_SAMPLING_RATE.string)
metricEvent.additionalProperties?.get(LocalAttribute.Key.REPORTING_SAMPLING_RATE.toString())
).isEqualTo(
samplingRate
)
Expand Down Expand Up @@ -544,11 +544,11 @@ internal class SdkInternalLoggerTest {
assertThat(
apiUsageEvent.additionalProperties
).doesNotContainKeys(
LocalAttribute.Key.CREATION_SAMPLING_RATE.string
LocalAttribute.Key.CREATION_SAMPLING_RATE.toString()
)

assertThat(
apiUsageEvent.additionalProperties[LocalAttribute.Key.REPORTING_SAMPLING_RATE.string]
apiUsageEvent.additionalProperties[LocalAttribute.Key.REPORTING_SAMPLING_RATE.toString()]
).isEqualTo(
samplingRate
)
Expand All @@ -569,7 +569,7 @@ internal class SdkInternalLoggerTest {
),
target = InternalLogger.Target.TELEMETRY,
messageBuilder = { forge.aString() },
additionalProperties = mapOf(LocalAttribute.Key.REPORTING_SAMPLING_RATE.string to samplingRate)
additionalProperties = mapOf(LocalAttribute.Key.REPORTING_SAMPLING_RATE.toString() to samplingRate)
)

// Then
Expand All @@ -581,11 +581,11 @@ internal class SdkInternalLoggerTest {
assertThat(
debugEvent.additionalProperties
).doesNotContainKeys(
LocalAttribute.Key.CREATION_SAMPLING_RATE.string
LocalAttribute.Key.CREATION_SAMPLING_RATE.toString()
)

assertThat(
debugEvent.additionalProperties?.get(LocalAttribute.Key.REPORTING_SAMPLING_RATE.string)
debugEvent.additionalProperties?.get(LocalAttribute.Key.REPORTING_SAMPLING_RATE.toString())
).isEqualTo(
samplingRate
)
Expand All @@ -604,7 +604,7 @@ internal class SdkInternalLoggerTest {
target = InternalLogger.Target.TELEMETRY,
throwable = forge.aThrowable(),
messageBuilder = { forge.aString() },
additionalProperties = mapOf(LocalAttribute.Key.REPORTING_SAMPLING_RATE.string to samplingRate)
additionalProperties = mapOf(LocalAttribute.Key.REPORTING_SAMPLING_RATE.toString() to samplingRate)
)

// Then
Expand All @@ -616,11 +616,11 @@ internal class SdkInternalLoggerTest {
assertThat(
debugEvent.additionalProperties
).doesNotContainKeys(
LocalAttribute.Key.CREATION_SAMPLING_RATE.string
LocalAttribute.Key.CREATION_SAMPLING_RATE.toString()
)

assertThat(
debugEvent.additionalProperties?.get(LocalAttribute.Key.REPORTING_SAMPLING_RATE.string)
debugEvent.additionalProperties?.get(LocalAttribute.Key.REPORTING_SAMPLING_RATE.toString())
).isEqualTo(
samplingRate
)
Expand Down
26 changes: 25 additions & 1 deletion features/dd-sdk-android-rum/api/apiSurface
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,7 @@ data class com.datadog.android.telemetry.model.TelemetryConfigurationEvent
fun fromJson(kotlin.String): Os
fun fromJsonObject(com.google.gson.JsonObject): Os
data class Configuration
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)
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)
fun toJson(): com.google.gson.JsonElement
companion object
fun fromJson(kotlin.String): Configuration
Expand Down Expand Up @@ -2467,6 +2467,30 @@ data class com.datadog.android.telemetry.model.TelemetryUsageEvent
companion object
fun fromJson(kotlin.String): StartView
fun fromJsonObject(com.google.gson.JsonObject): StartView
class SetViewContext : Usage
val feature: kotlin.String
override fun toJson(): com.google.gson.JsonElement
companion object
fun fromJson(kotlin.String): SetViewContext
fun fromJsonObject(com.google.gson.JsonObject): SetViewContext
class SetViewContextProperty : Usage
val feature: kotlin.String
override fun toJson(): com.google.gson.JsonElement
companion object
fun fromJson(kotlin.String): SetViewContextProperty
fun fromJsonObject(com.google.gson.JsonObject): SetViewContextProperty
class SetViewName : Usage
val feature: kotlin.String
override fun toJson(): com.google.gson.JsonElement
companion object
fun fromJson(kotlin.String): SetViewName
fun fromJsonObject(com.google.gson.JsonObject): SetViewName
class GetViewContext : Usage
val feature: kotlin.String
override fun toJson(): com.google.gson.JsonElement
companion object
fun fromJson(kotlin.String): GetViewContext
fun fromJsonObject(com.google.gson.JsonObject): GetViewContext
class AddAction : Usage
val feature: kotlin.String
override fun toJson(): com.google.gson.JsonElement
Expand Down
Loading

0 comments on commit 85637ab

Please sign in to comment.