diff --git a/.chloggen/session_start_end_event.yaml b/.chloggen/session_start_end_event.yaml new file mode 100755 index 0000000000..1dd2bf020d --- /dev/null +++ b/.chloggen/session_start_end_event.yaml @@ -0,0 +1,22 @@ +# Use this changelog template to create an entry for release notes. +# +# If your change doesn't affect end users you should instead start +# your pull request title with [chore] or use the "Skip Changelog" label. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: 'enhancement' + +# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db) +component: 'session' + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add new experimental `session.start` and `session.end` events + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +# The values here must be integers. +issues: [1091] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/docs/general/session.md b/docs/general/session.md index 3c4d50209f..99ab4d63f5 100644 --- a/docs/general/session.md +++ b/docs/general/session.md @@ -13,7 +13,7 @@ the Logs, Events, and Spans generated during the Session's lifecycle. When a session reaches end of life, typically due to user inactivity or session timeout, a new session identifier will be assigned. The previous session identifier may be provided by the instrumentation so that telemetry -backends can link the two sessions. +backends can link the two sessions (see [Session Start Event](#session-start-event) below). ## Attributes @@ -35,4 +35,41 @@ backends can link the two sessions. +## Session Events + +### Session Start Event + +![Experimental](https://img.shields.io/badge/-experimental-blue) + +`event.name` MUST be`session.start` + +For instrumentation that tracks user behavior during user sessions, a `session.start` event MUST be emitted +every time a session is created. When a new session is created as a continuation of a prior session, +the `session.previous_id` SHOULD be included in the event. The values of `session.id` and `session.previous_id` +MUST be different. + +When the `session.start` event contains both `session.id` and `session.previous_id` fields, the event then implies +that the previous session has ended. If the session ID in `session.previous_id` has not yet ended via explicit +`session.end` event, then the consumer SHOULD treat this continuation event as semantically equivalent to +`session.end(session.previous_id)` and `session.start(session.id)`. + +| Body field | Type | Description | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | +|---------------------------------------------------------------|--------|------------------------------------------------------|-------------------------------------------------------------------------------------------------------|------------------------------------------------------------------| +| [`session.id`](/docs/attributes-registry/session.md) | string | The ID of the new session being started. | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| [`session.previous_id`](/docs/attributes-registry/session.md) | string | The previous `session.id` for this user, when known. | `Conditionally Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | + +### Session End Event + +![Experimental](https://img.shields.io/badge/-experimental-blue) + +`event.name` MUST be `session.end` + +For instrumentation that tracks user behavior during user sessions, a `session.end` event SHOULD be emitted +every time a session ends. When a session ends and continues as a new session, this event SHOULD be +emitted prior to the `session.start` event. + +| Body field | Type | Description | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | +|---------------------------------------------------------------|--------|----------------------------------------|--------------------------|------------------------------------------------------------------| +| [`session.id`](/docs/attributes-registry/session.md) | string | The ID of the new session being ended. | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | + [DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status