You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🐛 on grpc when no status code into header, fallback to OK (previously Unkown)
It's a quick fix, need test and maybe a better implementation and understanding (and being able to create tonic middleware that use tonic response and not http response)
FIX#122
Signed-off-by: David Bernard <david.bernard.31@gmail.com>
/// If "grpc-status" can not be extracted from http response, the status "2" (UNKNOWN error) is defined
105
-
//TODO create similar but with tonic::Response<B> ?
104
+
/// gRPC status codes
105
+
/// [gRPC status codes]: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md#status-codes-and-their-use-in-grpc
106
+
/// copied from tonic
107
+
#[derive(Clone,Copy,Debug,PartialEq,Eq,Hash)]
108
+
pubenumGrpcCode{
109
+
/// The operation completed successfully.
110
+
Ok = 0,
111
+
112
+
/// The operation was cancelled.
113
+
Cancelled = 1,
114
+
115
+
/// Unknown error.
116
+
Unknown = 2,
117
+
118
+
/// Client specified an invalid argument.
119
+
InvalidArgument = 3,
120
+
121
+
/// Deadline expired before operation could complete.
122
+
DeadlineExceeded = 4,
123
+
124
+
/// Some requested entity was not found.
125
+
NotFound = 5,
126
+
127
+
/// Some entity that we attempted to create already exists.
128
+
AlreadyExists = 6,
129
+
130
+
/// The caller does not have permission to execute the specified operation.
131
+
PermissionDenied = 7,
132
+
133
+
/// Some resource has been exhausted.
134
+
ResourceExhausted = 8,
135
+
136
+
/// The system is not in a state required for the operation's execution.
137
+
FailedPrecondition = 9,
138
+
139
+
/// The operation was aborted.
140
+
Aborted = 10,
141
+
142
+
/// Operation was attempted past the valid range.
143
+
OutOfRange = 11,
144
+
145
+
/// Operation is not implemented or not supported.
146
+
Unimplemented = 12,
147
+
148
+
/// Internal error.
149
+
Internal = 13,
150
+
151
+
/// The service is currently unavailable.
152
+
Unavailable = 14,
153
+
154
+
/// Unrecoverable data loss or corruption.
155
+
DataLoss = 15,
156
+
157
+
/// The request does not have valid authentication credentials
158
+
Unauthenticated = 16,
159
+
}
160
+
161
+
/// If "grpc-status" can not be extracted from http response, the status "0" (Ok) is defined
162
+
//TODO create similar but with tonic::Response<B> ? and use of [Status in tonic](https://docs.rs/tonic/latest/tonic/struct.Status.html) (more complete)
106
163
pubfngrpc_update_span_from_response<B>(
107
164
span:&tracing::Span,
108
165
response:&http::Response<B>,
109
166
is_spankind_server:bool,
110
167
){
111
-
let status = response
112
-
.headers()
113
-
.get("grpc-status")
114
-
.and_then(|v| v.to_str().ok())
115
-
.and_then(|v| v.parse::<u16>().ok())
116
-
.unwrap_or(2);
168
+
let status = grpc_status_from_http_header(response.headers())
0 commit comments