You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See <PlatformLinkto="/tracing/instrumentation/automatic-instrumentation">Automatic Instrumentation</PlatformLink> to learn about all the things that the SDK automatically instruments for you.
69
+
See <PlatformLinkto="/tracing/instrumentation/automatic-instrumentation">Automatic Instrumentation</PlatformLink> to learn about all the things that the SDK automatically instruments for you.
70
+
70
71
</PlatformSection>
71
72
72
73
## Custom Instrumentation
73
74
74
75
You can also manually start spans to instrument specific parts of your code. This is useful when you want to measure the performance of a specific operation or function.
75
76
76
-
See <PlatformLinkto="/tracing/span-metrics/">Sending Span Metrics</PlatformLink> to learn how to manually start spans.
Copy file name to clipboardExpand all lines: docs/platforms/javascript/common/tracing/instrumentation/index.mdx
+15-85Lines changed: 15 additions & 85 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,8 @@ To capture transactions and spans customized to your organization's needs, you m
12
12
13
13
To add custom performance data to your application, you need to add custom instrumentation in the form of spans. Spans are a way to measure the time it takes for a specific action to occur. For example, you can create a span to measure the time it takes for a function to execute.
14
14
15
+
You can find a list of all tracing APIs in the <PlatformLinkto="/apis/#tracing">Tracing API</PlatformLink> section.
@@ -106,7 +108,7 @@ To add spans that aren't active, you can create independent spans. This is usefu
106
108
107
109
By default, any span that is started will be the child of the currently active span. If you want to have a different behavior, you can force spans to be the children of a specific span with the `parentSpan` option:
This method allows you to make a span active for the duration of a callback. You can use this in combination with `startInactiveSpan` to manually associate child spans with the correct parent span:
Suppresses the creation of sampled spans for the duration of the callback. This is useful when you want to prevent certain spans from being captured. For example, if you do not want to create spans for a given fetch request, you can do:
179
-
180
-
```javascript
181
-
Sentry.suppressTracing(() => {
182
-
fetch("https://example.com");
183
-
});
184
-
```
124
+
See <PlatformLinkto="/apis/#tracing-utilities">Tracing Utility APIs</PlatformLink> for more information.
See <PlatformLinkto="/tracing/trace-propagation/custom-instrumentation/">Distributed Tracing</PlatformLink> for details on how to manually set up distributed tracing.
129
+
See <PlatformLinkto="/tracing/trace-propagation/custom-instrumentation/">Custom Trace Propagation</PlatformLink> for details on how to manually set up distributed tracing.
190
130
191
131
</PlatformSection>
192
132
@@ -227,32 +167,22 @@ if (span) {
227
167
228
168
### Adding attributes to all spans
229
169
230
-
To add an attribute to all spans, use the `beforeSendTransaction` callback:
170
+
To add an attribute to all spans, use the `beforeSendSpan` callback:
231
171
232
172
```javascript
233
173
Sentry.init({
234
174
// dsn, ...
235
-
beforeSendTransaction(event) {
236
-
237
-
// set the attribute on the root span
238
-
event.contexts.trace.data= {
239
-
...event.contexts.trace.data,
240
-
myAttribute:"myValue",
241
-
}
242
-
243
-
// and on all child spans
244
-
event.spans.forEach(span=> {
245
-
span.data= {
246
-
...span.data,
247
-
myAttribute:"myValue",
248
-
}
249
-
});
250
-
}
175
+
beforeSendSpan(span) {
176
+
span.data= {
177
+
...span.data,
178
+
"environment.region":"us-west-2",
179
+
};
180
+
181
+
return span;
182
+
},
251
183
});
252
184
```
253
185
254
-
255
-
256
186
### Adding Span Operations ("op")
257
187
258
188
Spans can have an operation associated with them, which help Sentry identify additional context about the span. For example, database related spans have the `db` span operation associated with them. The Sentry product offers additional controls, visualizations, and filters for spans with known operations.
0 commit comments