server.web.otlp
Server-specific OpenTelemetry instrumentation for jobmon.
This package contains server-specific OTLP functionality that should not be in the shared jobmon_core package. It handles:
FastAPI application instrumentation
SQLAlchemy engine instrumentation
Server-specific configuration patterns
Structured logging with structlog
Architecture: - Delegates to JobmonOTLPManager from core for shared functionality - Adds server-specific instrumentation methods - Provides server-specific structured logging handlers
Submodules
Attributes
Classes
Server-specific OTLP manager that builds on core functionality. |
Functions
|
Get or create the server OTLP manager singleton. |
|
Initialize server-specific OTLP functionality. |
Package Contents
- server.web.otlp.OTLP_AVAILABLE = True
- class server.web.otlp.ServerOTLPManager
Server-specific OTLP manager that builds on core functionality.
Initialize server OTLP manager.
- instrument_app(app: Any) None
Instrument FastAPI application with OpenTelemetry.
This is server-specific functionality that should not be in core.
- classmethod instrument_requests() None
Instrument requests library - server-specific implementation.
- classmethod instrument_sqlalchemy() None
Instrument SQLAlchemy globally - server-specific implementation.
- classmethod instrument_engine(engine: Any) Any
Instrument a specific SQLAlchemy engine with OpenTelemetry.
This directly creates an EngineTracer for the engine, bypassing the SQLAlchemyInstrumentor class. This is necessary because:
SQLAlchemyInstrumentor uses a class-level is_instrumented_by_opentelemetry flag that prevents _instrument() from running if global instrumentation was already performed.
Our engine.py imports create_engine BEFORE instrument_sqlalchemy() patches it, so engines are created with the unpatched function.
The EngineTracer attaches event listeners for query tracing that wouldn’t otherwise be present.
- Returns:
The EngineTracer instance (kept alive to prevent garbage collection of event listeners), or None if instrumentation failed.
- server.web.otlp.get_server_otlp_manager() ServerOTLPManager
Get or create the server OTLP manager singleton.
- server.web.otlp.initialize_server_otlp() ServerOTLPManager
Initialize server-specific OTLP functionality.
This should be called by the server during startup.
- Returns:
The server OTLP manager instance