Table of Contents

Class RuntimeContext

Namespace
OpenTelemetry.Context
Assembly
OpenTelemetry.Api.dll

Generic runtime context management API.

public static class RuntimeContext
Inheritance
RuntimeContext
Inherited Members

Properties

ContextSlotType

Gets or sets the actual context carrier implementation.

public static Type ContextSlotType { get; set; }

Property Value

Type

Methods

GetSlot<T>(string)

Get a registered slot from a given name.

public static RuntimeContextSlot<T> GetSlot<T>(string slotName)

Parameters

slotName string

The name of the context slot.

Returns

RuntimeContextSlot<T>

The slot previously registered.

Type Parameters

T

The type of the underlying value.

GetValue(string)

Gets the value from a registered slot.

public static object GetValue(string slotName)

Parameters

slotName string

The name of the context slot.

Returns

object

The value retrieved from the context slot.

GetValue<T>(string)

Gets the value from a registered slot.

public static T GetValue<T>(string slotName)

Parameters

slotName string

The name of the context slot.

Returns

T

The value retrieved from the context slot.

Type Parameters

T

The type of the value.

RegisterSlot<T>(string)

Register a named context slot.

public static RuntimeContextSlot<T> RegisterSlot<T>(string slotName)

Parameters

slotName string

The name of the context slot.

Returns

RuntimeContextSlot<T>

The slot registered.

Type Parameters

T

The type of the underlying value.

SetValue(string, object)

Sets the value to a registered slot.

public static void SetValue(string slotName, object value)

Parameters

slotName string

The name of the context slot.

value object

The value to be set.

SetValue<T>(string, T)

Sets the value to a registered slot.

public static void SetValue<T>(string slotName, T value)

Parameters

slotName string

The name of the context slot.

value T

The value to be set.

Type Parameters

T

The type of the value.