-
Notifications
You must be signed in to change notification settings - Fork 117
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Goal: Add OTel spans for session start/end and HTTP/WebSocket connections.
Tasks
- Modify
AppSession._run()method to wrap server initialization insession.startspan- Updated in Phase 3: Moved span to wrap only
app.server()call, not entire session loop
- Updated in Phase 3: Moved span to wrap only
- Modify
_run_session_ended_tasks()to wrap session-ended callbacks insession.endspan - Create
shiny/otel/_attributes.pywith:extract_http_attributes(scope)- Extract HTTP attributes from ASGI scope- Attributes:
server.address,server.port,url.path,url.scheme
- Apply HTTP attributes to session start span
- Include session ID in all session spans
Acceptance Criteria
- Session lifecycle creates spans when
SHINY_OTEL_COLLECT >= session - Spans include
session.idattribute - Spans include HTTP metadata (address, port, path, scheme)
- No spans created when
SHINY_OTEL_COLLECT=none - Async context propagates correctly through session lifecycle
-
session.startspan only wraps server initialization (fixed in Phase 3)
Implementation
Files Created
shiny/otel/_attributes.py- HTTP attribute extraction utilities
Files Modified
shiny/session/_session.py- Session lifecycle instrumentationsession.startspan wrapsapp.server()call (server initialization)session.endspan wraps session cleanup callbacks
tests/pytest/test_otel_session.py- 9 comprehensive tests
Status
✅ COMPLETED - Phase 2 complete with Phase 3 refinement
Note: The session.start span scope was refined in Phase 3 (commit 8e0420f8) to only wrap the server function initialization instead of the entire session event loop. This provides a more accurate measurement of server initialization time.
Closed by PR #2144
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request