light-sentry-sdk/dist/utils/tracing.d.ts

149 lines
4.6 KiB
TypeScript

import type { Span as SpanInterface, SpanContext, Transaction as TransactionInterface, TransactionContext, SpanStatus, LightClient, BaggageFields } from '../types';
declare function generateTraceId(): string;
declare function generateSpanId(): string;
export declare function httpStatusToSpanStatus(statusCode: number): SpanStatus;
export declare function dbStatusToSpanStatus(dbStatusCode?: string | number): SpanStatus;
export declare function statusToSpanStatus(status: string | number | undefined, op: string | undefined): SpanStatus;
export declare class Span implements SpanInterface {
readonly traceId: string;
readonly spanId: string;
readonly parentSpanId?: string;
op?: string;
description?: string;
status?: SpanStatus;
tags: Record<string, string>;
data: Record<string, unknown>;
readonly startTimestamp: number;
endTimestamp?: number;
transaction?: TransactionInterface;
protected _isFinished: boolean;
protected _client?: LightClient;
constructor(context: SpanContext, transaction?: TransactionInterface, client?: LightClient);
setTag(key: string, value: string): this;
setData(key: string, value: unknown): this;
setStatus(status: SpanStatus): this;
setHttpStatus(statusCode: number): this;
setStatusFromResponse(status: string | number | undefined, tagKey?: string): this;
startChild(context?: SpanContext): Span;
finish(endTimestamp?: number): void;
toTraceparent(): string;
toJSON(): {
trace_id: string;
span_id: string;
parent_span_id: string;
op: string;
description: string;
status: SpanStatus;
tags: {
[x: string]: string;
};
data: {
[x: string]: unknown;
};
start_timestamp: number;
timestamp: number;
};
}
export declare class Transaction extends Span implements TransactionInterface {
name: string;
type?: string;
spans: Span[];
sampled?: boolean;
maxSpans: number;
private _baggage?;
private _dsnPublicKey?;
private _release?;
private _environment?;
private _droppedSpans;
constructor(context: TransactionContext, client?: LightClient, dsnPublicKey?: string, release?: string, environment?: string, maxSpans?: number);
_addSpan(span: Span): void;
private _ensureBaggage;
setBaggage(key: string, value: string): this;
setUserBaggage(userId?: string, segment?: string): this;
toBaggage(): string | undefined;
getBaggage(): BaggageFields | undefined;
finish(endTimestamp?: number): void;
private _getSource;
toEvent(): {
type: "transaction";
transaction: string;
transaction_info: {
source: string;
};
level: "info";
timestamp: number;
start_timestamp: number;
spans: {
trace_id: string;
span_id: string;
parent_span_id: string;
op: string;
description: string;
status: SpanStatus;
tags: {
[x: string]: string;
};
data: {
[x: string]: unknown;
};
start_timestamp: number;
timestamp: number;
}[];
contexts: {
trace: {
trace_id: string;
span_id: string;
parent_span_id: string;
op: string;
status: SpanStatus;
};
};
tags: {
[x: string]: string;
};
extra: Record<string, unknown>;
measurements: Record<string, {
value: number;
unit?: string;
rating?: "good" | "needs-improvement" | "poor";
}>;
platform: string;
};
toJSON(): {
transaction: string;
type: string;
spans: {
trace_id: string;
span_id: string;
parent_span_id: string;
op: string;
description: string;
status: SpanStatus;
tags: {
[x: string]: string;
};
data: {
[x: string]: unknown;
};
start_timestamp: number;
timestamp: number;
}[];
sampled: boolean;
trace_id: string;
span_id: string;
parent_span_id: string;
op: string;
description: string;
status: SpanStatus;
tags: {
[x: string]: string;
};
data: {
[x: string]: unknown;
};
start_timestamp: number;
timestamp: number;
};
}
export { generateTraceId, generateSpanId };