Allow `ignoreSpans` to match scope attributes (e.g. `Sentry.getGlobalScope().setAttribute()`) in span streaming mode
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- backend-api-design
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
--
- Lenguaje dominante
- TypeScript
- Estrellas
- 8.8k
- Forks
- 1.9k
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 744
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de getsentry/sentry-javascript
-
AWS Lambda Waiting for: Product Owner
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
getsentry/sentry-javascript#26910 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Only create Nuxt database and storage spans when there is a parent spanQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. AbiertoImprovement Nuxt
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
getsentry/sentry-javascript#25805 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Only create Cloudflare storage and D1 db spans when there is a parent spanQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. AbiertoCloudflare Workers Improvement Spans
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
getsentry/sentry-javascript#25804 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Core Feature: Typescript Meta: Breaking
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
getsentry/sentry-javascript#25286 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
javascript
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
getsentry/sentry-javascript#24200 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de getsentry/sentry-javascript
Issues similares
-
foreground-up-signals-live: delivery-repair cell expects a spawn suggestion status no longer printsAbiertobug triage:owned
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
e2e-failure ready-to-code
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
redhat-developer/rhdh-plugin-export-overlays#4905 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
directus/directus#28558 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
review: medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
1lck/Lithe-IDEA#2432 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
cloudflare/workers-sdk#17189 ·
Los mantenedores suelen responder en 1 día