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
36 changes: 18 additions & 18 deletions core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,25 @@ public final class io/opentelemetry/android/SessionIdRatioBasedSampler : io/open
public fun shouldSample (Lio/opentelemetry/context/Context;Ljava/lang/String;Ljava/lang/String;Lio/opentelemetry/api/trace/SpanKind;Lio/opentelemetry/api/common/Attributes;Ljava/util/List;)Lio/opentelemetry/sdk/trace/samplers/SamplingResult;
}

public class io/opentelemetry/android/config/OtelRumConfig {
public final class io/opentelemetry/android/config/OtelRumConfig {
public fun <init> ()V
public fun allowInstrumentation (Ljava/lang/String;)Lio/opentelemetry/android/config/OtelRumConfig;
public fun disableInstrumentationDiscovery ()Lio/opentelemetry/android/config/OtelRumConfig;
public fun disableNetworkAttributes ()Lio/opentelemetry/android/config/OtelRumConfig;
public fun disableScreenAttributes ()Lio/opentelemetry/android/config/OtelRumConfig;
public fun disableSdkInitializationEvents ()Lio/opentelemetry/android/config/OtelRumConfig;
public fun getDiskBufferingConfig ()Lio/opentelemetry/android/features/diskbuffering/DiskBufferingConfig;
public fun getGlobalAttributesSupplier ()Ljava/util/function/Supplier;
public fun hasGlobalAttributes ()Z
public fun isSuppressed (Ljava/lang/String;)Z
public fun setDiskBufferingConfig (Lio/opentelemetry/android/features/diskbuffering/DiskBufferingConfig;)Lio/opentelemetry/android/config/OtelRumConfig;
public fun setGlobalAttributes (Lio/opentelemetry/api/common/Attributes;)Lio/opentelemetry/android/config/OtelRumConfig;
public fun setGlobalAttributes (Ljava/util/function/Supplier;)Lio/opentelemetry/android/config/OtelRumConfig;
public fun shouldDiscoverInstrumentations ()Z
public fun shouldGenerateSdkInitializationEvents ()Z
public fun shouldIncludeNetworkAttributes ()Z
public fun shouldIncludeScreenAttributes ()Z
public fun suppressInstrumentation (Ljava/lang/String;)Lio/opentelemetry/android/config/OtelRumConfig;
public final fun allowInstrumentation (Ljava/lang/String;)Lio/opentelemetry/android/config/OtelRumConfig;
public final fun disableInstrumentationDiscovery ()Lio/opentelemetry/android/config/OtelRumConfig;
public final fun disableNetworkAttributes ()Lio/opentelemetry/android/config/OtelRumConfig;
public final fun disableScreenAttributes ()Lio/opentelemetry/android/config/OtelRumConfig;
public final fun disableSdkInitializationEvents ()Lio/opentelemetry/android/config/OtelRumConfig;
public final fun getDiskBufferingConfig ()Lio/opentelemetry/android/features/diskbuffering/DiskBufferingConfig;
public final fun getGlobalAttributesSupplier ()Ljava/util/function/Supplier;
public final fun hasGlobalAttributes ()Z
public final fun isSuppressed (Ljava/lang/String;)Z
public final fun setDiskBufferingConfig (Lio/opentelemetry/android/features/diskbuffering/DiskBufferingConfig;)Lio/opentelemetry/android/config/OtelRumConfig;
public final fun setGlobalAttributes (Lio/opentelemetry/api/common/Attributes;)Lio/opentelemetry/android/config/OtelRumConfig;
public final fun setGlobalAttributes (Ljava/util/function/Supplier;)Lio/opentelemetry/android/config/OtelRumConfig;
public final fun shouldDiscoverInstrumentations ()Z
public final fun shouldGenerateSdkInitializationEvents ()Z
public final fun shouldIncludeNetworkAttributes ()Z
public final fun shouldIncludeScreenAttributes ()Z
public final fun suppressInstrumentation (Ljava/lang/String;)Lio/opentelemetry/android/config/OtelRumConfig;
}

public final class io/opentelemetry/android/export/AttributeModifyingSpanExporter : io/opentelemetry/sdk/trace/export/SpanExporter {
Expand Down

This file was deleted.

136 changes: 136 additions & 0 deletions core/src/main/java/io/opentelemetry/android/config/OtelRumConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.android.config

import io.opentelemetry.android.features.diskbuffering.DiskBufferingConfig
import io.opentelemetry.android.features.diskbuffering.DiskBufferingConfig.Companion.create
import io.opentelemetry.api.common.Attributes
import java.util.function.Supplier

/**
* Configuration object for OpenTelemetry Android. The configuration items in this class will be
* used in the OpenTelemetryRumBuilder to wire up and enable/disable various mobile instrumentation
* components.
*/
class OtelRumConfig {
private var globalAttributesSupplierImpl: Supplier<Attributes>? = null
private var includeNetworkAttributes = true
private var generateSdkInitializationEvents = true
private var includeScreenAttributes = true
private var discoverInstrumentations = true
private val suppressedInstrumentations: MutableList<String> = mutableListOf()
private var diskBufferingConfigImpl: DiskBufferingConfig = create()

/**
* Configures the set of global attributes to emit with every span and event. Any existing
* configured attributes will be dropped. Default = none.
*/
fun setGlobalAttributes(attributes: Attributes): OtelRumConfig {
if (attributes.isEmpty) {
return this
}
return setGlobalAttributes { attributes }
}

fun setGlobalAttributes(globalAttributesSupplier: Supplier<Attributes>?): OtelRumConfig {
this.globalAttributesSupplierImpl = globalAttributesSupplier
return this
}

fun hasGlobalAttributes(): Boolean = globalAttributesSupplierImpl != null

fun getGlobalAttributesSupplier(): Supplier<Attributes> = globalAttributesSupplierImpl ?: Supplier { Attributes.empty() }

/**
* Disables the collection of runtime network attributes. See [CurrentNetworkProvider] for
* more information. Default = true.
*
* @return this
*/
fun disableNetworkAttributes(): OtelRumConfig {
includeNetworkAttributes = false
return this
}

/** Returns true if runtime network attributes are enabled, false otherwise. */
fun shouldIncludeNetworkAttributes(): Boolean = includeNetworkAttributes

/**
* Disables the collection of events related to the initialization of the OTel Android SDK
* itself. Default = true.
*
* @return this
*/
fun disableSdkInitializationEvents(): OtelRumConfig {
generateSdkInitializationEvents = false
return this
}

/** Returns true if the SDK is configured to generate initialization events, false otherwise. */
fun shouldGenerateSdkInitializationEvents(): Boolean = generateSdkInitializationEvents

/**
* Call this to disable the collection of screen attributes. See [ ] for more information. Default = true.
*
* @return this
*/
fun disableScreenAttributes(): OtelRumConfig {
includeScreenAttributes = false
return this
}

/** Return true if the SDK should be configured to report screen attributes. */
fun shouldIncludeScreenAttributes(): Boolean = includeScreenAttributes

/**
* Return true if the RUM initialization should look for instrumentations in the
* classpath and apply them automatically.
*/
fun shouldDiscoverInstrumentations(): Boolean = discoverInstrumentations

/**
* Call this to disable the automatic search for instrumentations in the classpath.
*
* @return this
*/
fun disableInstrumentationDiscovery(): OtelRumConfig {
discoverInstrumentations = false
return this
}

/**
* Adds an instrumentation name to the list of suppressed instrumentations. Instrumentations
* that have been suppressed will not be installed at startup.
*/
fun suppressInstrumentation(instrumentationName: String): OtelRumConfig {
suppressedInstrumentations.add(instrumentationName)
return this
}

/**
* Removes an instrumentation name from the list of suppressed instrumentations.
* Instrumentations that have been suppressed will not be installed at startup.
*/
fun allowInstrumentation(instrumentationName: String): OtelRumConfig {
suppressedInstrumentations.remove(instrumentationName)
return this
}

/** Returns false when the given instrumentation has been suppressed. True otherwise. */
fun isSuppressed(instrumentationName: String): Boolean = suppressedInstrumentations.contains(instrumentationName)

fun getDiskBufferingConfig(): DiskBufferingConfig = diskBufferingConfigImpl

/**
* Sets the parameters for caching signals in disk in order to export them later.
*
* @return this
*/
fun setDiskBufferingConfig(diskBufferingConfig: DiskBufferingConfig): OtelRumConfig {
this.diskBufferingConfigImpl = diskBufferingConfig
return this
}
}
Loading