Screen Lifecycle Instrumentation
Generates: Spans
Automatically tracks Activity and Fragment lifecycle events, including app startup.
How It Works
Pulse Android SDK automatically instruments Activity and Fragment lifecycle callbacks to track:
- App startup (cold, warm, hot)
- Activity state transitions (Created, Resumed, Paused, Stopped, Destroyed)
- Fragment state transitions (Created, Resumed, Paused, Stopped, Destroyed)
- Screen sessions (time spent on each screen)
Configuration
Screen lifecycle instrumentation is enabled by default when using the Android agent. You can configure it during SDK initialization:
PulseSDK.INSTANCE.initialize(
application = this,
endpointBaseUrl = "https://your-backend.com",
) {
activity {
enabled(true) // Enabled by default
}
fragment {
enabled(true) // Enabled by default (disable if not using fragments)
}
}
What Gets Tracked
App Startup
- Span Name:
AppStart - pulse.type:
app_start(for cold starts only)
Activity Lifecycle
- Span Names:
Created,Resumed,Paused,Stopped,Destroyed,Restarted - pulse.type:
screen_load(forCreatedspans)
Fragment Lifecycle
- Span Names:
Created,Restored,Resumed,Paused,Stopped,Destroyed,ViewDestroyed,Detached - pulse.type:
screen_load(forCreatedspans)
Screen Sessions
- Span Name:
ActivitySessionorFragmentSession - pulse.type:
screen_session - Description: Tracks the time a user spends on a screen
Generated Telemetry
Type: Span
Span Name: Varies by lifecycle event (e.g., Created, Resumed, AppStart)
Span Kind: INTERNAL
pulse.type: app_start, screen_load, or screen_session (depending on span type)
Attributes
Lifecycle-Specific Attributes
| Attribute | Description | Example | Always Present |
|---|---|---|---|
pulse.type | Instrumentation type | "app_start", "screen_load", "screen_session" | ✅ Yes |
start.type | App start type | "cold", "warm", "hot" | ⚠️ Only in AppStart spans |
activity.name | Activity class name | "com.example.MainActivity" | ⚠️ Only in Activity spans |
fragment.name | Fragment class name | "com.example.UserFragment" | ⚠️ Only in Fragment spans |
screen.name | Screen name | "MainActivity" | ✅ Yes (Activity/Fragment spans) |
last.screen.name | Previous screen name | "HomeActivity" | ⚠️ Only in Resumed spans |
session.id | Session identifier | "f40364c92b85ec0c19c35a65be42b97f" | ✅ Yes |
Note: All screen lifecycle spans include global attributes (service, device, OS, session, network carrier, etc.) in the
resourcesobject. See Global Attributes for complete list.
Sample Payload: App Startup (Cold Start)
{
"name": "AppStart",
"kind": "INTERNAL",
"startTimeUnixNano": "1701000200000000000",
"endTimeUnixNano": "1701000200125000000",
"duration": "125ms",
"attributes": {
"pulse.type": "app_start",
"start.type": "cold",
"session.id": "f40364c92b85ec0c19c35a65be42b97f"
},
"resources": {
"android.os.api_level": "36",
"app.build_id": "1",
"app.build_name": "1.0_1",
"device.manufacturer": "Google",
"device.model.identifier": "sdk_gphone64_arm64",
"device.model.name": "sdk_gphone64_arm64",
"os.description": "BE2A.250530.026.D1",
"os.name": "Android",
"os.type": "linux",
"os.version": "16",
"rum.sdk.version": "0.16.0-alpha-SNAPSHOT",
"service.name": "PulseReactNativeOtelExample",
"service.version": "1.0_1",
"telemetry.sdk.language": "java",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "1.54.1"
}
}
Sample Payload: Activity Created (Screen Load)
{
"name": "Created",
"kind": "INTERNAL",
"startTimeUnixNano": "1701000300000000000",
"endTimeUnixNano": "1701000300010000000",
"duration": "1ms",
"attributes": {
"pulse.type": "screen_load",
"activity.name": "com.example.MainActivity",
"screen.name": "MainActivity",
"session.id": "f40364c92b85ec0c19c35a65be42b97f"
},
"resources": {
"android.os.api_level": "36",
"app.build_id": "1",
"app.build_name": "1.0_1",
"device.manufacturer": "Google",
"device.model.identifier": "sdk_gphone64_arm64",
"device.model.name": "sdk_gphone64_arm64",
"os.description": "BE2A.250530.026.D1",
"os.name": "Android",
"os.type": "linux",
"os.version": "16",
"rum.sdk.version": "0.16.0-alpha-SNAPSHOT",
"service.name": "PulseReactNativeOtelExample",
"service.version": "1.0_1",
"telemetry.sdk.language": "java",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "1.54.1"
}
}
Sample Payload: Activity Resumed (Screen Transition)
{
"name": "Resumed",
"kind": "INTERNAL",
"startTimeUnixNano": "1701000400000000000",
"endTimeUnixNano": "1701000400005000000",
"duration": "0.5ms",
"attributes": {
"activity.name": "com.example.ProfileActivity",
"screen.name": "ProfileActivity",
"last.screen.name": "MainActivity",
"session.id": "f40364c92b85ec0c19c35a65be42b97f"
},
"events": [
{
"name": "activityPreResumed",
"timeUnixNano": "1701000400001000000"
},
{
"name": "activityResumed",
"timeUnixNano": "1701000400002000000"
},
{
"name": "activityPostResumed",
"timeUnixNano": "1701000400003000000"
}
],
"resources": {
"android.os.api_level": "36",
"app.build_id": "1",
"app.build_name": "1.0_1",
"device.manufacturer": "Google",
"device.model.identifier": "sdk_gphone64_arm64",
"device.model.name": "sdk_gphone64_arm64",
"os.description": "BE2A.250530.026.D1",
"os.name": "Android",
"os.type": "linux",
"os.version": "16",
"rum.sdk.version": "0.16.0-alpha-SNAPSHOT",
"service.name": "PulseReactNativeOtelExample",
"service.version": "1.0_1",
"telemetry.sdk.language": "java",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "1.54.1"
}
}
Sample Payload: Screen Session
{
"name": "ActivitySession",
"kind": "INTERNAL",
"startTimeUnixNano": "1701000500000000000",
"endTimeUnixNano": "1701000500300000000",
"duration": "3s",
"attributes": {
"pulse.type": "screen_session",
"activity.name": "com.example.MainActivity",
"screen.name": "MainActivity",
"session.id": "f40364c92b85ec0c19c35a65be42b97f"
},
"resources": {
"android.os.api_level": "36",
"app.build_id": "1",
"app.build_name": "1.0_1",
"device.manufacturer": "Google",
"device.model.identifier": "sdk_gphone64_arm64",
"device.model.name": "sdk_gphone64_arm64",
"os.description": "BE2A.250530.026.D1",
"os.name": "Android",
"os.type": "linux",
"os.version": "16",
"rum.sdk.version": "0.16.0-alpha-SNAPSHOT",
"service.name": "PulseReactNativeOtelExample",
"service.version": "1.0_1",
"telemetry.sdk.language": "java",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "1.54.1"
}
}
Lifecycle Events
Lifecycle spans include detailed events for state transitions:
Activity Events:
activityPreCreated,activityCreated,activityPostCreatedactivityPreStarted,activityStarted,activityPostStartedactivityPreResumed,activityResumed,activityPostResumedactivityPrePaused,activityPaused,activityPostPausedactivityPreStopped,activityStopped,activityPostStoppedactivityPreDestroyed,activityDestroyed,activityPostDestroyed
Fragment Events:
fragmentPreAttached,fragmentAttachedfragmentPreCreated,fragmentCreated,fragmentViewCreatedfragmentStarted,fragmentResumed,fragmentPaused,fragmentStoppedfragmentViewDestroyed,fragmentDestroyed,fragmentDetached
Note: Disable fragment instrumentation if your app doesn't use fragments to reduce overhead. You can configure this in the Configuration section above.