build(deps): bump github.com/riandyrn/otelchi from 0.7.0 to 0.8.0
Bumps [github.com/riandyrn/otelchi](https://github.com/riandyrn/otelchi) from 0.7.0 to 0.8.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.7.0...v0.8.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:
+72
-26
@@ -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
|
||||
|
||||
+1
-1
@@ -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:
|
||||
|
||||
+42
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
+31
-5
@@ -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
|
||||
|
||||
+1
-1
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user