core.otlp.handlers

Custom OTLP logging handlers that prevent global log pollution.

Classes

JobmonOTLPLoggingHandler

Universal OTLP logging handler supporting dict configs and pre-configured exporters.

JobmonOTLPStructlogHandler

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.Handler

Universal 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:

  1. 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

  2. Pre-configured exporter instance:

    handler = JobmonOTLPLoggingHandler(exporter=my_exporter)

_exporter_config = None[source]
_otlp_handler: logging.Handler | None = None[source]
_debug_mode[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.

_create_exporter_from_dict(config: Any) Any | None[source]

Create an OTLP exporter from dictionary configuration (handles ConvertingDict).

_create_processor_from_dict(exporter: Any, config: Any) Any[source]

Create a batch processor with configuration from dict (handles ConvertingDict).

class core.otlp.handlers.JobmonOTLPStructlogHandler(level: int = logging.NOTSET, exporter: Any | Dict | None = None)[source]

Bases: JobmonOTLPLoggingHandler

OTLP logging handler with structlog formatting for structured logs.

This handler extends JobmonOTLPLoggingHandler to provide structured logging using structlog formatting before sending to OTLP.