Skip to content

Commit c357260

Browse files
committed
Merge branch 'master' into txiao/docs/update-python-continuous-profiling-docs
2 parents a3700ac + 901895d commit c357260

File tree

53 files changed

+1976
-522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1976
-522
lines changed

docs/concepts/key-terms/tracing/span-metrics.mdx

Lines changed: 69 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,17 @@ By attaching attributes directly to spans, you create a unified view of both the
2020
// Simple database query with dynamic attributes
2121
Sentry.startSpan(
2222
{
23-
name: 'Database Query',
24-
op: 'db.query'
23+
name: "Database Query",
24+
op: "db.query",
2525
},
26-
() => {
27-
// Get active span to set attributes as data becomes available
28-
const span = Sentry.getActiveSpan();
29-
26+
(span) => {
3027
// Execute query and add results to span
31-
const result = executeQuery('SELECT * FROM users WHERE active = true');
32-
28+
const result = executeQuery("SELECT * FROM users WHERE active = true");
29+
3330
// Set attributes with the results data
34-
if (span) {
35-
span.setAttribute('db.rows_returned', result.length);
36-
span.setAttribute('db.execution_time_ms', result.executionTime);
37-
}
38-
31+
span.setAttribute("db.rows_returned", result.length);
32+
span.setAttribute("db.execution_time_ms", result.executionTime);
33+
3934
return result;
4035
}
4136
);
@@ -55,14 +50,14 @@ By integrating these attributes into tracing, you can maintain a single telemetr
5550
// Adding business context to a payment processing span
5651
Sentry.startSpan(
5752
{
58-
name: 'Process Payment',
59-
op: 'payment.process',
53+
name: "Process Payment",
54+
op: "payment.process",
6055
attributes: {
61-
'payment.amount': 99.99,
62-
'payment.currency': 'USD',
63-
'payment.method': 'credit_card',
64-
'customer.type': 'returning'
65-
}
56+
"payment.amount": 99.99,
57+
"payment.currency": "USD",
58+
"payment.method": "credit_card",
59+
"customer.type": "returning",
60+
},
6661
},
6762
async () => {
6863
// Payment processing implementation
@@ -91,12 +86,12 @@ Augment automatically-created or manually-defined spans with additional attribut
9186
const span = Sentry.getActiveSpan();
9287
if (span) {
9388
// User context
94-
span.setAttribute('user.subscription_tier', 'premium');
95-
89+
span.setAttribute("user.subscription_tier", "premium");
90+
9691
// Multiple metrics in a single operation
9792
span.setAttributes({
98-
'memory.heap_used': 1024000,
99-
'processing.total_steps': 5
93+
"memory.heap_used": 1024000,
94+
"processing.total_steps": 5,
10095
});
10196
}
10297
```
@@ -109,16 +104,16 @@ Create spans specifically for grouping related attributes or metrics, particular
109104
// Creating a span for monitoring external API usage
110105
Sentry.startSpan(
111106
{
112-
name: 'Third-Party API Usage',
113-
op: 'external.api',
107+
name: "Third-Party API Usage",
108+
op: "external.api",
114109
attributes: {
115110
// Performance metrics
116-
'api.response_time_ms': 245,
117-
111+
"api.response_time_ms": 245,
112+
118113
// Context data
119-
'feature.using_api': 'image_recognition',
120-
'user.plan': 'enterprise'
121-
}
114+
"feature.using_api": "image_recognition",
115+
"user.plan": "enterprise",
116+
},
122117
},
123118
async () => {
124119
// API call implementation
@@ -138,15 +133,15 @@ Monitor client-side performance metrics related to user experience:
138133
// UI performance monitoring
139134
Sentry.startSpan(
140135
{
141-
name: 'Page Interaction',
142-
op: 'ui.interaction',
136+
name: "Page Interaction",
137+
op: "ui.interaction",
143138
attributes: {
144-
'ui.first_input_delay_ms': 24,
145-
'ui.time_to_interactive_ms': 320,
146-
'ui.frames_dropped': 0,
147-
'user.device_type': 'mobile',
148-
'feature.being_used': 'image_carousel'
149-
}
139+
"ui.first_input_delay_ms": 24,
140+
"ui.time_to_interactive_ms": 320,
141+
"ui.frames_dropped": 0,
142+
"user.device_type": "mobile",
143+
"feature.being_used": "image_carousel",
144+
},
150145
},
151146
async () => {
152147
// UI interaction handling
@@ -162,17 +157,17 @@ Track database performance characteristics and their impact on application behav
162157
// Database query monitoring
163158
Sentry.startSpan(
164159
{
165-
name: 'Product Search Query',
166-
op: 'db.query',
160+
name: "Product Search Query",
161+
op: "db.query",
167162
attributes: {
168-
'db.query_type': 'SELECT',
169-
'db.table': 'products',
170-
'db.execution_time_ms': 145,
171-
'db.rows_returned': 87,
172-
'db.index_used': 'product_category_idx',
173-
'business.search_term': 'winter jacket',
174-
'business.search_filters_applied': 3
175-
}
163+
"db.query_type": "SELECT",
164+
"db.table": "products",
165+
"db.execution_time_ms": 145,
166+
"db.rows_returned": 87,
167+
"db.index_used": "product_category_idx",
168+
"business.search_term": "winter jacket",
169+
"business.search_filters_applied": 3,
170+
},
176171
},
177172
async () => {
178173
// Database query execution
@@ -188,21 +183,21 @@ Monitor file handling operations across your application stack:
188183
// File processing monitoring
189184
Sentry.startSpan(
190185
{
191-
name: 'Process Uploaded Image',
192-
op: 'file.process',
186+
name: "Process Uploaded Image",
187+
op: "file.process",
193188
attributes: {
194189
// Technical metrics
195-
'file.size_bytes': 2500000,
196-
'file.type': 'image/jpeg',
197-
190+
"file.size_bytes": 2500000,
191+
"file.type": "image/jpeg",
192+
198193
// Processing metrics
199-
'processing.steps_completed': ['virus_scan', 'resize', 'compress'],
200-
'processing.total_time_ms': 850,
201-
194+
"processing.steps_completed": ["virus_scan", "resize", "compress"],
195+
"processing.total_time_ms": 850,
196+
202197
// Context data
203-
'feature.using_upload': 'user_avatar',
204-
'subscription.allows_hd': true
205-
}
198+
"feature.using_upload": "user_avatar",
199+
"subscription.allows_hd": true,
200+
},
206201
},
207202
async () => {
208203
// Image processing implementation
@@ -218,21 +213,21 @@ Monitor performance and reliability of third-party service interactions:
218213
// Payment gateway monitoring
219214
Sentry.startSpan(
220215
{
221-
name: 'Payment Gateway',
222-
op: 'payment.gateway',
216+
name: "Payment Gateway",
217+
op: "payment.gateway",
223218
attributes: {
224219
// Performance metrics
225-
'gateway.response_time_ms': 980,
226-
'gateway.retry_count': 0,
227-
220+
"gateway.response_time_ms": 980,
221+
"gateway.retry_count": 0,
222+
228223
// Transaction data
229-
'order.total_amount': 159.99,
230-
'order.items_count': 3,
231-
224+
"order.total_amount": 159.99,
225+
"order.items_count": 3,
226+
232227
// Service metrics
233-
'gateway.fee_amount': 4.50,
234-
'gateway.fee_percent': 0.029
235-
}
228+
"gateway.fee_amount": 4.5,
229+
"gateway.fee_percent": 0.029,
230+
},
236231
},
237232
async () => {
238233
// Payment gateway integration
@@ -255,6 +250,7 @@ Maintain consistent naming patterns following the format `category.metric_name`
255250
#### Data Type Selection
256251

257252
Choose appropriate data types for your metrics:
253+
258254
- Numeric values for measurements (`response_time_ms`: 250)
259255
- Boolean values for state indicators (`cache.hit`: true)
260256
- String values for categorical data (`user.subscription`: 'premium')
@@ -263,6 +259,7 @@ Choose appropriate data types for your metrics:
263259
#### Performance Considerations
264260

265261
Be mindful of the performance impact of collecting metrics, especially for high-volume operations:
262+
266263
- Consider implementing sampling for high-frequency operations
267264
- Prioritize metrics with the highest analytical value
268265
- Avoid redundant or closely correlated metrics
@@ -276,6 +273,7 @@ If you're currently using Sentry's standalone Metrics product, migrating to span
276273
- **Improved correlation**: Direct association between attributes, traces, and errors
277274

278275
Migration process:
276+
279277
1. Identify your current metric instrumentation points
280278
2. Locate corresponding spans in your application
281279
3. Transfer your metrics to span attributes

docs/platforms/javascript/common/configuration/filtering.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,8 @@ Learn more about <PlatformLink to="/configuration/sampling/">configuring the sam
176176

177177
## Filtering Spans
178178

179-
Available since JavaScript SDK version `8.2.0`.
180-
181179
Use the <PlatformIdentifier name="before-send-span" /> configuration option which allows you to provide a function to modify a span.
182180
This function is called for the root span and all child spans. If you want to drop the root span, including its child spans, use [`beforeSendTransaction`](#using-beforesendtransaction) instead.
181+
Please note that you cannot use `beforeSendSpan` to drop a span, you can only modify it and filter data on it.
183182

184183
<PlatformContent includePath="configuration/before-send-span" />

docs/platforms/javascript/common/tracing/configure-sampling/index.mdx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ sidebar_order: 30
66

77
Sentry's tracing functionality helps you monitor application performance by capturing distributed traces, attaching attributes, and span performance across your application. However, Capturing traces for every transaction can generate significant volumes of data. Sampling allows you to control the amount of spans that are sent to Sentry from your application.
88

9-
## Sampling Configuration Options
10-
119
The JavaScript SDK provides two main options for controlling the sampling rate:
1210

13-
1. Uniform Sample Rate (`tracesSampleRate`)
11+
1. [Uniform Sample Rate](#uniform-sample-rate-tracessamplerate) (recommended)
12+
2. [Sampling Function](#sampling-function-tracessampler)
13+
14+
## Uniform Sample Rate (`tracesSampleRate`)
15+
1416
`tracesSampleRate` is floating point value 0.0 and 1.0, which controls the probability that a transaction will be sampled.
1517

1618
<PlatformContent includePath="/tracing/sample-rate" />
1719

1820
With `tracesSampleRate` set to `0.25`, each transaction in your application is randomly sampled with a probability of 25%, so you can expect that one in every four transactions will be sent to Sentry.
1921

20-
### Sampling Function (`tracesSampler`)
22+
## Sampling Function (`tracesSampler`)
2123

2224
For more granular control, you provide a `tracesSampler` function. This approach allows you to:
2325

@@ -36,16 +38,16 @@ When the `tracesSampler` function is called, it receives a `samplingContext` obj
3638
interface SamplingContext {
3739
// Name of the span/transaction
3840
name: string;
39-
41+
4042
// Initial attributes of the span/transaction
4143
attributes: SpanAttributes | undefined;
42-
44+
4345
// Whether the parent span was sampled (undefined if no incoming trace)
4446
parentSampled: boolean | undefined;
45-
47+
4648
// Sample rate from incoming trace (undefined if no incoming trace)
4749
parentSampleRate: number | undefined;
48-
50+
4951
// Utility function to inherit parent decision or fallback
5052
inheritOrSampleWith: (fallbackRate: number) => number;
5153
}
@@ -125,7 +127,7 @@ tracesSampler: (samplingContext) => {
125127
126128
When multiple sampling mechanisms could apply, Sentry follows this order of precedence:
127129
128-
- If `tracesSampler` is defined, its decision is used. Although the `tracesSampler` can override the parent sampling decision, most users will want to ensure their `tracesSampler` respects the parent sampling decision.
130+
- If `tracesSampler` is defined, its decision is used. Although the `tracesSampler` can override the parent sampling decision, most users will want to ensure their `tracesSampler` respects the parent sampling decision.
129131
- If no `tracesSampler` is defined, but there is a parent sampling decision from an incoming distributed trace, we use the parent sampling decision
130132
- If neither of the above, `tracesSampleRate` is used
131133
- If `tracesSampleRate` is set to 0, no spans will be sampled, and no downstream spans will be sampled either since they inherit the parent sampling decision
@@ -134,4 +136,3 @@ When multiple sampling mechanisms could apply, Sentry follows this order of prec
134136
## Conclusion
135137
136138
Effective sampling is key to getting the most value from Sentry's performance monitoring while minimizing overhead. The `tracesSampler` function gives you precise control over which transactions to record, allowing you to focus on the most important parts of your application.
137-

docs/platforms/javascript/common/tracing/index.mdx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ With [tracing](/product/insights/overview/), Sentry automatically tracks your so
3030
## Configure
3131

3232
<PlatformSection supported={["javascript"]}>
33-
Enable tracing by configuring the sampling rate for transactions. Set
34-
the sample rate for your transactions by either:
33+
Enable tracing by configuring the sampling rate for transactions. Set the
34+
sample rate for your transactions by either:
3535
</PlatformSection>
3636

3737
<PlatformSection notSupported={["javascript"]}>
@@ -66,14 +66,20 @@ If you leave your sample rate at `1.0`, a transaction will be sent every time a
6666
<PlatformSection notSupported={["javascript.cordova"]}>
6767
## Automatic Instrumentation
6868

69-
See <PlatformLink to="/tracing/instrumentation/automatic-instrumentation">Automatic Instrumentation</PlatformLink> to learn about all the things that the SDK automatically instruments for you.
69+
See <PlatformLink to="/tracing/instrumentation/automatic-instrumentation">Automatic Instrumentation</PlatformLink> to learn about all the things that the SDK automatically instruments for you.
70+
7071
</PlatformSection>
7172

7273
## Custom Instrumentation
7374

7475
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.
7576

76-
See <PlatformLink to="/tracing/span-metrics/">Sending Span Metrics</PlatformLink> to learn how to manually start spans.
77+
- <PlatformLink to="/apis/#tracing">Tracing APIs</PlatformLink>:
78+
Find information about APIs for custom tracing instrumentation
79+
- <PlatformLink to="/tracing/instrumentation/">Instrumentation</PlatformLink>:
80+
Find information about manual instrumentation with the Sentry SDK
81+
- <PlatformLink to="/tracing/span-metrics/">Sending Span Metrics</PlatformLink>:
82+
Learn how to capture metrics on your spans
7783

7884
## Next Steps
7985

0 commit comments

Comments
 (0)