Advanced Configuration
Customize SDK behavior with advanced configuration options.
Global Attributes
Set attributes that will be included in all telemetry. See Global Attributes for detailed documentation.
Custom Headers
Add custom HTTP headers for backend authentication:
PulseSDK.INSTANCE.initialize(
application = this,
endpointBaseUrl = "https://your-backend.com",
endpointHeaders = mapOf(
"Authorization" to "Bearer your-token",
"X-API-Key" to "your-api-key"
)
)
Disk Buffering
Configure offline storage for telemetry:
PulseSDK.INSTANCE.initialize(
application = this,
endpointBaseUrl = "https://your-backend.com",
diskBuffering = {
enabled(true)
maxCacheSize(50 * 1024 * 1024) // 50 MB
}
)
Instrumentation Configuration
Enable or disable specific instrumentations:
PulseSDK.INSTANCE.initialize(
application = this,
endpointBaseUrl = "https://your-backend.com"
) {
// User interactions
interaction {
enabled(true)
}
// Activity lifecycle
activity {
enabled(true)
}
// Fragment lifecycle
fragment {
enabled(false) // Disable if not using fragments
}
// Network monitoring
network {
enabled(true)
}
// ANR detection
anr {
enabled(true)
}
// Slow/frozen render detection
slowRendering {
enabled(true)
}
}
Session Configuration
Customize session behavior:
import io.opentelemetry.android.agent.session.SessionConfig
PulseSDK.INSTANCE.initialize(
application = this,
endpointBaseUrl = "https://your-backend.com",
sessionConfig = SessionConfig.builder()
.setSessionIdLength(32)
.build()
)
Important Notes
StrictMode
For guidance on Android StrictMode violations (disk/network I/O warnings) triggered by SDK initialization, see StrictMode Policy.
Exporter Chain
The SDK performs asynchronous exporter initialization with in-memory buffering and optional disk buffering. See Exporter Chain Documentation for details.
Next Steps
- Review the instrumentation guides for recommended patterns
- Check Troubleshooting if you encounter issues