server.web.otlp =============== .. py:module:: server.web.otlp .. autoapi-nested-parse:: 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 ---------- .. toctree:: :maxdepth: 1 /autoapi/server/web/otlp/manager/index Attributes ---------- .. autoapisummary:: server.web.otlp.OTLP_AVAILABLE Classes ------- .. autoapisummary:: server.web.otlp.ServerOTLPManager Functions --------- .. autoapisummary:: server.web.otlp.get_server_otlp_manager server.web.otlp.initialize_server_otlp Package Contents ---------------- .. py:data:: OTLP_AVAILABLE :value: True .. py:class:: ServerOTLPManager Server-specific OTLP manager that builds on core functionality. Initialize server OTLP manager. .. py:method:: initialize() -> None Initialize the core OTLP manager for server use. .. py:property:: tracer_provider :type: Optional[Any] Get the tracer provider from core manager. .. py:property:: logger_provider :type: Optional[Any] Get the logger provider from core manager. .. py:method:: get_tracer(name: str) -> Optional[Any] Get a tracer for the given name. .. py:method:: instrument_app(app: Any) -> None Instrument FastAPI application with OpenTelemetry. This is server-specific functionality that should not be in core. .. py:method:: instrument_requests() -> None :classmethod: Instrument requests library - server-specific implementation. .. py:method:: instrument_sqlalchemy() -> None :classmethod: Instrument SQLAlchemy globally - server-specific implementation. .. py:method:: instrument_engine(engine: Any) -> Any :classmethod: Instrument a specific SQLAlchemy engine with OpenTelemetry. This directly creates an EngineTracer for the engine, bypassing the SQLAlchemyInstrumentor class. This is necessary because: 1. SQLAlchemyInstrumentor uses a class-level `is_instrumented_by_opentelemetry` flag that prevents `_instrument()` from running if global instrumentation was already performed. 2. Our engine.py imports `create_engine` BEFORE `instrument_sqlalchemy()` patches it, so engines are created with the unpatched function. 3. 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. .. py:function:: get_server_otlp_manager() -> ServerOTLPManager Get or create the server OTLP manager singleton. .. py:function:: initialize_server_otlp() -> ServerOTLPManager Initialize server-specific OTLP functionality. This should be called by the server during startup. :returns: The server OTLP manager instance