* add opentracing section and otelCollectorEndpoint * initialize OTLP exporter * pkg/controller: changes for context propagation * pkg/executor: changes for context propagation * pkg/fetcher: changes for context propagation * pkg/router: changes for context propagation * pkg/storagesvc: changes for context propagation * set no default value for otel collector endpoint * update readme and add notes to charts * move common code to pkg/utils/otel * adding fn and env as attributes * don't use otelhttp transport for websocket * URL ignore with common filter UrlsToIgnore Note: The web socket example does not work when using OTEL HTTP. Here is an issue related to that on open-telemetry/opentelemetry-js-contrib. Signed-off-by: Gaurav Gahlot <gauravgahlot0107@gmail.com> Co-authored-by: Sanket Sudake <sanketsudake@gmail.com>
32 lines
687 B
Go
32 lines
687 B
Go
package otel
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
|
)
|
|
|
|
func UrlsToIgnore(ignoreEndpoints ...string) func(r *http.Request) bool {
|
|
return func(r *http.Request) bool {
|
|
for _, ignore := range ignoreEndpoints {
|
|
if strings.HasPrefix(r.URL.Path, ignore) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
}
|
|
|
|
func GetHandlerWithOTEL(h http.Handler, name string, filter ...otelhttp.Filter) http.Handler {
|
|
opts := []otelhttp.Option{
|
|
otelhttp.WithMessageEvents(otelhttp.ReadEvents, otelhttp.WriteEvents),
|
|
}
|
|
|
|
for _, f := range filter {
|
|
opts = append(opts, otelhttp.WithFilter(f))
|
|
}
|
|
|
|
return otelhttp.NewHandler(h, name, opts...)
|
|
}
|