core.logging.context

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.

Functions

get_jobmon_context(→ Dict[str, Any])

Return a copy of all active Jobmon telemetry metadata.

clear_jobmon_context(→ None)

Remove all Jobmon telemetry metadata from the current context.

set_jobmon_context(→ None)

Bind telemetry metadata to the current structlog context.

unset_jobmon_context(→ None)

Remove telemetry metadata keys from the current context.

bind_jobmon_context(→ Iterator[None])

Context manager that binds Jobmon telemetry metadata temporarily.

Module Contents

core.logging.context.get_jobmon_context() Dict[str, Any]

Return a copy of all active Jobmon telemetry metadata.

Returns all context variables with the telemetry_ prefix.

core.logging.context.clear_jobmon_context() None

Remove all Jobmon telemetry metadata from the current context.

core.logging.context.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.

Parameters:
  • allow_non_jobmon_keysINTERNAL 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.

  • **metadata – Key-value pairs to bind to context.

core.logging.context.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.

Parameters:
  • *keys – Keys to remove from context.

  • allow_non_jobmon_keysINTERNAL 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.

core.logging.context.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.