UNPKG

3.2 kBTypeScriptView Raw
1import type { MeasurementUnit, Primitive, Span, SpanAttributes, SpanJSON, SpanStatus, SpanTimeInput, TraceContext } from '@sentry/types';
2import type { MetricType } from '../metrics/types';
3export declare const TRACE_FLAG_NONE = 0;
4export declare const TRACE_FLAG_SAMPLED = 1;
5/**
6 * Convert a span to a trace context, which can be sent as the `trace` context in an event.
7 * By default, this will only include trace_id, span_id & parent_span_id.
8 * If `includeAllData` is true, it will also include data, op, status & origin.
9 */
10export declare function spanToTransactionTraceContext(span: Span): TraceContext;
11/**
12 * Convert a span to a trace context, which can be sent as the `trace` context in a non-transaction event.
13 */
14export declare function spanToTraceContext(span: Span): TraceContext;
15/**
16 * Convert a Span to a Sentry trace header.
17 */
18export declare function spanToTraceHeader(span: Span): string;
19/**
20 * Convert a span time input intp a timestamp in seconds.
21 */
22export declare function spanTimeInputToSeconds(input: SpanTimeInput | undefined): number;
23/**
24 * Convert a span to a JSON representation.
25 */
26export declare function spanToJSON(span: Span): Partial<SpanJSON>;
27/** Exported only for tests. */
28export interface OpenTelemetrySdkTraceBaseSpan extends Span {
29 attributes: SpanAttributes;
30 startTime: SpanTimeInput;
31 name: string;
32 status: SpanStatus;
33 endTime: SpanTimeInput;
34 parentSpanId?: string;
35}
36/**
37 * Returns true if a span is sampled.
38 * In most cases, you should just use `span.isRecording()` instead.
39 * However, this has a slightly different semantic, as it also returns false if the span is finished.
40 * So in the case where this distinction is important, use this method.
41 */
42export declare function spanIsSampled(span: Span): boolean;
43/** Get the status message to use for a JSON representation of a span. */
44export declare function getStatusMessage(status: SpanStatus | undefined): string | undefined;
45declare const CHILD_SPANS_FIELD = "_sentryChildSpans";
46declare const ROOT_SPAN_FIELD = "_sentryRootSpan";
47type SpanWithPotentialChildren = Span & {
48 [CHILD_SPANS_FIELD]?: Set<Span>;
49 [ROOT_SPAN_FIELD]?: Span;
50};
51/**
52 * Adds an opaque child span reference to a span.
53 */
54export declare function addChildSpanToSpan(span: SpanWithPotentialChildren, childSpan: Span): void;
55/** This is only used internally by Idle Spans. */
56export declare function removeChildSpanFromSpan(span: SpanWithPotentialChildren, childSpan: Span): void;
57/**
58 * Returns an array of the given span and all of its descendants.
59 */
60export declare function getSpanDescendants(span: SpanWithPotentialChildren): Span[];
61/**
62 * Returns the root span of a given span.
63 */
64export declare function getRootSpan(span: SpanWithPotentialChildren): Span;
65/**
66 * Returns the currently active span.
67 */
68export declare function getActiveSpan(): Span | undefined;
69/**
70 * Updates the metric summary on the currently active span
71 */
72export declare function updateMetricSummaryOnActiveSpan(metricType: MetricType, sanitizedName: string, value: number, unit: MeasurementUnit, tags: Record<string, Primitive>, bucketKey: string): void;
73export {};
74//# sourceMappingURL=spanUtils.d.ts.map
\No newline at end of file