@sentry/core
Version:
Base implementation for all Sentry JavaScript SDKs
211 lines • 5.21 kB
TypeScript
import type { Instrumenter, Primitive, Span as SpanInterface, SpanContext, SpanOrigin, TraceContext, Transaction } from '@sentry/types';
/**
* Keeps track of finished spans for a given transaction
* @internal
* @hideconstructor
* @hidden
*/
export declare class SpanRecorder {
spans: Span[];
private readonly _maxlen;
constructor(maxlen?: number);
/**
* This is just so that we don't run out of memory while recording a lot
* of spans. At some point we just stop and flush out the start of the
* trace tree (i.e.the first n spans with the smallest
* start_timestamp).
*/
add(span: Span): void;
}
/**
* Span contains all data about a span
*/
export declare class Span implements SpanInterface {
/**
* @inheritDoc
*/
traceId: string;
/**
* @inheritDoc
*/
spanId: string;
/**
* @inheritDoc
*/
parentSpanId?: string;
/**
* Internal keeper of the status
*/
status?: SpanStatusType | string;
/**
* @inheritDoc
*/
sampled?: boolean;
/**
* Timestamp in seconds when the span was created.
*/
startTimestamp: number;
/**
* Timestamp in seconds when the span ended.
*/
endTimestamp?: number;
/**
* @inheritDoc
*/
op?: string;
/**
* @inheritDoc
*/
description?: string;
/**
* @inheritDoc
*/
tags: {
[key: string]: Primitive;
};
/**
* @inheritDoc
*/
data: {
[key: string]: any;
};
/**
* List of spans that were finalized
*/
spanRecorder?: SpanRecorder;
/**
* @inheritDoc
*/
transaction?: Transaction;
/**
* The instrumenter that created this span.
*/
instrumenter: Instrumenter;
/**
* The origin of the span, giving context about what created the span.
*/
origin?: SpanOrigin;
/**
* You should never call the constructor manually, always use `Sentry.startTransaction()`
* or call `startChild()` on an existing span.
* @internal
* @hideconstructor
* @hidden
*/
constructor(spanContext?: SpanContext);
/** An alias for `description` of the Span. */
get name(): string;
/** Update the name of the span. */
set name(name: string);
/**
* @inheritDoc
*/
startChild(spanContext?: Pick<SpanContext, Exclude<keyof SpanContext, 'sampled' | 'traceId' | 'parentSpanId'>>): Span;
/**
* @inheritDoc
*/
setTag(key: string, value: Primitive): this;
/**
* @inheritDoc
*/
setData(key: string, value: any): this;
/**
* @inheritDoc
*/
setStatus(value: SpanStatusType): this;
/**
* @inheritDoc
*/
setHttpStatus(httpStatus: number): this;
/**
* @inheritDoc
*/
setName(name: string): void;
/**
* @inheritDoc
*/
isSuccess(): boolean;
/**
* @inheritDoc
*/
finish(endTimestamp?: number): void;
/**
* @inheritDoc
*/
toTraceparent(): string;
/**
* @inheritDoc
*/
toContext(): SpanContext;
/**
* @inheritDoc
*/
updateWithContext(spanContext: SpanContext): this;
/**
* @inheritDoc
*/
getTraceContext(): TraceContext;
/**
* @inheritDoc
*/
toJSON(): {
data?: {
[key: string]: any;
};
description?: string;
op?: string;
parent_span_id?: string;
span_id: string;
start_timestamp: number;
status?: string;
tags?: {
[key: string]: Primitive;
};
timestamp?: number;
trace_id: string;
origin?: SpanOrigin;
};
}
export type SpanStatusType =
/** The operation completed successfully. */
'ok'
/** Deadline expired before operation could complete. */
| 'deadline_exceeded'
/** 401 Unauthorized (actually does mean unauthenticated according to RFC 7235) */
| 'unauthenticated'
/** 403 Forbidden */
| 'permission_denied'
/** 404 Not Found. Some requested entity (file or directory) was not found. */
| 'not_found'
/** 429 Too Many Requests */
| 'resource_exhausted'
/** Client specified an invalid argument. 4xx. */
| 'invalid_argument'
/** 501 Not Implemented */
| 'unimplemented'
/** 503 Service Unavailable */
| 'unavailable'
/** Other/generic 5xx. */
| 'internal_error'
/** Unknown. Any non-standard HTTP status code. */
| 'unknown_error'
/** The operation was cancelled (typically by the user). */
| 'cancelled'
/** Already exists (409) */
| 'already_exists'
/** Operation was rejected because the system is not in a state required for the operation's */
| 'failed_precondition'
/** The operation was aborted, typically due to a concurrency issue. */
| 'aborted'
/** Operation was attempted past the valid range. */
| 'out_of_range'
/** Unrecoverable data loss or corruption */
| 'data_loss';
/**
* Converts a HTTP status code into a {@link SpanStatusType}.
*
* @param httpStatus The HTTP response status code.
* @returns The span status or unknown_error.
*/
export declare function spanStatusfromHttpCode(httpStatus: number): SpanStatusType;
//# sourceMappingURL=span.d.ts.map