Skip to content

Commit 08c4d22

Browse files
authored
docs: Update readme with options refactor (#326)
## Summary - Readme updated - `activityLifecycle` property added to `ObservabilityOptions.Instrumentation` KDocs ## How did you test this change? - No tests needed ## Are there any deployment considerations? No <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Updates Android Observability README to use ObservabilityOptions and mobileKey with version 0.19.1, and adds KDoc for the activityLifecycle instrumentation option. > > - **Docs (Android Observability)**: > - Bump dependency to `launchdarkly-observability-android:0.19.1`. > - Update setup to pass `mobileKey` and construct `Observability(this, mobileKey)`. > - Replace `Options` with `ObservabilityOptions`; add example and outline for `logsApiLevel`, `tracesApi`, `metricsApi`, and `instrumentations` (including `crashReporting`, `activityLifecycle`, `launchTime`). > - **API KDoc**: > - Document `activityLifecycle` in `ObservabilityOptions.Instrumentations`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit a6e82c4. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent f199e2d commit 08c4d22

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

sdk/@launchdarkly/observability-android/README.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Add the dependency to your app's Gradle file:
2626
```kotlin
2727
dependencies {
2828
implementation("com.launchdarkly:launchdarkly-android-client-sdk:5.+")
29-
implementation("com.launchdarkly:launchdarkly-observability-android:0.5.0")
29+
implementation("com.launchdarkly:launchdarkly-observability-android:0.19.1")
3030
}
3131
```
3232

@@ -45,13 +45,15 @@ import com.launchdarkly.sdk.android.LDClient
4545
class MyApplication : Application() {
4646
override fun onCreate() {
4747
super.onCreate()
48+
49+
val mobileKey = "your-mobile-key"
4850

4951
val ldConfig = LDConfig.Builder(LDConfig.Builder.AutoEnvAttributes.Enabled)
50-
.mobileKey("your-mobile-key")
52+
.mobileKey(mobileKey)
5153
.plugins(
5254
Components.plugins().setPlugins(
5355
listOf(
54-
Observability(this@MyApplication)
56+
Observability(this@MyApplication, mobileKey)
5557
)
5658
)
5759
)
@@ -93,14 +95,17 @@ dependencies {
9395
You can customize the observability plugin with various options:
9496

9597
```kotlin
96-
import com.launchdarkly.observability.api.Options
98+
import com.launchdarkly.observability.api.ObservabilityOptions
9799
import com.launchdarkly.sdk.android.LDAndroidLogging
98100
import io.opentelemetry.api.common.AttributeKey
99101
import io.opentelemetry.api.common.Attributes
100102

103+
val mobileKey = "your-mobile-key"
104+
101105
val observabilityPlugin = Observability(
102106
application = this@MyApplication,
103-
options = Options(
107+
mobileKey = mobileKey,
108+
options = ObservabilityOptions(
104109
serviceName = "my-android-app",
105110
serviceVersion = "1.0.0",
106111
debug = true,
@@ -116,6 +121,28 @@ val observabilityPlugin = Observability(
116121
)
117122
```
118123

124+
Additional `ObservabilityOptions` settings:
125+
126+
- `logsApiLevel`: Minimum log severity to export (defaults to `INFO`). Set to `ObservabilityOptions.LogLevel.NONE` to disable log exporting.
127+
- `tracesApi`: Controls trace recording (defaults to enabled). Use `ObservabilityOptions.TracesApi.disabled()` to disable all tracing, or set `includeErrors`/`includeSpans`.
128+
- `metricsApi`: Controls metric export (defaults to enabled). Use `ObservabilityOptions.MetricsApi.disabled()` to disable metrics.
129+
- `instrumentations`: Enables/disables specific automatic instrumentations like `crashReporting`, `activityLifecycle`, and `launchTime`.
130+
131+
Example:
132+
133+
```kotlin
134+
val options = ObservabilityOptions(
135+
logsApiLevel = ObservabilityOptions.LogLevel.WARN,
136+
tracesApi = ObservabilityOptions.TracesApi(includeErrors = true, includeSpans = false),
137+
metricsApi = ObservabilityOptions.MetricsApi.disabled(),
138+
instrumentations = ObservabilityOptions.Instrumentations(
139+
crashReporting = false,
140+
activityLifecycle = true,
141+
launchTime = true
142+
)
143+
)
144+
```
145+
119146
### Recording Observability Data
120147

121148
After initialization of the LaunchDarkly Android Client SDK, use `LDObserve` to record metrics, logs, errors, and traces:

sdk/@launchdarkly/observability-android/lib/src/main/kotlin/com/launchdarkly/observability/api/ObservabilityOptions.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ data class ObservabilityOptions(
7777
* This class allows enabling or disabling specific automatic instrumentations.
7878
*
7979
* @property crashReporting If `true`, the plugin will automatically report any uncaught exceptions as errors.
80+
* @property activityLifecycle If `true`, the plugin will automatically start spans for Android Activity lifecycle events.
8081
* @property launchTime If `true`, the plugin will automatically measure and report the application's startup time as metrics.
8182
*/
8283
data class Instrumentations(

0 commit comments

Comments
 (0)