Skip to content

otel: Testing Infrastructure #2139

@schloerke

Description

@schloerke

Goal: Add comprehensive tests for OTel functionality with > 90% coverage.

Tasks

  • Create tests/pytest/test_otel_utils.py with fixtures:
    • in_memory_exporter - Capture spans/logs for assertions
    • with_otel_sdk - Context manager to enable OTel for tests
    • assert_span_exists(name, attributes) - Helper for assertions
  • Create tests/pytest/test_otel_session.py to test:
    • Session start span with correct attributes
    • Session end span
    • Collection level controls span creation
    • Session ID included in spans
  • Create tests/pytest/test_otel_reactive.py to test:
    • Reactive flush creates update span
    • Calc/Effect execution creates child spans
    • Span nesting (update → calc/effect)
    • Label generation
    • Source attribute extraction
  • Create tests/pytest/test_otel_collect.py to test:
    • Environment variable controls default level
    • Context manager overrides
    • Decorator overrides
    • Nested context managers
  • Create tests/pytest/test_otel_async.py to test:
    • Spans propagate through async boundaries
    • Concurrent reactive executions maintain correct context
    • Extended tasks maintain span context

Acceptance Criteria

  • All tests pass
  • Coverage > 90% for shiny/otel/ code
  • Tests verify span structure, attributes, and nesting
  • Tests verify context propagation in async scenarios
  • Tests verify collection level controls work correctly
  • Tests verify error recording and sanitization

Files to Create

  • tests/pytest/test_otel_utils.py
  • tests/pytest/test_otel_session.py
  • tests/pytest/test_otel_reactive.py
  • tests/pytest/test_otel_collect.py
  • tests/pytest/test_otel_async.py

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