mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Tracing: Use common traceID context value for opentracing and opentelemetry (#46411)
* use common traceID context value for opentracing and opentelemetry * support sampled trace IDs as well * inject traceID into NormalResponse on errors * Finally the test passed * fix the test * fix linter * change the function parameter Co-authored-by: Ying WANG <ying.wang@grafana.com>
This commit is contained in:
@@ -25,7 +25,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
cw "github.com/weaveworks/common/tracing"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -98,8 +97,8 @@ func (h *ContextHandler) Middleware(mContext *web.Context) {
|
||||
mContext.Req = mContext.Req.WithContext(context.WithValue(mContext.Req.Context(), reqContextKey{}, reqContext))
|
||||
mContext.Map(mContext.Req)
|
||||
|
||||
traceID, exists := cw.ExtractTraceID(mContext.Req.Context())
|
||||
if exists {
|
||||
traceID := tracing.TraceIDFromContext(mContext.Req.Context(), false)
|
||||
if traceID != "" {
|
||||
reqContext.Logger = reqContext.Logger.New("traceID", traceID)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user