import { PutTraceSegmentsResult, XRay, XRayClientConfig } from '@aws-sdk/client-xray'; import { BuildMiddleware, Client, MetadataBearer } from '@aws-sdk/types'; import { FetchInterceptor } from '@collabland/common'; import { Segment, Subsegment, TraceId } from './types.js'; export declare class XRayServiceClient { readonly xray: XRay; constructor(options?: XRayClientConfig); send(...segments: XRaySubsegment[]): Promise; startSegment(segment: Partial): Promise; endSegment(segment: XRaySubsegment): Promise; trace(fn: () => T | Promise, segment: XRaySubsegment | string): Promise; getFetchInterceptor(): FetchInterceptor | undefined; addMiddleware(client: Client, name?: string): BuildMiddleware | undefined; } export declare function generateXRayId(): string; /** * Subsegment backed by XRay */ export declare class XRaySubsegment implements Subsegment { readonly xray: XRayServiceClient; trace_id?: string; parent_id?: string; id: string; name: string; start_time: number; end_time?: number; in_progress?: boolean; origin: string; http?: { request?: Record; response?: Record; }; readonly subsegments: Subsegment[]; [name: string]: unknown; constructor(xray: XRayServiceClient, name?: string); toJSON(): Record; start(): Promise; end(): Promise; checkHttpRes(res: { statusCode?: number; }): { statusCode?: number | undefined; } | undefined; /** * Add and start a subsegment * @param subsegment - Subsegment object or name */ startSubsegment(subsegment: XRaySubsegment | string): Promise; addSubsegment(subsegment: string | XRaySubsegment): XRaySubsegment; } /** * Segment backed by XRay */ export declare class XRaySegment extends XRaySubsegment implements Segment { trace_id: string; constructor(xray: XRayServiceClient, name: string, traceId?: string, parentId?: string); start(): Promise; end(): Promise; } /** * Class describing an AWS X-Ray trace ID. * @see https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-traces */ export declare class XRayTraceId implements TraceId { readonly version = 1; timestamp: string; id: string; /** * Constructs a new trace ID using the current time. * @constructor */ constructor(); static generate(): string; /** * Constructs a new trace ID from provided string. If no string is provided * or the provided string is invalid, * log an error but a new trace ID still returned. This can be used as a * trace ID string validator. * @param rawId - string to create a Trace ID object from. */ static from(rawId?: string): XRayTraceId; /** * Returns a string representation of the trace ID */ toString(): string; } /** * Check if XRay tracing is enabled */ export declare function isXRayEnabled(): boolean;