1 | import type { Context } from './context';
|
2 | import type { DynamicSamplingContext } from './envelope';
|
3 | import type { Instrumenter } from './instrumenter';
|
4 | import type { MeasurementUnit } from './measurement';
|
5 | import type { ExtractedNodeRequestData, Primitive, WorkerLocation } from './misc';
|
6 | import type { PolymorphicRequest } from './polymorphics';
|
7 | import type { Span, SpanContext } from './span';
|
8 | /**
|
9 | * Interface holding Transaction-specific properties
|
10 | */
|
11 | export interface TransactionContext extends SpanContext {
|
12 | /**
|
13 | * Human-readable identifier for the transaction
|
14 | */
|
15 | name: string;
|
16 | /**
|
17 | * If true, sets the end timestamp of the transaction to the highest timestamp of child spans, trimming
|
18 | * the duration of the transaction. This is useful to discard extra time in the transaction that is not
|
19 | * accounted for in child spans, like what happens in the idle transaction Tracing integration, where we finish the
|
20 | * transaction after a given "idle time" and we don't want this "idle time" to be part of the transaction.
|
21 | */
|
22 | trimEnd?: boolean;
|
23 | /**
|
24 | * If this transaction has a parent, the parent's sampling decision
|
25 | */
|
26 | parentSampled?: boolean;
|
27 | /**
|
28 | * Metadata associated with the transaction, for internal SDK use.
|
29 | */
|
30 | metadata?: Partial<TransactionMetadata>;
|
31 | }
|
32 | /**
|
33 | * Data pulled from a `sentry-trace` header
|
34 | */
|
35 | export declare type TraceparentData = Pick<TransactionContext, 'traceId' | 'parentSpanId' | 'parentSampled'>;
|
36 | /**
|
37 | * Transaction "Class", inherits Span only has `setName`
|
38 | */
|
39 | export interface Transaction extends TransactionContext, Span {
|
40 | /**
|
41 | * @inheritDoc
|
42 | */
|
43 | spanId: string;
|
44 | /**
|
45 | * @inheritDoc
|
46 | */
|
47 | traceId: string;
|
48 | /**
|
49 | * @inheritDoc
|
50 | */
|
51 | startTimestamp: number;
|
52 | /**
|
53 | * @inheritDoc
|
54 | */
|
55 | tags: {
|
56 | [key: string]: Primitive;
|
57 | };
|
58 | /**
|
59 | * @inheritDoc
|
60 | */
|
61 | data: {
|
62 | [key: string]: any;
|
63 | };
|
64 | /**
|
65 | * Metadata about the transaction
|
66 | */
|
67 | metadata: TransactionMetadata;
|
68 | /**
|
69 | * The instrumenter that created this transaction.
|
70 | */
|
71 | instrumenter: Instrumenter;
|
72 | /**
|
73 | * Set the name of the transaction
|
74 | */
|
75 | setName(name: string, source?: TransactionMetadata['source']): void;
|
76 | /**
|
77 | * Set the context of a transaction event
|
78 | */
|
79 | setContext(key: string, context: Context): void;
|
80 | /**
|
81 | * Set observed measurement for this transaction.
|
82 | *
|
83 | * @param name Name of the measurement
|
84 | * @param value Value of the measurement
|
85 | * @param unit Unit of the measurement. (Defaults to an empty string)
|
86 | */
|
87 | setMeasurement(name: string, value: number, unit: MeasurementUnit): void;
|
88 | /** Returns the current transaction properties as a `TransactionContext` */
|
89 | toContext(): TransactionContext;
|
90 | /** Updates the current transaction with a new `TransactionContext` */
|
91 | updateWithContext(transactionContext: TransactionContext): this;
|
92 | /**
|
93 | * Set metadata for this transaction.
|
94 | * @hidden
|
95 | */
|
96 | setMetadata(newMetadata: Partial<TransactionMetadata>): void;
|
97 | /** Return the current Dynamic Sampling Context of this transaction */
|
98 | getDynamicSamplingContext(): Partial<DynamicSamplingContext>;
|
99 | }
|
100 | /**
|
101 | * Context data passed by the user when starting a transaction, to be used by the tracesSampler method.
|
102 | */
|
103 | export interface CustomSamplingContext {
|
104 | [key: string]: any;
|
105 | }
|
106 | /**
|
107 | * Data passed to the `tracesSampler` function, which forms the basis for whatever decisions it might make.
|
108 | *
|
109 | * Adds default data to data provided by the user. See {@link Hub.startTransaction}
|
110 | */
|
111 | export interface SamplingContext extends CustomSamplingContext {
|
112 | /**
|
113 | * Context data with which transaction being sampled was created
|
114 | */
|
115 | transactionContext: TransactionContext;
|
116 | /**
|
117 | * Sampling decision from the parent transaction, if any.
|
118 | */
|
119 | parentSampled?: boolean;
|
120 | /**
|
121 | * Object representing the URL of the current page or worker script. Passed by default when using the `BrowserTracing`
|
122 | * integration.
|
123 | */
|
124 | location?: WorkerLocation;
|
125 | /**
|
126 | * Object representing the incoming request to a node server. Passed by default when using the TracingHandler.
|
127 | */
|
128 | request?: ExtractedNodeRequestData;
|
129 | }
|
130 | export interface TransactionMetadata {
|
131 | /** The sample rate used when sampling this transaction */
|
132 | sampleRate?: number;
|
133 | /**
|
134 | * The Dynamic Sampling Context of a transaction. If provided during transaction creation, its Dynamic Sampling
|
135 | * Context Will be frozen
|
136 | */
|
137 | dynamicSamplingContext?: Partial<DynamicSamplingContext>;
|
138 | /** For transactions tracing server-side request handling, the request being tracked. */
|
139 | request?: PolymorphicRequest;
|
140 | /** Compatibility shim for transitioning to the `RequestData` integration. The options passed to our Express request
|
141 | * handler controlling what request data is added to the event.
|
142 | * TODO (v8): This should go away
|
143 | */
|
144 | requestDataOptionsFromExpressHandler?: {
|
145 | [key: string]: unknown;
|
146 | };
|
147 | /** For transactions tracing server-side request handling, the path of the request being tracked. */
|
148 | /** TODO: If we rm -rf `instrumentServer`, this can go, too */
|
149 | requestPath?: string;
|
150 | /** Information on how a transaction name was generated. */
|
151 | source: TransactionSource;
|
152 | /** Metadata for the transaction's spans, keyed by spanId */
|
153 | spanMetadata: {
|
154 | [spanId: string]: {
|
155 | [key: string]: unknown;
|
156 | };
|
157 | };
|
158 | }
|
159 | /**
|
160 | * Contains information about how the name of the transaction was determined. This will be used by the server to decide
|
161 | * whether or not to scrub identifiers from the transaction name, or replace the entire name with a placeholder.
|
162 | */
|
163 | export declare type TransactionSource =
|
164 | /** User-defined name */
|
165 | 'custom'
|
166 | /** Raw URL, potentially containing identifiers */
|
167 | | 'url'
|
168 | /** Parametrized URL / route */
|
169 | | 'route'
|
170 | /** Name of the view handling the request */
|
171 | | 'view'
|
172 | /** Named after a software component, such as a function or class name. */
|
173 | | 'component'
|
174 | /** Name of a background task (e.g. a Celery task) */
|
175 | | 'task';
|
176 | //# sourceMappingURL=transaction.d.ts.map |
\ | No newline at end of file |