core.otlp.utils =============== .. py:module:: core.otlp.utils .. autoapi-nested-parse:: OTLP utility functions for jobmon. Classes ------- .. autoapisummary:: core.otlp.utils.JobmonOTLPFormatter Functions --------- .. autoapisummary:: core.otlp.utils.get_current_span_details core.otlp.utils.add_span_details_processor Module Contents --------------- .. py:function:: get_current_span_details() -> Tuple[Optional[str], Optional[str], Optional[str]] Get details of the current OpenTelemetry span. :returns: Tuple of (span_id, trace_id, parent_span_id) as hex strings, or (None, None, None) .. py:function:: add_span_details_processor(logger: Any, method_name: str, event_dict: Dict[str, Any]) -> Dict[str, Any] Structlog processor to add OpenTelemetry span details to log entries. :param logger: The logger instance (not used, but required by Structlog processor signature). :param method_name: The logging method name (e.g., "info", "debug"). :param event_dict: The event dictionary representing the log entry. :returns: The modified event dictionary with OpenTelemetry span details added. .. py:class:: JobmonOTLPFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None) Bases: :py:obj:`logging.Formatter` Formatter that adds OpenTelemetry span details to jobmon logs. Note: For handlers using _JobmonOTLPLoggingHandler, this formatter is not used for OTLP output (handler creates OTLPLogRecord directly). It only affects console/file output. Initialize the formatter with specified format strings. Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format. Use a style parameter of '%', '{' or '$' to specify that you want to use one of %-formatting, :meth:`str.format` (``{}``) formatting or :class:`string.Template` formatting in your format string. .. versionchanged:: 3.2 Added the ``style`` parameter. .. py:method:: format(record: logging.LogRecord) -> str Format log record with OpenTelemetry span details.