Skip to content

Commit

Permalink
fix: use correct tracer in middleware (#3567)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr authored Jul 10, 2023
1 parent 42a9615 commit 807cbd2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/server/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import (
"sync"
"time"

"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"

"github.com/ory/x/otelx/semconv"

"github.com/ory/x/servicelocatorx"

"github.com/ory/x/corsx"
Expand Down Expand Up @@ -204,6 +208,7 @@ func setup(ctx context.Context, d driver.Registry, cmd *cobra.Command) (admin *h
adminLogger = adminLogger.ExcludePaths(healthx.AliveCheckPath, healthx.ReadyCheckPath, "/admin"+prometheus.MetricsPrometheusPath)
}

adminmw.UseFunc(semconv.Middleware)
adminmw.Use(adminLogger)
adminmw.Use(d.PrometheusManager())

Expand All @@ -215,6 +220,7 @@ func setup(ctx context.Context, d driver.Registry, cmd *cobra.Command) (admin *h
publicLogger.ExcludePaths(healthx.AliveCheckPath, healthx.ReadyCheckPath)
}

publicmw.UseFunc(semconv.Middleware)
publicmw.Use(publicLogger)
publicmw.Use(d.PrometheusManager())

Expand Down Expand Up @@ -307,7 +313,7 @@ func serve(
defer wg.Done()

if tracer := d.Tracer(cmd.Context()); tracer.IsLoaded() {
handler = otelx.TraceHandler(handler)
handler = otelx.TraceHandler(handler, otelhttp.WithTracerProvider(tracer.Provider()))
}

var tlsConfig *tls.Config
Expand Down

0 comments on commit 807cbd2

Please sign in to comment.