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
Copy file name to clipboardExpand all lines: docs/concepts/key-terms/tracing/span-metrics.mdx
+42-47Lines changed: 42 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,40 +1,55 @@
1
1
---
2
2
title: Span Metrics
3
-
description: "Learn how span metrics provide enhanced application performance monitoring by attaching attributes to trace spans."
3
+
description: "Learn how attaching attributes to spans provides enhanced application performance monitoring and improved debugging."
4
4
sidebar_order: 10
5
5
---
6
6
7
-
Span metrics enable you to attach metrics and important debugging context to your application's traces. This approach provides context-rich performance monitoring by connecting metrics directly to the operations that generate them.
7
+
Span metrics enable you to attach user defined attributes to spans, which might include application metrics or important debugging context within your application's traces. This approach provides context-rich performance monitoring by connecting attributes directly to the operations that generate them.
8
8
9
-
## What Are Span Metrics?
9
+
These attributes allow you to enrich trace spans with attributes that represent various types of measurement data:
10
10
11
-
Span metrics allow you to enrich trace spans with various types of measurement data:
12
-
13
-
- Performance metrics (memory usage, processing time, latency)
11
+
- Performance attributes (memory usage, processing time, latency)
14
12
- Business metrics (transaction value, user engagement rates)
15
13
- Technical indicators (queue depth, cache hit ratios)
16
14
- Debugging context (input parameters, process states)
17
15
18
-
By attaching metrics directly to spans, you create a unified view of both the execution path and its associated performance data.
16
+
By attaching attributes directly to spans, you create a unified view of both the execution path and its associated performance data.
19
17
20
18
```javascript
21
19
// Adding performance metrics to a database span
22
-
constspan=Sentry.getActiveSpan();
23
-
if (span) {
24
-
span.setAttribute('db.rows_returned', 42);
25
-
span.setAttribute('db.execution_time_ms', 18);
26
-
}
20
+
// Simple database query with dynamic attributes
21
+
Sentry.startSpan(
22
+
{
23
+
name:'Database Query',
24
+
op:'db.query'
25
+
},
26
+
() => {
27
+
// Get active span to set attributes as data becomes available
28
+
constspan=Sentry.getActiveSpan();
29
+
30
+
// Execute query and add results to span
31
+
constresult=executeQuery('SELECT * FROM users WHERE active = true');
Span metrics provide contextual data that connects execution flow with performance measurements. When investigating an issue, you can view both what occurred (the trace) and the performance characteristics (the metrics) in a single view.
48
+
Span attributes provide contextual data that connects execution flow with specific metrics that developers care about, or performance measurements. When investigating an issue, you can view both what occurred (the trace) and the performance characteristics in a single view.
34
49
35
50
### Unified Telemetry
36
51
37
-
By integrating metrics with tracing, you can maintain a single telemetry pipeline rather than managing separate systems for traces and metrics, resulting in simplified instrumentation and more efficient monitoring.
52
+
By integrating these attributes into tracing, you can maintain a single telemetry pipeline rather than managing separate systems for traces and metrics, resulting in simplified instrumentation and more efficient monitoring.
38
53
39
54
```javascript
40
55
// Adding business context to a payment processing span
@@ -57,44 +72,38 @@ Sentry.startSpan(
57
72
58
73
### Accelerated Troubleshooting
59
74
60
-
When performance issues arise, span metrics provide the necessary context to quickly identify bottlenecks. For example, when investigating slow checkout processes, you can immediately see which specific component (payment gateway, database query, third-party API) is causing the delay.
75
+
When performance issues arise, these attributes provide the necessary context to quickly identify bottlenecks. For example, when investigating slow checkout processes, you can immediately see which specific component (payment gateway, database query, third-party API) is causing the delay.
61
76
62
77
### Technical-Business Correlation
63
78
64
-
Span metrics enable correlation between technical performance data and business outcomes by connecting metrics like response time or error rates directly to business metrics such as conversion rates or revenue.
79
+
Span attributes enable correlation between technical performance data and business outcomes by connecting metrics like response time or error rates directly to business metrics such as conversion rates or revenue.
65
80
66
81
## Implementation Approaches
67
82
68
-
There are two primary methods for implementing span metrics:
83
+
There are two primary methods for implementing attributes on spans:
69
84
70
85
### 1. Enhancing Existing Spans
71
86
72
-
Augment automatically-created or manually-defined spans with additional metric attributes:
87
+
Augment automatically-created or manually-defined spans with additional attributes:
-[File upload and processing](/platforms/javascript/tracing/span-metrics/examples/#file-upload-and-processing-pipeline)
296
291
-[Job scheduling and processing](/platforms/javascript/tracing/span-metrics/examples/#job-scheduling-and-processing-pipeline)
297
292
298
-
These examples demonstrate how to implement comprehensive span metrics across distributed systems, providing end-to-end visibility into application performance and behavior.
293
+
These examples demonstrate how to implement comprehensive attribute tracking across distributed systems, providing end-to-end visibility into application performance and behavior.
0 commit comments