Allow `ignoreSpans` to match scope attributes (e.g. `Sentry.getGlobalScope().setAttribute()`) in span streaming mode
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- backend-api-design
Direzione di ricerca
Start with _shouldIgnoreStreamedSpan in packages/core/src/tracing/trace.ts and how commonSpanAttributes merges scope data in packages/core/src/tracing/spans/captureSpan.ts. Check the existing ignoreSpans tests and documentation for stream mode and scope attributes. Done means the intended matching behavior and its timing are documented and covered by tests.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
In v11 span streaming mode (traceLifecycle: 'stream'), there's no supported way to drop spans based on an attribute set on the scope:
ignoreSpansis evaluated once at span start (_shouldIgnoreStreamedSpaninpackages/core/src/tracing/trace.ts) and only seesspanArguments.attributes, i.e. the attributes passed directly tostartSpan.- Scope attributes (
scope.setAttribute()/setAttributes()) are merged into the span later, at capture time (commonSpanAttributes→scopeData.attributesinpackages/core/src/tracing/spans/captureSpan.ts), soignoreSpansnever sees them. beforeSendSpancan't drop spans in v11 (documented inMIGRATION.md).
So an ignoreSpans rule with an attributes filter looks like it should work for scope attributes, since those attributes do end up on every sent span, but it silently never matches. For SDK-generated spans (pageload, navigation, http, etc.) users can't add the attribute at start themselves, so there's no workaround short of wrapping the transport.
Use case (from a customer)
A browser app wants to drop spans recorded after the page has been hidden at least once, since timings from backgrounded tabs are noisy:
Sentry.init({
ignoreSpans: [{ attributes: { document_hid_once: true } }],
});
const globalScope = Sentry.getGlobalScope();
globalScope.setAttribute('document_hid_once', false);
document.addEventListener(
'visibilitychange',
() => {
if (document.visibilityState === 'hidden') {
globalScope.setAttribute('document_hid_once', true);
}
},
{ once: true },
);
Expected: spans started after the flag flips to true are ignored. Actual: nothing is ignored, because ignoreSpans doesn't consider scope attributes.
Proposal
When evaluating ignoreSpans at span start in stream mode, merge the current scope attributes (global → isolation → current, same precedence used at capture) under the span's own start attributes, and match against the result. Span start attributes should take precedence over scope attributes, as they do at capture.
Open questions:
- Timing: start-time evaluation means a scope attribute changed after a span started won't affect that span. That seems fine and consistent with the documented "
ignoreSpanstakes effect when a span starts" behavior, but it should be called out in the docs. - Docs: whatever the outcome, the
ignoreSpansdocs should say explicitly whether scope attributes are considered. Right now it's easy to assume they are. - Alternative: if matching scope attributes in
ignoreSpansisn't wanted, a supported way to drop a streamed span based on its final attributes would also cover this use case. Today the only option is filtering thespanenvelope item in a custom transport.
Environment
@sentry/*v11 (verified againstdevelopat 11.9.0)- Span streaming mode (the v11 default)
via ADV.
--
- Lingua principale
- TypeScript
- Stelle
- 8.8k
- Fork
- 1.9k
- Merge medio
- 1g 8h
- PR unite (30g)
- 744
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di getsentry/sentry-javascript
-
AWS Lambda Waiting for: Product Owner
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
getsentry/sentry-javascript#26910 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Only create Nuxt database and storage spans when there is a parent spanForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. ApertaImprovement Nuxt
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
getsentry/sentry-javascript#25805 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Only create Cloudflare storage and D1 db spans when there is a parent spanForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. ApertaCloudflare Workers Improvement Spans
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
getsentry/sentry-javascript#25804 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Core Feature: Typescript Meta: Breaking
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
getsentry/sentry-javascript#25286 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
javascript
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
getsentry/sentry-javascript#24200 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di getsentry/sentry-javascript
Issue simili
-
Postgres upgrade golden leaves fixture URL query parameters in the expected output comparisonAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
garrytan/gbrain#10437 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Bedrock "Too many tokens" throttle is not auto-retried, unlike "Too many requests"Forse già presa @acmerfight l’ha presa oggi. Apertauntriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
earendil-works/pi#12573 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
agentes-chat/agentes-chat#1506 ·
I maintainer di solito rispondono entro 1 giorno
-
comp/desktop desktop/files os/windows P2 type/perf
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
NousResearch/hermes-agent#160359 ·
I maintainer di solito rispondono entro 1 giorno
-
Missing repro Platform: Android
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
software-mansion/react-native-reanimated#11554 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno