Skip to content

Commit

Permalink
RUM-1844: Extract metrics enum to its own class
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmos committed Mar 27, 2024
1 parent 3362449 commit 413769b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.datadog.android.sessionreplay.internal.async.RecordedDataQueueRefs
import com.datadog.android.sessionreplay.internal.recorder.Debouncer
import com.datadog.android.sessionreplay.internal.recorder.SnapshotProducer
import com.datadog.android.sessionreplay.internal.recorder.telemetry.MetricBase
import com.datadog.android.sessionreplay.internal.recorder.telemetry.TelemetryMetricType
import com.datadog.android.sessionreplay.internal.utils.MiscUtils
import java.lang.ref.WeakReference

Expand Down Expand Up @@ -64,7 +65,7 @@ internal class WindowsOnDrawListener(

val methodCallTelemetry = MetricBase.startMetric(
logger = logger,
metric = MetricBase.Companion.TelemetryMetrics.MethodCalled,
metric = TelemetryMetricType.MethodCalled,
callerClass = this.javaClass.name,
samplingRate = methodCallTelemetrySamplingRate
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,17 @@ internal interface MetricBase {
// Basic Metric type key.
internal const val METRIC_TYPE = "metric_type"

internal enum class TelemetryMetrics {
MethodCalled
}

fun startMetric(
logger: InternalLogger,
callerClass: String,
metric: TelemetryMetrics,
metric: TelemetryMetricType,
samplingRate: Float = 100.0f
): MetricBase? {
val sampler: Sampler = RateBasedSampler(samplingRate)
if (!sampler.sample()) return null

return when (metric) {
TelemetryMetrics.MethodCalled -> {
TelemetryMetricType.MethodCalled -> {
MethodCalledTelemetry(
callerClass,
logger
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/

package com.datadog.android.sessionreplay.internal.recorder.telemetry

internal enum class TelemetryMetricType {
MethodCalled
}

0 comments on commit 413769b

Please sign in to comment.