Skip to content

Conversation

schloerke
Copy link
Collaborator

@schloerke schloerke commented Aug 4, 2025

Fixes: #4258

Not implementing #4265 - bindOtel(x), withOtel(expr, ..., bind = "all")
Fixes #4268 - options(shiny.otel.bind = "all") (and "none")
Fixes #4267 - ExtendedTask
Fixes #4282 - options(shiny.otel.bind = "session")
Fixes #4266 - options(shiny.otel.bind = "reactive_update")
Fixes #4268 - options(shiny.otel.bind = "reactivity") / options(shiny.otel.bind = "all")


News entry:

OpenTelemetry support (#4269)

  • Added support for OpenTelemetry via {otel}. By default, if otel::is_tracing_enabled() returns TRUE, then {shiny} will record all OpenTelemetery spans. See {otelsdk}'s Collecting Telemetry Data for more details on configuring OpenTelemetry.

  • Supported values for options(shiny.otel.bind) (or Sys.getenv("SHINY_OTEL_BIND")):

    • "none" - No Shiny OpenTelemetry tracing.
    • "session" - Adds session start/end spans.
    • "reactive_update" - Spans for any synchronous/asynchronous reactive update. (Includes "session" features).
    • "reactivity" - Spans for all reactive expressions. (Includes "reactive_update" features).
    • "all" [default] - All Shiny OpenTelemetry tracing. Currently equivalent to "reactivity".
  • Spans are recorded for:

    • session_start: Wraps the calling of the server() function. Also contains HTTP request within the attributes.
    • session_end: Wraps the calling of the onSessionEnded() handlers.
    • reactive_update: Signals the start of when Shiny knows something is to be calculated. This span ends when there are no more reactive updates (promises or synchronous) to be calculated.
    • reactive, observe, output: Captures the calculation (including any async promise chains) of a reactive expression (reactive()), an observer (observe()), or an output render function (render*()).
    • reactive debounce, reactive throttle: Captures the calculation (including any async promise chains) of a debounce()d or throttle()d reactive expression.
    • ExtendedTask: Captures the calculation (including any async promise chains) of an ExtendedTask.
  • OpenTelemetry Logs are recorded for:

    • Set reactiveVal <name> - When a reactiveVal() is set
    • Set reactiveValues <name>$<key> - When a reactiveValues() element is set
    • Fatal or unhandled errors - When an error occurs that causes the session to end, or when an unhandled error occurs in a reactive context. Contains the error within the attributes. To unsantize the error message being collected, set options(shiny.otel.sanitize.errors = FALSE).
    • Set ExtendedTask <name> <value> - When an ExtendedTask's respective reactive value (e.g., status, value, and error) is set.
    • <ExtendedTask name> add to queue - When an ExtendedTask is added to the task queue.
  • All logs and spans contain the session.id attribute.

screencapture-logfire-us-pydantic-dev-schloerke-posit-conf-demo-2025-10-14-15_19_36

Introduces bindOtel() and withOtelShiny() to enable OpenTelemetry tracing for reactive objects and observers. Adds options shiny.otel.bindall and shiny.otel.graphlocked for automatic binding and graph locking. Updates reactiveVal, reactiveValues, reactive, and observe to support automatic OpenTelemetry binding. Documentation and NAMESPACE updated accordingly.
Included r-lib/otelsdk in the Remotes field to enable installation from GitHub. This supports dependencies required for development or testing.
@schloerke schloerke changed the title feat(otel): Add bindOtel() feat(otel): Add bindOtel() support Aug 5, 2025
@schloerke

This comment was marked as outdated.

Copy link
Member

@jcheng5 jcheng5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...after few remaining nits

@@ -0,0 +1,469 @@
# Personal debugging function -------------------------------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove before merge

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to merge with in it. And perform testing in a followup PR.

@schloerke schloerke changed the title feat(otel): Add bindOtel() support feat: Add {otel} support Oct 10, 2025
@schloerke schloerke marked this pull request as ready for review October 14, 2025 19:30
@schloerke schloerke merged commit 48d255a into main Oct 14, 2025
11 of 12 checks passed
@schloerke schloerke deleted the feat/otel branch October 14, 2025 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants