Class TracingInterceptor
- Namespace
- Temporalio.Extensions.OpenTelemetry
- Assembly
- Temporalio.Extensions.OpenTelemetry.dll
Client and worker interceptor that will create and propagate diagnostic activities for clients, workflows, and activities. This can be instantiated and set as an interceptor on the client options and it will automatically apply to all uses including workers.
public class TracingInterceptor : IClientInterceptor, IWorkerInterceptor- Inheritance
- 
      
      TracingInterceptor
- Implements
- Inherited Members
Remarks
This uses OpenTelemetry context propagation and Temporal headers to serialize the diagnostic activities across workers. Normal ActivitySource methods can be used for client and activity code. Workflows however are interruptible/resumable and therefore cannot support .NET activities (i.e. OpenTelemetry spans) that remain open across workers. Therefore, all uses of diagnostic activities inside workflows should only use TrackWorkflowDiagnosticActivity(ActivitySource, string, ActivityKind, IEnumerable<KeyValuePair<string, object?>>?, IEnumerable<ActivityLink>?, bool, bool, Action<Activity>?). See the project README for more information.
Constructors
TracingInterceptor(TracingInterceptorOptions?)
Initializes a new instance of the TracingInterceptor class.
public TracingInterceptor(TracingInterceptorOptions? options = null)Parameters
- optionsTracingInterceptorOptions
- Optional options. 
Fields
ActivitiesSource
Source used for all activity inbound diagnostic activities.
public static readonly ActivitySource ActivitiesSourceField Value
ClientSource
Source used for all client outbound diagnostic activities.
public static readonly ActivitySource ClientSourceField Value
NexusSource
Source used for all Nexus operation inbound diagnostic activities.
public static readonly ActivitySource NexusSourceField Value
WorkflowsSource
Source used for all workflow inbound/outbound diagnostic activities.
public static readonly ActivitySource WorkflowsSourceField Value
Properties
Options
Gets the options this interceptor was created with. This should never be mutated.
public TracingInterceptorOptions Options { get; init; }Property Value
Methods
CreateInActivityTags()
Create tag collection from the current activity environment. Must be called within an activity.
protected virtual IEnumerable<KeyValuePair<string, object?>> CreateInActivityTags()Returns
- IEnumerable<KeyValuePair<string, object>>
- Tags. 
CreateInWorkflowTags()
Create tag collection from the current workflow environment. Must be called within a workflow.
protected virtual IEnumerable<KeyValuePair<string, object?>> CreateInWorkflowTags()Returns
- IEnumerable<KeyValuePair<string, object>>
- Tags. 
CreateUpdateTags(string, string?)
Create tag collection for the given workflow and update ID.
protected virtual IEnumerable<KeyValuePair<string, object?>> CreateUpdateTags(string workflowId, string? updateId)Parameters
Returns
- IEnumerable<KeyValuePair<string, object>>
- Tags. 
CreateWorkflowTags(string)
Create tag collection for the given workflow ID.
protected virtual IEnumerable<KeyValuePair<string, object?>> CreateWorkflowTags(string workflowId)Parameters
- workflowIdstring
- Workflow ID. 
Returns
- IEnumerable<KeyValuePair<string, object>>
- Tags. 
HeadersFromContext(IDictionary<string, string>?, PropagationContext)
Serialize an OTel context to Temporal headers.
protected virtual IDictionary<string, string> HeadersFromContext(IDictionary<string, string>? headers, PropagationContext ctx)Parameters
- headersIDictionary<string, string>
- Headers to mutate if present. 
- ctxPropagationContext
- OTel context. 
Returns
- IDictionary<string, string>
- Created/updated headers. 
HeadersFromContext(IDictionary<string, Payload>?, PropagationContext)
Serialize an OTel context to Temporal headers.
protected virtual IDictionary<string, Payload> HeadersFromContext(IDictionary<string, Payload>? headers, PropagationContext ctx)Parameters
- headersIDictionary<string, Payload>
- Headers to mutate if present. 
- ctxPropagationContext
- OTel context. 
Returns
- IDictionary<string, Payload>
- Created/updated headers. 
HeadersToContext(IReadOnlyDictionary<string, string>?)
Deserialize Temporal headers to OTel context.
protected virtual PropagationContext? HeadersToContext(IReadOnlyDictionary<string, string>? headers)Parameters
- headersIReadOnlyDictionary<string, string>
- Headers to deserialize from. 
Returns
- PropagationContext?
- OTel context if any on the headers. 
HeadersToContext(IReadOnlyDictionary<string, Payload>?)
Deserialize Temporal headers to OTel context.
protected virtual PropagationContext? HeadersToContext(IReadOnlyDictionary<string, Payload>? headers)Parameters
- headersIReadOnlyDictionary<string, Payload>
- Headers to deserialize from. 
Returns
- PropagationContext?
- OTel context if any on the headers. 
InterceptActivity(ActivityInboundInterceptor)
Create an activity inbound interceptor to intercept calls.
public ActivityInboundInterceptor InterceptActivity(ActivityInboundInterceptor nextInterceptor)Parameters
- nextInterceptorActivityInboundInterceptor
- The next interceptor in the chain to call. 
Returns
- ActivityInboundInterceptor
- Created interceptor. 
InterceptClient(ClientOutboundInterceptor)
Create a client outbound interceptor to intercept calls.
public ClientOutboundInterceptor InterceptClient(ClientOutboundInterceptor nextInterceptor)Parameters
- nextInterceptorClientOutboundInterceptor
- The next interceptor in the chain to call. 
Returns
- ClientOutboundInterceptor
- Created interceptor. 
InterceptNexusOperation(NexusOperationInboundInterceptor)
Create a Nexus operation inbound interceptor to intercept calls.
public NexusOperationInboundInterceptor InterceptNexusOperation(NexusOperationInboundInterceptor nextInterceptor)Parameters
- nextInterceptorNexusOperationInboundInterceptor
- The next interceptor in the chain to call. 
Returns
- NexusOperationInboundInterceptor
- Created interceptor. 
Remarks
WARNING: Nexus support is experimental.
InterceptWorkflow(WorkflowInboundInterceptor)
Create a workflow inbound interceptor to intercept calls.
public WorkflowInboundInterceptor InterceptWorkflow(WorkflowInboundInterceptor nextInterceptor)Parameters
- nextInterceptorWorkflowInboundInterceptor
- The next interceptor in the chain to call. 
Returns
- WorkflowInboundInterceptor
- Created interceptor.