@@ -50,6 +50,22 @@ func NewTracingMiddleware(
5050 "http.server.request.duration" ,
5151 metric .WithDescription ("Duration of HTTP server requests" ),
5252 metric .WithUnit ("s" ),
53+ metric .WithExplicitBucketBoundaries (
54+ 0.005 ,
55+ 0.01 ,
56+ 0.025 ,
57+ 0.05 ,
58+ 0.075 ,
59+ 0.1 ,
60+ 0.25 ,
61+ 0.5 ,
62+ 0.75 ,
63+ 1 ,
64+ 2.5 ,
65+ 5 ,
66+ 7.5 ,
67+ 10 ,
68+ ),
5369 )
5470 if err != nil {
5571 panic (fmt .Errorf ("failed to create http.server.request.duration metric: %w" , err ))
@@ -133,8 +149,10 @@ func (tm *tracingMiddleware) ServeHTTP( //nolint:gocognit,cyclop,funlen,maintidx
133149 }
134150
135151 requestID := getRequestID (r )
136- logger := tm .Exporters .Logger .With (slog .String ("request_id" , requestID ))
137- httpLogger := logger .With (slog .String ("type" , "http-log" ))
152+ logger := tm .Exporters .Logger .With (
153+ slog .String ("request_id" , requestID ),
154+ slog .String ("type" , "http-log" ),
155+ )
138156 isDebug := logger .Enabled (ctx , slog .LevelDebug )
139157
140158 if tm .Options .CustomAttributesFunc != nil {
@@ -253,7 +271,7 @@ func (tm *tracingMiddleware) ServeHTTP( //nolint:gocognit,cyclop,funlen,maintidx
253271
254272 if statusCode >= http .StatusBadRequest {
255273 span .SetStatus (codes .Error , description )
256- httpLogger .LogAttrs (ctx , slog .LevelError , description , logAttrs ... )
274+ logger .LogAttrs (ctx , slog .LevelError , description , logAttrs ... )
257275
258276 return
259277 }
@@ -273,7 +291,7 @@ func (tm *tracingMiddleware) ServeHTTP( //nolint:gocognit,cyclop,funlen,maintidx
273291 logger .LogAttrs (ctx , successLevel , http .StatusText (statusCode ), logAttrs ... )
274292 }
275293
276- if isDebug && r .Body != nil &&
294+ if isDebug && r .Body != nil && r . Body != http . NoBody &&
277295 otelutils .IsContentTypeDebuggable (r .Header .Get (contentTypeHeader )) {
278296 bodyStr , err := debugRequestBody (ww , r , logger )
279297 if err != nil {
0 commit comments