Allow disabling per-filter events in SecurityObservationSettings
I maintainer di solito rispondono entro 1 giorno
@erfannvb ci sta già lavorando.
Dal 18/10/2026.
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
- Ambito
- observability
Direzione di ricerca
Start by reading SecurityObservationSettings and ObservationFilterChainDecorator, which the issue identifies as the settings API and the source of per-filter events. Trace how settings control filter chain observations and how the decorator adds events; the payload names no tests or specific files beyond these entry points. Done means filter chain spans and their existing key values remain recorded while per-filter events can be disabled.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Expected Behavior
SecurityObservationSettings offers a way to keep the filter chain observations (i.e. the existing shouldObserveRequests(true) method) but turn off the per-filter events, for example:
@Bean
SecurityObservationSettings securityObservations() {
return SecurityObservationSettings.withDefaults()
.shouldObserveRequests(true)
.shouldObserveFilterEvents(false) // new
.build();
}
With this setting, the security filter spans are still recorded, with their existing key values, but no before XxxFilter / after XxxFilter events are added to them.
Current Behavior
ObservationFilterChainDecorator adds two events per filter to the chain observation (spring.security.filterchains): one named <filter>.before with contextual name before <FilterClass> and one named <filter>.after with contextual name after <FilterClass>. When distributed tracing is enabled, they become span events, so every request produces a dozen or more events such as before LogoutFilter, before RequestCacheAwareFilter, before AuthorizationFilter, and their after counterparts.
SecurityObservationSettings is all-or-nothing per observation type. shouldObserveRequests(false) removes the events, but also removes all the filter chain spans which are really useful for latency analysis and for investigating where a request was rejected. So if we want to remove the span events, we are also forced to get rid of the spans as well currently.
The events cannot be filtered downstream either: Micrometer's ObservationFilter only operates on the context, and events are forwarded to handlers directly.
Replacing the decorator is not really feasible. ObservationFilterChainDecorator is final, has a single ObservationRegistry constructor, and its FilterChainObservationConvention and FilterChainObservationContext are package-private and final.
Context
This was previously requested in #18646, which was closed as "not planned".
Such events might be useful in specific scenarios, but I found that more often than not they are not really needed, yet they are enabled by default and there's no way today to disable them. The consequence of keeping them on is extra noise on the spans when using observability platforms that support span events (e.g. Grafana), which is still acceptable. The main problem happens with observability platforms that don't support span event, such as Elasticsearch, which translates each span event to a log. That is not only noisy but also results in lots of extra disk space used.
There's always an option to operate at the OpenTelemetry level, but that's not optimal since it's not a portable solution and it's not straightforward to target only specific events at that point.
In this issue, I'm suggesting adding a new method to SecurityObservationSettings as a simple solution. But for even greater flexibility, it would be nice to follow the Micrometer best practices and accept an ObservationConvention to customize the filter chain observations, including the events (e.g. ObservationConvention<FilterChainObservationContext>). Perhaps SecurityObservationSettings could accept observation conventions for that.
- Lingua principale
- Java
- Stelle
- 9.7k
- Fork
- 6.4k
- Merge medio
- 3h 11m
- PR unite (30g)
- 19
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 spring-projects/spring-security
-
Update spring-ldap to 4.0.7Apertatype: dependency-upgrade
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
spring-projects/spring-security#20057 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Update micrometer to 1.16.9Apertatype: dependency-upgrade
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
spring-projects/spring-security#20056 ·
I maintainer di solito rispondono entro 1 giorno
-
Update spring-ldap to 4.1.3Apertatype: dependency-upgrade
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
spring-projects/spring-security#20055 ·
I maintainer di solito rispondono entro 1 giorno
-
Update micrometer to 1.17.3Apertatype: dependency-upgrade
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
spring-projects/spring-security#20054 ·
I maintainer di solito rispondono entro 1 giorno
-
Update spring-ldap to 4.2.0Apertatype: dependency-upgrade
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
spring-projects/spring-security#20053 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di spring-projects/spring-security
Issue simili
-
jules
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
open-learning-exchange/myplanet#18568 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
hibernate/hibernate-reactive#4485 ·
I maintainer di solito rispondono entro 1 giorno
-
type: dependency-upgrade
Difficoltà 2/5 1-3 ore Idoneità per principianti 61/100
spring-projects/spring-graphql#1556 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
higress-group/higress-console#800 ·
I maintainer di solito rispondono entro 1 giorno