Skip to content

Commit

Permalink
[exporter/dynatrace] do not disable when module temporarily disabled (o…
Browse files Browse the repository at this point in the history
…pen-telemetry#7161)

* fix(dt): do not disable exporter when module temporarily disabled
  • Loading branch information
dyladan committed Jan 13, 2022
1 parent 772f39c commit 1429556
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- `datadogexporter`: Add http.status_code tag to trace stats (#6889)
- `tanzuobservabilityexporter`: Support delta histograms (#6897)
- `mysqlreceiver`: Add the receiver to available components (#7078)
- `dynatraceexporter`: Do not shut down exporter when metrics ingest module is temporarily unavailable (#7161)

## 🛑 Breaking changes 🛑

Expand Down
13 changes: 8 additions & 5 deletions exporter/dynatraceexporter/metrics_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,18 @@ func (e *exporter) sendBatch(ctx context.Context, lines []string) error {
return nil
}

if resp.StatusCode == http.StatusUnauthorized || resp.StatusCode == http.StatusForbidden {
// Unauthorized and Unauthenticated errors are permanent
if resp.StatusCode == http.StatusUnauthorized {
// token is missing or wrong format
e.isDisabled = true
return consumererror.NewPermanent(fmt.Errorf(resp.Status))
return consumererror.NewPermanent(fmt.Errorf("API token missing or invalid"))
}

if resp.StatusCode == http.StatusForbidden {
return consumererror.NewPermanent(fmt.Errorf("API token missing the required scope (metrics.ingest)"))
}

if resp.StatusCode == http.StatusNotFound {
e.isDisabled = true
return consumererror.NewPermanent(fmt.Errorf("dynatrace metrics ingest module is disabled"))
return consumererror.NewPermanent(fmt.Errorf("metrics ingest v2 module not found - ensure module is enabled and endpoint is correct"))
}

// No known errors
Expand Down
4 changes: 2 additions & 2 deletions exporter/dynatraceexporter/metrics_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ func Test_exporter_send_NotFound(t *testing.T) {
t.Errorf("Expected error to be permanent %v", err)
return
}
if !e.isDisabled {
t.Error("Expected exporter to be disabled")
if e.isDisabled {
t.Error("Expected exporter to not be disabled")
return
}
}
Expand Down

0 comments on commit 1429556

Please sign in to comment.