-
Notifications
You must be signed in to change notification settings - Fork 5.4k
update tracing error tag for grpc status codes #20090
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
Changes from 1 commit
33732fc
124b3b7
5cd17ac
e8600f6
da6c0fc
4f0e818
66db5b4
40ad373
d272800
e5f58c0
45838d3
75c711c
a77e2af
fea65c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,10 +84,21 @@ static void addGrpcRequestTags(Span& span, const Http::RequestHeaderMap& headers | |
| template <class T> static void addGrpcResponseTags(Span& span, const T& headers) { | ||
| addTagIfNotNull(span, Tracing::Tags::get().GrpcStatusCode, headers.GrpcStatus()); | ||
| addTagIfNotNull(span, Tracing::Tags::get().GrpcMessage, headers.GrpcMessage()); | ||
| // Set error tag when status is not OK. | ||
| // Set error tag when Grpc status code represents an error. See | ||
| // https://github.com/envoyproxy/envoy/issues/18877 | ||
| absl::optional<Grpc::Status::GrpcStatus> grpc_status_code = Grpc::Common::getGrpcStatus(headers); | ||
| if (grpc_status_code && grpc_status_code.value() != Grpc::Status::WellKnownGrpcStatus::Ok) { | ||
| span.setTag(Tracing::Tags::get().Error, Tracing::Tags::get().True); | ||
| if (grpc_status_code.has_value()) { | ||
| const auto& status = grpc_status_code.value(); | ||
| if (status != Grpc::Status::WellKnownGrpcStatus::InvalidCode && | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does these cover all the error status?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, detailed introduction can be found here: https://grpc.github.io/grpc/core/md_doc_statuscodes.html
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think of converting to a switch, so if gRPC adds new error codes and we pick up on import, we compile fail?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also can we link https://grpc.github.io/grpc/core/md_doc_statuscodes.html here in the comment as well?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, I agree a switch makes more sense in this case.
Done |
||
| (status == Grpc::Status::WellKnownGrpcStatus::Unknown || | ||
| status == Grpc::Status::WellKnownGrpcStatus::DeadlineExceeded || | ||
| status == Grpc::Status::WellKnownGrpcStatus::Unimplemented || | ||
| status == Grpc::Status::WellKnownGrpcStatus::Internal || | ||
| status == Grpc::Status::WellKnownGrpcStatus::Unavailable || | ||
| status == Grpc::Status::WellKnownGrpcStatus::DataLoss || | ||
| status == Grpc::Status::WellKnownGrpcStatus::Unauthenticated)) { | ||
| span.setTag(Tracing::Tags::get().Error, Tracing::Tags::get().True); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -267,4 +278,4 @@ SpanPtr HttpTracerImpl::startSpan(const Config& config, Http::RequestHeaderMap& | |
| } | ||
|
|
||
| } // namespace Tracing | ||
| } // namespace Envoy | ||
| } // namespace Envoy | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're going to want to runtime guard this change, as described in CONTRIBUTING.md
Let's also add a comment where the tracing error code is defined to be more clear about what error means in this case (upstream or envoy error, not client error)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.