Skip to content

[OTEL] Add OpenTelemetry event tracing for session$allowReconnect() #4311

@karangattu

Description

@karangattu

Shiny has an session$allowReconnect() method that allows apps to enable automatic client reconnection when the network connection is lost. This method sends a control message to the client (TRUE, FALSE, or "force") to determine whether automatic reconnection is allowed.

Currently, OTEL tracing in Shiny covers:

  • Session lifecycle events (session_start, session_end spans )
  • Reactive updates and expressions
  • Error handling and logging
  • Custom events and labels

However, there is no OTEL event/span created when session$allowReconnect() is called, which means we cannot track which sessions have reconnection enabled in the trace data. Additionally, when a client reconnects after a network interruption, it's unclear how to correlate the new session with the previous session in OTEL traces.

Problem: When a client disconnects and reconnects:

The client typically creates a new session object on the server
The new session gets a new session.id (token)
Current OTEL spans are tied to the original session ID, making it hard to trace the reconnection event

Some feasible options

  1. Option A (Recommended): Reuse session ID on reconnection
  2. Option B: Link previous session ID as trace context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions