From fa6572ebcbe89aa5041e24a20d51cfeb1a4014fe Mon Sep 17 00:00:00 2001 From: Avadhut Pisal Date: Fri, 12 Jan 2024 17:57:48 +0530 Subject: [PATCH] [exporter/logicmonitor] Update the lm-data-sdk-go version to v1.2.0 and fix error handling issue (#30431) **Description:** Fixing a bug - Using the updated version (v1.2.0) of `lm-data-sdk-go` causes each error to be considered as a permanent. This PR updates the version as well as changes the error handling to fix this issue. **Link to tracking Issue:** NA **Testing:** Unit and functional testing. **Documentation:** NA --- cmd/configschema/go.mod | 2 +- cmd/configschema/go.sum | 4 +-- cmd/otelcontribcol/go.mod | 2 +- cmd/otelcontribcol/go.sum | 4 +-- exporter/logicmonitorexporter/go.mod | 4 +-- exporter/logicmonitorexporter/go.sum | 8 ++--- .../internal/logs/sender.go | 32 ++++++++----------- .../internal/traces/sender.go | 32 ++++++++----------- go.mod | 2 +- go.sum | 4 +-- 10 files changed, 43 insertions(+), 51 deletions(-) diff --git a/cmd/configschema/go.mod b/cmd/configschema/go.mod index 2141b77a92e1..9ee54ac4d8ca 100644 --- a/cmd/configschema/go.mod +++ b/cmd/configschema/go.mod @@ -443,7 +443,7 @@ require ( github.com/lightstep/go-expohisto v1.0.0 // indirect github.com/linkedin/goavro/v2 v2.9.8 // indirect github.com/linode/linodego v1.23.0 // indirect - github.com/logicmonitor/lm-data-sdk-go v1.1.0 // indirect + github.com/logicmonitor/lm-data-sdk-go v1.2.0 // indirect github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect diff --git a/cmd/configschema/go.sum b/cmd/configschema/go.sum index 5bce0378be82..fc06b8001a40 100644 --- a/cmd/configschema/go.sum +++ b/cmd/configschema/go.sum @@ -1084,8 +1084,8 @@ github.com/linkedin/goavro/v2 v2.9.8 h1:jN50elxBsGBDGVDEKqUlDuU1cFwJ11K/yrJCBMe/ github.com/linkedin/goavro/v2 v2.9.8/go.mod h1:UgQUb2N/pmueQYH9bfqFioWxzYCZXSfF8Jw03O5sjqA= github.com/linode/linodego v1.23.0 h1:s0ReCZtuN9Z1IoUN9w1RLeYO1dMZUGPwOQ/IBFsBHtU= github.com/linode/linodego v1.23.0/go.mod h1:0U7wj/UQOqBNbKv1FYTXiBUXueR8DY4HvIotwE0ENgg= -github.com/logicmonitor/lm-data-sdk-go v1.1.0 h1:kfUWTzC3IKaNWihowaRgEYZ28fksYDJNkhG2AHsNelI= -github.com/logicmonitor/lm-data-sdk-go v1.1.0/go.mod h1:Iqvbe9R/NWrvUw3pp/kN9RF4HmQyyVBky6XyluGgKH8= +github.com/logicmonitor/lm-data-sdk-go v1.2.0 h1:p2nui4Nv3rc4f/tHRuUk2xyVrIuDELIOdK2/WVzllYE= +github.com/logicmonitor/lm-data-sdk-go v1.2.0/go.mod h1:nIHr4uOPfg6AM7mG1rewg3L4O3rfge34o7UYB7joBM4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c h1:VtwQ41oftZwlMnOEbMWQtSEUgU64U4s+GHk7hZK+jtY= github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE= diff --git a/cmd/otelcontribcol/go.mod b/cmd/otelcontribcol/go.mod index 3bb601396448..3318c6190c09 100644 --- a/cmd/otelcontribcol/go.mod +++ b/cmd/otelcontribcol/go.mod @@ -495,7 +495,7 @@ require ( github.com/lightstep/go-expohisto v1.0.0 // indirect github.com/linkedin/goavro/v2 v2.9.8 // indirect github.com/linode/linodego v1.23.0 // indirect - github.com/logicmonitor/lm-data-sdk-go v1.1.0 // indirect + github.com/logicmonitor/lm-data-sdk-go v1.2.0 // indirect github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect diff --git a/cmd/otelcontribcol/go.sum b/cmd/otelcontribcol/go.sum index d06b910ccd42..c34576531beb 100644 --- a/cmd/otelcontribcol/go.sum +++ b/cmd/otelcontribcol/go.sum @@ -1080,8 +1080,8 @@ github.com/linkedin/goavro/v2 v2.9.8 h1:jN50elxBsGBDGVDEKqUlDuU1cFwJ11K/yrJCBMe/ github.com/linkedin/goavro/v2 v2.9.8/go.mod h1:UgQUb2N/pmueQYH9bfqFioWxzYCZXSfF8Jw03O5sjqA= github.com/linode/linodego v1.23.0 h1:s0ReCZtuN9Z1IoUN9w1RLeYO1dMZUGPwOQ/IBFsBHtU= github.com/linode/linodego v1.23.0/go.mod h1:0U7wj/UQOqBNbKv1FYTXiBUXueR8DY4HvIotwE0ENgg= -github.com/logicmonitor/lm-data-sdk-go v1.1.0 h1:kfUWTzC3IKaNWihowaRgEYZ28fksYDJNkhG2AHsNelI= -github.com/logicmonitor/lm-data-sdk-go v1.1.0/go.mod h1:Iqvbe9R/NWrvUw3pp/kN9RF4HmQyyVBky6XyluGgKH8= +github.com/logicmonitor/lm-data-sdk-go v1.2.0 h1:p2nui4Nv3rc4f/tHRuUk2xyVrIuDELIOdK2/WVzllYE= +github.com/logicmonitor/lm-data-sdk-go v1.2.0/go.mod h1:nIHr4uOPfg6AM7mG1rewg3L4O3rfge34o7UYB7joBM4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c h1:VtwQ41oftZwlMnOEbMWQtSEUgU64U4s+GHk7hZK+jtY= github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE= diff --git a/exporter/logicmonitorexporter/go.mod b/exporter/logicmonitorexporter/go.mod index 48b0400fc863..7f28d8d6cbf2 100644 --- a/exporter/logicmonitorexporter/go.mod +++ b/exporter/logicmonitorexporter/go.mod @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/logicm go 1.20 require ( - github.com/logicmonitor/lm-data-sdk-go v1.1.0 + github.com/logicmonitor/lm-data-sdk-go v1.2.0 github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.92.0 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry v0.92.0 github.com/stretchr/testify v1.8.4 @@ -30,7 +30,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/google/uuid v1.4.0 // indirect + github.com/google/uuid v1.5.0 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.4 // indirect diff --git a/exporter/logicmonitorexporter/go.sum b/exporter/logicmonitorexporter/go.sum index 82c3b9412e6f..6ab159f2d339 100644 --- a/exporter/logicmonitorexporter/go.sum +++ b/exporter/logicmonitorexporter/go.sum @@ -56,8 +56,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -74,8 +74,8 @@ github.com/knadh/koanf/v2 v2.0.1 h1:1dYGITt1I23x8cfx8ZnldtezdyaZtfAuRtIFOiRzK7g= github.com/knadh/koanf/v2 v2.0.1/go.mod h1:ZeiIlIDXTE7w1lMT6UVcNiRAS2/rCeLn/GdLNvY1Dus= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/logicmonitor/lm-data-sdk-go v1.1.0 h1:kfUWTzC3IKaNWihowaRgEYZ28fksYDJNkhG2AHsNelI= -github.com/logicmonitor/lm-data-sdk-go v1.1.0/go.mod h1:Iqvbe9R/NWrvUw3pp/kN9RF4HmQyyVBky6XyluGgKH8= +github.com/logicmonitor/lm-data-sdk-go v1.2.0 h1:p2nui4Nv3rc4f/tHRuUk2xyVrIuDELIOdK2/WVzllYE= +github.com/logicmonitor/lm-data-sdk-go v1.2.0/go.mod h1:nIHr4uOPfg6AM7mG1rewg3L4O3rfge34o7UYB7joBM4= github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= diff --git a/exporter/logicmonitorexporter/internal/logs/sender.go b/exporter/logicmonitorexporter/internal/logs/sender.go index 02c276d23562..426ec04d6898 100644 --- a/exporter/logicmonitorexporter/internal/logs/sender.go +++ b/exporter/logicmonitorexporter/internal/logs/sender.go @@ -36,27 +36,23 @@ func NewSender(ctx context.Context, logger *zap.Logger, opts ...lmsdklogs.Option func (s *Sender) SendLogs(ctx context.Context, payload []model.LogInput) error { ingestResponse, err := s.logIngestClient.SendLogs(ctx, payload) if err != nil { - return consumererror.NewPermanent(err) - } - if ingestResponse != nil { - - if ingestResponse.Success { - return nil - } - if ingestResponse.RetryAfter > 0 { - return exporterhelper.NewThrottleRetry(ingestResponse.Error, time.Duration(ingestResponse.RetryAfter)*time.Second) - } - if ingestResponse.StatusCode == http.StatusMultiStatus { - for _, status := range ingestResponse.MultiStatus { - if isPermanentClientFailure(int(status.Code)) { - return consumererror.NewPermanent(fmt.Errorf("permanent failure error %s, complete error log %w", status.Error, ingestResponse.Error)) + if ingestResponse != nil { + if ingestResponse.RetryAfter > 0 { + return exporterhelper.NewThrottleRetry(ingestResponse.Error, time.Duration(ingestResponse.RetryAfter)*time.Second) + } + if ingestResponse.StatusCode == http.StatusMultiStatus { + for _, status := range ingestResponse.MultiStatus { + if isPermanentClientFailure(int(status.Code)) { + return consumererror.NewPermanent(fmt.Errorf("permanent failure error %s, complete error log %w", status.Error, ingestResponse.Error)) + } } } + if isPermanentClientFailure(ingestResponse.StatusCode) { + return consumererror.NewPermanent(ingestResponse.Error) + } + return ingestResponse.Error } - if isPermanentClientFailure(ingestResponse.StatusCode) { - return consumererror.NewPermanent(ingestResponse.Error) - } - return ingestResponse.Error + return consumererror.NewPermanent(err) } return nil } diff --git a/exporter/logicmonitorexporter/internal/traces/sender.go b/exporter/logicmonitorexporter/internal/traces/sender.go index b7ecc4cbefe2..208ca69a4b13 100644 --- a/exporter/logicmonitorexporter/internal/traces/sender.go +++ b/exporter/logicmonitorexporter/internal/traces/sender.go @@ -44,27 +44,23 @@ func NewSender(ctx context.Context, endpoint string, client *http.Client, authPa func (s *Sender) SendTraces(ctx context.Context, td ptrace.Traces) error { ingestResponse, err := s.traceIngestClient.SendTraces(ctx, td) if err != nil { - return consumererror.NewPermanent(err) - } - if ingestResponse != nil { - - if ingestResponse.Success { - return nil - } - if ingestResponse.RetryAfter > 0 { - return exporterhelper.NewThrottleRetry(ingestResponse.Error, time.Duration(ingestResponse.RetryAfter)*time.Second) - } - if ingestResponse.StatusCode == http.StatusMultiStatus { - for _, status := range ingestResponse.MultiStatus { - if isPermanentClientFailure(int(status.Code)) { - return consumererror.NewPermanent(fmt.Errorf("permanent failure error %s, complete error log %w", status.Error, ingestResponse.Error)) + if ingestResponse != nil { + if ingestResponse.RetryAfter > 0 { + return exporterhelper.NewThrottleRetry(ingestResponse.Error, time.Duration(ingestResponse.RetryAfter)*time.Second) + } + if ingestResponse.StatusCode == http.StatusMultiStatus { + for _, status := range ingestResponse.MultiStatus { + if isPermanentClientFailure(int(status.Code)) { + return consumererror.NewPermanent(fmt.Errorf("permanent failure error %s, complete error log %w", status.Error, ingestResponse.Error)) + } } } + if isPermanentClientFailure(ingestResponse.StatusCode) { + return consumererror.NewPermanent(ingestResponse.Error) + } + return ingestResponse.Error } - if isPermanentClientFailure(ingestResponse.StatusCode) { - return consumererror.NewPermanent(ingestResponse.Error) - } - return ingestResponse.Error + return consumererror.NewPermanent(err) } return nil } diff --git a/go.mod b/go.mod index bf7d02b3ae3b..c52d19dd4f3e 100644 --- a/go.mod +++ b/go.mod @@ -468,7 +468,7 @@ require ( github.com/lightstep/go-expohisto v1.0.0 // indirect github.com/linkedin/goavro/v2 v2.9.8 // indirect github.com/linode/linodego v1.23.0 // indirect - github.com/logicmonitor/lm-data-sdk-go v1.1.0 // indirect + github.com/logicmonitor/lm-data-sdk-go v1.2.0 // indirect github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect diff --git a/go.sum b/go.sum index 411c8d8e63a4..e00fa43c1987 100644 --- a/go.sum +++ b/go.sum @@ -1089,8 +1089,8 @@ github.com/linkedin/goavro/v2 v2.9.8 h1:jN50elxBsGBDGVDEKqUlDuU1cFwJ11K/yrJCBMe/ github.com/linkedin/goavro/v2 v2.9.8/go.mod h1:UgQUb2N/pmueQYH9bfqFioWxzYCZXSfF8Jw03O5sjqA= github.com/linode/linodego v1.23.0 h1:s0ReCZtuN9Z1IoUN9w1RLeYO1dMZUGPwOQ/IBFsBHtU= github.com/linode/linodego v1.23.0/go.mod h1:0U7wj/UQOqBNbKv1FYTXiBUXueR8DY4HvIotwE0ENgg= -github.com/logicmonitor/lm-data-sdk-go v1.1.0 h1:kfUWTzC3IKaNWihowaRgEYZ28fksYDJNkhG2AHsNelI= -github.com/logicmonitor/lm-data-sdk-go v1.1.0/go.mod h1:Iqvbe9R/NWrvUw3pp/kN9RF4HmQyyVBky6XyluGgKH8= +github.com/logicmonitor/lm-data-sdk-go v1.2.0 h1:p2nui4Nv3rc4f/tHRuUk2xyVrIuDELIOdK2/WVzllYE= +github.com/logicmonitor/lm-data-sdk-go v1.2.0/go.mod h1:nIHr4uOPfg6AM7mG1rewg3L4O3rfge34o7UYB7joBM4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c h1:VtwQ41oftZwlMnOEbMWQtSEUgU64U4s+GHk7hZK+jtY= github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE=