From 54c85676979767ee87206dda08e4c6f1e26e4ba8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 10:20:22 +0000 Subject: [PATCH] chore(deps): bump github.com/riandyrn/otelchi from 0.9.0 to 0.10.0 Bumps [github.com/riandyrn/otelchi](https://github.com/riandyrn/otelchi) from 0.9.0 to 0.10.0. - [Release notes](https://github.com/riandyrn/otelchi/releases) - [Changelog](https://github.com/riandyrn/otelchi/blob/master/CHANGELOG.md) - [Commits](https://github.com/riandyrn/otelchi/compare/v0.9.0...v0.10.0) --- updated-dependencies: - dependency-name: github.com/riandyrn/otelchi dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../github.com/riandyrn/otelchi/CHANGELOG.md | 26 +++++++- vendor/github.com/riandyrn/otelchi/CODEOWNERS | 2 +- vendor/github.com/riandyrn/otelchi/Makefile | 2 +- vendor/github.com/riandyrn/otelchi/config.go | 62 ++++++++++++++----- .../github.com/riandyrn/otelchi/middleware.go | 46 +++++++------- vendor/github.com/riandyrn/otelchi/version.go | 2 +- vendor/modules.txt | 4 +- 9 files changed, 105 insertions(+), 45 deletions(-) diff --git a/go.mod b/go.mod index 4545e3ffb..cf9a59c8b 100644 --- a/go.mod +++ b/go.mod @@ -76,7 +76,7 @@ require ( github.com/pkg/xattr v0.4.10 github.com/prometheus/client_golang v1.20.2 github.com/r3labs/sse/v2 v2.10.0 - github.com/riandyrn/otelchi v0.9.0 + github.com/riandyrn/otelchi v0.10.0 github.com/rogpeppe/go-internal v1.12.0 github.com/rs/cors v1.11.0 github.com/rs/zerolog v1.33.0 diff --git a/go.sum b/go.sum index 7bb3194bd..9b59f2118 100644 --- a/go.sum +++ b/go.sum @@ -1040,8 +1040,8 @@ github.com/rainycape/memcache v0.0.0-20150622160815-1031fa0ce2f2/go.mod h1:7tZKc github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/riandyrn/otelchi v0.9.0 h1:BuQxXR7/JF2yYOQl21Yyz5d52hns/96ecAaPUZiKQzc= -github.com/riandyrn/otelchi v0.9.0/go.mod h1:iX30kllzThsf8oEcEbl3GifPJZtN4cnCWUUc+UhE4yM= +github.com/riandyrn/otelchi v0.10.0 h1:QMbR/FMDWBOkej6dfyWteYefUKqIFxnyrpaoWRJ9RPQ= +github.com/riandyrn/otelchi v0.10.0/go.mod h1:zBaX2FavWMlsvq4GqHit+QXxF1c5wIMZZFaYyW4+7FA= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= diff --git a/vendor/github.com/riandyrn/otelchi/CHANGELOG.md b/vendor/github.com/riandyrn/otelchi/CHANGELOG.md index 62595863b..e17a3e56c 100644 --- a/vendor/github.com/riandyrn/otelchi/CHANGELOG.md +++ b/vendor/github.com/riandyrn/otelchi/CHANGELOG.md @@ -8,6 +8,26 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +## [0.10.0] - 2024-09-17 + +### Added + +- Add `WithTraceResponseHeaders` option to include trace information in response headers, this option replaces the deprecated `WithTraceIDResponseHeader` option. ([#62]) + +### Changed + +- Upgrade `go.opentelemetry.io/otel`, `go.opentelemetry.io/otel/sdk`, & `go.opentelemetry.io/otel/trace` to `v1.30.0`. ([#64]) +- Set the go versions for testing in both `Makefile` & `compatibility-test.yml` to `1.22` & `1.23`. ([#64]) + +### Fixed + +- Fix Gobrew installation in CI pipeline. ([#63]) + +### Removed + +- Drop support for Go 1.21. ([#64]) +- Deprecated `WithTraceIDResponseHeader` option, use `WithTraceResponseHeaders` instead. ([#62]) + ## [0.9.0] - 2024-07-06 ### Changed @@ -174,6 +194,9 @@ It contains instrumentation for trace and depends on: - Example code for a basic usage. - Apache-2.0 license. +[#64]: https://github.com/riandyrn/otelchi/pull/64 +[#63]: https://github.com/riandyrn/otelchi/pull/63 +[#62]: https://github.com/riandyrn/otelchi/pull/62 [#49]: https://github.com/riandyrn/otelchi/pull/49 [#47]: https://github.com/riandyrn/otelchi/pull/47 [#43]: https://github.com/riandyrn/otelchi/pull/43 @@ -196,7 +219,8 @@ It contains instrumentation for trace and depends on: [#2]: https://github.com/riandyrn/otelchi/pull/2 [#1]: https://github.com/riandyrn/otelchi/pull/1 -[Unreleased]: https://github.com/riandyrn/otelchi/compare/v0.9.0...HEAD +[Unreleased]: https://github.com/riandyrn/otelchi/compare/v0.10.0...HEAD +[0.10.0]: https://github.com/riandyrn/otelchi/releases/tag/v0.10.0 [0.9.0]: https://github.com/riandyrn/otelchi/releases/tag/v0.9.0 [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 diff --git a/vendor/github.com/riandyrn/otelchi/CODEOWNERS b/vendor/github.com/riandyrn/otelchi/CODEOWNERS index 9445a6d02..8e539f425 100644 --- a/vendor/github.com/riandyrn/otelchi/CODEOWNERS +++ b/vendor/github.com/riandyrn/otelchi/CODEOWNERS @@ -1 +1 @@ -* @riandyrn @ilhamsyahids @ProtozoaJr \ No newline at end of file +* @riandyrn @ilhamsyahids \ No newline at end of file diff --git a/vendor/github.com/riandyrn/otelchi/Makefile b/vendor/github.com/riandyrn/otelchi/Makefile index 02625b6d8..0408709e8 100644 --- a/vendor/github.com/riandyrn/otelchi/Makefile +++ b/vendor/github.com/riandyrn/otelchi/Makefile @@ -1,6 +1,6 @@ .PHONY: * -GO_VERSIONS="1.21 1.22" +GO_VERSIONS="1.22 1.23" # 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 1763a28dd..75e5a2968 100644 --- a/vendor/github.com/riandyrn/otelchi/config.go +++ b/vendor/github.com/riandyrn/otelchi/config.go @@ -8,17 +8,22 @@ import ( oteltrace "go.opentelemetry.io/otel/trace" ) -const defaultTraceResponseHeaderKey = "X-Trace-Id" +// These defaults are used in `TraceHeaderConfig`. +const ( + DefaultTraceIDResponseHeaderKey = "X-Trace-Id" + DefaultTraceSampledResponseHeaderKey = "X-Trace-Sampled" +) // config is used to configure the mux middleware. type config struct { - TracerProvider oteltrace.TracerProvider - Propagators propagation.TextMapPropagator - ChiRoutes chi.Routes - RequestMethodInSpanName bool - Filters []Filter - TraceResponseHeaderKey string - PublicEndpointFn func(r *http.Request) bool + TracerProvider oteltrace.TracerProvider + Propagators propagation.TextMapPropagator + ChiRoutes chi.Routes + RequestMethodInSpanName bool + Filters []Filter + TraceIDResponseHeaderKey string + TraceSampledResponseHeaderKey string + PublicEndpointFn func(r *http.Request) bool } // Option specifies instrumentation configuration options. @@ -32,7 +37,7 @@ func (o optionFunc) apply(c *config) { o(c) } -// Filter is a predicate used to determine whether a given http.request should +// 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 @@ -95,12 +100,39 @@ func WithFilter(filter Filter) Option { // WithTraceIDResponseHeader enables adding trace id into response header. // It accepts a function that generates the header key name. If this parameter // function set to `nil` the default header key which is `X-Trace-Id` will be used. +// +// Deprecated: use `WithTraceResponseHeaders` instead. func WithTraceIDResponseHeader(headerKeyFunc func() string) Option { - return optionFunc(func(cfg *config) { - if headerKeyFunc == nil { - cfg.TraceResponseHeaderKey = defaultTraceResponseHeaderKey // use default trace header - } else { - cfg.TraceResponseHeaderKey = headerKeyFunc() + cfg := TraceHeaderConfig{ + TraceIDHeader: "", + TraceSampledHeader: "", + } + if headerKeyFunc != nil { + cfg.TraceIDHeader = headerKeyFunc() + } + return WithTraceResponseHeaders(cfg) +} + +// TraceHeaderConfig is configuration for trace headers in the response. +type TraceHeaderConfig struct { + TraceIDHeader string // if non-empty overrides the default of X-Trace-ID + TraceSampledHeader string // if non-empty overrides the default of X-Trace-Sampled +} + +// WithTraceResponseHeaders configures the response headers for trace information. +// It accepts a TraceHeaderConfig struct that contains the keys for the Trace ID +// and Trace Sampled headers. If the provided keys are empty, default values will +// be used for the respective headers. +func WithTraceResponseHeaders(cfg TraceHeaderConfig) Option { + return optionFunc(func(c *config) { + c.TraceIDResponseHeaderKey = cfg.TraceIDHeader + if c.TraceIDResponseHeaderKey == "" { + c.TraceIDResponseHeaderKey = DefaultTraceIDResponseHeaderKey + } + + c.TraceSampledResponseHeaderKey = cfg.TraceSampledHeader + if c.TraceSampledResponseHeaderKey == "" { + c.TraceSampledResponseHeaderKey = DefaultTraceSampledResponseHeaderKey } }) } @@ -138,7 +170,7 @@ func WithPublicEndpoint() Option { // 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 +// 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) { diff --git a/vendor/github.com/riandyrn/otelchi/middleware.go b/vendor/github.com/riandyrn/otelchi/middleware.go index 4d9cdafbf..aedb3a808 100644 --- a/vendor/github.com/riandyrn/otelchi/middleware.go +++ b/vendor/github.com/riandyrn/otelchi/middleware.go @@ -2,6 +2,7 @@ package otelchi import ( "net/http" + "strconv" "sync" "github.com/felixge/httpsnoop" @@ -40,29 +41,31 @@ func Middleware(serverName string, opts ...Option) func(next http.Handler) http. return func(handler http.Handler) http.Handler { return traceware{ - serverName: serverName, - tracer: tracer, - propagators: cfg.Propagators, - handler: handler, - chiRoutes: cfg.ChiRoutes, - reqMethodInSpanName: cfg.RequestMethodInSpanName, - filters: cfg.Filters, - traceResponseHeaderKey: cfg.TraceResponseHeaderKey, - publicEndpointFn: cfg.PublicEndpointFn, + serverName: serverName, + tracer: tracer, + propagators: cfg.Propagators, + handler: handler, + chiRoutes: cfg.ChiRoutes, + reqMethodInSpanName: cfg.RequestMethodInSpanName, + filters: cfg.Filters, + traceIDResponseHeaderKey: cfg.TraceIDResponseHeaderKey, + traceSampledResponseHeaderKey: cfg.TraceSampledResponseHeaderKey, + publicEndpointFn: cfg.PublicEndpointFn, } } } type traceware struct { - serverName string - tracer oteltrace.Tracer - propagators propagation.TextMapPropagator - handler http.Handler - chiRoutes chi.Routes - reqMethodInSpanName bool - filters []Filter - traceResponseHeaderKey string - publicEndpointFn func(r *http.Request) bool + serverName string + tracer oteltrace.Tracer + propagators propagation.TextMapPropagator + handler http.Handler + chiRoutes chi.Routes + reqMethodInSpanName bool + filters []Filter + traceIDResponseHeaderKey string + traceSampledResponseHeaderKey string + publicEndpointFn func(r *http.Request) bool } type recordingResponseWriter struct { @@ -175,9 +178,10 @@ func (tw traceware) ServeHTTP(w http.ResponseWriter, r *http.Request) { ctx, span := tw.tracer.Start(ctx, spanName, spanOpts...) defer span.End() - // put trace_id to response header only when WithTraceResponseHeaderKey is used - if len(tw.traceResponseHeaderKey) > 0 && span.SpanContext().HasTraceID() { - w.Header().Add(tw.traceResponseHeaderKey, span.SpanContext().TraceID().String()) + // put trace_id to response header only when `WithTraceIDResponseHeader` is used + if len(tw.traceIDResponseHeaderKey) > 0 && span.SpanContext().HasTraceID() { + w.Header().Add(tw.traceIDResponseHeaderKey, span.SpanContext().TraceID().String()) + w.Header().Add(tw.traceSampledResponseHeaderKey, strconv.FormatBool(span.SpanContext().IsSampled())) } // get recording response writer diff --git a/vendor/github.com/riandyrn/otelchi/version.go b/vendor/github.com/riandyrn/otelchi/version.go index c6761f24c..8ab8ec45c 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.9.0" + return "0.10.0" } diff --git a/vendor/modules.txt b/vendor/modules.txt index 99040d24e..bfc513947 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1710,8 +1710,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.9.0 -## explicit; go 1.21 +# github.com/riandyrn/otelchi v0.10.0 +## explicit; go 1.22.0 github.com/riandyrn/otelchi # github.com/rivo/uniseg v0.4.7 ## explicit; go 1.18