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