From ccdcdd6c409f5d7a61b5bb607ec2b3c596f48d2e Mon Sep 17 00:00:00 2001 From: vchitai Date: Tue, 27 Oct 2020 17:01:04 +0700 Subject: [PATCH 01/15] add otelhttp client metrics --- go.mod | 2 + go.sum | 15 ++ instrumentation/net/http/otelhttp/common.go | 8 + instrumentation/net/http/otelhttp/go.sum | 6 + instrumentation/net/http/otelhttp/stats.go | 215 ++++++++++++++++++ .../net/http/otelhttp/transport.go | 8 +- 6 files changed, 251 insertions(+), 3 deletions(-) create mode 100644 instrumentation/net/http/otelhttp/stats.go diff --git a/go.mod b/go.mod index 9b514238e15..d0b9756a5da 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,8 @@ go 1.14 require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/kr/pretty v0.1.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0 // indirect go.opentelemetry.io/otel v0.13.0 + go.opentelemetry.io/otel/exporters/stdout v0.13.0 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect ) diff --git a/go.sum b/go.sum index f6d2c5e2280..faaf907fc3c 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,14 @@ +github.com/DataDog/sketches-go v0.0.1 h1:RtG+76WKgZuz6FIaGsjoPePmadDBkuD/KC6+ZWu78b8= +github.com/DataDog/sketches-go v0.0.1/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60= +github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= +github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -14,8 +20,17 @@ github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +go.opentelemetry.io v0.1.0 h1:EANZoRCOP+A3faIlw/iN6YEWoYb1vleZRKm1EvH8T48= +go.opentelemetry.io/contrib v0.13.0/go.mod h1:HzCu6ebm0ywgNxGaEfs3izyJOMP4rZnzxycyTgpI5Sg= +go.opentelemetry.io/contrib/instrumentation/net/http v0.11.0 h1:ufewgDRmtrrdDpPgm7b4/gr4RXLS7KhDttAhyThtYS4= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0 h1:dnZy1afzxEDrHybTYoJE1bQ3fphNwZF2ipSsynlITP4= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0/go.mod h1:SeQm4RTCcZ2/hlMSTuHb7nwIROe5odBtgfKx+7MMqEs= go.opentelemetry.io/otel v0.13.0 h1:2isEnyzjjJZq6r2EKMsFj4TxiQiexsM04AVhwbR/oBA= go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY= +go.opentelemetry.io/otel/exporters/stdout v0.13.0 h1:A+XiGIPQbGoJoBOJfKAKnZyiUSjSWvL3XWETUvtom5k= +go.opentelemetry.io/otel/exporters/stdout v0.13.0/go.mod h1:JJt8RpNY6K+ft9ir3iKpceCvT/rhzJXEExGrWFCbv1o= +go.opentelemetry.io/otel/sdk v0.13.0 h1:4VCfpKamZ8GtnepXxMRurSpHpMKkcxhtO33z1S4rGDQ= +go.opentelemetry.io/otel/sdk v0.13.0/go.mod h1:dKvLH8Uu8LcEPlSAUsfW7kMGaJBhk/1NYvpPZ6wIMbU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/instrumentation/net/http/otelhttp/common.go b/instrumentation/net/http/otelhttp/common.go index 4d4e24ad58d..08bb13a69e8 100644 --- a/instrumentation/net/http/otelhttp/common.go +++ b/instrumentation/net/http/otelhttp/common.go @@ -36,6 +36,14 @@ const ( ServerLatency = "http.server.duration" // Incoming end to end duration, microseconds ) +// Client HTTP metrics +const ( + ClientRequestCount = "http.client.request_count" // Incoming request count total + ClientRequestContentLength = "http.client.request_content_length" // Incoming request bytes total + ClientResponseContentLength = "http.client.response_content_length" // Incoming response bytes total + ClientRoundTripLatency = "http.client.roundtrip_latency" // Incoming end to end duration, microseconds +) + // Filter is a predicate used to determine whether a given http.request should // be traced. A Filter must return true if the request should be traced. type Filter func(*http.Request) bool diff --git a/instrumentation/net/http/otelhttp/go.sum b/instrumentation/net/http/otelhttp/go.sum index 2d8036638ec..1242acf1d8a 100644 --- a/instrumentation/net/http/otelhttp/go.sum +++ b/instrumentation/net/http/otelhttp/go.sum @@ -1,3 +1,5 @@ +github.com/DataDog/sketches-go v0.0.1/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60= +github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -5,6 +7,7 @@ github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8S github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -15,8 +18,11 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0/go.mod h1:SeQm4RTCcZ2/hlMSTuHb7nwIROe5odBtgfKx+7MMqEs= go.opentelemetry.io/otel v0.13.0 h1:2isEnyzjjJZq6r2EKMsFj4TxiQiexsM04AVhwbR/oBA= go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY= +go.opentelemetry.io/otel/exporters/stdout v0.13.0/go.mod h1:JJt8RpNY6K+ft9ir3iKpceCvT/rhzJXEExGrWFCbv1o= +go.opentelemetry.io/otel/sdk v0.13.0/go.mod h1:dKvLH8Uu8LcEPlSAUsfW7kMGaJBhk/1NYvpPZ6wIMbU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/instrumentation/net/http/otelhttp/stats.go b/instrumentation/net/http/otelhttp/stats.go new file mode 100644 index 00000000000..4d99e921389 --- /dev/null +++ b/instrumentation/net/http/otelhttp/stats.go @@ -0,0 +1,215 @@ +package otelhttp + +import ( + "context" + "io" + "net/http" + "sync" + "time" + + "go.opentelemetry.io/otel/api/metric" + "go.opentelemetry.io/otel/label" +) + +type statTransport struct { + meter metric.Meter + base *Transport + labels label.Set + counters map[string]metric.Int64Counter + valueRecorders map[string]metric.Float64ValueRecorder +} + +type tracker struct { + ctx context.Context + respSize int64 + respContentLength int64 + reqSize int64 + start time.Time + body io.ReadCloser + statusCode int + endOnce sync.Once + labels label.Set + + counters map[string]metric.Int64Counter + valueRecorders map[string]metric.Float64ValueRecorder +} + +// The following tags are applied to stats recorded by this package. Host, Path +// and Method are applied to all measures. StatusCode is not applied to +// ClientRequestCount or ServerRequestCount, since it is recorded before the status is known. +var ( + // Host is the value of the HTTP Host header. + // + // The value of this tag can be controlled by the HTTP client, so you need + // to watch out for potentially generating high-cardinality labels in your + // metrics backend if you use this tag in views. + Host = label.Key("http.host") + + // StatusCode is the numeric HTTP response status code, + // or "error" if a transport error occurred and no status code was read. + StatusCode = label.Key("http.status") + + // Path is the URL path (not including query string) in the request. + // + // The value of this tag can be controlled by the HTTP client, so you need + // to watch out for potentially generating high-cardinality labels in your + // metrics backend if you use this tag in views. + Path = label.Key("http.path") + + // Method is the HTTP method of the request, capitalized (GET, POST, etc.). + Method = label.Key("http.method") +) + +// Client tag keys. +var ( + // KeyClientMethod is the HTTP method, capitalized (i.e. GET, POST, PUT, DELETE, etc.). + KeyClientMethod = label.Key("http_client_method") + // KeyClientPath is the URL path (not including query string). + KeyClientPath = label.Key("http_client_path") + // KeyClientStatus is the HTTP status code as an integer (e.g. 200, 404, 500.), or "error" if no response status line was received. + KeyClientStatus = label.Key("http_client_status") + // KeyClientHost is the value of the request Host header. + KeyClientHost = label.Key("http_client_host") +) + +func (trans *statTransport) applyConfig(c *config) { + trans.base.applyConfig(c) + + trans.meter = c.Meter + trans.createMeasures() +} + +// 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( + KeyClientHost.String(req.Host), + Host.String(req.Host), + KeyClientPath.String(req.URL.Path), + Path.String(req.URL.Path), + KeyClientMethod.String(req.Method), + Method.String(req.Method), + ) + + ctx := req.Context() + track := &tracker{ + start: time.Now(), + ctx: ctx, + counters: trans.counters, + valueRecorders: trans.valueRecorders, + } + 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()...) + + // Perform request. + resp, err := trans.base.RoundTrip(req) + + if err != nil { + track.statusCode = http.StatusInternalServerError + track.end() + } else { + track.statusCode = resp.StatusCode + if req.Method != "HEAD" { + track.respContentLength = resp.ContentLength + } + if resp.Body == nil { + track.end() + } else { + track.body = resp.Body + resp.Body = wrappedBodyIO(track, resp.Body) + } + } + return resp, err +} + +// wrappedBodyIO returns a wrapped version of the original +// Body and only implements the same combination of additional +// interfaces as the original. +func wrappedBodyIO(wrapper io.ReadCloser, body io.ReadCloser) io.ReadCloser { + wr, i0 := body.(io.Writer) + switch { + case !i0: + return struct { + io.ReadCloser + }{wrapper} + + case i0: + return struct { + io.ReadCloser + io.Writer + }{wrapper, wr} + default: + return struct { + io.ReadCloser + }{wrapper} + } +} + +func (trans *statTransport) createMeasures() { + trans.counters = make(map[string]metric.Int64Counter) + trans.valueRecorders = make(map[string]metric.Float64ValueRecorder) + + clientRequestCountCounter, err := trans.meter.NewInt64Counter(ClientRequestCount) + handleErr(err) + + requestBytesCounter, err := trans.meter.NewInt64Counter(ClientRequestContentLength) + handleErr(err) + + responseBytesCounter, err := trans.meter.NewInt64Counter(ClientResponseContentLength) + handleErr(err) + + serverLatencyMeasure, err := trans.meter.NewFloat64ValueRecorder(ClientRoundTripLatency) + handleErr(err) + + trans.counters[ClientRequestCount] = clientRequestCountCounter + trans.counters[ClientRequestContentLength] = requestBytesCounter + trans.counters[ClientResponseContentLength] = responseBytesCounter + trans.valueRecorders[ClientRoundTripLatency] = serverLatencyMeasure +} + +var _ io.ReadCloser = (*tracker)(nil) + +func (t *tracker) end() { + t.endOnce.Do(func() { + latencyMs := float64(time.Since(t.start)) / float64(time.Millisecond) + respSize := t.respSize + if t.respSize == 0 && t.respContentLength > 0 { + respSize = t.respContentLength + } + labels := label.NewSet( + append(t.labels.ToSlice(), StatusCode.Int(t.statusCode), + KeyClientStatus.Int(t.statusCode))..., + ) + ls := labels.ToSlice() + + t.counters[ClientResponseContentLength].Add(t.ctx, respSize, ls...) + t.valueRecorders[ClientRoundTripLatency].Record(t.ctx, latencyMs, ls...) + if t.reqSize >= 0 { + t.counters[ClientRequestContentLength].Add(t.ctx, respSize, ls...) + } + }) +} + +func (t *tracker) Read(b []byte) (int, error) { + n, err := t.body.Read(b) + t.respSize += int64(n) + switch err { + case nil: + return n, nil + case io.EOF: + t.end() + } + return n, err +} + +func (t *tracker) Close() error { + // Invoking endSpan on Close will help catch the cases + // in which a read returned a non-nil error, we set the + // span status but didn't end the span. + t.end() + return t.body.Close() +} diff --git a/instrumentation/net/http/otelhttp/transport.go b/instrumentation/net/http/otelhttp/transport.go index 04ec0d14978..032f5670bf8 100644 --- a/instrumentation/net/http/otelhttp/transport.go +++ b/instrumentation/net/http/otelhttp/transport.go @@ -42,9 +42,11 @@ var _ http.RoundTripper = &Transport{} // NewTransport wraps the provided http.RoundTripper with one that // starts a span and injects the span context into the outbound request headers. -func NewTransport(base http.RoundTripper, opts ...Option) *Transport { - t := Transport{ - rt: base, +func NewTransport(base http.RoundTripper, opts ...Option) http.RoundTripper { + t := statTransport{ + base: &Transport{ + rt: base, + }, } defaultOpts := []Option{ From 755ead15ded4669b3a1a9283f59bf95f18abf7a7 Mon Sep 17 00:00:00 2001 From: vchitai Date: Tue, 27 Oct 2020 17:15:20 +0700 Subject: [PATCH 02/15] add otelhttp client metrics --- go.mod | 12 ------- go.sum | 40 ------------------------ instrumentation/net/http/otelhttp/go.sum | 32 ------------------- 3 files changed, 84 deletions(-) delete mode 100644 go.mod delete mode 100644 go.sum delete mode 100644 instrumentation/net/http/otelhttp/go.sum diff --git a/go.mod b/go.mod deleted file mode 100644 index d0b9756a5da..00000000000 --- a/go.mod +++ /dev/null @@ -1,12 +0,0 @@ -module go.opentelemetry.io/contrib - -go 1.14 - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/kr/pretty v0.1.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0 // indirect - go.opentelemetry.io/otel v0.13.0 - go.opentelemetry.io/otel/exporters/stdout v0.13.0 // indirect - gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect -) diff --git a/go.sum b/go.sum deleted file mode 100644 index faaf907fc3c..00000000000 --- a/go.sum +++ /dev/null @@ -1,40 +0,0 @@ -github.com/DataDog/sketches-go v0.0.1 h1:RtG+76WKgZuz6FIaGsjoPePmadDBkuD/KC6+ZWu78b8= -github.com/DataDog/sketches-go v0.0.1/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60= -github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= -github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -go.opentelemetry.io v0.1.0 h1:EANZoRCOP+A3faIlw/iN6YEWoYb1vleZRKm1EvH8T48= -go.opentelemetry.io/contrib v0.13.0/go.mod h1:HzCu6ebm0ywgNxGaEfs3izyJOMP4rZnzxycyTgpI5Sg= -go.opentelemetry.io/contrib/instrumentation/net/http v0.11.0 h1:ufewgDRmtrrdDpPgm7b4/gr4RXLS7KhDttAhyThtYS4= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0 h1:dnZy1afzxEDrHybTYoJE1bQ3fphNwZF2ipSsynlITP4= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0/go.mod h1:SeQm4RTCcZ2/hlMSTuHb7nwIROe5odBtgfKx+7MMqEs= -go.opentelemetry.io/otel v0.13.0 h1:2isEnyzjjJZq6r2EKMsFj4TxiQiexsM04AVhwbR/oBA= -go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY= -go.opentelemetry.io/otel/exporters/stdout v0.13.0 h1:A+XiGIPQbGoJoBOJfKAKnZyiUSjSWvL3XWETUvtom5k= -go.opentelemetry.io/otel/exporters/stdout v0.13.0/go.mod h1:JJt8RpNY6K+ft9ir3iKpceCvT/rhzJXEExGrWFCbv1o= -go.opentelemetry.io/otel/sdk v0.13.0 h1:4VCfpKamZ8GtnepXxMRurSpHpMKkcxhtO33z1S4rGDQ= -go.opentelemetry.io/otel/sdk v0.13.0/go.mod h1:dKvLH8Uu8LcEPlSAUsfW7kMGaJBhk/1NYvpPZ6wIMbU= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/instrumentation/net/http/otelhttp/go.sum b/instrumentation/net/http/otelhttp/go.sum deleted file mode 100644 index 1242acf1d8a..00000000000 --- a/instrumentation/net/http/otelhttp/go.sum +++ /dev/null @@ -1,32 +0,0 @@ -github.com/DataDog/sketches-go v0.0.1/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60= -github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= -github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0/go.mod h1:SeQm4RTCcZ2/hlMSTuHb7nwIROe5odBtgfKx+7MMqEs= -go.opentelemetry.io/otel v0.13.0 h1:2isEnyzjjJZq6r2EKMsFj4TxiQiexsM04AVhwbR/oBA= -go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY= -go.opentelemetry.io/otel/exporters/stdout v0.13.0/go.mod h1:JJt8RpNY6K+ft9ir3iKpceCvT/rhzJXEExGrWFCbv1o= -go.opentelemetry.io/otel/sdk v0.13.0/go.mod h1:dKvLH8Uu8LcEPlSAUsfW7kMGaJBhk/1NYvpPZ6wIMbU= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 55844746df777e77c8b0bc175151d025f3c73fd3 Mon Sep 17 00:00:00 2001 From: vchitai Date: Tue, 27 Oct 2020 17:17:49 +0700 Subject: [PATCH 03/15] add otelhttp client metrics --- go.mod | 12 +++++++ go.sum | 40 ++++++++++++++++++++++++ instrumentation/net/http/otelhttp/go.sum | 32 +++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 go.mod create mode 100644 go.sum create mode 100644 instrumentation/net/http/otelhttp/go.sum diff --git a/go.mod b/go.mod new file mode 100644 index 00000000000..d0b9756a5da --- /dev/null +++ b/go.mod @@ -0,0 +1,12 @@ +module go.opentelemetry.io/contrib + +go 1.14 + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/kr/pretty v0.1.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0 // indirect + go.opentelemetry.io/otel v0.13.0 + go.opentelemetry.io/otel/exporters/stdout v0.13.0 // indirect + gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 00000000000..faaf907fc3c --- /dev/null +++ b/go.sum @@ -0,0 +1,40 @@ +github.com/DataDog/sketches-go v0.0.1 h1:RtG+76WKgZuz6FIaGsjoPePmadDBkuD/KC6+ZWu78b8= +github.com/DataDog/sketches-go v0.0.1/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60= +github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= +github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +go.opentelemetry.io v0.1.0 h1:EANZoRCOP+A3faIlw/iN6YEWoYb1vleZRKm1EvH8T48= +go.opentelemetry.io/contrib v0.13.0/go.mod h1:HzCu6ebm0ywgNxGaEfs3izyJOMP4rZnzxycyTgpI5Sg= +go.opentelemetry.io/contrib/instrumentation/net/http v0.11.0 h1:ufewgDRmtrrdDpPgm7b4/gr4RXLS7KhDttAhyThtYS4= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0 h1:dnZy1afzxEDrHybTYoJE1bQ3fphNwZF2ipSsynlITP4= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0/go.mod h1:SeQm4RTCcZ2/hlMSTuHb7nwIROe5odBtgfKx+7MMqEs= +go.opentelemetry.io/otel v0.13.0 h1:2isEnyzjjJZq6r2EKMsFj4TxiQiexsM04AVhwbR/oBA= +go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY= +go.opentelemetry.io/otel/exporters/stdout v0.13.0 h1:A+XiGIPQbGoJoBOJfKAKnZyiUSjSWvL3XWETUvtom5k= +go.opentelemetry.io/otel/exporters/stdout v0.13.0/go.mod h1:JJt8RpNY6K+ft9ir3iKpceCvT/rhzJXEExGrWFCbv1o= +go.opentelemetry.io/otel/sdk v0.13.0 h1:4VCfpKamZ8GtnepXxMRurSpHpMKkcxhtO33z1S4rGDQ= +go.opentelemetry.io/otel/sdk v0.13.0/go.mod h1:dKvLH8Uu8LcEPlSAUsfW7kMGaJBhk/1NYvpPZ6wIMbU= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/instrumentation/net/http/otelhttp/go.sum b/instrumentation/net/http/otelhttp/go.sum new file mode 100644 index 00000000000..1242acf1d8a --- /dev/null +++ b/instrumentation/net/http/otelhttp/go.sum @@ -0,0 +1,32 @@ +github.com/DataDog/sketches-go v0.0.1/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60= +github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= +github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0/go.mod h1:SeQm4RTCcZ2/hlMSTuHb7nwIROe5odBtgfKx+7MMqEs= +go.opentelemetry.io/otel v0.13.0 h1:2isEnyzjjJZq6r2EKMsFj4TxiQiexsM04AVhwbR/oBA= +go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY= +go.opentelemetry.io/otel/exporters/stdout v0.13.0/go.mod h1:JJt8RpNY6K+ft9ir3iKpceCvT/rhzJXEExGrWFCbv1o= +go.opentelemetry.io/otel/sdk v0.13.0/go.mod h1:dKvLH8Uu8LcEPlSAUsfW7kMGaJBhk/1NYvpPZ6wIMbU= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From d6a2098d3aa01a0cc1ab2bdc0b6b772437ef40bb Mon Sep 17 00:00:00 2001 From: vchitai Date: Tue, 27 Oct 2020 17:20:38 +0700 Subject: [PATCH 04/15] add otelhttp client metrics --- go.mod | 2 -- go.sum | 18 ++---------------- instrumentation/net/http/otelhttp/go.sum | 6 ------ 3 files changed, 2 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index d0b9756a5da..9b514238e15 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,6 @@ go 1.14 require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/kr/pretty v0.1.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0 // indirect go.opentelemetry.io/otel v0.13.0 - go.opentelemetry.io/otel/exporters/stdout v0.13.0 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect ) diff --git a/go.sum b/go.sum index faaf907fc3c..52c489516c8 100644 --- a/go.sum +++ b/go.sum @@ -1,14 +1,9 @@ -github.com/DataDog/sketches-go v0.0.1 h1:RtG+76WKgZuz6FIaGsjoPePmadDBkuD/KC6+ZWu78b8= -github.com/DataDog/sketches-go v0.0.1/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60= -github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= -github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -16,23 +11,14 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -go.opentelemetry.io v0.1.0 h1:EANZoRCOP+A3faIlw/iN6YEWoYb1vleZRKm1EvH8T48= -go.opentelemetry.io/contrib v0.13.0/go.mod h1:HzCu6ebm0ywgNxGaEfs3izyJOMP4rZnzxycyTgpI5Sg= -go.opentelemetry.io/contrib/instrumentation/net/http v0.11.0 h1:ufewgDRmtrrdDpPgm7b4/gr4RXLS7KhDttAhyThtYS4= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0 h1:dnZy1afzxEDrHybTYoJE1bQ3fphNwZF2ipSsynlITP4= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0/go.mod h1:SeQm4RTCcZ2/hlMSTuHb7nwIROe5odBtgfKx+7MMqEs= go.opentelemetry.io/otel v0.13.0 h1:2isEnyzjjJZq6r2EKMsFj4TxiQiexsM04AVhwbR/oBA= go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY= -go.opentelemetry.io/otel/exporters/stdout v0.13.0 h1:A+XiGIPQbGoJoBOJfKAKnZyiUSjSWvL3XWETUvtom5k= -go.opentelemetry.io/otel/exporters/stdout v0.13.0/go.mod h1:JJt8RpNY6K+ft9ir3iKpceCvT/rhzJXEExGrWFCbv1o= -go.opentelemetry.io/otel/sdk v0.13.0 h1:4VCfpKamZ8GtnepXxMRurSpHpMKkcxhtO33z1S4rGDQ= -go.opentelemetry.io/otel/sdk v0.13.0/go.mod h1:dKvLH8Uu8LcEPlSAUsfW7kMGaJBhk/1NYvpPZ6wIMbU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +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/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/instrumentation/net/http/otelhttp/go.sum b/instrumentation/net/http/otelhttp/go.sum index 1242acf1d8a..2d8036638ec 100644 --- a/instrumentation/net/http/otelhttp/go.sum +++ b/instrumentation/net/http/otelhttp/go.sum @@ -1,5 +1,3 @@ -github.com/DataDog/sketches-go v0.0.1/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60= -github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -7,7 +5,6 @@ github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8S github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -18,11 +15,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0/go.mod h1:SeQm4RTCcZ2/hlMSTuHb7nwIROe5odBtgfKx+7MMqEs= go.opentelemetry.io/otel v0.13.0 h1:2isEnyzjjJZq6r2EKMsFj4TxiQiexsM04AVhwbR/oBA= go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY= -go.opentelemetry.io/otel/exporters/stdout v0.13.0/go.mod h1:JJt8RpNY6K+ft9ir3iKpceCvT/rhzJXEExGrWFCbv1o= -go.opentelemetry.io/otel/sdk v0.13.0/go.mod h1:dKvLH8Uu8LcEPlSAUsfW7kMGaJBhk/1NYvpPZ6wIMbU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 5f70e63c753e098cc92ba976a79e160639b37ceb Mon Sep 17 00:00:00 2001 From: vchitai Date: Wed, 28 Oct 2020 08:15:53 +0700 Subject: [PATCH 05/15] update stats labels --- instrumentation/net/http/otelhttp/stats.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/instrumentation/net/http/otelhttp/stats.go b/instrumentation/net/http/otelhttp/stats.go index 4d99e921389..fc700d81ea0 100644 --- a/instrumentation/net/http/otelhttp/stats.go +++ b/instrumentation/net/http/otelhttp/stats.go @@ -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 } @@ -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 @@ -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), @@ -96,6 +95,7 @@ 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. @@ -103,7 +103,7 @@ func (trans *statTransport) RoundTrip(req *http.Request) (*http.Response, error) } 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) From ebcde2ad8f2a056485210afe7e668f3174fefba5 Mon Sep 17 00:00:00 2001 From: vchitai Date: Fri, 30 Oct 2020 09:31:34 +0700 Subject: [PATCH 06/15] update license headers --- instrumentation/net/http/otelhttp/stats.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/instrumentation/net/http/otelhttp/stats.go b/instrumentation/net/http/otelhttp/stats.go index fc700d81ea0..cdf64eaf689 100644 --- a/instrumentation/net/http/otelhttp/stats.go +++ b/instrumentation/net/http/otelhttp/stats.go @@ -1,3 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package otelhttp import ( From 6ef90647ed893efb5ed6c6245aabd2387e28c594 Mon Sep 17 00:00:00 2001 From: vchitai Date: Mon, 2 Nov 2020 16:16:20 +0700 Subject: [PATCH 07/15] update metrics based on otel new definition --- instrumentation/net/http/otelhttp/common.go | 5 +- instrumentation/net/http/otelhttp/stats.go | 90 ++++++++------------- 2 files changed, 34 insertions(+), 61 deletions(-) diff --git a/instrumentation/net/http/otelhttp/common.go b/instrumentation/net/http/otelhttp/common.go index 08bb13a69e8..c601c31781c 100644 --- a/instrumentation/net/http/otelhttp/common.go +++ b/instrumentation/net/http/otelhttp/common.go @@ -38,10 +38,7 @@ const ( // Client HTTP metrics const ( - ClientRequestCount = "http.client.request_count" // Incoming request count total - ClientRequestContentLength = "http.client.request_content_length" // Incoming request bytes total - ClientResponseContentLength = "http.client.response_content_length" // Incoming response bytes total - ClientRoundTripLatency = "http.client.roundtrip_latency" // Incoming end to end duration, microseconds + ClientRequestDuration = "http.client.duration" // Incoming end to end duration, microseconds ) // Filter is a predicate used to determine whether a given http.request should diff --git a/instrumentation/net/http/otelhttp/stats.go b/instrumentation/net/http/otelhttp/stats.go index cdf64eaf689..ab1bcbd40cc 100644 --- a/instrumentation/net/http/otelhttp/stats.go +++ b/instrumentation/net/http/otelhttp/stats.go @@ -16,6 +16,7 @@ package otelhttp import ( "context" + "go.opentelemetry.io/otel/unit" "io" "net/http" "sync" @@ -28,22 +29,17 @@ import ( type statTransport struct { meter metric.Meter base *Transport - counters map[string]metric.Int64Counter valueRecorders map[string]metric.Float64ValueRecorder } type tracker struct { - ctx context.Context - respSize int64 - respContentLength int64 - reqSize int64 - start time.Time - body io.ReadCloser - statusCode int - endOnce sync.Once - labels *label.Set - - counters map[string]metric.Int64Counter + ctx context.Context + start time.Time + body io.ReadCloser + statusCode int + endOnce sync.Once + labels *label.Set + valueRecorders map[string]metric.Float64ValueRecorder } @@ -51,6 +47,8 @@ type tracker struct { // and Method are applied to all measures. StatusCode is not applied to // ClientRequestCount or ServerRequestCount, since it is recorded before the status is known. var ( + // Method is the HTTP method of the request, capitalized (GET, POST, etc.). + Method = label.Key("http.method") // Host is the value of the HTTP Host header. // // The value of this tag can be controlled by the HTTP client, so you need @@ -58,6 +56,9 @@ var ( // metrics backend if you use this tag in views. Host = label.Key("http.host") + // Scheme is the URI scheme identifying the used protocol: "http" or "https" + Scheme = label.Key("http.scheme") + // StatusCode is the numeric HTTP response status code, // or "error" if a transport error occurred and no status code was read. StatusCode = label.Key("http.status") @@ -68,9 +69,6 @@ var ( // to watch out for potentially generating high-cardinality labels in your // metrics backend if you use this tag in views. Path = label.Key("http.path") - - // Method is the HTTP method of the request, capitalized (GET, POST, etc.). - Method = label.Key("http.method") ) // Client tag keys. @@ -83,6 +81,8 @@ var ( KeyClientStatus = label.Key("http_client_status") // KeyClientHost is the value of the request Host header. KeyClientHost = label.Key("http_client_host") + // KeyClientScheme is the URI scheme identifying the used protocol: "http" or "https" + KeyClientScheme = label.Key("http_client_host") ) func (trans *statTransport) applyConfig(c *config) { @@ -95,41 +95,33 @@ 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) { labels := label.NewSet( - KeyClientHost.String(req.Host), + // conform open-telemetry label definition + Method.String(req.Method), Host.String(req.Host), - KeyClientPath.String(req.URL.Path), + Scheme.String(req.URL.Scheme), Path.String(req.URL.Path), + // for prometheus KeyClientMethod.String(req.Method), - Method.String(req.Method), + KeyClientHost.String(req.Host), + KeyClientScheme.String(req.URL.Scheme), + KeyClientPath.String(req.URL.Path), ) ctx := req.Context() track := &tracker{ start: time.Now(), 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, labels.ToSlice()...) // Perform request. resp, err := trans.base.RoundTrip(req) - if err != nil { track.statusCode = http.StatusInternalServerError track.end() } else { track.statusCode = resp.StatusCode - if req.Method != "HEAD" { - track.respContentLength = resp.ContentLength - } if resp.Body == nil { track.end() } else { @@ -164,25 +156,16 @@ func wrappedBodyIO(wrapper io.ReadCloser, body io.ReadCloser) io.ReadCloser { } func (trans *statTransport) createMeasures() { - trans.counters = make(map[string]metric.Int64Counter) trans.valueRecorders = make(map[string]metric.Float64ValueRecorder) - clientRequestCountCounter, err := trans.meter.NewInt64Counter(ClientRequestCount) - handleErr(err) - - requestBytesCounter, err := trans.meter.NewInt64Counter(ClientRequestContentLength) - handleErr(err) - - responseBytesCounter, err := trans.meter.NewInt64Counter(ClientResponseContentLength) - handleErr(err) - - serverLatencyMeasure, err := trans.meter.NewFloat64ValueRecorder(ClientRoundTripLatency) + requestDurationMeasure, err := trans.meter.NewFloat64ValueRecorder( + ClientRequestDuration, + metric.WithDescription("measure the duration of the outbound HTTP request"), + metric.WithUnit(unit.Milliseconds), + ) handleErr(err) - trans.counters[ClientRequestCount] = clientRequestCountCounter - trans.counters[ClientRequestContentLength] = requestBytesCounter - trans.counters[ClientResponseContentLength] = responseBytesCounter - trans.valueRecorders[ClientRoundTripLatency] = serverLatencyMeasure + trans.valueRecorders[ClientRequestDuration] = requestDurationMeasure } var _ io.ReadCloser = (*tracker)(nil) @@ -190,27 +173,20 @@ var _ io.ReadCloser = (*tracker)(nil) func (t *tracker) end() { t.endOnce.Do(func() { latencyMs := float64(time.Since(t.start)) / float64(time.Millisecond) - respSize := t.respSize - if t.respSize == 0 && t.respContentLength > 0 { - respSize = t.respContentLength - } labels := label.NewSet( - append(t.labels.ToSlice(), StatusCode.Int(t.statusCode), - KeyClientStatus.Int(t.statusCode))..., + append(t.labels.ToSlice(), + StatusCode.Int(t.statusCode), + KeyClientStatus.Int(t.statusCode), + )..., ) ls := labels.ToSlice() - t.counters[ClientResponseContentLength].Add(t.ctx, respSize, ls...) - t.valueRecorders[ClientRoundTripLatency].Record(t.ctx, latencyMs, ls...) - if t.reqSize >= 0 { - t.counters[ClientRequestContentLength].Add(t.ctx, respSize, ls...) - } + t.valueRecorders[ClientRequestDuration].Record(t.ctx, latencyMs, ls...) }) } func (t *tracker) Read(b []byte) (int, error) { n, err := t.body.Read(b) - t.respSize += int64(n) switch err { case nil: return n, nil From 7bca3f12d47898f9a16b43b195b463b2fb641dd3 Mon Sep 17 00:00:00 2001 From: vchitai Date: Mon, 2 Nov 2020 16:33:08 +0700 Subject: [PATCH 08/15] update metrics based on otel new definition --- instrumentation/net/http/otelhttp/stats.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/instrumentation/net/http/otelhttp/stats.go b/instrumentation/net/http/otelhttp/stats.go index ab1bcbd40cc..1048db1bb88 100644 --- a/instrumentation/net/http/otelhttp/stats.go +++ b/instrumentation/net/http/otelhttp/stats.go @@ -16,12 +16,13 @@ package otelhttp import ( "context" - "go.opentelemetry.io/otel/unit" "io" "net/http" "sync" "time" + "go.opentelemetry.io/otel/unit" + "go.opentelemetry.io/otel/api/metric" "go.opentelemetry.io/otel/label" ) From 281e8f0240b6c4531f8e48b6cbdb6c7510e859e9 Mon Sep 17 00:00:00 2001 From: vchitai Date: Fri, 13 Nov 2020 08:25:08 +0700 Subject: [PATCH 09/15] update otel metrics --- instrumentation/net/http/otelhttp/common.go | 5 +- instrumentation/net/http/otelhttp/metrics.go | 142 ++++++++++++ instrumentation/net/http/otelhttp/stats.go | 206 ------------------ .../net/http/otelhttp/transport.go | 2 +- 4 files changed, 146 insertions(+), 209 deletions(-) create mode 100644 instrumentation/net/http/otelhttp/metrics.go delete mode 100644 instrumentation/net/http/otelhttp/stats.go diff --git a/instrumentation/net/http/otelhttp/common.go b/instrumentation/net/http/otelhttp/common.go index c601c31781c..8469bd491cc 100644 --- a/instrumentation/net/http/otelhttp/common.go +++ b/instrumentation/net/http/otelhttp/common.go @@ -36,9 +36,10 @@ const ( ServerLatency = "http.server.duration" // Incoming end to end duration, microseconds ) -// Client HTTP metrics +// Client HTTP metric instrument names const ( - ClientRequestDuration = "http.client.duration" // Incoming end to end duration, microseconds + // clientRequestDuration is the name of the instrument that measures the duration of outbound HTTP requests. + clientRequestDuration = "http.client.duration" ) // Filter is a predicate used to determine whether a given http.request should diff --git a/instrumentation/net/http/otelhttp/metrics.go b/instrumentation/net/http/otelhttp/metrics.go new file mode 100644 index 00000000000..4ca34b5592b --- /dev/null +++ b/instrumentation/net/http/otelhttp/metrics.go @@ -0,0 +1,142 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package otelhttp + +import ( + "context" + "go.opentelemetry.io/otel/semconv" + "io" + "net/http" + "sync" + "time" + + "go.opentelemetry.io/otel/unit" + + "go.opentelemetry.io/otel/api/metric" + "go.opentelemetry.io/otel/label" +) + +type metricsTransport struct { + meter metric.Meter + base *Transport + clientDurationRecorder metric.Float64ValueRecorder +} + +type tracker struct { + ctx context.Context + start time.Time + body io.ReadCloser + endOnce sync.Once + labels []label.KeyValue + + // recorders + clientDurationRecorder metric.Float64ValueRecorder +} + +func (trans *metricsTransport) applyConfig(c *config) { + trans.base.applyConfig(c) + + trans.meter = c.Meter + trans.createMeasures() +} + +// RoundTrip implements http.RoundTripper, delegating to Base and recording stats for the request. +func (trans *metricsTransport) RoundTrip(req *http.Request) (*http.Response, error) { + labels := semconv.HTTPClientAttributesFromHTTPRequest(req) + + ctx := req.Context() + tracker := &tracker{ + start: time.Now(), + ctx: ctx, + clientDurationRecorder: trans.clientDurationRecorder, + } + + // Perform request.; + resp, err := trans.base.RoundTrip(req) + if err != nil { + tracker.labels = append(labels, semconv.HTTPAttributesFromHTTPStatusCode(http.StatusInternalServerError)...) + tracker.end() + } else { + tracker.labels = append(labels, semconv.HTTPAttributesFromHTTPStatusCode(http.StatusInternalServerError)...) + if resp.Body == nil { + tracker.end() + } else { + tracker.body = resp.Body + resp.Body = wrappedBodyIO(tracker, resp.Body) + } + } + return resp, err +} + +// wrappedBodyIO returns a wrapped version of the original +// Body and only implements the same combination of additional +// interfaces as the original. +func wrappedBodyIO(wrapper io.ReadCloser, body io.ReadCloser) io.ReadCloser { + wr, i0 := body.(io.Writer) + switch { + case !i0: + return struct { + io.ReadCloser + }{wrapper} + + case i0: + return struct { + io.ReadCloser + io.Writer + }{wrapper, wr} + default: + return struct { + io.ReadCloser + }{wrapper} + } +} + +func (trans *metricsTransport) createMeasures() { + var err error + trans.clientDurationRecorder, err = trans.meter.NewFloat64ValueRecorder( + clientRequestDuration, + metric.WithDescription("measure the duration of the outbound HTTP request"), + metric.WithUnit(unit.Milliseconds), + ) + handleErr(err) +} + +var _ io.ReadCloser = (*tracker)(nil) + +func (tracker *tracker) end() { + tracker.endOnce.Do(func() { + latencyMs := float64(time.Since(tracker.start)) / float64(time.Millisecond) + tracker.clientDurationRecorder.Record(tracker.ctx, latencyMs, tracker.labels...) + }) +} + +func (tracker *tracker) Read(b []byte) (int, error) { + n, err := tracker.body.Read(b) + switch err { + case nil: + return n, nil + case io.EOF: + tracker.end() + } + return n, err +} + +func (tracker *tracker) Close() error { + // Invoking endSpan on Close will help catch the cases + // in which a read returned a non-nil error, we set the + // span status but didn't end the span. + tracker.end() + return tracker.body.Close() +} diff --git a/instrumentation/net/http/otelhttp/stats.go b/instrumentation/net/http/otelhttp/stats.go deleted file mode 100644 index 1048db1bb88..00000000000 --- a/instrumentation/net/http/otelhttp/stats.go +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package otelhttp - -import ( - "context" - "io" - "net/http" - "sync" - "time" - - "go.opentelemetry.io/otel/unit" - - "go.opentelemetry.io/otel/api/metric" - "go.opentelemetry.io/otel/label" -) - -type statTransport struct { - meter metric.Meter - base *Transport - valueRecorders map[string]metric.Float64ValueRecorder -} - -type tracker struct { - ctx context.Context - start time.Time - body io.ReadCloser - statusCode int - endOnce sync.Once - labels *label.Set - - valueRecorders map[string]metric.Float64ValueRecorder -} - -// The following tags are applied to stats recorded by this package. Host, Path -// and Method are applied to all measures. StatusCode is not applied to -// ClientRequestCount or ServerRequestCount, since it is recorded before the status is known. -var ( - // Method is the HTTP method of the request, capitalized (GET, POST, etc.). - Method = label.Key("http.method") - // Host is the value of the HTTP Host header. - // - // The value of this tag can be controlled by the HTTP client, so you need - // to watch out for potentially generating high-cardinality labels in your - // metrics backend if you use this tag in views. - Host = label.Key("http.host") - - // Scheme is the URI scheme identifying the used protocol: "http" or "https" - Scheme = label.Key("http.scheme") - - // StatusCode is the numeric HTTP response status code, - // or "error" if a transport error occurred and no status code was read. - StatusCode = label.Key("http.status") - - // Path is the URL path (not including query string) in the request. - // - // The value of this tag can be controlled by the HTTP client, so you need - // to watch out for potentially generating high-cardinality labels in your - // metrics backend if you use this tag in views. - Path = label.Key("http.path") -) - -// Client tag keys. -var ( - // KeyClientMethod is the HTTP method, capitalized (i.e. GET, POST, PUT, DELETE, etc.). - KeyClientMethod = label.Key("http_client_method") - // KeyClientPath is the URL path (not including query string). - KeyClientPath = label.Key("http_client_path") - // KeyClientStatus is the HTTP status code as an integer (e.g. 200, 404, 500.), or "error" if no response status line was received. - KeyClientStatus = label.Key("http_client_status") - // KeyClientHost is the value of the request Host header. - KeyClientHost = label.Key("http_client_host") - // KeyClientScheme is the URI scheme identifying the used protocol: "http" or "https" - KeyClientScheme = label.Key("http_client_host") -) - -func (trans *statTransport) applyConfig(c *config) { - trans.base.applyConfig(c) - - trans.meter = c.Meter - trans.createMeasures() -} - -// RoundTrip implements http.RoundTripper, delegating to Base and recording stats for the request. -func (trans *statTransport) RoundTrip(req *http.Request) (*http.Response, error) { - labels := label.NewSet( - // conform open-telemetry label definition - Method.String(req.Method), - Host.String(req.Host), - Scheme.String(req.URL.Scheme), - Path.String(req.URL.Path), - // for prometheus - KeyClientMethod.String(req.Method), - KeyClientHost.String(req.Host), - KeyClientScheme.String(req.URL.Scheme), - KeyClientPath.String(req.URL.Path), - ) - - ctx := req.Context() - track := &tracker{ - start: time.Now(), - ctx: ctx, - valueRecorders: trans.valueRecorders, - labels: &labels, - } - - // Perform request. - resp, err := trans.base.RoundTrip(req) - if err != nil { - track.statusCode = http.StatusInternalServerError - track.end() - } else { - track.statusCode = resp.StatusCode - if resp.Body == nil { - track.end() - } else { - track.body = resp.Body - resp.Body = wrappedBodyIO(track, resp.Body) - } - } - return resp, err -} - -// wrappedBodyIO returns a wrapped version of the original -// Body and only implements the same combination of additional -// interfaces as the original. -func wrappedBodyIO(wrapper io.ReadCloser, body io.ReadCloser) io.ReadCloser { - wr, i0 := body.(io.Writer) - switch { - case !i0: - return struct { - io.ReadCloser - }{wrapper} - - case i0: - return struct { - io.ReadCloser - io.Writer - }{wrapper, wr} - default: - return struct { - io.ReadCloser - }{wrapper} - } -} - -func (trans *statTransport) createMeasures() { - trans.valueRecorders = make(map[string]metric.Float64ValueRecorder) - - requestDurationMeasure, err := trans.meter.NewFloat64ValueRecorder( - ClientRequestDuration, - metric.WithDescription("measure the duration of the outbound HTTP request"), - metric.WithUnit(unit.Milliseconds), - ) - handleErr(err) - - trans.valueRecorders[ClientRequestDuration] = requestDurationMeasure -} - -var _ io.ReadCloser = (*tracker)(nil) - -func (t *tracker) end() { - t.endOnce.Do(func() { - latencyMs := float64(time.Since(t.start)) / float64(time.Millisecond) - labels := label.NewSet( - append(t.labels.ToSlice(), - StatusCode.Int(t.statusCode), - KeyClientStatus.Int(t.statusCode), - )..., - ) - ls := labels.ToSlice() - - t.valueRecorders[ClientRequestDuration].Record(t.ctx, latencyMs, ls...) - }) -} - -func (t *tracker) Read(b []byte) (int, error) { - n, err := t.body.Read(b) - switch err { - case nil: - return n, nil - case io.EOF: - t.end() - } - return n, err -} - -func (t *tracker) Close() error { - // Invoking endSpan on Close will help catch the cases - // in which a read returned a non-nil error, we set the - // span status but didn't end the span. - t.end() - return t.body.Close() -} diff --git a/instrumentation/net/http/otelhttp/transport.go b/instrumentation/net/http/otelhttp/transport.go index 032f5670bf8..4862469269a 100644 --- a/instrumentation/net/http/otelhttp/transport.go +++ b/instrumentation/net/http/otelhttp/transport.go @@ -43,7 +43,7 @@ var _ http.RoundTripper = &Transport{} // NewTransport wraps the provided http.RoundTripper with one that // starts a span and injects the span context into the outbound request headers. func NewTransport(base http.RoundTripper, opts ...Option) http.RoundTripper { - t := statTransport{ + t := metricsTransport{ base: &Transport{ rt: base, }, From 44f984fa5b7f9344b3a8703d7af95a94a5d1b16d Mon Sep 17 00:00:00 2001 From: vchitai Date: Fri, 13 Nov 2020 08:35:04 +0700 Subject: [PATCH 10/15] update otel metrics --- go.sum | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/go.sum b/go.sum index 52c489516c8..d5b2bf2d17c 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,3 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -11,6 +10,7 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -18,9 +18,8 @@ go.opentelemetry.io/otel v0.13.0 h1:2isEnyzjjJZq6r2EKMsFj4TxiQiexsM04AVhwbR/oBA= go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -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/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= \ No newline at end of file From 3e3a025e8d91c737f762571e3512c323d147edb1 Mon Sep 17 00:00:00 2001 From: vchitai Date: Fri, 13 Nov 2020 08:40:23 +0700 Subject: [PATCH 11/15] update otel metrics --- instrumentation/net/http/otelhttp/metrics.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/instrumentation/net/http/otelhttp/metrics.go b/instrumentation/net/http/otelhttp/metrics.go index 4ca34b5592b..b0ea33c85b9 100644 --- a/instrumentation/net/http/otelhttp/metrics.go +++ b/instrumentation/net/http/otelhttp/metrics.go @@ -16,12 +16,13 @@ package otelhttp import ( "context" - "go.opentelemetry.io/otel/semconv" "io" "net/http" "sync" "time" + "go.opentelemetry.io/otel/semconv" + "go.opentelemetry.io/otel/unit" "go.opentelemetry.io/otel/api/metric" @@ -35,11 +36,11 @@ type metricsTransport struct { } type tracker struct { - ctx context.Context - start time.Time - body io.ReadCloser - endOnce sync.Once - labels []label.KeyValue + ctx context.Context + start time.Time + body io.ReadCloser + endOnce sync.Once + labels []label.KeyValue // recorders clientDurationRecorder metric.Float64ValueRecorder From b166165bf197a101eea8e989b330277cae2b03f0 Mon Sep 17 00:00:00 2001 From: vchitai Date: Fri, 13 Nov 2020 10:34:41 +0700 Subject: [PATCH 12/15] update otel metrics --- go.sum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.sum b/go.sum index d5b2bf2d17c..f6d2c5e2280 100644 --- a/go.sum +++ b/go.sum @@ -22,4 +22,4 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= \ No newline at end of file +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From e13ab2242943e6d73efabfb7f2a13042fb840ba3 Mon Sep 17 00:00:00 2001 From: Chi-Tai Vong Date: Fri, 20 Nov 2020 10:12:06 +0700 Subject: [PATCH 13/15] Update instrumentation/net/http/otelhttp/metrics.go Co-authored-by: Tyler Yahn --- instrumentation/net/http/otelhttp/metrics.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/net/http/otelhttp/metrics.go b/instrumentation/net/http/otelhttp/metrics.go index b0ea33c85b9..25641c16887 100644 --- a/instrumentation/net/http/otelhttp/metrics.go +++ b/instrumentation/net/http/otelhttp/metrics.go @@ -108,7 +108,7 @@ func (trans *metricsTransport) createMeasures() { var err error trans.clientDurationRecorder, err = trans.meter.NewFloat64ValueRecorder( clientRequestDuration, - metric.WithDescription("measure the duration of the outbound HTTP request"), + metric.WithDescription("measures the duration of the outbound HTTP request"), metric.WithUnit(unit.Milliseconds), ) handleErr(err) From be431b8b36ca756c7b96bfeff3939946f0f339ca Mon Sep 17 00:00:00 2001 From: Chi-Tai Vong Date: Fri, 20 Nov 2020 10:12:18 +0700 Subject: [PATCH 14/15] Update instrumentation/net/http/otelhttp/common.go Co-authored-by: Tyler Yahn --- instrumentation/net/http/otelhttp/common.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/net/http/otelhttp/common.go b/instrumentation/net/http/otelhttp/common.go index 8469bd491cc..23cab5b908e 100644 --- a/instrumentation/net/http/otelhttp/common.go +++ b/instrumentation/net/http/otelhttp/common.go @@ -36,7 +36,7 @@ const ( ServerLatency = "http.server.duration" // Incoming end to end duration, microseconds ) -// Client HTTP metric instrument names +// Client HTTP metric instrument names. const ( // clientRequestDuration is the name of the instrument that measures the duration of outbound HTTP requests. clientRequestDuration = "http.client.duration" From 439e653ca727ab6d8b4479e064f00793692874e1 Mon Sep 17 00:00:00 2001 From: vchitai Date: Fri, 20 Nov 2020 10:46:46 +0700 Subject: [PATCH 15/15] update metrics --- instrumentation/net/http/otelhttp/metrics.go | 29 +++++-------------- .../net/http/otelhttp/transport.go | 2 +- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/instrumentation/net/http/otelhttp/metrics.go b/instrumentation/net/http/otelhttp/metrics.go index 25641c16887..afbda0b784b 100644 --- a/instrumentation/net/http/otelhttp/metrics.go +++ b/instrumentation/net/http/otelhttp/metrics.go @@ -29,7 +29,7 @@ import ( "go.opentelemetry.io/otel/label" ) -type metricsTransport struct { +type instrumentedTransport struct { meter metric.Meter base *Transport clientDurationRecorder metric.Float64ValueRecorder @@ -42,11 +42,10 @@ type tracker struct { endOnce sync.Once labels []label.KeyValue - // recorders clientDurationRecorder metric.Float64ValueRecorder } -func (trans *metricsTransport) applyConfig(c *config) { +func (trans *instrumentedTransport) applyConfig(c *config) { trans.base.applyConfig(c) trans.meter = c.Meter @@ -54,7 +53,7 @@ func (trans *metricsTransport) applyConfig(c *config) { } // RoundTrip implements http.RoundTripper, delegating to Base and recording stats for the request. -func (trans *metricsTransport) RoundTrip(req *http.Request) (*http.Response, error) { +func (trans *instrumentedTransport) RoundTrip(req *http.Request) (*http.Response, error) { labels := semconv.HTTPClientAttributesFromHTTPRequest(req) ctx := req.Context() @@ -64,13 +63,12 @@ func (trans *metricsTransport) RoundTrip(req *http.Request) (*http.Response, err clientDurationRecorder: trans.clientDurationRecorder, } - // Perform request.; resp, err := trans.base.RoundTrip(req) if err != nil { tracker.labels = append(labels, semconv.HTTPAttributesFromHTTPStatusCode(http.StatusInternalServerError)...) tracker.end() } else { - tracker.labels = append(labels, semconv.HTTPAttributesFromHTTPStatusCode(http.StatusInternalServerError)...) + tracker.labels = append(labels, semconv.HTTPAttributesFromHTTPStatusCode(resp.StatusCode)...) if resp.Body == nil { tracker.end() } else { @@ -85,26 +83,16 @@ func (trans *metricsTransport) RoundTrip(req *http.Request) (*http.Response, err // Body and only implements the same combination of additional // interfaces as the original. func wrappedBodyIO(wrapper io.ReadCloser, body io.ReadCloser) io.ReadCloser { - wr, i0 := body.(io.Writer) - switch { - case !i0: - return struct { - io.ReadCloser - }{wrapper} - - case i0: + if wr, ok := body.(io.Writer); ok { return struct { io.ReadCloser io.Writer }{wrapper, wr} - default: - return struct { - io.ReadCloser - }{wrapper} } + return wrapper } -func (trans *metricsTransport) createMeasures() { +func (trans *instrumentedTransport) createMeasures() { var err error trans.clientDurationRecorder, err = trans.meter.NewFloat64ValueRecorder( clientRequestDuration, @@ -135,9 +123,6 @@ func (tracker *tracker) Read(b []byte) (int, error) { } func (tracker *tracker) Close() error { - // Invoking endSpan on Close will help catch the cases - // in which a read returned a non-nil error, we set the - // span status but didn't end the span. tracker.end() return tracker.body.Close() } diff --git a/instrumentation/net/http/otelhttp/transport.go b/instrumentation/net/http/otelhttp/transport.go index 4862469269a..d8ea4d232c4 100644 --- a/instrumentation/net/http/otelhttp/transport.go +++ b/instrumentation/net/http/otelhttp/transport.go @@ -43,7 +43,7 @@ var _ http.RoundTripper = &Transport{} // NewTransport wraps the provided http.RoundTripper with one that // starts a span and injects the span context into the outbound request headers. func NewTransport(base http.RoundTripper, opts ...Option) http.RoundTripper { - t := metricsTransport{ + t := instrumentedTransport{ base: &Transport{ rt: base, },