mirror of
https://github.com/3ybactuk/marketplace-go-service-project.git
synced 2025-10-30 14:03:45 +03:00
[hw-7] add metrics, tracing
This commit is contained in:
17
cart/internal/infra/http/middlewares/tracing.go
Normal file
17
cart/internal/infra/http/middlewares/tracing.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"route256/cart/internal/infra/tracing"
|
||||
)
|
||||
|
||||
func NewTracingMiddleware(h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := tracing.Tracer().Start(r.Context(),
|
||||
r.Method+" "+r.URL.Path)
|
||||
defer span.End()
|
||||
|
||||
h.ServeHTTP(w, r.WithContext(ctx))
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user