Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[exporters/otlptracehttp] Do not log errors for 2XX response #3707

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Fixed

- Do not log errors for 202 Accepted response for otlptracehttp exporter. (#3706)

### Added

- Semantic conventions of the `event` type are now generated. (#3697)
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/otlptrace/otlptracehttp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (d *client) UploadTraces(ctx context.Context, protoSpans []*tracepb.Resourc
}

switch resp.StatusCode {
case http.StatusOK:
case http.StatusOK, http.StatusAccepted:
songy23 marked this conversation as resolved.
Show resolved Hide resolved
// Success, do not retry.
// Read the partial success message, if any.
var respData bytes.Buffer
Expand Down
6 changes: 6 additions & 0 deletions exporters/otlp/otlptrace/otlptracehttp/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ func TestEndToEnd(t *testing.T) {
otlptracehttp.WithCompression(otlptracehttp.GzipCompression),
},
},
{
name: "no errors on 202 Accepted",
mcCfg: mockCollectorConfig{
InjectHTTPStatus: []int{202},
},
},
{
name: "retry",
opts: []otlptracehttp.Option{
Expand Down
11 changes: 8 additions & 3 deletions exporters/otlp/otlptrace/otlptracehttp/mock_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ func (c *mockCollector) serveTraces(w http.ResponseWriter, r *http.Request) {
return
}
h := c.getInjectResponseHeader()
if injectedStatus := c.getInjectHTTPStatus(); injectedStatus != 0 {
injectedStatus := c.getInjectHTTPStatus()
if injectedStatus != 0 {
writeReply(w, rawResponse, injectedStatus, c.injectContentType, h)
return
if injectedStatus != http.StatusAccepted {
return
}
}
rawRequest, err := readRequest(r)
if err != nil {
Expand All @@ -118,7 +121,9 @@ func (c *mockCollector) serveTraces(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusBadRequest)
return
}
writeReply(w, rawResponse, 0, c.injectContentType, h)
if injectedStatus == 0 {
writeReply(w, rawResponse, 0, c.injectContentType, h)
}
c.spanLock.Lock()
defer c.spanLock.Unlock()
c.spansStorage.AddSpans(request)
Expand Down