core.otlp.handlers
Custom OTLP logging handlers that prevent global log pollution.
Classes
Universal OTLP logging handler supporting dict configs and pre-configured exporters. |
|
OTLP logging handler with structlog formatting for structured logs. |
Module Contents
- class core.otlp.handlers.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)
- _otlp_handler: logging.Handler | None = None[source]
- 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.handlers.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.