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:
Serge Zaitsev
2022-04-14 17:54:49 +02:00
committed by GitHub
co-authored by Ying WANG
parent ab4c7f14aa
commit 41012af997
16 changed files with 140 additions and 78 deletions
+1 -2
View File
@@ -16,7 +16,6 @@ import (
"github.com/lib/pq"
"github.com/mattn/go-sqlite3"
"github.com/prometheus/client_golang/prometheus"
cw "github.com/weaveworks/common/tracing"
"xorm.io/core"
)
@@ -83,7 +82,7 @@ func (h *databaseQueryWrapper) instrument(ctx context.Context, status string, qu
elapsed := time.Since(begin)
histogram := databaseQueryHistogram.WithLabelValues(status)
if traceID, ok := cw.ExtractSampledTraceID(ctx); ok {
if traceID := tracing.TraceIDFromContext(ctx, true); traceID != "" {
// Need to type-convert the Observer to an
// ExemplarObserver. This will always work for a
// HistogramVec.