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
37 changes: 32 additions & 5 deletions sdk/@launchdarkly/observability-android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Add the dependency to your app's Gradle file:
```kotlin
dependencies {
implementation("com.launchdarkly:launchdarkly-android-client-sdk:5.+")
implementation("com.launchdarkly:launchdarkly-observability-android:0.5.0")
implementation("com.launchdarkly:launchdarkly-observability-android:0.19.1")
}
```

Expand All @@ -45,13 +45,15 @@ import com.launchdarkly.sdk.android.LDClient
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()

val mobileKey = "your-mobile-key"

val ldConfig = LDConfig.Builder(LDConfig.Builder.AutoEnvAttributes.Enabled)
.mobileKey("your-mobile-key")
.mobileKey(mobileKey)
.plugins(
Components.plugins().setPlugins(
listOf(
Observability(this@MyApplication)
Observability(this@MyApplication, mobileKey)
)
)
)
Expand Down Expand Up @@ -93,14 +95,17 @@ dependencies {
You can customize the observability plugin with various options:

```kotlin
import com.launchdarkly.observability.api.Options
import com.launchdarkly.observability.api.ObservabilityOptions
import com.launchdarkly.sdk.android.LDAndroidLogging
import io.opentelemetry.api.common.AttributeKey
import io.opentelemetry.api.common.Attributes

val mobileKey = "your-mobile-key"

val observabilityPlugin = Observability(
application = this@MyApplication,
options = Options(
mobileKey = mobileKey,
options = ObservabilityOptions(
serviceName = "my-android-app",
serviceVersion = "1.0.0",
debug = true,
Expand All @@ -116,6 +121,28 @@ val observabilityPlugin = Observability(
)
```

Additional `ObservabilityOptions` settings:

- `logsApiLevel`: Minimum log severity to export (defaults to `INFO`). Set to `ObservabilityOptions.LogLevel.NONE` to disable log exporting.
- `tracesApi`: Controls trace recording (defaults to enabled). Use `ObservabilityOptions.TracesApi.disabled()` to disable all tracing, or set `includeErrors`/`includeSpans`.
- `metricsApi`: Controls metric export (defaults to enabled). Use `ObservabilityOptions.MetricsApi.disabled()` to disable metrics.
- `instrumentations`: Enables/disables specific automatic instrumentations like `crashReporting`, `activityLifecycle`, and `launchTime`.

Example:

```kotlin
val options = ObservabilityOptions(
logsApiLevel = ObservabilityOptions.LogLevel.WARN,
tracesApi = ObservabilityOptions.TracesApi(includeErrors = true, includeSpans = false),
metricsApi = ObservabilityOptions.MetricsApi.disabled(),
instrumentations = ObservabilityOptions.Instrumentations(
crashReporting = false,
activityLifecycle = true,
launchTime = true
)
)
```

### Recording Observability Data

After initialization of the LaunchDarkly Android Client SDK, use `LDObserve` to record metrics, logs, errors, and traces:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ data class ObservabilityOptions(
* This class allows enabling or disabling specific automatic instrumentations.
*
* @property crashReporting If `true`, the plugin will automatically report any uncaught exceptions as errors.
* @property activityLifecycle If `true`, the plugin will automatically start spans for Android Activity lifecycle events.
* @property launchTime If `true`, the plugin will automatically measure and report the application's startup time as metrics.
*/
data class Instrumentations(
Expand Down
Loading