core.otlp.manager
Core OTLP manager for jobmon-scoped telemetry.
Classes
OTLP manager for shared trace and log resources. |
Functions
|
Context manager that guarantees OTLP flush when exiting. |
|
Register a FastAPI shutdown hook that flushes OTLP telemetry. |
|
Validate OTLP exporter configuration and return list of issues. |
|
Initialize OTLP for shared resources (traces and logs). |
|
Get the shared logger provider, initializing if needed. |
|
Get a logger from the shared provider. |
|
Create a pre-configured log exporter for client applications. |
Module Contents
- class core.otlp.manager.JobmonOTLPManager
OTLP manager for shared trace and log resources.
This manager handles: - Trace provider setup (for distributed tracing) - Logger provider setup (for OTLP log export) - Resource detection (shared across components) - Request instrumentation (shared utility)
All OTLP handlers should use the shared logger provider to avoid duplicate connections and log emissions.
Initialize the OTLP manager.
- classmethod get_instance() JobmonOTLPManager
Get or create the singleton OTLP manager with thread safety.
- core.otlp.manager.otlp_flush_on_exit() Generator[JobmonOTLPManager | None, None, None]
Context manager that guarantees OTLP flush when exiting.
- core.otlp.manager.register_otlp_shutdown_event(app: Any) None
Register a FastAPI shutdown hook that flushes OTLP telemetry.
- core.otlp.manager.validate_otlp_exporter_config(config: Any, exporter_type: str = 'log') list[str]
Validate OTLP exporter configuration and return list of issues.
- Parameters:
config – Exporter configuration dictionary
exporter_type – Type of exporter (‘log’, ‘trace’, ‘metric’)
- Returns:
List of validation error messages. Empty list if valid.
- core.otlp.manager.initialize_jobmon_otlp() JobmonOTLPManager
Initialize OTLP for shared resources (traces and logs).
This creates shared TracerProvider and LoggerProvider instances that should be used by all OTLP handlers to avoid duplicate connections.
- Returns:
The OTLP manager instance with shared providers
Get the shared logger provider, initializing if needed.
This function provides a clean interface for handlers to access the shared LoggerProvider without dealing with manager instances directly. Uses double-checked locking to prevent race conditions in multi-threaded environments like Kubernetes with multiple workers.
- Returns:
The shared LoggerProvider instance, or None if unavailable
- core.otlp.manager.get_logger(name: str) Any | None
Get a logger from the shared provider.
This is the cleanest way for handlers to get OTLP loggers without dealing with manager instances or initialization complexity.
- Parameters:
name – Logger name (typically __name__)
- Returns:
OTLP logger instance, or None if unavailable
- core.otlp.manager.create_log_exporter(**kwargs: Any) Any | None
Create a pre-configured log exporter for client applications.
This factory function creates exporters that can be passed to JobmonOTLPLoggingHandler for pure separation.
- Parameters:
**kwargs – Exporter configuration (endpoint, headers, etc.)
- Returns:
Pre-configured OTLP log exporter, or None if unavailable
Example:
exporter = create_log_exporter( endpoint="otelcol.dev.aks:443", max_batch_size=8 ) handler = JobmonOTLPLoggingHandler(exporter=exporter)