Skip to content

Spring Boot (Webflux): many unrelated http breadcrumbs are recorded with events #1790

@s-volkov-1

Description

@s-volkov-1

Platform:

  • Spring Boot (Webflux server & WebClient) -> 2.5.5

IDE:

  • IntelliJ -> 2021.2

Build system:

  • Maven -> 3.6.3-jdk-11

Platform installed with:

  • Maven Central

The version of the SDK:
5.2.4


I have the following issue:

Many (tens or even ~hundred) unrelated http breadcrumbs recorded with events. These breadcrumbs are:

  • Incoming server http requests (to actuator endpoints, for example)
  • Outgoing http client requests to external services, but they are old and/or unrelated to original incoming server request

Steps to reproduce:

  • Use spring-boot webflux server application
  • Use sentry-spring-boot-starter
  • Use actual sentry server (probably won't work with NoOpHub)
  • Start app locally
  • Put some load on application
    • I used 50 threads in jmeter accessing actuator health, info and prometheus endpoints without delays
    • prometheus worked better
  • Make some meaningful requests which should cause some kind of error which should be sent to sentry
  • Observe events on sentry server or via debugging SentryClient (less effective)

Actual result:
Screenshot from actual server-running instance
sentry webflux bug

Expected result:
Only a couple of related http breadcrumbs are present

Personal thoughts
Both SentryWebFilter & SentrySpanClientWebRequestFilter use HubAdapter, which uses static Sentry.getCurrentHub() method, which returns ThreadLocal instance of Hub.

It seems like this mechanism may not work correctly with reactive application, which serves requests on a small number of threads, and they are switched frequently.

As far as I know, there is a way of storing arbitrary request-related data in webflux:

  • org.springframework.web.server.ServerWebExchange.getAttributes()
  • org.springframework.web.reactive.function.client.ClientRequest.attributes()

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIssue typeThreadLocalHubProblemIssues caused by Hub being ThreadLocal and no or no easy way to clone the hubWebFlux
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions