From 72a0f1f43494f4b09f2dabc92b15fd3a5c25266a Mon Sep 17 00:00:00 2001 From: rahuldimri <107100022+rahuldimri@users.noreply.github.com> Date: Fri, 5 Aug 2022 19:57:56 +0530 Subject: [PATCH] Add support to handle 404 and 405 http error code in OTLP exporter #5827 --- CHANGELOG.md | 1 + exporter/otlphttpexporter/otlp.go | 4 ++++ exporter/otlphttpexporter/otlp_test.go | 9 ++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b4968ebea1..5868c8a3f78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ - Bump to opentelemetry-proto v0.19.0. (#5823) - Expose `Scope.Attributes` in pdata (#5826) +- Add support to handle 404, 405 http error code as permanent errors in OTLP exporter (#5827) ### 🧰 Bug fixes 🧰 diff --git a/exporter/otlphttpexporter/otlp.go b/exporter/otlphttpexporter/otlp.go index e40fc0b3503..351fec4b7c1 100644 --- a/exporter/otlphttpexporter/otlp.go +++ b/exporter/otlphttpexporter/otlp.go @@ -201,6 +201,10 @@ func isPermanentClientFailure(code int) bool { return true case http.StatusRequestHeaderFieldsTooLarge: return true + case http.StatusNotFound: + return true + case http.StatusMethodNotAllowed: + return true default: return false } diff --git a/exporter/otlphttpexporter/otlp_test.go b/exporter/otlphttpexporter/otlp_test.go index e0a8f9842f6..bb84a9fdd90 100644 --- a/exporter/otlphttpexporter/otlp_test.go +++ b/exporter/otlphttpexporter/otlp_test.go @@ -402,7 +402,14 @@ func TestErrorResponses(t *testing.T) { { name: "404", responseStatus: http.StatusNotFound, - err: errors.New(errMsgPrefix + "404"), + err: status.New(codes.InvalidArgument, "Bad field"), + isPermErr: true, + }, + { + name: "405", + responseStatus: http.StatusMethodNotAllowed, + err: status.New(codes.InvalidArgument, "Bad field"), + isPermErr: true, }, { name: "413",