fix(exporter/otlp/http): log error details from response on export failure#5155
Draft
grvmishra788 wants to merge 1 commit intoopen-telemetry:mainfrom
Draft
fix(exporter/otlp/http): log error details from response on export failure#5155grvmishra788 wants to merge 1 commit intoopen-telemetry:mainfrom
grvmishra788 wants to merge 1 commit intoopen-telemetry:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4526.
Before: When an OTLP HTTP export fails (non-2xx response), all three exporters (trace, metrics, logs) log only
resp.reason— the HTTP reason phrase (e.g."Bad Request"). The response body is never read, so server-provided error details (e.g. a protobuf-encoded error fromtelemetry.googleapis.com) are silently discarded.After: On a non-2xx response, exporters parse the body using the
Content-Typeheader before logging:application/x-protobufExport*ServiceResponse; extractpartial_success.error_messageapplication/jsonpartialSuccess.errorMessageormessage(google.rpc.Status)resp.textresp.reason(previous behaviour, unchanged)Type of change
How Has This Been Tested?
The fix was verified end-to-end by constructing a
400response with a protobuf-encodedExportTraceServiceResponsebody (containingpartial_success.error_message = "Request contains too many spans (limit: 10000)") and a mocked OTLP endpoint (via theresponseslibrary). Before the fix, the logged reason was"Bad Request"; after, it is the server-provided message. The same was confirmed for a JSONgoogle.rpc.Statusbody and for an empty body (fallback toresp.reason, no regression).Run from the repo root:
test_response_body_parsing.py— cover every branch of_parse_response_body: protobuf with/without error message, JSONpartialSuccessandmessagefields,; charset=utf-8content-type variants, unknown content-type, empty body, malformed protobuf, malformed JSON.test_proto_span_exporter.pyandtest_proto_log_exporter.py— verify the parsed message appears in the error log on a real export call.Does This PR Require a Contrib Repo Change?
Checklist: