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:
committed by
Ralf Haferkamp
parent
e3176e6f98
commit
7eb69d5142
+17
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
* @riandyrn @ilhamsyahids @mustafasegf @ProtozoaJr
|
||||
* @riandyrn @ilhamsyahids @ProtozoaJr
|
||||
+1
-1
@@ -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:
|
||||
|
||||
+4
-4
@@ -1,14 +1,14 @@
|
||||
# otelchi
|
||||
|
||||
[](https://github.com/riandyrn/otelchi/actions/workflows/ci.yaml)
|
||||
[](https://github.com/riandyrn/otelchi/actions/workflows/compatibility-test.yaml)
|
||||
[](https://goreportcard.com/report/github.com/riandyrn/otelchi)
|
||||
[](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.
|
||||
|
||||
+13
-6
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -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
|
||||
|
||||
+1
-1
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user