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:
Silvan
2020-11-20 07:57:39 +01:00
committed by GitHub
parent fcf81bed5f
commit 168242e725
47 changed files with 412 additions and 796 deletions
+20 -21
View File
@@ -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()
}