Tracing: Use common traceID context value for opentracing and opentelemetry (#46411) (#47786)

* 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>
(cherry picked from commit 41012af997)

Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2022-04-14 11:08:51 -05:00
committed by GitHub
parent a0ff246fcb
commit c8327d04a8
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.