TUN-6250: Add upstream response status code to tracing span attributes

This commit is contained in:
João Oliveirinha
2022-05-18 12:11:38 +01:00
parent 26a7b59f6f
commit 6f78ccde04
4 changed files with 44 additions and 15 deletions

View File

@@ -238,20 +238,15 @@ func (o helloWorld) MarshalJSON() ([]byte, error) {
// statusCode is an OriginService that just responds with a given HTTP status.
// Typical use-case is "user wants the catch-all rule to just respond 404".
type statusCode struct {
resp *http.Response
code int
}
func newStatusCode(status int) statusCode {
resp := &http.Response{
StatusCode: status,
Status: fmt.Sprintf("%d %s", status, http.StatusText(status)),
Body: new(NopReadCloser),
}
return statusCode{resp: resp}
return statusCode{code: status}
}
func (o *statusCode) String() string {
return fmt.Sprintf("http_status:%d", o.resp.StatusCode)
return fmt.Sprintf("http_status:%d", o.code)
}
func (o *statusCode) start(