Skip to content

WebClient drops uri tag in metrics #36927

@kkurczewski

Description

@kkurczewski

Follow up on #22371

Version: Spring Webflux 7.0.8

Using URI wrapper on WebClient drops uri tag in metrics.

@SpringBootTest
class UriMetricsTest(
    @param:Autowired private val builder: WebClient.Builder,
    @param:Autowired private val meterRegistry: MeterRegistry,
) {
    @Test
    fun `uri via string`() {
        runCatching {
            builder
                .build()
                .get().uri("http://localhost:8080/foo")
                .retrieve()
                .bodyToMono<String>()
                .block()
        }
        Thread.sleep(1000)

        val timer = meterRegistry["http.client.requests"].timer()
        assert(timer.id.tags.contains(Tag.of("uri", "/foo"))) { "${timer.id.tags}" } // passes
    }

    @Test
    fun `uri via url`() {
        runCatching {
            builder
                .build()
                .get().uri(URI("http://localhost:8080/bar"))
                .retrieve()
                .bodyToMono<String>()
                .block()
        }
        Thread.sleep(1000)

        val timer = meterRegistry["http.client.requests"].timer()
        assert(timer.id.tags.contains(Tag.of("uri", "/bar"))) { "${timer.id.tags}" } // fails
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    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