Bump github.com/riandyrn/otelchi from 0.8.0 to 0.9.0

Bumps [github.com/riandyrn/otelchi](https://github.com/riandyrn/otelchi) from 0.8.0 to 0.9.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.8.0...v0.9.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2024-08-20 06:12:45 +00:00
committed by Ralf Haferkamp
parent e3176e6f98
commit 7eb69d5142
10 changed files with 52 additions and 25 deletions

2
go.mod
View File

@@ -76,7 +76,7 @@ require (
github.com/pkg/xattr v0.4.9
github.com/prometheus/client_golang v1.19.1
github.com/r3labs/sse/v2 v2.10.0
github.com/riandyrn/otelchi v0.8.0
github.com/riandyrn/otelchi v0.9.0
github.com/rogpeppe/go-internal v1.12.0
github.com/rs/cors v1.11.0
github.com/rs/zerolog v1.33.0

4
go.sum
View File

@@ -1036,8 +1036,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.8.0 h1:q60HKpwt1MmGjOWgM7m5gGyXYAY3DfTSdfBdBt6ICV4=
github.com/riandyrn/otelchi v0.8.0/go.mod h1:ErTae2TG7lrOtEPFsd5/hYLOHJpkk0NNyMaeTMWxl0U=
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/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=

View File

@@ -8,6 +8,19 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [Unreleased]
## [0.9.0] - 2024-07-06
### Changed
- `WithFilter` option now support multiple filter functions, just like in [otelmux](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/v1.24.0/instrumentation/github.com/gorilla/mux/otelmux/config.go#L106-L110). ([#47])
- Upgrade `go.opentelemetry.io/otel`, `go.opentelemetry.io/otel/sdk`, & `go.opentelemetry.io/otel/trace` to `v1.28.0`. ([#49])
- Upgrade `github.com/go-chi/chi/v5` to `v5.1.0`. ([#49])
- Set the go versions for testing in both `Makefile` & `compatibility-test.yml` to `1.21` & `1.22`. ([#49])
### Removed
- Drop support for Go `<1.21`. ([#49])
## [0.8.0] - 2024-04-29
### ⚠️ Notice ⚠️
@@ -161,6 +174,8 @@ It contains instrumentation for trace and depends on:
- Example code for a basic usage.
- Apache-2.0 license.
[#49]: https://github.com/riandyrn/otelchi/pull/49
[#47]: https://github.com/riandyrn/otelchi/pull/47
[#43]: https://github.com/riandyrn/otelchi/pull/43
[#42]: https://github.com/riandyrn/otelchi/pull/42
[#41]: https://github.com/riandyrn/otelchi/pull/41
@@ -181,7 +196,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.8.0...HEAD
[Unreleased]: https://github.com/riandyrn/otelchi/compare/v0.9.0...HEAD
[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
[0.6.0]: https://github.com/riandyrn/otelchi/releases/tag/v0.6.0

View File

@@ -1 +1 @@
* @riandyrn @ilhamsyahids @mustafasegf @ProtozoaJr
* @riandyrn @ilhamsyahids @ProtozoaJr

View File

@@ -1,6 +1,6 @@
.PHONY: *
GO_VERSIONS="1.19 1.20 1.21"
GO_VERSIONS="1.21 1.22"
# This is the command that will be used to run the tests
go-test:

View File

@@ -1,14 +1,14 @@
# otelchi
[![ci](https://github.com/riandyrn/otelchi/actions/workflows/ci.yaml/badge.svg)](https://github.com/riandyrn/otelchi/actions/workflows/ci.yaml)
[![compatibility-test](https://github.com/riandyrn/otelchi/actions/workflows/compatibility-test.yaml/badge.svg)](https://github.com/riandyrn/otelchi/actions/workflows/compatibility-test.yaml)
[![Go Report Card](https://goreportcard.com/badge/github.com/riandyrn/otelchi)](https://goreportcard.com/report/github.com/riandyrn/otelchi)
[![Documentation](https://godoc.org/github.com/riandyrn/otelchi?status.svg)](https://pkg.go.dev/mod/github.com/riandyrn/otelchi)
OpenTelemetry instrumentation for [go-chi/chi](https://github.com/go-chi/chi).
Essentialy this is adaptation from [otelmux](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation/github.com/gorilla/mux/otelmux) but instead using `gorilla/mux`, we use `go-chi/chi`.
Essentially this is an adaptation from [otelmux](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation/github.com/gorilla/mux/otelmux) but instead of using `gorilla/mux`, we use `go-chi/chi`.
Currently it could only instrument traces.
Currently, this library can only instrument traces.
Contributions are welcomed!
@@ -24,4 +24,4 @@ See [examples](./examples) for details.
## Why Port This?
I was planning to make this project as part of Open Telemetry Go instrumentation project. However based on [this comment](https://github.com/open-telemetry/opentelemetry-go-contrib/pull/986#issuecomment-941280855) they no longer accept new instrumentation. This is why I maintain this project here.
I was planning to make this project as part of the Open Telemetry Go instrumentation project. However, based on [this comment](https://github.com/open-telemetry/opentelemetry-go-contrib/pull/986#issuecomment-941280855) they no longer accept new instrumentation. This is why I maintain this project here.

View File

@@ -16,7 +16,7 @@ type config struct {
Propagators propagation.TextMapPropagator
ChiRoutes chi.Routes
RequestMethodInSpanName bool
Filter func(r *http.Request) bool
Filters []Filter
TraceResponseHeaderKey string
PublicEndpointFn func(r *http.Request) bool
}
@@ -32,6 +32,10 @@ func (o optionFunc) apply(c *config) {
o(c)
}
// 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
// WithPropagators specifies propagators to use for extracting
// information from the HTTP requests. If none are specified, global
// ones will be used.
@@ -76,12 +80,15 @@ func WithRequestMethodInSpanName(isActive bool) Option {
})
}
// WithFilter is used for filtering request that should not be traced.
// This is useful for filtering health check request, etc.
// A Filter must return true if the request should be traced.
func WithFilter(filter func(r *http.Request) bool) Option {
// WithFilter adds a filter to the list of filters used by the handler.
// If any filter indicates to exclude a request then the request will not be
// traced. All filters must allow a request to be traced for a Span to be created.
// If no filters are provided then all requests are traced.
// Filters will be invoked for each processed request, it is advised to make them
// simple and fast.
func WithFilter(filter Filter) Option {
return optionFunc(func(cfg *config) {
cfg.Filter = filter
cfg.Filters = append(cfg.Filters, filter)
})
}

View File

@@ -46,7 +46,7 @@ func Middleware(serverName string, opts ...Option) func(next http.Handler) http.
handler: handler,
chiRoutes: cfg.ChiRoutes,
reqMethodInSpanName: cfg.RequestMethodInSpanName,
filter: cfg.Filter,
filters: cfg.Filters,
traceResponseHeaderKey: cfg.TraceResponseHeaderKey,
publicEndpointFn: cfg.PublicEndpointFn,
}
@@ -60,7 +60,7 @@ type traceware struct {
handler http.Handler
chiRoutes chi.Routes
reqMethodInSpanName bool
filter func(r *http.Request) bool
filters []Filter
traceResponseHeaderKey string
publicEndpointFn func(r *http.Request) bool
}
@@ -111,10 +111,14 @@ func putRRW(rrw *recordingResponseWriter) {
// ServeHTTP implements the http.Handler interface. It does the actual
// tracing of the request.
func (tw traceware) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// skip if filter returns false
if tw.filter != nil && !tw.filter(r) {
tw.handler.ServeHTTP(w, r)
return
// go through all filters if any
for _, filter := range tw.filters {
// if there is a filter that returns false, we skip tracing
// and execute next handler
if !filter(r) {
tw.handler.ServeHTTP(w, r)
return
}
}
// extract tracing header using propagator

View File

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

4
vendor/modules.txt vendored
View File

@@ -1701,8 +1701,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.8.0
## explicit; go 1.19
# github.com/riandyrn/otelchi v0.9.0
## explicit; go 1.21
github.com/riandyrn/otelchi
# github.com/rivo/uniseg v0.4.2
## explicit; go 1.18