Skip to content

Commit

Permalink
[exporter/logicmonitor] Update the lm-data-sdk-go version to v1.2.0 a…
Browse files Browse the repository at this point in the history
…nd fix error handling issue (open-telemetry#30431)

**Description:** <Describe what has changed.>
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
  • Loading branch information
avadhut123pisal authored and cparkins committed Feb 1, 2024
1 parent c1c6151 commit fa6572e
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 51 deletions.
2 changes: 1 addition & 1 deletion cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmd/configschema/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmd/otelcontribcol/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions exporter/logicmonitorexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions exporter/logicmonitorexporter/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 14 additions & 18 deletions exporter/logicmonitorexporter/internal/logs/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
32 changes: 14 additions & 18 deletions exporter/logicmonitorexporter/internal/traces/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fa6572e

Please sign in to comment.