Skip to content

Commit

Permalink
update stats labels
Browse files Browse the repository at this point in the history
  • Loading branch information
vchitai committed Oct 28, 2020
1 parent d6a2098 commit 5f70e63
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions instrumentation/net/http/otelhttp/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
type statTransport struct {
meter metric.Meter
base *Transport
labels label.Set
counters map[string]metric.Int64Counter
valueRecorders map[string]metric.Float64ValueRecorder
}
Expand All @@ -28,7 +27,7 @@ type tracker struct {
body io.ReadCloser
statusCode int
endOnce sync.Once
labels label.Set
labels *label.Set

counters map[string]metric.Int64Counter
valueRecorders map[string]metric.Float64ValueRecorder
Expand Down Expand Up @@ -81,7 +80,7 @@ func (trans *statTransport) applyConfig(c *config) {

// RoundTrip implements http.RoundTripper, delegating to Base and recording stats for the request.
func (trans *statTransport) RoundTrip(req *http.Request) (*http.Response, error) {
trans.labels = label.NewSet(
labels := label.NewSet(
KeyClientHost.String(req.Host),
Host.String(req.Host),
KeyClientPath.String(req.URL.Path),
Expand All @@ -96,14 +95,15 @@ func (trans *statTransport) RoundTrip(req *http.Request) (*http.Response, error)
ctx: ctx,
counters: trans.counters,
valueRecorders: trans.valueRecorders,
labels: &labels,
}
if req.Body == nil {
// TODO: Handle cases where ContentLength is not set.
track.reqSize = -1
} else if req.ContentLength > 0 {
track.reqSize = req.ContentLength
}
trans.counters[ClientRequestCount].Add(ctx, 1, trans.labels.ToSlice()...)
trans.counters[ClientRequestCount].Add(ctx, 1, labels.ToSlice()...)

// Perform request.
resp, err := trans.base.RoundTrip(req)
Expand Down

0 comments on commit 5f70e63

Please sign in to comment.