Instrumentation: Add examplars for request histograms (#29357)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
This commit is contained in:
@@ -16,15 +16,13 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/uber/jaeger-client-go"
|
||||
cw "github.com/weaveworks/common/middleware"
|
||||
"gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
@@ -63,7 +61,7 @@ func Logger() macaron.Handler {
|
||||
"referer", req.Referer(),
|
||||
}
|
||||
|
||||
traceID, exist := extractTraceID(ctxTyped.Req.Request.Context())
|
||||
traceID, exist := cw.ExtractTraceID(ctxTyped.Req.Request.Context())
|
||||
if exist {
|
||||
logParams = append(logParams, "traceID", traceID)
|
||||
}
|
||||
@@ -76,16 +74,3 @@ func Logger() macaron.Handler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func extractTraceID(ctx context.Context) (string, bool) {
|
||||
sp := opentracing.SpanFromContext(ctx)
|
||||
if sp == nil {
|
||||
return "", false
|
||||
}
|
||||
sctx, ok := sp.Context().(jaeger.SpanContext)
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
|
||||
return sctx.TraceID().String(), true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user