mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 03:54:21 +00:00
168242e725
* 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
32 lines
767 B
Go
32 lines
767 B
Go
package tracing
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
http_trace "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
|
)
|
|
|
|
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 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()
|
|
}
|