Skip to content

otel: Value Updates and Logging #2136

@schloerke

Description

@schloerke

Goal: Log reactive value updates as OTel log events.

Tasks

  • Add logging helper to shiny/otel/_core.py:
    • emit_otel_log(body, severity, attributes) - Emit OTel log record
  • Modify Value._set() to log value updates
  • Store value name at creation time for logging
  • Include session ID in log attributes
  • Add comprehensive tests
  • Create example application

Acceptance Criteria

  • Value updates logged when SHINY_OTEL_COLLECT >= reactivity
  • Logs include value name (e.g., "Set reactiveVal myValue")
  • Logs include session.id attribute
  • No logs when collection level insufficient
  • No-op when OTel SDK not configured

Implementation

Completed in PR #2169:

  • Added emit_otel_log() helper function (renamed from emit_log for clarity)
  • Value updates log with DEBUG severity
  • Namespace support for module-scoped values
  • Standalone values log as <unnamed>
  • 12 comprehensive tests
  • Example application demonstrating functionality

Files Modified

  • shiny/otel/_core.py - Added emit_otel_log() helper
  • shiny/otel/__init__.py - Export emit_otel_log
  • shiny/reactive/_reactives.py - Log in Value._set() method
  • shiny/session/_session.py - Set value names in Inputs
  • tests/pytest/test_otel_value_logging.py - 12 tests
  • examples/otel-value-logging/ - Demo application

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions