Skip to content

Commit 61db904

Browse files
authored
Merge pull request Expensify#83032 from callstack-internal/sentry/docs-filters
[No QA][Sentry] Add debug and filter tips to docs
2 parents bb6f7f3 + 3ec74d2 commit 61db904

1 file changed

Lines changed: 37 additions & 3 deletions

File tree

contributingGuides/OBSERVABILITY.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ When users encounter issues in live sessions that we can't reproduce locally, bu
1818
## Tools & implementation
1919

2020
We use **Sentry** for observability across all platforms (Web, iOS, Android) and environments (production, staging, development). Sentry collects traces, spans, and contextual data from user sessions to identify and diagnose issues. For a better understanding of Sentry visit [Sentry docs](https://docs.sentry.io/).
21-
For testing Sentry locally remember to set env variable `ENABLE_SENTRY_ON_DEV=true` in your local .env file.
21+
For testing Sentry locally, remember to see the section [Debugging Spans](#debugging-spans) below.
2222

2323
### Working with Spans
2424

@@ -62,6 +62,24 @@ cancelSpan(spanId); // Operation abandoned (e.g., user navigated away, component
6262

6363
The difference is that the latter adds a `canceled` attribute to the span indicating that it was canceled.
6464

65+
### Debugging Spans
66+
67+
Sentry is disabled in development by default. To enable it, add `ENABLE_SENTRY_ON_DEV=true` to your `.env` file. This activates an internal debug transport that logs span data locally instead of sending it to Sentry.
68+
69+
To view spans in the DevConsole, go to **Account → Troubleshoot → Log Sentry requests to console**.
70+
71+
In rare cases where you need to inspect spans directly in the Sentry dashboard, comment out the `transport` line in [`src/setup/telemetry/index.ts`](../src/setup/telemetry/index.ts):
72+
73+
```typescript
74+
Sentry.init({
75+
dsn: CONFIG.SENTRY_DSN,
76+
// transport: isDevelopment() ? makeDebugTransport : undefined,
77+
...
78+
});
79+
```
80+
81+
This sends spans to the real Sentry project instead of the local console.
82+
6583
### Constants
6684

6785
Defined in `src/CONST/index.ts` under `CONST.TELEMETRY`:
@@ -181,6 +199,22 @@ Add metrics when:
181199
- Debugging requires operation visibility
182200

183201
Don't add metrics for:
184-
- Internal operations invisible to users
202+
- Internal operations, invisible to users
185203
- Operations already covered by parent spans
186-
- Operations too granular to be actionable
204+
- Operations too granular to be actionable
205+
206+
## Working with Sentry Dashboard
207+
208+
### Filtering Spans
209+
210+
When debugging our manual spans, always filter out canceled spans to avoid noise. Use the following query (you can copy & paste it into the filter bar):
211+
212+
```
213+
span.status:ok !has:canceled has:tags[finished_manually,number]
214+
```
215+
216+
| Filter | Purpose |
217+
|--------|---------|
218+
| `span.status:ok` | Only show spans that completed without errors |
219+
| `!has:canceled` | Exclude spans abandoned mid-flight (e.g. user navigated away) |
220+
| `has:finished_manually` | Only show spans finished by our instrumentation, not auto-collected ones |

0 commit comments

Comments
 (0)