-
Notifications
You must be signed in to change notification settings - Fork 327
Set the error code based on the HTTP status code #457
Comments
@rakyll where did this code come from? |
what about 418 I'm a Teapot?
|
@jadekler suggested that he can add a function to the ochttp package.
@jadekler, can I assign it to you? |
@rakyll Yes, please do |
I'd like to understand the full cross product of behavior here. How does Stackdriver/prometheus/etc. handle gRPC codes/HTTP codes/arbitrary int32s? I think it would be fine if Google's HTTP-based clients used the gRPC codes; it seems reasonable that Google's clients are optimized for Google's monitoring. But none of the code in this repo should have that bias. So maybe this repo contains |
I think we need to define what the status code maps to: either HTTP status codes or gRPC. Otherwise it's impossible to interpret in any meaningful way without knowing exactly where a Span was produced, which an exporter will in general not know. At minimum we need to know that an error occurred (non-successful status) and probably also whether it's a client problem or server problem. cc @bogdandrutu |
We are also recording the HTTP status code as an attribute, so no information loss here.
For metrics, they will be labels. For traces, they will be span attributes. Some backends already have first-class canonical label or attribute keys for errors. If that's the case, the exporters should populate them.
It shouldn't be called after gRPC, HTTPStatusToCode is more preferable. This is not a gRPC-specific mapping, we just happened to have the same mapping. That's why it is not Google-specific. It would be better to argue the rationale behind error codes all together and change the proto if we don't think they are useful. |
In that case, you should have your own Code type that is a copy of the gRPC one so you don't have a dependency on gRPC, and you should change the type of |
Along those lines: if the HTTP code is going to be an attribute anyway, then maybe there shouldn't be a privileged |
We don't have a type dependency on gRPC. What exactly are you pointing at? See https://godoc.org/go.opencensus.io/trace#Status. We will remove the comment there and replace it with our spec for error codes as soon as we have a consensus on this.
There is no maybe in this. We specify what the exporter behavior should be. I don't understand why you are dealing with any of the HTTP attributes and annotations unless you want to add custom ones. You should just use the ochttp package and it will provide a basic set of attributes, annotations, etc. We currently set the attributes (example), and will set the error as soon as there is consensus on the mapping. You shouldn't care about them. |
Sorry for not being clear. Here is what I mean: If you make the choice to use this set of error codes, then
I'm not. Sorry again about lack of clarity. In that comment, I was suggesting that you delete the
When an exporter's But another exporter could make a different choice, choosing to transmit HTTP codes to its backend and converting the gRPC codes in the other direction. |
Agreed with the above. I'm concerned about,
The intention behind https://godoc.org/go.opencensus.io/trace#Status seems to be to represent gRPC codes. I think the way that this ends up if we don't explicitly break out http and grpc is copy-pasting gRPC's codes into something called I'm not convinced that opencensus should have its own codes - I reckon it should be a transparent middleman that facilitates stats/tracing from my app to my exporter, not something I need to "conform" to. +1 to deletion of Status.Code and instead setting |
Setting status code only in cases we are confident enough to map the HTTP status code to error codes. Fixes census-instrumentation#457.
Setting status code only in cases we are confident enough to map the HTTP status code to error codes. Fixes census-instrumentation#457.
Setting status code only in cases we are confident enough to map the HTTP status code to error codes. Fixes #457.
plugin/ochttp need to set the error code based on the HTTP response code.
Below, there is a reference how HTTP status codes maps to error codes:
The text was updated successfully, but these errors were encountered: