UNPKG

couchbase

Version:

The official Couchbase Node.js Client Library.

70 lines (69 loc) 2.35 kB
import { AttributeValue, SpanStatus, TimeInput } from './observabilitytypes'; import { RequestSpan, RequestTracer } from './tracing'; import type { Tracer as OTelTracer, TracerProvider as OTelTracerProvider, Span as OTelSpan } from '@opentelemetry/api'; /** * Wrapper class for OpenTelemetry Span that implements RequestSpan interface. */ export declare class OTelWrapperSpan implements RequestSpan { readonly name: string; readonly _otelSpan: OTelSpan; /** * Creates an instance of OTelWrapperSpan. * * @param otelSpan - OpenTelemetry Span to wrap. * @param name - The name of the span. */ constructor(otelSpan: OTelSpan, name: string); /** * Sets an attribute on the span. * * @param key - The attribute key. * @param value - The attribute value. */ setAttribute(key: string, value: AttributeValue): void; /** * Adds an event to the span. * * @param key - The event key. * @param startTime - Optional timestamp for the event. */ addEvent(key: string, startTime?: TimeInput): void; /** * Sets the status of the span. * * @param status - The SpanStatus to set. */ setStatus(status: SpanStatus): void; /** * Ends the span. * * @param endTime - Optional timestamp for when the span ended. */ end(endTime?: TimeInput): void; } /** * Wrapper class for OpenTelemetry Tracer that implements RequestTracer interface. */ export declare class OTelWrapperTracer implements RequestTracer { private _tracer; /** * Creates an instance of OTelWrapperTracer. * * @param tracer - OpenTelemetry Tracer to wrap. */ constructor(tracer: OTelTracer); /** * Creates a new request span, optionally with a parent span. * * @param name - The name of the span. * @param parentSpan - Optional parent span for this request. * @param startTime - Optional timestamp for when the span started. * @returns A RequestSpan instance for the new span. */ requestSpan(name: string, parentSpan?: RequestSpan, startTime?: TimeInput): RequestSpan; } /** * Creates an OpenTelemetry wrapper tracer. * Throws an Error if @opentelemetry/api is not installed. */ export declare function getOTelTracer(tracerProvider?: OTelTracerProvider): RequestTracer;