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

Handle "not modified" errors properly #120

Merged
merged 3 commits into from
Jul 6, 2023
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ $(BIN)/license-header: Makefile

$(BIN)/golangci-lint: Makefile
@mkdir -p $(@D)
GOBIN=$(abspath $(@D)) $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.0
GOBIN=$(abspath $(@D)) $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0

$(BIN)/protoc-gen-go: Makefile
@mkdir -p $(@D)
Expand Down
6 changes: 6 additions & 0 deletions attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ func statusCodeAttribute(protocol string, serverErr error) (attribute.KeyValue,
}
return codeKey.Int64(0), true // gRPC uses 0 for success
case connectProtocol:
if connect.IsNotModifiedError(serverErr) {
// A "not modified" error is special: it's code is technically "unknown" but
// it would be misleading to label it as an unknown error since it's not really
// an error, but rather a sentinel to trigger a "304 Not Modified" HTTP status.
return semconv.HTTPStatusCodeKey.Int(http.StatusNotModified), true
}
codeKey := attribute.Key("rpc." + protocol + ".error_code")
if serverErr != nil {
return codeKey.String(connect.CodeOf(serverErr).String()), true
Expand Down