diff --git a/go.mod b/go.mod index f93a0583a6..7e70f07ee2 100644 --- a/go.mod +++ b/go.mod @@ -77,7 +77,7 @@ require ( github.com/pkg/xattr v0.4.9 github.com/prometheus/client_golang v1.19.0 github.com/r3labs/sse/v2 v2.10.0 - github.com/riandyrn/otelchi v0.7.0 + github.com/riandyrn/otelchi v0.8.0 github.com/rogpeppe/go-internal v1.12.0 github.com/rs/zerolog v1.32.0 github.com/shamaton/msgpack/v2 v2.2.0 diff --git a/go.sum b/go.sum index 5865a9f15f..981016f5c6 100644 --- a/go.sum +++ b/go.sum @@ -1908,8 +1908,8 @@ github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/riandyrn/otelchi v0.7.0 h1:Zr/WxFnQnVgfAgJuFUqKzepryVIDBq+F+Pv/rA7qL28= -github.com/riandyrn/otelchi v0.7.0/go.mod h1:ICb2XuXIInKsznOt2SJKcKnG1++LadHzVGoZHP8MXPo= +github.com/riandyrn/otelchi v0.8.0 h1:q60HKpwt1MmGjOWgM7m5gGyXYAY3DfTSdfBdBt6ICV4= +github.com/riandyrn/otelchi v0.8.0/go.mod h1:ErTae2TG7lrOtEPFsd5/hYLOHJpkk0NNyMaeTMWxl0U= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.2 h1:YwD0ulJSJytLpiaWua0sBDusfsCZohxjxzVTYjwxfV8= github.com/rivo/uniseg v0.4.2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= diff --git a/vendor/github.com/riandyrn/otelchi/CHANGELOG.md b/vendor/github.com/riandyrn/otelchi/CHANGELOG.md index 746c45a85a..2d5aa47186 100644 --- a/vendor/github.com/riandyrn/otelchi/CHANGELOG.md +++ b/vendor/github.com/riandyrn/otelchi/CHANGELOG.md @@ -8,6 +8,31 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +## [0.8.0] - 2024-04-29 + +### ⚠️ Notice ⚠️ + +This release is the last to support Go `1.19`. The next release will require at least Go `1.21`. + +### Added + +- Add `WithPublicEndpoint` & `WithPublicEndpointFn` options. ([#43]) + +### Changed + +- Upgrade to `v1.24.0` of `go.opentelemetry.io/otel`. ([#41]) +- Upgrade to `v1.20.0` of `go.opentelemetry.io/otel/semconv`. ([#41]) +- Adjust Go version for both `examples/basic` & `examples/multi-services` to `1.19` & `go.opentelemetry.io/otel` to `v1.24.0`. ([#41]) +- Update otelhttp version to `0.49.0` since it is the version that uses otel `1.24.0` internally, check [here](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/v1.24.0/instrumentation/net/http/otelhttp/go.mod#L8) for details. ([#42]) +- Set the go versions in compatibility-test.yml to 1.19, 1.20, & 1.21. ([#42]) +- Set the sampling strategy to always sample in test cases to avoid random error. ([#42]) +- Use `otlptrace` exporter instead of `jaeger` exporter in `examples/multi-services`. ([#42]) + +### Removed + +- Remove the deprecated `jaeger` exporter from `examples/multi-services` & use `otlptrace` exporter instead. ([#42]) +- Drop support for Go `<1.19`. ([#41]) + ## [0.7.0] - 2024-04-22 ### ⚠️ Notice ⚠️ @@ -16,15 +41,15 @@ This release is the last to support Go `1.18`. The next release will require at ### Changed -- Upgrade to `v1.14.0` of `go.opentelemetry.io/otel`. (#38) -- Upgrade to `v1.17.0` of `go.opentelemetry.io/otel/semconv`. (#38) -- Adjust Go version for both `examples/basic` & `examples/multi-services` to `1.18` & `go.opentelemetry.io/otel` to `v1.14.0`. (#38) -- Change `http.server_name` attributes to `net.host.name`, this is because semconv is removing this attribute for http. (#38) +- Upgrade to `v1.14.0` of `go.opentelemetry.io/otel`. ([#38]) +- Upgrade to `v1.17.0` of `go.opentelemetry.io/otel/semconv`. ([#38]) +- Adjust Go version for both `examples/basic` & `examples/multi-services` to `1.18` & `go.opentelemetry.io/otel` to `v1.14.0`. ([#38]) +- Change `http.server_name` attributes to `net.host.name`, this is because semconv is removing this attribute for http. ([#38]) ### Removed -- Remove `http.target` attribute on implementation & tests based on [this comment](https://github.com/open-telemetry/opentelemetry-go/blob/v1.17.0/semconv/internal/v2/http.go#L160-L165). (#39) -- Drop support for Go `<1.18`. (#38) +- Remove `http.target` attribute on implementation & tests based on [this comment](https://github.com/open-telemetry/opentelemetry-go/blob/v1.17.0/semconv/internal/v2/http.go#L160-L165). ([#39]) +- Drop support for Go `<1.18`. ([#38]) ## [0.6.0] - 2024-04-02 @@ -34,33 +59,33 @@ This release is the last to support Go `1.15`. The next release will require at ### Added -- Add `WithTraceIDResponseHeader` option to enable adding trace id into response header. (#36) -- Add multiple go versions test scripts for local and CI pipeline. (#29) -- Add compatibility testing for `ubuntu`, `macos` and `windows`. (#32) -- Add repo essentials docs. (#33) +- Add `WithTraceIDResponseHeader` option to enable adding trace id into response header. ([#36]) +- Add multiple go versions test scripts for local and CI pipeline. ([#29]) +- Add compatibility testing for `ubuntu`, `macos` and `windows`. ([#32]) +- Add repo essentials docs. ([#33]) ### Changed -- Upgrade to `v5.0.12` of `go-chi/chi`. (#29) -- Upgrade to `v1.10.0` of `go.opentelemetry.io/otel`. (#29) -- Upgrade to `v1.12.0` of `go.opentelemetry.io/otel/semconv`. (#29) -- Set the required go version for both `examples/basic` & `examples/multi-services` to `1.15`, `go-chi/chi` to `v5.0.12`, & `go.opentelemetry.io/otel` to `v1.10.0` (#35) +- Upgrade to `v5.0.12` of `go-chi/chi`. ([#29]) +- Upgrade to `v1.10.0` of `go.opentelemetry.io/otel`. ([#29]) +- Upgrade to `v1.12.0` of `go.opentelemetry.io/otel/semconv`. ([#29]) +- Set the required go version for both `examples/basic` & `examples/multi-services` to `1.15`, `go-chi/chi` to `v5.0.12`, & `go.opentelemetry.io/otel` to `v1.10.0` ([#35]) ## [0.5.2] - 2024-03-25 ### Fixed -- Fix empty status code. (#30) +- Fix empty status code. ([#30]) ### Changed -- Return `http.StatusOK` (200) as a default `http.status_code` span attribute. (#30) +- Return `http.StatusOK` (200) as a default `http.status_code` span attribute. ([#30]) ## [0.5.1] - 2023-02-18 ### Fixed -- Fix broken empty routes. (#18) +- Fix broken empty routes. ([#18]) ### Changed @@ -70,14 +95,14 @@ This release is the last to support Go `1.15`. The next release will require at ### Added -- Add multi services example. (#9) -- Add `WithFilter()` option to ignore tracing in certain endpoints. (#11) +- Add multi services example. ([#9]) +- Add `WithFilter()` option to ignore tracing in certain endpoints. ([#11]) ## [0.4.0] - 2022-02-22 ### Added -- Add Option `WithRequestMethodInSpanName()` to handle vendor that do not include HTTP request method as mentioned in #6. (#7) +- Add Option `WithRequestMethodInSpanName()` to handle vendor that do not include HTTP request method as mentioned in [#6]. ([#7]) - Refine description for `WithChiRoutes()` option to announce it is possible to override the span name in underlying handler with this option. ### Changed @@ -86,22 +111,22 @@ This release is the last to support Go `1.15`. The next release will require at ### Fixed -- Fix both `docker-compose.yml` & `Dockerfile` in the example. (#5) +- Fix both `docker-compose.yml` & `Dockerfile` in the example. ([#5]) ### Added -- Add `WithChiRoutes()` option to make the middleware able to determine full route pattern on span creation. (#5) -- Set all known span attributes on span creation rather than set them after request is being executed. (#5) +- Add `WithChiRoutes()` option to make the middleware able to determine full route pattern on span creation. ([#5]) +- Set all known span attributes on span creation rather than set them after request is being executed. ([#5]) ## [0.2.1] - 2022-01-08 ### Added -- Add build example to CI pipeline. (#2) +- Add build example to CI pipeline. ([#2]) ### Changed -- Use `ctx.RoutePattern()` to get span name, this is to strip out noisy wildcard pattern. (#1) +- Use `ctx.RoutePattern()` to get span name, this is to strip out noisy wildcard pattern. ([#1]) ## [0.2.0] - 2021-10-18 @@ -136,7 +161,28 @@ It contains instrumentation for trace and depends on: - Example code for a basic usage. - Apache-2.0 license. -[Unreleased]: https://github.com/riandyrn/otelchi/compare/v0.7.0...HEAD +[#43]: https://github.com/riandyrn/otelchi/pull/43 +[#42]: https://github.com/riandyrn/otelchi/pull/42 +[#41]: https://github.com/riandyrn/otelchi/pull/41 +[#39]: https://github.com/riandyrn/otelchi/pull/39 +[#38]: https://github.com/riandyrn/otelchi/pull/38 +[#36]: https://github.com/riandyrn/otelchi/pull/36 +[#35]: https://github.com/riandyrn/otelchi/pull/35 +[#33]: https://github.com/riandyrn/otelchi/pull/33 +[#32]: https://github.com/riandyrn/otelchi/pull/32 +[#30]: https://github.com/riandyrn/otelchi/pull/30 +[#29]: https://github.com/riandyrn/otelchi/pull/29 +[#18]: https://github.com/riandyrn/otelchi/pull/18 +[#11]: https://github.com/riandyrn/otelchi/pull/11 +[#9]: https://github.com/riandyrn/otelchi/pull/9 +[#7]: https://github.com/riandyrn/otelchi/pull/7 +[#6]: https://github.com/riandyrn/otelchi/pull/6 +[#5]: https://github.com/riandyrn/otelchi/pull/5 +[#2]: https://github.com/riandyrn/otelchi/pull/2 +[#1]: https://github.com/riandyrn/otelchi/pull/1 + +[Unreleased]: https://github.com/riandyrn/otelchi/compare/v0.8.0...HEAD +[0.8.0]: https://github.com/riandyrn/otelchi/releases/tag/v0.8.0 [0.7.0]: https://github.com/riandyrn/otelchi/releases/tag/v0.7.0 [0.6.0]: https://github.com/riandyrn/otelchi/releases/tag/v0.6.0 [0.5.2]: https://github.com/riandyrn/otelchi/releases/tag/v0.5.2 diff --git a/vendor/github.com/riandyrn/otelchi/Makefile b/vendor/github.com/riandyrn/otelchi/Makefile index 98d1f005f2..ec261df89a 100644 --- a/vendor/github.com/riandyrn/otelchi/Makefile +++ b/vendor/github.com/riandyrn/otelchi/Makefile @@ -1,6 +1,6 @@ .PHONY: * -GO_VERSIONS="1.18 1.19 1.20" +GO_VERSIONS="1.19 1.20 1.21" # This is the command that will be used to run the tests go-test: diff --git a/vendor/github.com/riandyrn/otelchi/config.go b/vendor/github.com/riandyrn/otelchi/config.go index 6a9371537a..3529268af1 100644 --- a/vendor/github.com/riandyrn/otelchi/config.go +++ b/vendor/github.com/riandyrn/otelchi/config.go @@ -18,6 +18,7 @@ type config struct { RequestMethodInSpanName bool Filter func(r *http.Request) bool TraceResponseHeaderKey string + PublicEndpointFn func(r *http.Request) bool } // Option specifies instrumentation configuration options. @@ -96,3 +97,44 @@ func WithTraceIDResponseHeader(headerKeyFunc func() string) Option { } }) } + +// WithPublicEndpoint is used for marking every endpoint as public endpoint. +// This means if the incoming request has span context, it won't be used as +// parent span by the span generated by this middleware, instead the generated +// span will be the root span (new trace) and then linked to the span from the +// incoming request. +// +// Let say we have the following scenario: +// +// 1. We have 2 systems: `SysA` & `SysB`. +// 2. `SysA` has the following services: `SvcA.1` & `SvcA.2`. +// 3. `SysB` has the following services: `SvcB.1` & `SvcB.2`. +// 4. `SvcA.2` is used internally only by `SvcA.1`. +// 5. `SvcB.2` is used internally only by `SvcB.1`. +// 6. All of these services already instrumented otelchi & using the same collector (e.g Jaeger). +// 7. In `SvcA.1` we should set `WithPublicEndpoint()` since it is the entry point (a.k.a "public endpoint") for entering `SysA`. +// 8. In `SvcA.2` we should not set `WithPublicEndpoint()` since it is only used internally by `SvcA.1` inside `SysA`. +// 9. Point 7 & 8 also applies to both services in `SysB`. +// +// Now, whenever `SvcA.1` calls `SvcA.2` there will be only a single trace generated. This trace will contain 2 spans: root span from `SvcA.1` & child span from `SvcA.2`. +// +// But if let say `SvcA.2` calls `SvcB.1`, then there will be 2 traces generated: trace from `SysA` & trace from `SysB`. But in trace generated in `SysB` there will be like a marking that this trace is actually related to trace in `SysA` (a.k.a linked with the trace from `SysA`). +func WithPublicEndpoint() Option { + return WithPublicEndpointFn(func(r *http.Request) bool { return true }) +} + +// WithPublicEndpointFn runs with every request, and allows conditionally +// configuring the Handler to link the generated span with an incoming span +// context. +// +// If the function return `true` the generated span will be linked with the +// incoming span context. Otherwise, the generated span will be set as the +// child span of the incoming span context. +// +// Essentially it has the same functionality as WithPublicEndpoint but with +// more flexibility. +func WithPublicEndpointFn(fn func(r *http.Request) bool) Option { + return optionFunc(func(cfg *config) { + cfg.PublicEndpointFn = fn + }) +} diff --git a/vendor/github.com/riandyrn/otelchi/middleware.go b/vendor/github.com/riandyrn/otelchi/middleware.go index 9d25e46e88..d6dfda0318 100644 --- a/vendor/github.com/riandyrn/otelchi/middleware.go +++ b/vendor/github.com/riandyrn/otelchi/middleware.go @@ -10,8 +10,8 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/propagation" - semconv "go.opentelemetry.io/otel/semconv/v1.17.0" - "go.opentelemetry.io/otel/semconv/v1.17.0/httpconv" + semconv "go.opentelemetry.io/otel/semconv/v1.20.0" + "go.opentelemetry.io/otel/semconv/v1.20.0/httpconv" oteltrace "go.opentelemetry.io/otel/trace" ) @@ -48,6 +48,7 @@ func Middleware(serverName string, opts ...Option) func(next http.Handler) http. reqMethodInSpanName: cfg.RequestMethodInSpanName, filter: cfg.Filter, traceResponseHeaderKey: cfg.TraceResponseHeaderKey, + publicEndpointFn: cfg.PublicEndpointFn, } } } @@ -61,6 +62,7 @@ type traceware struct { reqMethodInSpanName bool filter func(r *http.Request) bool traceResponseHeaderKey string + publicEndpointFn func(r *http.Request) bool } type recordingResponseWriter struct { @@ -138,11 +140,35 @@ func (tw traceware) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } - ctx, span := tw.tracer.Start( - ctx, spanName, + // define span start options + spanOpts := []oteltrace.SpanStartOption{ oteltrace.WithAttributes(spanAttributes...), oteltrace.WithSpanKind(oteltrace.SpanKindServer), - ) + } + + if tw.publicEndpointFn != nil && tw.publicEndpointFn(r) { + // mark span as the root span + spanOpts = append(spanOpts, oteltrace.WithNewRoot()) + + // linking incoming span context to the root span, we need to + // ensure if the incoming span context is valid (because it is + // possible for us to receive invalid span context due to various + // reason such as bug or context propagation error) and it is + // coming from another service (remote) before linking it to the + // root span + spanCtx := oteltrace.SpanContextFromContext(ctx) + if spanCtx.IsValid() && spanCtx.IsRemote() { + spanOpts = append( + spanOpts, + oteltrace.WithLinks(oteltrace.Link{ + SpanContext: spanCtx, + }), + ) + } + } + + // start span + ctx, span := tw.tracer.Start(ctx, spanName, spanOpts...) defer span.End() // put trace_id to response header only when WithTraceResponseHeaderKey is used diff --git a/vendor/github.com/riandyrn/otelchi/version.go b/vendor/github.com/riandyrn/otelchi/version.go index 830cf01cf1..8d6a5e2f05 100644 --- a/vendor/github.com/riandyrn/otelchi/version.go +++ b/vendor/github.com/riandyrn/otelchi/version.go @@ -2,5 +2,5 @@ package otelchi // Version is the current release version of otelchi in use. func Version() string { - return "0.7.0" + return "0.8.0" } diff --git a/vendor/go.opentelemetry.io/otel/semconv/internal/v2/http.go b/vendor/go.opentelemetry.io/otel/semconv/internal/v4/http.go similarity index 95% rename from vendor/go.opentelemetry.io/otel/semconv/internal/v2/http.go rename to vendor/go.opentelemetry.io/otel/semconv/internal/v4/http.go index 09e094de9a..aab73ffe13 100644 --- a/vendor/go.opentelemetry.io/otel/semconv/internal/v2/http.go +++ b/vendor/go.opentelemetry.io/otel/semconv/internal/v4/http.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package internal // import "go.opentelemetry.io/otel/semconv/internal/v2" +package internal // import "go.opentelemetry.io/otel/semconv/internal/v4" import ( "fmt" @@ -19,7 +19,8 @@ type HTTPConv struct { EnduserIDKey attribute.Key HTTPClientIPKey attribute.Key - HTTPFlavorKey attribute.Key + NetProtocolNameKey attribute.Key + NetProtocolVersionKey attribute.Key HTTPMethodKey attribute.Key HTTPRequestContentLengthKey attribute.Key HTTPResponseContentLengthKey attribute.Key @@ -29,7 +30,7 @@ type HTTPConv struct { HTTPStatusCodeKey attribute.Key HTTPTargetKey attribute.Key HTTPURLKey attribute.Key - HTTPUserAgentKey attribute.Key + UserAgentOriginalKey attribute.Key } // ClientResponse returns attributes for an HTTP response received by a client @@ -110,7 +111,7 @@ func (c *HTTPConv) ClientRequest(req *http.Request) []attribute.KeyValue { } if useragent != "" { - attrs = append(attrs, c.HTTPUserAgentKey.String(useragent)) + attrs = append(attrs, c.UserAgentOriginalKey.String(useragent)) } if l := req.ContentLength; l > 0 { @@ -209,7 +210,7 @@ func (c *HTTPConv) ServerRequest(server string, req *http.Request) []attribute.K } if useragent != "" { - attrs = append(attrs, c.HTTPUserAgentKey.String(useragent)) + attrs = append(attrs, c.UserAgentOriginalKey.String(useragent)) } if hasUserID { @@ -240,15 +241,15 @@ func (c *HTTPConv) scheme(https bool) attribute.KeyValue { // nolint:revive func (c *HTTPConv) proto(proto string) attribute.KeyValue { switch proto { case "HTTP/1.0": - return c.HTTPFlavorKey.String("1.0") + return c.NetProtocolVersionKey.String("1.0") case "HTTP/1.1": - return c.HTTPFlavorKey.String("1.1") + return c.NetProtocolVersionKey.String("1.1") case "HTTP/2": - return c.HTTPFlavorKey.String("2.0") + return c.NetProtocolVersionKey.String("2.0") case "HTTP/3": - return c.HTTPFlavorKey.String("3.0") + return c.NetProtocolVersionKey.String("3.0") default: - return c.HTTPFlavorKey.String(proto) + return c.NetProtocolNameKey.String(proto) } } diff --git a/vendor/go.opentelemetry.io/otel/semconv/internal/v2/net.go b/vendor/go.opentelemetry.io/otel/semconv/internal/v4/net.go similarity index 99% rename from vendor/go.opentelemetry.io/otel/semconv/internal/v2/net.go rename to vendor/go.opentelemetry.io/otel/semconv/internal/v4/net.go index 45a1b06acf..65db0cb61f 100644 --- a/vendor/go.opentelemetry.io/otel/semconv/internal/v2/net.go +++ b/vendor/go.opentelemetry.io/otel/semconv/internal/v4/net.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package internal // import "go.opentelemetry.io/otel/semconv/internal/v2" +package internal // import "go.opentelemetry.io/otel/semconv/internal/v4" import ( "net" diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/httpconv/README.md b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/httpconv/README.md deleted file mode 100644 index 18ee2f3d62..0000000000 --- a/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/httpconv/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Semconv v1.17.0 HTTP conv - -[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/semconv/v1.17.0/httpconv)](https://pkg.go.dev/go.opentelemetry.io/otel/semconv/v1.17.0/httpconv) diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/httpconv/README.md b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/httpconv/README.md new file mode 100644 index 0000000000..96b4b0d0b1 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/httpconv/README.md @@ -0,0 +1,3 @@ +# Semconv v1.20.0 HTTP conv + +[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/semconv/v1.20.0/httpconv)](https://pkg.go.dev/go.opentelemetry.io/otel/semconv/v1.20.0/httpconv) diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/httpconv/http.go b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/httpconv/http.go similarity index 83% rename from vendor/go.opentelemetry.io/otel/semconv/v1.17.0/httpconv/http.go rename to vendor/go.opentelemetry.io/otel/semconv/v1.20.0/httpconv/http.go index 76d1dc86b4..8f261a9db0 100644 --- a/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/httpconv/http.go +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.20.0/httpconv/http.go @@ -3,15 +3,15 @@ // Package httpconv provides OpenTelemetry HTTP semantic conventions for // tracing telemetry. -package httpconv // import "go.opentelemetry.io/otel/semconv/v1.17.0/httpconv" +package httpconv // import "go.opentelemetry.io/otel/semconv/v1.20.0/httpconv" import ( "net/http" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" - "go.opentelemetry.io/otel/semconv/internal/v2" - semconv "go.opentelemetry.io/otel/semconv/v1.17.0" + "go.opentelemetry.io/otel/semconv/internal/v4" + semconv "go.opentelemetry.io/otel/semconv/v1.20.0" ) var ( @@ -33,7 +33,8 @@ var ( EnduserIDKey: semconv.EnduserIDKey, HTTPClientIPKey: semconv.HTTPClientIPKey, - HTTPFlavorKey: semconv.HTTPFlavorKey, + NetProtocolNameKey: semconv.NetProtocolNameKey, + NetProtocolVersionKey: semconv.NetProtocolVersionKey, HTTPMethodKey: semconv.HTTPMethodKey, HTTPRequestContentLengthKey: semconv.HTTPRequestContentLengthKey, HTTPResponseContentLengthKey: semconv.HTTPResponseContentLengthKey, @@ -43,7 +44,7 @@ var ( HTTPStatusCodeKey: semconv.HTTPStatusCodeKey, HTTPTargetKey: semconv.HTTPTargetKey, HTTPURLKey: semconv.HTTPURLKey, - HTTPUserAgentKey: semconv.HTTPUserAgentKey, + UserAgentOriginalKey: semconv.UserAgentOriginalKey, } ) @@ -63,10 +64,11 @@ func ClientResponse(resp *http.Response) []attribute.KeyValue { } // ClientRequest returns trace attributes for an HTTP request made by a client. -// The following attributes are always returned: "http.url", "http.flavor", -// "http.method", "net.peer.name". The following attributes are returned if the -// related values are defined in req: "net.peer.port", "http.user_agent", -// "http.request_content_length", "enduser.id". +// The following attributes are always returned: "http.url", +// "net.protocol.(name|version)", "http.method", "net.peer.name". +// The following attributes are returned if the related values are defined +// in req: "net.peer.port", "http.user_agent", "http.request_content_length", +// "enduser.id". func ClientRequest(req *http.Request) []attribute.KeyValue { return hc.ClientRequest(req) } @@ -95,10 +97,10 @@ func ClientStatus(code int) (codes.Code, string) { // The req Host will be used to determine the server instead. // // The following attributes are always returned: "http.method", "http.scheme", -// "http.flavor", "http.target", "net.host.name". The following attributes are -// returned if they related values are defined in req: "net.host.port", -// "net.sock.peer.addr", "net.sock.peer.port", "http.user_agent", "enduser.id", -// "http.client_ip". +// ""net.protocol.(name|version)", "http.target", "net.host.name". +// The following attributes are returned if they related values are defined +// in req: "net.host.port", "net.sock.peer.addr", "net.sock.peer.port", +// "user_agent.original", "enduser.id", "http.client_ip". func ServerRequest(server string, req *http.Request) []attribute.KeyValue { return hc.ServerRequest(server, req) } @@ -117,7 +119,7 @@ func ServerStatus(code int) (codes.Code, string) { // security risk - explicit configuration helps avoid leaking sensitive // information. // -// The User-Agent header is already captured in the http.user_agent attribute +// The User-Agent header is already captured in the user_agent.original attribute // from ClientRequest and ServerRequest. Instrumentation may provide an option // to capture that header here even though it is not recommended. Otherwise, // instrumentation should filter that out of what is passed. @@ -132,7 +134,7 @@ func RequestHeader(h http.Header) []attribute.KeyValue { // security risk - explicit configuration helps avoid leaking sensitive // information. // -// The User-Agent header is already captured in the http.user_agent attribute +// The User-Agent header is already captured in the user_agent.original attribute // from ClientRequest and ServerRequest. Instrumentation may provide an option // to capture that header here even though it is not recommended. Otherwise, // instrumentation should filter that out of what is passed. diff --git a/vendor/modules.txt b/vendor/modules.txt index 17e536ef68..727130d8a0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1671,8 +1671,8 @@ github.com/r3labs/sse/v2 # github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 ## explicit github.com/rcrowley/go-metrics -# github.com/riandyrn/otelchi v0.7.0 -## explicit; go 1.18 +# github.com/riandyrn/otelchi v0.8.0 +## explicit; go 1.19 github.com/riandyrn/otelchi # github.com/rivo/uniseg v0.4.2 ## explicit; go 1.18 @@ -1968,11 +1968,11 @@ go.opentelemetry.io/otel/internal/baggage go.opentelemetry.io/otel/internal/global go.opentelemetry.io/otel/propagation go.opentelemetry.io/otel/semconv/internal -go.opentelemetry.io/otel/semconv/internal/v2 +go.opentelemetry.io/otel/semconv/internal/v4 go.opentelemetry.io/otel/semconv/v1.10.0 go.opentelemetry.io/otel/semconv/v1.17.0 -go.opentelemetry.io/otel/semconv/v1.17.0/httpconv go.opentelemetry.io/otel/semconv/v1.20.0 +go.opentelemetry.io/otel/semconv/v1.20.0/httpconv go.opentelemetry.io/otel/semconv/v1.21.0 go.opentelemetry.io/otel/semconv/v1.24.0 go.opentelemetry.io/otel/semconv/v1.4.0