opentelemetry-java icon indicating copy to clipboard operation
opentelemetry-java copied to clipboard

Suppression of warning log in `extractErrorStatus` in HttpExporter.java

Open prasadw opened this issue 3 months ago • 10 comments

Our collector service does not support grpc responses. Hence, we send back JSON to the library and any failed requests are handled at the custom exporter level where the exception is available in the CompleteableResultCode object.

This works, however, in the extractErrorStatus method, we constantly see the warning log - Unable to parse response body, HTTP status message: + statusMessage. I want to ask how can we suppress this?

Looking at the code, I see that we need to send some kind of byte-encoded response but does it require any specific format?

prasadw avatar Sep 24 '25 17:09 prasadw

The code is expecting a gRPC response. To avoid the warning, you could send a static gPRC response that says "gRPC not supported".

zeitlinger avatar Sep 25 '25 08:09 zeitlinger

Are you trying to use io.opentelemetry.exporter.internal.http.HttpExporter with a custom sender? If you have a fully custom exporter implementation, you should never run into any code in HttpExporter, which is internal and not really meant to be used outside of the project itself (hence the marking as "internal").

jkwatson avatar Sep 25 '25 17:09 jkwatson

The code is expecting a gRPC response. To avoid the warning, you could send a static gPRC response that says "gRPC not supported".

But our server can only respond in json as grpc is not supported there. With json responses, the code flow still works, but we see the warning log

hsraps avatar Oct 01 '25 08:10 hsraps

Are you trying to use io.opentelemetry.exporter.internal.http.HttpExporter with a custom sender? If you have a fully custom exporter implementation, you should never run into any code in HttpExporter, which is internal and not really meant to be used outside of the project itself (hence the marking as "internal").

We have a batching logic implemented on top of the otlp exporter.. and we retry failed messages based on status codes received from the server. The problem is, that the export and retry works but there is a warning log. Is there any way to suppress this log?

hsraps avatar Oct 01 '25 08:10 hsraps

Are you trying to use io.opentelemetry.exporter.internal.http.HttpExporter with a custom sender? If you have a fully custom exporter implementation, you should never run into any code in HttpExporter, which is internal and not really meant to be used outside of the project itself (hence the marking as "internal").

We have a batching logic implemented on top of the otlp exporter.. and we retry failed messages based on status codes received from the server. The problem is, that the export and retry works but there is a warning log. Is there any way to suppress this log?

Currently, no.

jkwatson avatar Oct 01 '25 16:10 jkwatson

@prasadw OpenTelemetry SDK uses java.util.logging, I think you can suppress it through java.util.logging configuration (or if you are using a different logging framework you can pipe java.util.logging to that framework and suppress it there)

trask avatar Oct 02 '25 15:10 trask

@prasadw OpenTelemetry SDK uses java.util.logging, I think you can suppress it through java.util.logging configuration (or if you are using a different logging framework you can pipe java.util.logging to that framework and suppress it there)

Applying filters to the java.util.logger in our application did not work as the same filters were not applied to the opentelemetry loggers

hsraps avatar Oct 07 '25 06:10 hsraps

Are you trying to use io.opentelemetry.exporter.internal.http.HttpExporter with a custom sender? If you have a fully custom exporter implementation, you should never run into any code in HttpExporter, which is internal and not really meant to be used outside of the project itself (hence the marking as "internal").

We have a batching logic implemented on top of the otlp exporter.. and we retry failed messages based on status codes received from the server. The problem is, that the export and retry works but there is a warning log. Is there any way to suppress this log?

Currently, no.

Can we raise this as a feature request then? For an environment variable or configuration option to suppress warning logs originating only from the OpenTelemetry SDK. Currently, we can’t adjust the log level at the application level to exclude warnings, since that would also suppress warning logs from our own application code.

hsraps avatar Oct 07 '25 06:10 hsraps

Can we raise this as a feature request then?

A PR would be welcome 😄

For an environment variable

new env vars are not added - but declarative configuration can be used: https://opentelemetry.io/docs/languages/sdk-configuration/declarative-configuration/

zeitlinger avatar Oct 07 '25 06:10 zeitlinger

Applying filters to the java.util.logger in our application did not work as the same filters were not applied to the opentelemetry loggers

hi @hsraps, can you explain why this doesn't work for you, since this is the standard solution for reducing log severity (as opposed to adding env vars around each individual logging statement)

e.g. either programmatically at startup:

Logger.getLogger("io.opentelemetry.exporter.internal.http.HttpExporter")
      .setLevel(Level.SEVERE);

or via logging.properties, e.g.

# Suppress HttpExporter warnings - only show SEVERE and above
io.opentelemetry.exporter.internal.http.HttpExporter.level = SEVERE

and

java -Djava.util.logging.config.file=/path/to/logging.properties YourApp

trask avatar Oct 07 '25 23:10 trask