Skip to content

Commit

Permalink
Drop obsolete TraceLogHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
monstermunchkin committed Nov 29, 2024
1 parent 60d9aac commit 69a518c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
8 changes: 0 additions & 8 deletions http/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ func Router() *mux.Router {
// last resort error handler
r.Use(errors.Handler())

// this second handler is needed in order to have access to data managed by the log handler from above
r.Use(tracing.TraceLogHandler(
// no tracing for these prefixes
"/metrics",
"/health",
"/debug",
))

r.Use(locale.Handler())

// report use of external dependencies
Expand Down
34 changes: 0 additions & 34 deletions maintenance/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,40 +90,6 @@ func Handler(ignoredPrefixes ...string) func(http.Handler) http.Handler {
}, ignoredPrefixes...)
}

type traceLogHandler struct {
next http.Handler
}

// Trace the service function handler execution
func (h *traceLogHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
span := sentry.TransactionFromContext(r.Context())

if span != nil {
span.SetData("req_id", log.RequestIDFromContext(r.Context()))
span.SetData("path", r.URL.Path)
span.SetData("method", r.Method)
}

ww := mutil.WrapWriter(w)

h.next.ServeHTTP(ww, r)

if span != nil {
span.SetData("bytes", ww.BytesWritten())
span.SetData("status_code", ww.Status())
}
}

// TraceLogHandler generates a tracing handler that adds logging data to existing handler.
// The tracing handler will not start traces for the list of ignoredPrefixes.
func TraceLogHandler(ignoredPrefixes ...string) func(http.Handler) http.Handler {
return util.NewIgnorePrefixMiddleware(func(next http.Handler) http.Handler {
return &traceLogHandler{
next: next,
}
}, ignoredPrefixes...)
}

// getHTTPSpanName grab needed fields from *http.Request to generate a span name for `http.server` span op.
func getHTTPSpanName(r *http.Request) string {
if r.Pattern != "" {
Expand Down

0 comments on commit 69a518c

Please sign in to comment.