Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
Added handling of HTTP code 409 when parsing trace status in ochttp (#…
Browse files Browse the repository at this point in the history
…1190)

* Added handling of HTTP code 409 when parsing trace status on OCHTTP

* Reverted the change of stats/view/aggregation_data.go and stats/view/view_to_metric_test.go
  • Loading branch information
lonnblad authored and rghetia committed Jan 13, 2020
1 parent 643eada commit d851005
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
golang.org/x/net v0.0.0-20190620200207-3b0461eec859
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd // indirect
golang.org/x/text v0.3.2 // indirect
google.golang.org/appengine v1.4.0 // indirect
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb // indirect
google.golang.org/grpc v1.20.1
)
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
3 changes: 3 additions & 0 deletions plugin/ochttp/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ func TraceStatus(httpStatusCode int, statusLine string) trace.Status {
code = trace.StatusCodeUnavailable
case http.StatusOK:
code = trace.StatusCodeOK
case http.StatusConflict:
code = trace.StatusCodeAlreadyExists
}

return trace.Status{Code: code, Message: codeToStr[code]}
}

Expand Down
4 changes: 4 additions & 0 deletions plugin/ochttp/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,10 @@ func TestStatusUnitTest(t *testing.T) {
{403, trace.Status{Code: trace.StatusCodePermissionDenied, Message: `PERMISSION_DENIED`}},
{301, trace.Status{Code: trace.StatusCodeOK, Message: `OK`}},
{501, trace.Status{Code: trace.StatusCodeUnimplemented, Message: `UNIMPLEMENTED`}},
{409, trace.Status{Code: trace.StatusCodeAlreadyExists, Message: `ALREADY_EXISTS`}},
{429, trace.Status{Code: trace.StatusCodeResourceExhausted, Message: `RESOURCE_EXHAUSTED`}},
{503, trace.Status{Code: trace.StatusCodeUnavailable, Message: `UNAVAILABLE`}},
{504, trace.Status{Code: trace.StatusCodeDeadlineExceeded, Message: `DEADLINE_EXCEEDED`}},
}

for _, tt := range tests {
Expand Down

0 comments on commit d851005

Please sign in to comment.