core.otlp.manager
Core OTLP manager for jobmon-scoped telemetry.
Attributes
Classes
OTLP manager for shared trace and log resources. |
Functions
|
|
|
Flush OTLP telemetry a single time per process. |
|
Register the OTLP flush hook for interpreter shutdown. |
|
Install signal handlers that flush OTLP before termination. |
|
Ensure lifecycle hooks are installed exactly once. |
|
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
- core.otlp.manager._build_exporter_args(config: Dict[str, Any], module_name: str) Dict[str, Any][source]
- core.otlp.manager._normalize_exporter_config(config: Any, defaults: Dict[str, Any] | None = None) Tuple[Type[Any] | None, Dict[str, Any]][source]
- class core.otlp.manager.JobmonOTLPManager[source]
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.
- _instance: JobmonOTLPManager | None = None[source]
- classmethod get_instance() JobmonOTLPManager[source]
Get or create the singleton OTLP manager with thread safety.
- _create_log_exporter(config: Any) Any | None[source]
Create a log exporter from configuration dictionary.
- core.otlp.manager._flush_otlp_once(reason: str = 'atexit') None[source]
Flush OTLP telemetry a single time per process.
- core.otlp.manager._register_atexit_hook() None[source]
Register the OTLP flush hook for interpreter shutdown.
- core.otlp.manager._register_signal_handlers() None[source]
Install signal handlers that flush OTLP before termination.
- core.otlp.manager._install_lifecycle_hooks() None[source]
Ensure lifecycle hooks are installed exactly once.
- core.otlp.manager.otlp_flush_on_exit() Generator[JobmonOTLPManager | None, None, None][source]
Context manager that guarantees OTLP flush when exiting.
- core.otlp.manager.register_otlp_shutdown_event(app: Any) None[source]
Register a FastAPI shutdown hook that flushes OTLP telemetry.
- core.otlp.manager.validate_otlp_exporter_config(config: Any, exporter_type: str = 'log') list[str][source]
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[source]
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[source]
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[source]
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)