mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-25 22:08:46 +00:00
fix(tracing): from opencensus to opentelemetry (#937)
* refactor: switch from opencensus to opentelemetry * tempo works as designed nooooot * fix: log traceids * with grafana agent * fix: http tracing * fix: cleanup files * chore: remove todo * fix: bad test * fix: ignore methods in grpc interceptors * fix: remove test log * clean up * typo * fix(config): configure tracing endpoint * fix(span): add error id to span
This commit is contained in:
@@ -4,29 +4,28 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"go.opencensus.io/plugin/ochttp"
|
||||
"go.opencensus.io/trace"
|
||||
http_trace "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
||||
)
|
||||
|
||||
func TraceHandler(handler http.Handler, ignoredEndpoints ...string) http.Handler {
|
||||
return &ochttp.Handler{
|
||||
Handler: handler,
|
||||
FormatSpanName: func(r *http.Request) string {
|
||||
host := r.URL.Host
|
||||
if host == "" {
|
||||
host = r.Host
|
||||
func shouldNotIgnore(endpoints ...string) func(r *http.Request) bool {
|
||||
return func(r *http.Request) bool {
|
||||
for _, endpoint := range endpoints {
|
||||
if strings.HasPrefix(r.URL.RequestURI(), endpoint) {
|
||||
return false
|
||||
}
|
||||
return host + r.URL.Path
|
||||
},
|
||||
|
||||
StartOptions: trace.StartOptions{Sampler: Sampler()},
|
||||
IsHealthEndpoint: func(r *http.Request) bool {
|
||||
for _, endpoint := range ignoredEndpoints {
|
||||
if strings.HasPrefix(r.URL.RequestURI(), endpoint) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
},
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func TraceHandler(handler http.Handler, ignoredEndpoints ...string) http.Handler {
|
||||
return http_trace.NewHandler(handler,
|
||||
"zitadel",
|
||||
http_trace.WithFilter(shouldNotIgnore(ignoredEndpoints...)),
|
||||
http_trace.WithPublicEndpoint(),
|
||||
http_trace.WithSpanNameFormatter(spanNameFormatter))
|
||||
}
|
||||
|
||||
func spanNameFormatter(_ string, r *http.Request) string {
|
||||
return r.Host + r.URL.EscapedPath()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user