Convert IDP service to service trace provider.

This converts the IDP service to use the service trace provider.
This commit is contained in:
Daniël Franke
2023-07-20 13:36:08 +02:00
parent 02a3bfd176
commit d2d0461375
13 changed files with 199 additions and 87 deletions
+2 -3
View File
@@ -4,14 +4,13 @@ import (
"net/http"
"strings"
idpTracing "github.com/owncloud/ocis/v2/services/idp/pkg/tracing"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
)
// Static is a middleware that serves static assets.
func Static(root string, fs http.FileSystem) func(http.Handler) http.Handler {
func Static(root string, fs http.FileSystem, tp trace.TracerProvider) func(http.Handler) http.Handler {
if !strings.HasSuffix(root, "/") {
root = root + "/"
}
@@ -28,7 +27,7 @@ func Static(root string, fs http.FileSystem) func(http.Handler) http.Handler {
spanOpts := []trace.SpanStartOption{
trace.WithSpanKind(trace.SpanKindServer),
}
ctx, span := idpTracing.TraceProvider.Tracer("idp").Start(r.Context(), "serve static asset", spanOpts...)
ctx, span := tp.Tracer("idp").Start(r.Context(), "serve static asset", spanOpts...)
defer span.End()
r = r.WithContext(ctx)