core.otlp
Elegant OTLP integration for jobmon that prevents global log pollution.
Submodules
Attributes
Classes
Formatter that adds OpenTelemetry span details to jobmon logs. |
|
Universal OTLP logging handler supporting dict configs and pre-configured exporters. |
|
OTLP logging handler with structlog formatting for structured logs. |
Functions
|
Structlog processor to add OpenTelemetry span details to log entries. |
|
Get details of the current OpenTelemetry span. |
Package Contents
- class core.otlp.JobmonOTLPFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]
Bases:
logging.FormatterFormatter that adds OpenTelemetry span details to jobmon logs.
- format(record: logging.LogRecord) str[source]
Format log record with OpenTelemetry span details.
- class core.otlp.JobmonOTLPLoggingHandler(level: int = logging.NOTSET, exporter: Any | Dict | None = None)[source]
Bases:
logging.HandlerUniversal OTLP logging handler supporting dict configs and pre-configured exporters.
This handler follows the principle of single responsibility while being flexible enough to work with different configuration patterns:
- Inline dict configuration (server pattern):
- handlers:
- otlp_logs:
class: jobmon.core.otlp.JobmonOTLPLoggingHandler level: INFO exporter:
module: opentelemetry.exporter.otlp.proto.grpc._log_exporter class: OTLPLogExporter endpoint: otelcol.dev.aks.scicomp.ihme.washington.edu:443 options: [[“grpc.max_send_message_length”, 16777216]] max_export_batch_size: 8
- Pre-configured exporter instance:
handler = JobmonOTLPLoggingHandler(exporter=my_exporter)
- _exporter_config = None
- _otlp_handler: logging.Handler | None = None
- _debug_mode
- emit(record: logging.LogRecord) None[source]
Emit a log record to OTLP.
- _create_handler() logging.Handler | None[source]
Create OTLP handler by processing the exporter configuration.
- class core.otlp.JobmonOTLPStructlogHandler(level: int = logging.NOTSET, exporter: Any | Dict | None = None)[source]
Bases:
JobmonOTLPLoggingHandlerOTLP logging handler with structlog formatting for structured logs.
This handler extends JobmonOTLPLoggingHandler to provide structured logging using structlog formatting before sending to OTLP.
- core.otlp.add_span_details_processor(logger: Any, method_name: str, event_dict: Dict[str, Any]) Dict[str, Any][source]
Structlog processor to add OpenTelemetry span details to log entries.
- Parameters:
logger – The logger instance (not used, but required by Structlog processor signature).
method_name – The logging method name (e.g., “info”, “debug”).
event_dict – The event dictionary representing the log entry.
- Returns:
The modified event dictionary with OpenTelemetry span details added.