Skip to content

Commit 9976ea8

Browse files
[receiver/otlp] Switch from InvalidArgument to Internal (#9415)
The otlp receiver was recently updated via #8080 to properly propagate consumer errors back to clients as either permanent or retriable. The code we're using to indicate a non-retriable error is `codes.InvalidArgument`, which is the equivalent of `400` in HTTP. While 100% correct according to the [OTLP specification](https://github.com/open-telemetry/opentelemetry-proto/blob/main/docs/specification.md#failures) to indicate a non-retriable error, I think `codes.Internal` (which is equivalent to HTTP `500`), better conveys the actual state of the collector in these situations. Related to #9357 (comment) --------- Co-authored-by: Evan Bradley <[email protected]>
1 parent 923cba6 commit 9976ea8

File tree

7 files changed

+32
-6
lines changed

7 files changed

+32
-6
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: receiver/otlp
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Update gRPC code from `codes.InvalidArgument` to `codes.Internal` when a permanent error doesn't contain a gRPC status
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [9415]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: []

receiver/otlpreceiver/internal/errors/errors.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ func GetStatusFromError(err error) error {
1717
// https://github.com/open-telemetry/opentelemetry-proto/blob/main/docs/specification.md#failures
1818
code := codes.Unavailable
1919
if consumererror.IsPermanent(err) {
20-
code = codes.InvalidArgument
20+
// If an error is permanent but doesn't have an attached gRPC status, assume it is server-side.
21+
code = codes.Internal
2122
}
2223
s = status.New(code, err.Error())
2324
}

receiver/otlpreceiver/internal/errors/errors_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func Test_GetStatusFromError(t *testing.T) {
2828
{
2929
name: "Permanent Error",
3030
input: consumererror.NewPermanent(fmt.Errorf("test")),
31-
expected: status.New(codes.InvalidArgument, "Permanent error: test"),
31+
expected: status.New(codes.Internal, "Permanent error: test"),
3232
},
3333
{
3434
name: "Non-Permanent Error",

receiver/otlpreceiver/internal/logs/otlp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestExport_PermanentErrorConsumer(t *testing.T) {
6767

6868
logClient := makeLogsServiceClient(t, consumertest.NewErr(consumererror.NewPermanent(errors.New("my error"))))
6969
resp, err := logClient.Export(context.Background(), req)
70-
assert.EqualError(t, err, "rpc error: code = InvalidArgument desc = Permanent error: my error")
70+
assert.EqualError(t, err, "rpc error: code = Internal desc = Permanent error: my error")
7171
assert.IsType(t, status.Error(codes.Unknown, ""), err)
7272
assert.Equal(t, plogotlp.ExportResponse{}, resp)
7373
}

receiver/otlpreceiver/internal/metrics/otlp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestExport_PermanentErrorConsumer(t *testing.T) {
6767

6868
metricsClient := makeMetricsServiceClient(t, consumertest.NewErr(consumererror.NewPermanent(errors.New("my error"))))
6969
resp, err := metricsClient.Export(context.Background(), req)
70-
assert.EqualError(t, err, "rpc error: code = InvalidArgument desc = Permanent error: my error")
70+
assert.EqualError(t, err, "rpc error: code = Internal desc = Permanent error: my error")
7171
assert.IsType(t, status.Error(codes.Unknown, ""), err)
7272
assert.Equal(t, pmetricotlp.ExportResponse{}, resp)
7373
}

receiver/otlpreceiver/internal/trace/otlp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestExport_PermanentErrorConsumer(t *testing.T) {
6464

6565
traceClient := makeTraceServiceClient(t, consumertest.NewErr(consumererror.NewPermanent(errors.New("my error"))))
6666
resp, err := traceClient.Export(context.Background(), req)
67-
assert.EqualError(t, err, "rpc error: code = InvalidArgument desc = Permanent error: my error")
67+
assert.EqualError(t, err, "rpc error: code = Internal desc = Permanent error: my error")
6868
assert.IsType(t, status.Error(codes.Unknown, ""), err)
6969
assert.Equal(t, ptraceotlp.ExportResponse{}, resp)
7070
}

receiver/otlpreceiver/otlp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ func TestOTLPReceiverGRPCTracesIngestTest(t *testing.T) {
501501
},
502502
{
503503
okToIngest: false,
504-
expectedCode: codes.InvalidArgument,
504+
expectedCode: codes.Internal,
505505
permanent: true,
506506
},
507507
{

0 commit comments

Comments
 (0)