-
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 all commits
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,45 @@ 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 upstream 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 (Runtime::runtimeFeatureEnabled("envoy.reloadable_features.update_grpc_response_error_tag")) { | ||
| if (grpc_status_code.has_value()) { | ||
| const auto& status = grpc_status_code.value(); | ||
| if (status != Grpc::Status::WellKnownGrpcStatus::InvalidCode) { | ||
| switch (status) { | ||
| // Each case below is considered to be a client side error, therefore should not be | ||
| // tagged as an upstream error. See https://grpc.github.io/grpc/core/md_doc_statuscodes.html | ||
| // for more details about how each Grpc status code is defined and whether it is an | ||
| // upstream error or a client error. | ||
| case Grpc::Status::WellKnownGrpcStatus::Ok: | ||
|
alyssawilk marked this conversation as resolved.
|
||
| case Grpc::Status::WellKnownGrpcStatus::Canceled: | ||
| case Grpc::Status::WellKnownGrpcStatus::InvalidArgument: | ||
| case Grpc::Status::WellKnownGrpcStatus::NotFound: | ||
| case Grpc::Status::WellKnownGrpcStatus::AlreadyExists: | ||
| case Grpc::Status::WellKnownGrpcStatus::PermissionDenied: | ||
| case Grpc::Status::WellKnownGrpcStatus::FailedPrecondition: | ||
| case Grpc::Status::WellKnownGrpcStatus::Aborted: | ||
|
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. hm, canceled says "usually by the caller" but aborted says it's a concurrency issue. Would that be client side or server side error do you think?
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.
|
||
| case Grpc::Status::WellKnownGrpcStatus::OutOfRange: | ||
| case Grpc::Status::WellKnownGrpcStatus::Unauthenticated: | ||
| break; | ||
| case Grpc::Status::WellKnownGrpcStatus::Unknown: | ||
| case Grpc::Status::WellKnownGrpcStatus::DeadlineExceeded: | ||
| case Grpc::Status::WellKnownGrpcStatus::Unimplemented: | ||
| case Grpc::Status::WellKnownGrpcStatus::ResourceExhausted: | ||
| case Grpc::Status::WellKnownGrpcStatus::Internal: | ||
| case Grpc::Status::WellKnownGrpcStatus::Unavailable: | ||
| case Grpc::Status::WellKnownGrpcStatus::DataLoss: | ||
| span.setTag(Tracing::Tags::get().Error, Tracing::Tags::get().True); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| } else { | ||
| if (grpc_status_code && grpc_status_code.value() != Grpc::Status::WellKnownGrpcStatus::Ok) { | ||
| span.setTag(Tracing::Tags::get().Error, Tracing::Tags::get().True); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.