Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactive observation auto-configuration does not declare order for WebFilter #33444

Closed
codependent opened this issue Dec 2, 2022 · 1 comment
Assignees
Labels
theme: observability Issues related to observability type: bug A general bug
Milestone

Comments

@codependent
Copy link

codependent commented Dec 2, 2022

Affects: 6.0.2

When using micrometer-tracing to correlate requests in Webflux applications we are able to access the underlying Observation withing the Reactor context as seen in this spring-boot issue: #33372

However, currently there's no way to access that information within a WebFilter, even though we set it up with the lowest precedence to trigger ServerHttpObservationFilter before it:

@Component
@Order(Ordered.LOWEST_PRECEDENCE)
class RequestLoggerPropagationFilter: WebFilter {

    private val logger = LoggerFactory.getLogger(javaClass)
    override fun filter(exchange: ServerWebExchange, chain: WebFilterChain): Mono<Void> {
        return Mono.just(Unit)
            .handle { t: Unit, u: SynchronousSink<Any> ->
                logger.info("beginning request")
                u.next(t)
            }.flatMap {
                chain.filter(exchange)
            }
    }
}

ServerHttpObservationFilter, which doesn't have any @order, is always invoked last, so there's no way the traceId/spanId can be accessed within our filters.

Would you consider adding an @ Order(X) to ServerHttpObservationFilter. This way we will be able to place our application WebFilters after it to propertly access correlation/observation info.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 2, 2022
@bclozel
Copy link
Member

bclozel commented Dec 2, 2022

I don't think we should hard code the order on the filter class itself, but rather configure this in Spring Boot at the bean method level. This is done for the MVC counterpart but was never done for the metrics webflux variant in the past.

We should update the WebFluxObservationAutoConfiguration and also ensure that the order is properly documented. As for the ordering value itself, it should probably be aligned with the MVC variant to be set ahead of the security filter.

@bclozel bclozel transferred this issue from spring-projects/spring-framework Dec 2, 2022
@bclozel bclozel self-assigned this Dec 2, 2022
@bclozel bclozel added type: bug A general bug theme: observability Issues related to observability and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 2, 2022
@bclozel bclozel added this to the 3.0.x milestone Dec 2, 2022
@bclozel bclozel changed the title ServerHttpObservationFilter lacks an @Order value Reactive observation auto-configuration does not declare order for WebFilter Dec 2, 2022
@bclozel bclozel modified the milestones: 3.0.x, 3.0.1 Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: observability Issues related to observability type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants