Skip to content

Commit

Permalink
feat: add the already declared (and settable) tracer as a middleware (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
err0r500 committed Jul 31, 2020
1 parent 640d436 commit e24fffe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cmd/daemon/serve.go
Expand Up @@ -45,6 +45,10 @@ func servePublic(d driver.Driver, wg *sync.WaitGroup, cmd *cobra.Command, args [
n.Use(NewNegroniLoggerMiddleware(l, "public#"+c.SelfPublicURL().String()))
n.Use(sqa(cmd, d))

if tracer := d.Registry().Tracer(); tracer.IsLoaded() {
n.Use(tracer)
}

csrf := x.NewCSRFHandler(
router,
r.Writer(),
Expand Down Expand Up @@ -81,6 +85,10 @@ func serveAdmin(d driver.Driver, wg *sync.WaitGroup, cmd *cobra.Command, args []
n.Use(NewNegroniLoggerMiddleware(l, "admin#"+c.SelfAdminURL().String()))
n.Use(sqa(cmd, d))

if tracer := d.Registry().Tracer(); tracer.IsLoaded() {
n.Use(tracer)
}

n.UseHandler(router)
server := graceful.WithDefaults(&http.Server{
Addr: c.AdminListenOn(),
Expand Down
2 changes: 1 addition & 1 deletion driver/configuration/provider_viper.go
Expand Up @@ -438,7 +438,7 @@ func mustParseURLFromViper(l *logrusx.Logger, key string) *url.URL {
}

func (p *ViperProvider) TracingServiceName() string {
return viperx.GetString(p.l, "tracing.service_name", "ORY Hydra")
return viperx.GetString(p.l, "tracing.service_name", "ORY Kratos")
}

func (p *ViperProvider) TracingProvider() string {
Expand Down
4 changes: 3 additions & 1 deletion driver/registry.go
@@ -1,6 +1,8 @@
package driver

import (
"github.com/ory/x/tracing"

"github.com/gorilla/sessions"
"github.com/pkg/errors"

Expand Down Expand Up @@ -54,6 +56,7 @@ type Registry interface {
RegisterRoutes(public *x.RouterPublic, admin *x.RouterAdmin)
RegisterPublicRoutes(public *x.RouterPublic)
RegisterAdminRoutes(admin *x.RouterAdmin)
Tracer() *tracing.Tracer

x.CSRFProvider
x.WriterProvider
Expand Down Expand Up @@ -115,7 +118,6 @@ type Registry interface {

recovery.RequestPersistenceProvider
recovery.ErrorHandlerProvider
recovery.StrategyProvider
recovery.HandlerProvider
recovery.StrategyProvider

Expand Down

0 comments on commit e24fffe

Please sign in to comment.