build(deps): bump github.com/riandyrn/otelchi from 0.12.1 to 0.12.2

Bumps [github.com/riandyrn/otelchi](https://github.com/riandyrn/otelchi) from 0.12.1 to 0.12.2.
- [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.12.1...v0.12.2)

---
updated-dependencies:
- dependency-name: github.com/riandyrn/otelchi
  dependency-version: 0.12.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2025-09-04 02:55:32 +00:00
committed by GitHub
parent 3b0222ddbb
commit 2c07884c1b
6 changed files with 36 additions and 13 deletions

2
go.mod
View File

@@ -72,7 +72,7 @@ require (
github.com/pkg/xattr v0.4.12
github.com/prometheus/client_golang v1.23.0
github.com/r3labs/sse/v2 v2.10.0
github.com/riandyrn/otelchi v0.12.1
github.com/riandyrn/otelchi v0.12.2
github.com/rogpeppe/go-internal v1.14.1
github.com/rs/cors v1.11.1
github.com/rs/zerolog v1.34.0

4
go.sum
View File

@@ -1029,8 +1029,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.12.1 h1:FdRKK3/RgZ/T+d+qTH5Uw3MFx0KwRF38SkdfTMMq/m8=
github.com/riandyrn/otelchi v0.12.1/go.mod h1:weZZeUJURvtCcbWsdb7Y6F8KFZGedJlSrgUjq9VirV8=
github.com/riandyrn/otelchi v0.12.2 h1:6QhGv0LVw/dwjtPd12mnNrl0oEQF4ZAlmHcnlTYbeAg=
github.com/riandyrn/otelchi v0.12.2/go.mod h1:weZZeUJURvtCcbWsdb7Y6F8KFZGedJlSrgUjq9VirV8=
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=

View File

@@ -8,6 +8,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [Unreleased]
## [0.12.2] - 2025-09-02
### Fixed
- Use TracerProvider from request context when available ([#92])
- Fix high-cardinality metrics and allows user control attributes each metric record ([#95])
## [0.12.1] - 2025-02-12
### Fixed
@@ -228,6 +235,8 @@ It contains instrumentation for trace and depends on:
- Example code for a basic usage.
- Apache-2.0 license.
[#95]: https://github.com/riandyrn/otelchi/pull/95
[#92]: https://github.com/riandyrn/otelchi/pull/92
[#89]: https://github.com/riandyrn/otelchi/pull/89
[#88]: https://github.com/riandyrn/otelchi/pull/88
[#87]: https://github.com/riandyrn/otelchi/pull/87
@@ -260,7 +269,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.12.1...HEAD
[Unreleased]: https://github.com/riandyrn/otelchi/compare/v0.12.2...HEAD
[0.12.2]: https://github.com/riandyrn/otelchi/releases/tag/v0.12.2
[0.12.1]: https://github.com/riandyrn/otelchi/releases/tag/v0.12.1
[0.12.0]: https://github.com/riandyrn/otelchi/releases/tag/v0.12.0
[0.11.0]: https://github.com/riandyrn/otelchi/releases/tag/v0.11.0

View File

@@ -13,6 +13,7 @@ import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.20.0"
"go.opentelemetry.io/otel/semconv/v1.20.0/httpconv"
@@ -23,6 +24,10 @@ const (
tracerName = "github.com/riandyrn/otelchi"
)
func newTracer(tp trace.TracerProvider) trace.Tracer {
return tp.Tracer(tracerName, trace.WithInstrumentationVersion(version.Version()))
}
// Middleware sets up a handler to start tracing the incoming
// requests. The serverName parameter should describe the name of the
// (virtual) server handling the request.
@@ -31,13 +36,12 @@ func Middleware(serverName string, opts ...Option) func(next http.Handler) http.
for _, opt := range opts {
opt.apply(&cfg)
}
if cfg.tracerProvider == nil {
cfg.tracerProvider = otel.GetTracerProvider()
var tracer oteltrace.Tracer
if cfg.tracerProvider != nil {
tracer = newTracer(cfg.tracerProvider)
}
tracer := cfg.tracerProvider.Tracer(
tracerName,
oteltrace.WithInstrumentationVersion(version.Version()),
)
if cfg.propagators == nil {
cfg.propagators = otel.GetTextMapPropagator()
}
@@ -167,8 +171,17 @@ func (tw traceware) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
tracer := tw.tracer
if tracer == nil {
if span := trace.SpanFromContext(r.Context()); span.SpanContext().IsValid() {
tracer = newTracer(span.TracerProvider())
} else {
tracer = newTracer(otel.GetTracerProvider())
}
}
// start span
ctx, span := tw.tracer.Start(ctx, spanName, spanOpts...)
ctx, span := tracer.Start(ctx, spanName, spanOpts...)
defer span.End()
// put trace_id to response header only when `WithTraceIDResponseHeader` is used

View File

@@ -2,5 +2,5 @@ package version
// Version is the current release version of otelchi in use.
func Version() string {
return "0.12.1"
return "0.12.2"
}

2
vendor/modules.txt vendored
View File

@@ -1769,7 +1769,7 @@ 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.12.1
# github.com/riandyrn/otelchi v0.12.2
## explicit; go 1.22.0
github.com/riandyrn/otelchi
github.com/riandyrn/otelchi/version