Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yamlize existing session events #1845

Merged
merged 13 commits into from
Jan 30, 2025
7 changes: 7 additions & 0 deletions .chloggen/yamlize_session_events_1845.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
change_type: breaking
component: session
note: Move `session.id` and `session.previous_id` from body fields to event attributes, and yamlize `session.start` and `session.end` events.
issues: [1845]
subtext: >
As part of the ongoing migration of event fields from LogRecord body to extended/complex attributes, the
`session.start` and `session.end` events have been redefined.
71 changes: 46 additions & 25 deletions docs/general/session.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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 (see [Session Start Event](#session-start-event) below).
backends can link the two sessions (see [Session Start Event](#event-sessionstart) below).

## Attributes

Expand All @@ -40,39 +40,60 @@ backends can link the two sessions (see [Session Start Event](#session-start-eve

## Session Events

### Session Start Event
## Event: `session.start`

![Experimental](https://img.shields.io/badge/-experimental-blue)
<!-- semconv event.session.start -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->

**Status:** ![Experimental](https://img.shields.io/badge/-experimental-blue)

The event name MUST be `session.start`.

[EventName](https://github.com/open-telemetry/opentelemetry-specification/tree/v1.41.0/specification/logs/data-model.md#field-eventname) MUST be`session.start`
Indicates that a new session has been started, optionally linking to the prior session.

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 indicates 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)`.

| Attribute | Type | Description | Examples | [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. | `00112233-4455-6677-8899-aabbccddeeff` | `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. | `00112233-4455-6677-8899-aabbccddeeff` | `Conditionally Required` [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

**[1] `session.previous_id`:** If the new session is being created as a continuation of a previous session, the `session.previous_id` SHOULD be included in the event. The `session.id` and `session.previous_id` attributes MUST have different values.

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

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.
## Event: `session.end`

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)`.
<!-- semconv event.session.end -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->

| 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) |
**Status:** ![Experimental](https://img.shields.io/badge/-experimental-blue)

### Session End Event
The event name MUST be `session.end`.

![Experimental](https://img.shields.io/badge/-experimental-blue)
Indicates that a session has ended.

[EventName](https://github.com/open-telemetry/opentelemetry-specification/tree/v1.41.0/specification/logs/data-model.md#field-eventname) 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.

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.
| Attribute | Type | Description | Examples | [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 session being ended. | `00112233-4455-6677-8899-aabbccddeeff` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

| 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) |
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status
42 changes: 42 additions & 0 deletions model/session/events.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
groups:
- id: event.session.start
stability: development
type: event
name: session.start
brief: >
Indicates that a new session has been started, optionally linking to the prior session.
note: >
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 indicates
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)`.
attributes:
- ref: session.id
requirement_level: required
brief: The ID of the new session being started.
- ref: session.previous_id
requirement_level:
conditionally_required: >
If the new session is being created as a continuation of a previous session,
the `session.previous_id` SHOULD be included in the event. The `session.id` and `session.previous_id`
attributes MUST have different values.
brief: The previous `session.id` for this user, when known.
- id: event.session.end
stability: development
type: event
name: session.end
brief: >
Indicates that a session has ended.
note: >
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.
attributes:
- ref: session.id
requirement_level: required
brief: The ID of the session being ended.
Loading