Skip to content

Commit

Permalink
Update backend.go
Browse files Browse the repository at this point in the history
simplified count calls
  • Loading branch information
Marcel Ludwig committed Dec 5, 2022
1 parent 17ccc70 commit de29970
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions handler/transport/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,13 @@ func (b *Backend) innerRoundTrip(req *http.Request, tc *Config, deadlineErr <-ch
endSeconds := time.Since(start).Seconds()

statusKey := attribute.Key("code")
if beresp != nil {
attrs = append(attrs, statusKey.Int(beresp.StatusCode))
}
defer counter.Observe(req.Context(), 1, attrs...)
defer duration.Record(req.Context(), endSeconds, attrs...)

if err != nil {
defer counter.Observe(req.Context(), 1, attrs...)
defer duration.Record(req.Context(), endSeconds, attrs...)
select {
case derr := <-deadlineErr:
if derr != nil {
Expand All @@ -331,10 +335,6 @@ func (b *Backend) innerRoundTrip(req *http.Request, tc *Config, deadlineErr <-ch
}
}

attrs = append(attrs, statusKey.Int(beresp.StatusCode))
defer counter.Observe(req.Context(), 1, attrs...)
defer duration.Record(req.Context(), endSeconds, attrs...)

return beresp, nil
}

Expand Down

0 comments on commit de29970

Please sign in to comment.