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

[receiver/awsfirehose] follow receiver contract #36124

Merged
merged 9 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 25 additions & 0 deletions .chloggen/awsfirehose-contract.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: awsfirehosereceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Follow receiver contract based on type of error

# One or more tracking issues or pull requests related to the change
issues: [5909]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
2 changes: 1 addition & 1 deletion receiver/awsfirehosereceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
go.opentelemetry.io/collector/config/configtls v1.20.0
go.opentelemetry.io/collector/confmap v1.20.0
go.opentelemetry.io/collector/consumer v0.114.0
go.opentelemetry.io/collector/consumer/consumererror v0.114.0
go.opentelemetry.io/collector/consumer/consumertest v0.114.0
go.opentelemetry.io/collector/pdata v1.20.0
go.opentelemetry.io/collector/receiver v0.114.0
Expand Down Expand Up @@ -50,7 +51,6 @@ require (
go.opentelemetry.io/collector/config/configcompression v1.20.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.114.0 // indirect
go.opentelemetry.io/collector/config/internal v0.114.0 // indirect
go.opentelemetry.io/collector/consumer/consumererror v0.114.0 // indirect
go.opentelemetry.io/collector/consumer/consumerprofiles v0.114.0 // indirect
go.opentelemetry.io/collector/extension v0.114.0 // indirect
go.opentelemetry.io/collector/extension/auth v0.114.0 // indirect
Expand Down
6 changes: 5 additions & 1 deletion receiver/awsfirehosereceiver/logs_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"

"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/receiver"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsfirehosereceiver/internal/unmarshaler"
Expand Down Expand Up @@ -80,7 +81,10 @@ func (mc *logsConsumer) Consume(ctx context.Context, records [][]byte, commonAtt

err = mc.consumer.ConsumeLogs(ctx, md)
if err != nil {
return http.StatusInternalServerError, err
if consumererror.IsPermanent(err) {
return http.StatusBadRequest, err
}
return http.StatusServiceUnavailable, err
}
return http.StatusOK, nil
}
8 changes: 7 additions & 1 deletion receiver/awsfirehosereceiver/logs_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/receiver/receivertest"
Expand Down Expand Up @@ -79,9 +80,14 @@ func TestLogsConsumer(t *testing.T) {
wantStatus: http.StatusBadRequest,
wantErr: testErr,
},
"WithConsumerErrorPermanent": {
consumerErr: consumererror.NewPermanent(testErr),
wantStatus: http.StatusBadRequest,
wantErr: consumererror.NewPermanent(testErr),
},
"WithConsumerError": {
consumerErr: testErr,
wantStatus: http.StatusInternalServerError,
wantStatus: http.StatusServiceUnavailable,
wantErr: testErr,
},
"WithNoError": {
Expand Down
6 changes: 5 additions & 1 deletion receiver/awsfirehosereceiver/metrics_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/http"

"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/receiver"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsfirehosereceiver/internal/unmarshaler"
Expand Down Expand Up @@ -82,7 +83,10 @@ func (mc *metricsConsumer) Consume(ctx context.Context, records [][]byte, common

err = mc.consumer.ConsumeMetrics(ctx, md)
if err != nil {
return http.StatusInternalServerError, err
if consumererror.IsPermanent(err) {
return http.StatusBadRequest, err
}
return http.StatusServiceUnavailable, err
}
return http.StatusOK, nil
}
8 changes: 7 additions & 1 deletion receiver/awsfirehosereceiver/metrics_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/receiver/receivertest"
Expand Down Expand Up @@ -80,9 +81,14 @@ func TestMetricsConsumer(t *testing.T) {
wantStatus: http.StatusBadRequest,
wantErr: testErr,
},
"WithConsumerErrorPermanent": {
consumerErr: consumererror.NewPermanent(testErr),
wantStatus: http.StatusBadRequest,
wantErr: consumererror.NewPermanent(testErr),
},
"WithConsumerError": {
consumerErr: testErr,
wantStatus: http.StatusInternalServerError,
wantStatus: http.StatusServiceUnavailable,
wantErr: testErr,
},
"WithNoError": {
Expand Down