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

Reactor status code with ExchangeFilterFunction #13301

Open
jeanbisutti opened this issue Feb 14, 2025 · 0 comments
Open

Reactor status code with ExchangeFilterFunction #13301

jeanbisutti opened this issue Feb 14, 2025 · 0 comments
Labels
enhancement New feature or request needs triage New issue that requires triage

Comments

@jeanbisutti
Copy link
Member

jeanbisutti commented Feb 14, 2025

Let' take the following ExchangeFilterFunction in Reactor.

public ExchangeFilterFunction customStatusHandler() {
        return ExchangeFilterFunction.ofResponseProcessor(clientResponse -> {
            if (clientResponse.statusCode().isError()) {
                return clientResponse.createException().flatMap(clientError -> Mono.error(new CustomException(clientError.getResponseBodyAsString())));
            } else {
                return Mono.just(clientResponse);
            }
        });
    }

In case of an HTTP endpoint returning the 500 HTTP status, the following client telemetry is then emitted:

[reactor-http-nio-4] INFO io.opentelemetry.exporter.logging.LoggingSpanExporter - 'POST' : fe51b25aef90ef613b35553d9e8ddc66 985f9d622832cadd CLIENT [tracer: io.opentelemetry.spring-webflux-5.0:2.12.0-alpha] AttributesMap{data={http.request.method=POST, thread.id=67, server.address=localhost, server.port=8081, error.type=app1.CustomException, thread.name=http-nio-8080-exec-3, url.full=http://localhost:8081/test-app2}, capacity=128, totalAddedValues=7}

The instrumentation reflects the behavior of the Mono.error API and the client telemetry does not contain the status code.

It seems fine to me. Do you rather think that there is a bug or limitation and the client telemetry should contain the status code in this case?

Without the ExchangeFilterFunction or if the client response status is not an error:

[reactor-http-nio-2] INFO io.opentelemetry.exporter.logging.LoggingSpanExporter - 'POST' : e9b01c442c1f8ae805a25cbb3a438927 cd9588c7700b062a CLIENT [tracer: io.opentelemetry.spring-webflux-5.0:2.12.0-alpha] AttributesMap{data={server.port=8081, http.request.method=POST, http.response.status_code=500, error.type=500, server.address=localhost, thread.id=64, thread.name=http-nio-8080-exec-1, url.full=http://localhost:8081/test-app2}, capacity=128, totalAddedValues=8}

@jeanbisutti jeanbisutti added enhancement New feature or request needs triage New issue that requires triage labels Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs triage New issue that requires triage
Projects
None yet
Development

No branches or pull requests

1 participant