core.logging.context ==================== .. py:module:: core.logging.context .. autoapi-nested-parse:: Telemetry context helpers for Jobmon structlog instrumentation. All Jobmon telemetry metadata is namespaced with the 'telemetry_' prefix. This clearly indicates data that is exported to OTLP but stripped from console output, without requiring explicit key registries. Attributes ---------- .. autoapisummary:: core.logging.context._TELEMETRY_PREFIX Functions --------- .. autoapisummary:: core.logging.context._normalize_context_metadata core.logging.context._normalize_context_keys core.logging.context._normalize_context_key core.logging.context.get_jobmon_context core.logging.context.clear_jobmon_context core.logging.context.set_jobmon_context core.logging.context.unset_jobmon_context core.logging.context.bind_jobmon_context Module Contents --------------- .. py:data:: _TELEMETRY_PREFIX :value: 'telemetry_' .. py:function:: _normalize_context_metadata(metadata: Mapping[str, Any], *, allow_non_jobmon_keys: bool) -> Dict[str, Any] Filter ``None`` values and apply telemetry prefixing rules. .. py:function:: _normalize_context_keys(keys: Iterable[str], *, allow_non_jobmon_keys: bool) -> Sequence[str] Apply telemetry prefixing rules to context keys. .. py:function:: _normalize_context_key(key: str, *, allow_non_jobmon_keys: bool) -> str Return a context key that honours telemetry prefixing rules. .. py:function:: get_jobmon_context() -> Dict[str, Any] Return a copy of all active Jobmon telemetry metadata. Returns all context variables with the 'telemetry_' prefix. .. py:function:: clear_jobmon_context() -> None Remove all Jobmon telemetry metadata from the current context. .. py:function:: set_jobmon_context(*, allow_non_jobmon_keys: bool = False, **metadata: Any) -> None Bind telemetry metadata to the current structlog context. All keys are automatically prefixed with 'telemetry_' unless allow_non_jobmon_keys is True. :param allow_non_jobmon_keys: **INTERNAL USE ONLY**. If True, bind keys as-is without adding telemetry_ prefix. Used internally by the bind_context decorator and server middleware. External callers should not use this flag. :param \*\*metadata: Key-value pairs to bind to context. .. py:function:: unset_jobmon_context(*keys: str, allow_non_jobmon_keys: bool = False) -> None Remove telemetry metadata keys from the current context. Keys are automatically prefixed with 'telemetry_' unless allow_non_jobmon_keys is True. :param \*keys: Keys to remove from context. :param allow_non_jobmon_keys: **INTERNAL USE ONLY**. If True, remove keys as-is without adding telemetry_ prefix. Used internally by the bind_context decorator and server middleware. External callers should not use this flag. .. py:function:: bind_jobmon_context(**metadata: Any) -> Iterator[None] Context manager that binds Jobmon telemetry metadata temporarily. All keys are automatically prefixed with 'telemetry_' if not already.