Skip to content

Commit fc2af57

Browse files
coolguyzoneAlex Krawiec
and
Alex Krawiec
authored
Eap te updates (#12796)
* Implement latest updates for eap trace explorer * prettify code --------- Co-authored-by: Alex Krawiec <[email protected]>
1 parent 6019b27 commit fc2af57

File tree

2 files changed

+144
-33
lines changed

2 files changed

+144
-33
lines changed
Loading
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,66 @@
11
---
2-
title: "New Trace Explorer With Span Metrics"
2+
title: "New Trace Explorer With Span-Based Metrics"
33
sidebar_order: 31
44
description: "Learn how to use the new Sentry Trace Explorer to search span data, find distributed traces, and debug performance issues across your entire application stack."
55
---
66

77
<Alert>
8-
The new Trace Explorer is currently an Early Adopter feature, to use it you will need to [enable your Early Adopter status](/organization/early-adopter-features/). If you are not an Early Adopter, you will still see the [classic Trace Explorer](/product/explore/traces/).
8+
The new Trace Explorer is currently an Early Adopter feature, to use it you
9+
will need to [enable your Early Adopter
10+
status](/organization/early-adopter-features/). If you are not an Early
11+
Adopter, you will still see the [classic Trace
12+
Explorer](/product/explore/traces/).
913
</Alert>
1014

11-
The [**Trace Explorer**](https://sentry.io/orgredirect/organizations/:orgslug/traces/) in Sentry is designed to make investigating performance issues easier and more intuitive. You can now explore span samples, visualize span attributes, and aggregate your data with flexible queries and filters. This guide will walk you through the key concepts and features of the Trace Explorer.
15+
The [**Trace Explorer**](https://sentry.io/orgredirect/organizations/:orgslug/traces/) in Sentry is designed to make performance investigation easier and more intuitive. You can now explore span samples, visualize span attributes, and aggregate your data with flexible queries and filters. This guide will walk you through the key concepts and features of the Trace Explorer.
1216

1317
![Trace Explorer Screenshot](./img/trace-explorer01.png)
1418

1519
## Key Concepts
1620

1721
### Traces
1822

19-
- A trace represents a single transaction or request through your system.
23+
- A trace represents a single transaction or request through your system. This includes things like user browser sessions, HTTP requests, DB queries, middleware, caches and more.
2024
- It captures a series of operations (_spans_) that show how different parts of your application interacted during that transaction.
21-
- Each trace is identified by a **Trace ID**, which you can use to follow a request across services or projects (For example, from your frontend framework to your backend service).
25+
- Each trace is identified by a **Trace ID**, which you can use to follow a request across services or projects.
26+
- A [distributed trace](/platforms/javascript/tracing/trace-propagation/#what-is-distributed-tracing) is composed of spans that traverse multiple servers, clients, edge workers, etc. and is assembled by passing the Trace ID through browser headers.
2227

2328
### Spans
2429

2530
- A _span_ represents an individual operation within a trace. This could be a database query, HTTP request, or UI rendering task.
2631
- Each span has:
27-
- **Attributes**: Key-value pairs like `http.method`, `db.query`, `span.description`, or custom tags, providing additional context.
28-
- **Duration (`span.duration`)**: The time to complete the operation, used to measure performance.
32+
- **Attributes**: Key-value pairs like `http.method`, `db.query`, `span.description`, or custom attributes like `cart.value`, provide additional context that can be useful for debugging and investigating patterns. These are either numbers or strings. Note: numeric span attributes can be used to calculate **span metrics**, shown below.
33+
- **Duration (`span.duration`)**: The time the operation took, used to measure performance.
2934

30-
## Browsing Span and Trace samples
35+
### Span Metrics
36+
37+
- Span metrics are derived from applying a function to your span attributes (default or custom), like `p50(cart.value)` or `sum(ai.token_use)`, over a granular time frame. This calculation extrapolates metrics that then populate dashboards, alerts, etc. based on that rolling time window.
38+
- These 'metrics' aren't stored separately from your span data. Rather, they're queried on the fly. This reduces your need to manage, ingest, and store custom metrics.
39+
- The duration and granularity on which you can query your spans and extrapolate metrics depends on your plan - Developer: 7 days | Team: 14 days | Business: 30 days.
40+
41+
## Practical Examples
42+
43+
- **See your changes in action**: Search for `span.domain is localhost:XXXX` and sort by Timestamp to see traces from your dev environment.
44+
- **Diagnosing slow pages**: Search for `span.op:navigation` and visualize `p90(span.duration)` to pinpoint slow page loads.
45+
- **Finding problematic API calls**: Aggregate by `http.url` and filter where `avg.(span.duration) > 2s` to identify slow external API calls.
46+
- **Database query analysis**: Aggregate by `db.query` and sort by `avg(span.duration)` to find inefficient queries.
47+
48+
With these tools, the new Trace Explorer gives you powerful ways to understand your application's performance, identify bottlenecks, and make informed optimizations.
49+
50+
## Browsing Span and Trace Samples
3151

3252
Trace Explorer allows you to browse span and trace samples effortlessly. Here's how:
3353

3454
1. **Search for Samples**:
35-
- Use the search bar to filter results based on attributes like `span.op`, `http.method`, or any custom tags.
36-
- You can edit columns in span tables to view any attribute.
37-
- You can switch between **Span Samples** and **Trace Samples** tabs depending on your focus.
55+
- Use the search bar to filter results based on default or custom attributes, tags, etc. like `http.request_method is "GET`
56+
- **Edit and add** columns in teh span samples table to view any attribute
57+
- **Sort** by clicking the column header to toggle between ascending and descending
58+
- Switch between **Span Samples** and **Trace Samples** tabs depending on your focus.
3859
1. **Inspect Samples**:
3960

4061
- Clicking on a **Span ID** or **Trace ID** opens the **Trace Waterfall View**, showing the sequence of operations and their durations.
4162
- You can explore individual spans in detail or see the trace's overall structure.
4263

43-
1. **Sort Samples**:
44-
- Use the **Sort By** dropdown or click on the table column headers to sort your data by `span.duration`, `timestamp`, or any other field.
45-
4664
![Trace Explorer Screenshot](./img/trace-explorer02.png)
4765

4866
## Visualizing Span Attributes
@@ -51,7 +69,7 @@ Trace Explorer makes it easy to visualize metrics aggregated from any span attri
5169

5270
1. **Set Up Visualization**:
5371
- Use the **Visualize** section to add metrics like `avg(span.duration)` or `p90(span.duration)` to the same chart by clicking **Add Series** or a different chart by clicking the **+** icon.
54-
- You can also create custom visualizations such as:
72+
- You can also create custom visualizations like:
5573
- **P90 of span durations**: Useful for identifying outliers.
5674
- **Average cache size**: Analyze attributes specific to backend spans.
5775
2. **Filter Your Data**:
@@ -66,34 +84,127 @@ The line chart updates dynamically as you apply filters, helping you track trend
6684

6785
Dive deeper into your data with aggregation capabilities in Trace Explorer.
6886

69-
1. **Enable Aggregate Grouping**:
70-
- Click the **Aggregates** toggle to switch span samples to aggregate data.
71-
- You can add grouping, filters, and calculations for deeper analysis.
72-
2. **Group By Attributes**:
73-
- Use the **Group By** section to group spans by any attribute, like `http.method`, `span.op`, or custom tags.
74-
- For example:
75-
- Group spans by `http.method` to compare the performance of `GET` vs `POST` requests.
76-
- Analyze spans by `db.table` to find slow database operations.
77-
3. **Apply HAVING Conditions**:
78-
- After grouping, use **cell actions** to filter results directly in the table.
79-
- For example:
80-
- Filter for spans where `avg(span.duration) > 1s` to focus on long-running operations.
87+
1. **Enable Aggregate Grouping** by clicking the **Aggregates** toggle.
88+
89+
2. **Group By Attributes** to investigate patterns.
90+
91+
- Try `http.method` to compare GET vs POST performance, `db.table` to find slow database operations, `span.op` to investigate patterns in your traces, or custom tags like cart value, CPU or memory usage, or anything else you can think of.
92+
93+
3. **Filter and sort your aggregates** just like you would for transactions by querying in the search bar. Sort the table of aggregates by clicking the column headers (default: `timestamp`.)
94+
95+
4. **View sample traces** that fit your aggregates by clicking the stack icon to the left side of the table rows. Use this to find outliers, debug issues, and find complex performance optimizations.
8196

8297
![Trace Explorer Screenshot](./img/trace-explorer05.png)
8398

84-
## Creating Alerts and Dashboard Widgets From Queries
99+
## Create Alerts and Dashboard Widgets From Queries
85100

86101
You can create Alerts and Dashboard widgets from your queries by clicking the "Save As" button:
87102

88103
![Trace Explorer Screenshot](./img/trace-explorer06.png)
89104

90-
91105
## Practical Examples
92106

93-
- **Diagnosing Slow Pages**:
107+
- **Diagnosing slow pages**:
94108
- Search for `span.op:navigation` and visualize `p90(span.duration)` to pinpoint slow page loads.
95-
- **Finding Problematic API Calls**:
109+
- **Finding problematic API calls**:
96110
- Group by `http.url` and filter where `avg(span.duration) > 2s` to identify slow external API calls.
97-
- **Database Query Analysis**: Group by `db.query` and sort by `avg(span.duration)` to find inefficient queries.
111+
- **Database query analysis**: Group by `db.query` and sort by `avg(span.duration)` to find inefficient queries.
112+
113+
## How Sampling Affects Queries in Trace Explorer
114+
115+
You can use Sentry's SDKs to sample spans and control the volume of data sent to Sentry. Not every span gets captured when sampling is enabled, but Sentry will still give you accurate aggregate results by extrapolating the sampled data.
116+
117+
### How It Works
118+
119+
Every span sent to Sentry includes its **sampling rate**. We also derive the **sampling weight**, which is the inverse of the rate and indicates the number of original spans that this sample represents.
120+
121+
For example:
122+
123+
- At a rate of _10%_, the weight is _10_.
124+
- At a rate of _50%_, the weight is _2_.
125+
- At a rate of _100%_, the weight is _1_.
126+
127+
All spans you send us after sampling get stored.
128+
129+
When you run queries in Trace Explorer, Sentry uses the sampling weight to compute counts, averages, and percentiles.
130+
131+
### Example
132+
133+
Let's say you query for spans where `span.op:db` and get **2 spans** in the results:
134+
135+
{" "}
136+
137+
<table>
138+
<colgroup>
139+
<col />
140+
<col />
141+
<col />
142+
<col />
143+
<col />
144+
</colgroup>
145+
<thead>
146+
<tr>
147+
<th>span_id</th>
148+
<th>span.op</th>
149+
<th>span.duration</th>
150+
<th>sampling_factor</th>
151+
<th>sampling_weight</th>
152+
</tr>
153+
</thead>
154+
<tbody>
155+
<tr>
156+
<td>a1b2c3</td>
157+
<td>db</td>
158+
<td>100ms</td>
159+
<td>0.1</td>
160+
<td>10</td>
161+
</tr>
162+
<tr>
163+
<td>d4e5f6</td>
164+
<td>db</td>
165+
<td>200ms</td>
166+
<td>0.5</td>
167+
<td>2</td>
168+
</tr>
169+
</tbody>
170+
</table>
171+
172+
### Counts
173+
174+
Since each span was sampled with different weights, Sentry extrapolates the **count**:
175+
176+
```plaintext
177+
10 + 2 = 12 estimated spans
178+
```
179+
180+
Trace Explorer will display **Count: 12**.
181+
182+
### Sums
183+
184+
Similarly, Sentry incorporates the weight into **sum**:
185+
186+
```plaintext
187+
10 * 100ms + 2 * 200ms = 1.4s
188+
```
189+
190+
Trace Explorer will display **Sum: 1.4ms**.
191+
192+
### Averages and percentiles
193+
194+
Averages and percentiles are **weighted**. You don't just average the 2 spans -- Sentry accounts for the fact that they represent a larger dataset. For example, the weighted average works like this:
195+
196+
```Plaintext
197+
(100ms * 10 + 200ms * 2) / (10 + 2) = 117ms (This is the average duration shown)
198+
```
199+
200+
Sentry treats this as a representation of the average across all 12 estimated spans. You can trust that metrics like `avg()` and `p90()` reflect your services' true health, adjusted for sampling.
201+
202+
### Sampling Warnings
203+
204+
If your sampling rate is **too low** for an accurate extrapolation (for example, keeping less than 5% of an already low number of spans), Sentry may show a **low sampling rate warning**. This lets you know that extrapolation might be less reliable, especially for more restrictive queries.
205+
206+
![Trace Explorer Screenshot](./img/trace-explorer07.png)
207+
208+
Even if you sample your spans, **Trace Explorer's extrapolation gives you reasonably accurate answers** for counts, averages, and percentiles -- without you needing to do anything extra.
98209

99-
With these tools, the Trace Explorer gives you powerful ways to understand your application's performance, identify bottlenecks, and make informed optimizations.
210+
With these tools, the new Trace Explorer gives you powerful ways to understand your applications performance, identify bottlenecks, and make informed optimizations.

0 commit comments

Comments
 (0)