core.otlp.handlers ================== .. py:module:: core.otlp.handlers .. autoapi-nested-parse:: Custom OTLP logging handlers that prevent global log pollution. Attributes ---------- .. autoapisummary:: core.otlp.handlers.JobmonOTLPStructlogHandler Classes ------- .. autoapisummary:: core.otlp.handlers.JobmonOTLPLoggingHandler Module Contents --------------- .. py:class:: JobmonOTLPLoggingHandler(level: int = logging.NOTSET, exporter: Optional[Union[Any, Dict]] = None, logger_provider: Optional[Any] = None) Bases: :py:obj:`logging.Handler` Universal OTLP logging handler with lazy initialization and attribute extraction. This handler works with both stdlib logging and structlog. It extracts structured attributes from structlog's thread-local ``event_dict`` when available, enabling rich OTLP exports with queryable fields. Note: ``JobmonOTLPStructlogHandler`` is an alias for this class (kept for backward compatibility). Both names can be used interchangeably in configuration. Supports flexible 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) 3. Direct use with logger_provider (for testing):: handler = JobmonOTLPLoggingHandler(logger_provider=my_provider) Initialize with optional exporter config or pre-configured logger provider. :param level: Logging level for this handler :param exporter: Either a dict configuration or pre-configured OTLP exporter instance :param logger_provider: Optional pre-configured logger provider (for testing/direct use) .. py:method:: close() -> None Tidy up any resources used by the handler. This version removes the handler from an internal map of handlers, _handlers, which is used for handler lookup by name. Subclasses should ensure that this gets called from overridden close() methods. .. py:method:: emit(record: logging.LogRecord) -> None Emit log record to OTLP with extracted attributes. .. py:data:: JobmonOTLPStructlogHandler