Skip to content

Commit

Permalink
[chore] add error message on parsing bad protobuf response (#8283)
Browse files Browse the repository at this point in the history
Fixes #8282
  • Loading branch information
atoulme authored Aug 24, 2023
1 parent 2fe11f5 commit 26c150c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions exporter/otlphttpexporter/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func tracesPartialSuccessHandler(protoBytes []byte, contentType string) error {
exportResponse := ptraceotlp.NewExportResponse()
err := exportResponse.UnmarshalProto(protoBytes)
if err != nil {
return err
return fmt.Errorf("error parsing protobuf response: %w", err)
}
partialSuccess := exportResponse.PartialSuccess()
if !(partialSuccess.ErrorMessage() == "" && partialSuccess.RejectedSpans() == 0) {
Expand All @@ -282,7 +282,7 @@ func metricsPartialSuccessHandler(protoBytes []byte, contentType string) error {
exportResponse := pmetricotlp.NewExportResponse()
err := exportResponse.UnmarshalProto(protoBytes)
if err != nil {
return err
return fmt.Errorf("error parsing protobuf response: %w", err)
}
partialSuccess := exportResponse.PartialSuccess()
if !(partialSuccess.ErrorMessage() == "" && partialSuccess.RejectedDataPoints() == 0) {
Expand All @@ -298,7 +298,7 @@ func logsPartialSuccessHandler(protoBytes []byte, contentType string) error {
exportResponse := plogotlp.NewExportResponse()
err := exportResponse.UnmarshalProto(protoBytes)
if err != nil {
return err
return fmt.Errorf("error parsing protobuf response: %w", err)
}
partialSuccess := exportResponse.PartialSuccess()
if !(partialSuccess.ErrorMessage() == "" && partialSuccess.RejectedLogRecords() == 0) {
Expand Down
2 changes: 1 addition & 1 deletion exporter/otlphttpexporter/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ func TestPartialSuccessInvalidBody(t *testing.T) {
for _, tt := range invalidBodyCases {
t.Run("Invalid response body_"+tt.telemetryType, func(t *testing.T) {
err := tt.handler([]byte{1}, "application/x-protobuf")
assert.Error(t, err)
assert.ErrorContains(t, err, "error parsing protobuf response:")
})
}
}
Expand Down

0 comments on commit 26c150c

Please sign in to comment.