Skip to content

Commit

Permalink
made some minor changes for middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
maurafortino committed Jan 4, 2024
1 parent 15f9f75 commit df5e337
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
5 changes: 2 additions & 3 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ type ServerHandler struct {
telemetry *HandlerTelemetry
incomingQueueDepth int64
maxOutstanding int64

now func() time.Time
now func() time.Time
}

type HandlerTelemetryIn struct {
fx.In
ErrorRequests prometheus.Counter `name:"error_request_body_counter"`
Expand Down Expand Up @@ -211,5 +209,6 @@ func New(log *zap.Logger, t *HandlerTelemetry, maxOutstanding, incomingQueueDept
telemetry: t,
maxOutstanding: maxOutstanding,
incomingQueueDepth: incomingQueueDepth,
now: time.Now,
}, nil
}
13 changes: 7 additions & 6 deletions routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,16 @@ func provideCoreOption(server string, in RoutesIn) arrangehttp.Option[http.Serve
mux := chi.NewMux()
// TODO: should probably customize things a bit
mux.Use(recovery.Middleware(recovery.WithStatusCode(555)))

options := []otelmux.Option{
otelmux.WithTracerProvider(in.Tracing.TracerProvider()),
otelmux.WithPropagators(in.Tracing.Propagator()),
}

mux.Method("POST", urlPrefix+"/notify", in.Handler)
if server == "primary" {
options := []otelmux.Option{
otelmux.WithTracerProvider(in.Tracing.TracerProvider()),
otelmux.WithPropagators(in.Tracing.Propagator()),
}
mux.Use(otelmux.Middleware("server_primary", options...),
candlelight.EchoFirstTraceNodeInfo(in.Tracing.Propagator(), true))

mux.Method("POST", urlPrefix+"/notify", in.Handler)
s.Handler = in.PrimaryMetrics.Then(mux)
} else {
s.Handler = in.AlternateMetrics.Then(mux)
Expand Down

0 comments on commit df5e337

Please sign in to comment.