Skip to content

Session handling implementation #2358

@martinkuba

Description

@martinkuba

Related to open-telemetry/opentelemetry-browser#23

This is a proposal to implement sessions for web. The session.id attribute is now defined in semantic conventions (link). The attribute should be added to any span or log generated by a web instrumentation.

Implementation proposal:

  • implement SessionIdSpanProcessor and SessionIdLogRecordProcessor
  • these two processors will have a dependency on a SessionManager
  • when adding the attribute, the processors will get the session ID from the manager
  • the manager is responsible for managing the session ID value (generating, persisting and expiring)
  • we provide a default implementation of SessionManager that will use LocalStorage and configurable expiration
  • users can provide their own implementation of a SessionManager
  • all of this functionality will live in a new package called web-common

SessionManager interface

export interface SessionManager {
  getSessionId(): string
}

A prototype of this proposal is available here.

Prior implementations:

I am looking for any feedback on this approach. If there are no objections, I will open a PR in line with the prototype implementation.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions