opentelemetry.correlationcontext package

Module contents

opentelemetry.correlationcontext.get_correlations(context=None)[source]

Returns the name/value pairs in the CorrelationContext

Parameters

context (Optional[Context]) – The Context to use. If not set, uses current Context

Return type

Dict[str, object]

Returns

Name/value pairs in the CorrelationContext

opentelemetry.correlationcontext.get_correlation(name, context=None)[source]

Provides access to the value for a name/value pair in the CorrelationContext

Parameters
  • name (str) – The name of the value to retrieve

  • context (Optional[Context]) – The Context to use. If not set, uses current Context

Return type

Optional[object]

Returns

The value associated with the given name, or null if the given name is not present.

opentelemetry.correlationcontext.set_correlation(name, value, context=None)[source]

Sets a value in the CorrelationContext

Parameters
  • name (str) – The name of the value to set

  • value (object) – The value to set

  • context (Optional[Context]) – The Context to use. If not set, uses current Context

Return type

Context

Returns

A Context with the value updated

opentelemetry.correlationcontext.remove_correlation(name, context=None)[source]

Removes a value from the CorrelationContext

Parameters
  • name (str) – The name of the value to remove

  • context (Optional[Context]) – The Context to use. If not set, uses current Context

Return type

Context

Returns

A Context with the name/value removed

opentelemetry.correlationcontext.clear_correlations(context=None)[source]

Removes all values from the CorrelationContext

Parameters

context (Optional[Context]) – The Context to use. If not set, uses current Context

Return type

Context

Returns

A Context with all correlations removed