Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android-agent/api/android-agent.api
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public final class io/opentelemetry/android/agent/dsl/instrumentation/Instrument
public final fun networkMonitoring (Lkotlin/jvm/functions/Function1;)V
public final fun screenOrientation (Lkotlin/jvm/functions/Function1;)V
public final fun slowRenderingReporter (Lkotlin/jvm/functions/Function1;)V
public final fun suppressing ([Ljava/lang/String;)V
}

public final class io/opentelemetry/android/agent/dsl/instrumentation/NetworkMonitoringConfiguration : io/opentelemetry/android/agent/dsl/instrumentation/CanBeEnabledAndDisabled {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import io.opentelemetry.android.instrumentation.AndroidInstrumentationLoader
*/
@OpenTelemetryDslMarker
class InstrumentationConfiguration internal constructor(
config: OtelRumConfig,
private val config: OtelRumConfig,
private val instrumentationLoader: AndroidInstrumentationLoader,
) {
private val activity: ActivityLifecycleConfiguration by lazy {
Expand Down Expand Up @@ -84,4 +84,16 @@ class InstrumentationConfiguration internal constructor(
fun screenOrientation(configure: ScreenOrientationConfiguration.() -> Unit) {
screenOrientation.configure()
}

/**
* Suppresses the named instrumentations so they will not be installed at startup.
*
* The values passed here must match the instrumentation names as exposed by
* AndroidInstrumentation.
*/
fun suppressing(vararg instrumentationsToExclude: String) {
Comment thread
breedx-splk marked this conversation as resolved.
instrumentationsToExclude.forEach {
config.suppressInstrumentation(it)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.opentelemetry.android.agent.dsl

import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import io.opentelemetry.android.agent.FakeClock
import io.opentelemetry.android.agent.FakeInstrumentationLoader
import io.opentelemetry.android.config.OtelRumConfig
import io.opentelemetry.android.features.diskbuffering.DiskBufferingConfig
import org.junit.Before
import org.junit.Test

class InstrumentationConfigurationTest {
private lateinit var otelConfig: OpenTelemetryConfiguration
private lateinit var rumConfig: OtelRumConfig

@Before
fun setUp() {
rumConfig = mockk()
every { rumConfig.setDiskBufferingConfig(any<DiskBufferingConfig>()) } returns rumConfig
every { rumConfig.suppressInstrumentation(any<String>()) } returns rumConfig
otelConfig = OpenTelemetryConfiguration(
rumConfig = rumConfig,
instrumentationLoader = FakeInstrumentationLoader(),
clock = FakeClock()
)
}

@Test
fun canSuppressInstrumentation() {
otelConfig.instrumentations {
suppressing("one", "two", "three")
}
verify {
rumConfig.suppressInstrumentation("one")
rumConfig.suppressInstrumentation("two")
rumConfig.suppressInstrumentation("three")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ class OtelDemoApplication : Application() {
globalAttributes {
Attributes.of(stringKey("toolkit"), "jetpack compose")
}
}
instrumentations {
suppressing (
"unwanted.instrumentation.name",
"something.unwanted"
)
screenOrientation {
enabled(false)
}
}
},
Comment thread
breedx-splk marked this conversation as resolved.
)
Log.d(TAG, "RUM session started: " + rum?.sessionProvider?.getSessionId())
} catch (e: Exception) {
Expand Down