UNPKG

@temporalio/interceptors-opentelemetry

Version:
36 lines (35 loc) 1.84 kB
import * as otel from '@opentelemetry/api'; import { Resource } from '@opentelemetry/resources'; import { SpanExporter } from '@opentelemetry/sdk-trace-base'; import { Context as ActivityContext } from '@temporalio/activity'; import { ActivityExecuteInput, ActivityInboundCallsInterceptor, ActivityOutboundCallsInterceptor, GetLogAttributesInput, InjectedSink, Next } from '@temporalio/worker'; import { OpenTelemetryWorkflowExporter } from '../workflow'; export interface InterceptorOptions { readonly tracer?: otel.Tracer; } /** * Intercepts calls to start an Activity. * * Wraps the operation in an opentelemetry Span and links it to a parent Span context if one is * provided in the Activity input headers. */ export declare class OpenTelemetryActivityInboundInterceptor implements ActivityInboundCallsInterceptor { protected readonly ctx: ActivityContext; protected readonly tracer: otel.Tracer; constructor(ctx: ActivityContext, options?: InterceptorOptions); execute(input: ActivityExecuteInput, next: Next<ActivityInboundCallsInterceptor, 'execute'>): Promise<unknown>; } /** * Intercepts calls to emit logs from an Activity. * * Attach OpenTelemetry context tracing attributes to emitted log messages, if appropriate. */ export declare class OpenTelemetryActivityOutboundInterceptor implements ActivityOutboundCallsInterceptor { protected readonly ctx: ActivityContext; constructor(ctx: ActivityContext); getLogAttributes(input: GetLogAttributesInput, next: Next<ActivityOutboundCallsInterceptor, 'getLogAttributes'>): Record<string, unknown>; } /** * Takes an opentelemetry SpanExporter and turns it into an injected Workflow span exporter sink */ export declare function makeWorkflowExporter(exporter: SpanExporter, resource: Resource): InjectedSink<OpenTelemetryWorkflowExporter>;