Skip to main content

Global Attributes

Global attributes are automatically attached to all telemetry data (events, errors, spans) throughout your application's lifecycle.

Automatic Attributes

The Pulse Android SDK automatically includes the following attributes in all telemetry:

Device Information

  • device.model.name - Device model name (e.g., "Pixel 7")
  • device.model.identifier - Device model identifier
  • device.manufacturer - Device manufacturer (e.g., "Google")

Operating System

  • os.name - Always "Android"
  • os.type - Always "linux"
  • os.version - Android version (e.g., "13")
  • os.description - Full OS description
  • os.api_level - Android API level

Service Information

  • service.name - Application name (from AndroidManifest)
  • service.version - App version (e.g., "1.0.0_123")
  • rum.sdk.version - Pulse SDK version

Network Information

Network attributes are automatically added when network monitoring is enabled:

  • network.connection.type - Connection type (e.g., "wifi", "cellular")
  • network.connection.subtype - Connection subtype (e.g., "LTE", "5G") - requires permission
  • network.carrier.name - Carrier name (e.g., "Verizon") - requires permission
  • network.carrier.mcc - Mobile country code - requires permission
  • network.carrier.mnc - Mobile network code - requires permission
  • network.carrier.icc - ISO country code - requires permission

Note: To get detailed network information (subtype, carrier name, etc.), add READ_PHONE_STATE or READ_BASIC_PHONE_STATE (API 33+) permission to your AndroidManifest.xml.

Session Information

  • session.id - Unique session identifier

Custom Global Attributes

You can add custom global attributes that will be merged with the automatic attributes:

PulseSDK.INSTANCE.initialize(
application = this,
endpointBaseUrl = "https://your-backend.com",
globalAttributes = {
Attributes.builder()
.put("deployment.environment", "production")
.put("service.version", BuildConfig.VERSION_NAME)
.put("device.type", "mobile")
.build()
}
)

Note: Custom global attributes are merged with automatic attributes. Event/span-specific attributes override global attributes when keys conflict.

Practical Example

Set global attributes during SDK initialization:

PulseSDK.INSTANCE.initialize(
application = this,
endpointBaseUrl = "https://your-backend.com",
globalAttributes = {
Attributes.builder()
.put("deployment.environment", if (BuildConfig.DEBUG) "development" else "production")
.put("app.build.type", BuildConfig.BUILD_TYPE)
.put("app.version.code", BuildConfig.VERSION_CODE.toString())
.put("app.version.name", BuildConfig.VERSION_NAME)
.build()
}
)

Attribute Priority

Event/span-specific attributes override global attributes when keys conflict:

// Global attribute
PulseSDK.INSTANCE.initialize(
application = this,
endpointBaseUrl = "https://your-backend.com",
globalAttributes = {
Attributes.of(AttributeKey.stringKey("environment"), "production")
}
)

// This event's 'environment' will be 'staging'
PulseSDK.INSTANCE.trackEvent(
name = "test",
observedTimeStampInMs = System.currentTimeMillis(),
params = mapOf("environment" to "staging")
)

Best Practices

  1. Set global attributes during initialization: Set static metadata (app version, environment, etc.) once during SDK initialization
  2. Use for static metadata: Global attributes are ideal for information that doesn't change during the session
  3. Avoid sensitive data: Don't include PII (Personally Identifiable Information) in global attributes

Common Use Cases for Custom Attributes

  • Environment flags: Distinguish between development, staging, and production
  • Build metadata: Include build type, version code, and version name
  • Feature flags: Track which features are enabled
  • Deployment information: Add deployment-specific context
  • Custom metadata: Add any application-specific context

Note: Device and OS information are already automatically included, so you don't need to set them manually.

Next Steps