mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-18 05:47:32 +00:00
b3f68c8f48
* add tracing interceptors to login and oidc * add some tracing spans * trace login calls * add some spans * add some spans (change password) * add some more tracing in oauth/oidc * revert org exists * Merge branch 'master' into http-tracing # Conflicts: # internal/api/oidc/auth_request.go # internal/api/oidc/client.go # internal/auth/repository/eventsourcing/eventstore/auth_request.go # internal/auth/repository/eventsourcing/eventstore/user.go # internal/authz/repository/eventsourcing/eventstore/token_verifier.go # internal/authz/repository/eventsourcing/view/token.go # internal/user/repository/eventsourcing/eventstore.go
33 lines
651 B
Go
33 lines
651 B
Go
package tracing
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
"go.opencensus.io/plugin/ochttp"
|
|
"go.opencensus.io/trace"
|
|
)
|
|
|
|
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
|
|
}
|
|
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
|
|
},
|
|
}
|
|
}
|