import * as otel from '@opentelemetry/api'; import type { Resource } from '@opentelemetry/resources'; import type { SpanProcessor } from '@opentelemetry/sdk-trace-base'; import type * as nexus from 'nexus-rpc'; import type { Context as ActivityContext } from '@temporalio/activity'; import type { Next, ActivityInboundCallsInterceptor, ActivityOutboundCallsInterceptor, NexusInboundCallsInterceptor, NexusOutboundCallsInterceptor, NexusStartOperationInput, NexusStartOperationOutput, NexusCancelOperationInput, InjectedSink, GetLogAttributesInput, GetMetricTagsInput, ActivityExecuteInput } from '@temporalio/worker'; import { type OpenTelemetryWorkflowExporter } from '../workflow/definitions'; 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. * * @experimental This interceptor is experimental and APIs may change without notice. */ 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): Promise; } /** * Intercepts calls to emit logs and metrics from an Activity. * * Attach OpenTelemetry context tracing attributes to emitted log messages, if appropriate. * * @experimental This interceptor is experimental and APIs may change without notice. */ export declare class OpenTelemetryActivityOutboundInterceptor implements ActivityOutboundCallsInterceptor { protected readonly ctx: ActivityContext; constructor(ctx: ActivityContext); getLogAttributes(input: GetLogAttributesInput, next: Next): Record; getMetricTags(input: GetMetricTagsInput, next: Next): GetMetricTagsInput; } /** * Intercepts inbound Nexus Operation calls on the worker. * * Wraps `startOperation` and `cancelOperation` in opentelemetry Spans, linking to a parent Span context * if one is provided in the Nexus request headers. * * @experimental This interceptor is experimental and APIs may change without notice. */ export declare class OpenTelemetryNexusInboundInterceptor implements NexusInboundCallsInterceptor { protected readonly ctx: nexus.OperationContext; protected readonly tracer: otel.Tracer; constructor(ctx: nexus.OperationContext, options?: InterceptorOptions); startOperation(input: NexusStartOperationInput, next: Next): Promise; cancelOperation(input: NexusCancelOperationInput, next: Next): Promise; } /** * Intercepts outbound calls from a Nexus Operation handler. * * Attaches OpenTelemetry context tracing attributes to emitted log messages. * * @experimental This interceptor is experimental and APIs may change without notice. */ export declare class OpenTelemetryNexusOutboundInterceptor implements NexusOutboundCallsInterceptor { protected readonly ctx: nexus.OperationContext; constructor(ctx: nexus.OperationContext); getLogAttributes(input: GetLogAttributesInput, next: Next): Record; getMetricTags(input: GetMetricTagsInput, next: Next): GetMetricTagsInput; } /** * Takes an opentelemetry SpanProcessor and turns it into an injected Workflow span exporter sink. */ export declare function makeWorkflowExporter(processor: SpanProcessor, resource: Resource): InjectedSink;