chore(unified-storage): align how we do tracing (#114998)

This commit is contained in:
Jean-Philippe Quéméner
2025-12-09 14:53:53 +01:00
committed by GitHub
parent 3e66c7ed21
commit 1f5fd1c0da
22 changed files with 62 additions and 148 deletions
+2 -11
View File
@@ -5,8 +5,6 @@ import (
"fmt"
"time"
"go.opentelemetry.io/otel/trace"
"github.com/grafana/grafana-app-sdk/logging"
"github.com/grafana/grafana/pkg/storage/unified/resource"
@@ -19,7 +17,6 @@ var (
errHistoryPollRequired = fmt.Errorf("historyPoll is required")
errListLatestRVsRequired = fmt.Errorf("listLatestRVs is required")
errBulkLockRequired = fmt.Errorf("bulkLock is required")
errTracerRequired = fmt.Errorf("tracer is required")
errLogRequired = fmt.Errorf("log is required")
errInvalidWatchBufferSize = fmt.Errorf("watchBufferSize must be greater than 0")
errInvalidPollingInterval = fmt.Errorf("pollingInterval must be greater than 0")
@@ -34,7 +31,6 @@ type pollingNotifier struct {
watchBufferSize int
log logging.Logger
tracer trace.Tracer
storageMetrics *resource.StorageMetrics
bulkLock *bulkLock
@@ -50,7 +46,6 @@ type pollingNotifierConfig struct {
watchBufferSize int
log logging.Logger
tracer trace.Tracer
storageMetrics *resource.StorageMetrics
bulkLock *bulkLock
@@ -70,9 +65,6 @@ func (cfg *pollingNotifierConfig) validate() error {
if cfg.bulkLock == nil {
return errBulkLockRequired
}
if cfg.tracer == nil {
return errTracerRequired
}
if cfg.log == nil {
return errLogRequired
}
@@ -100,7 +92,6 @@ func newPollingNotifier(cfg *pollingNotifierConfig) (*pollingNotifier, error) {
pollingInterval: cfg.pollingInterval,
watchBufferSize: cfg.watchBufferSize,
log: cfg.log,
tracer: cfg.tracer,
bulkLock: cfg.bulkLock,
listLatestRVs: cfg.listLatestRVs,
historyPoll: cfg.historyPoll,
@@ -131,7 +122,7 @@ func (p *pollingNotifier) poller(ctx context.Context, since groupResourceRV, str
case <-p.done:
return
case <-t.C:
ctx, span := p.tracer.Start(ctx, tracePrefix+"poller")
ctx, span := tracer.Start(ctx, "sql.pollingNotifier.poller")
// List the latest RVs to see if any of those are not have been seen before.
grv, err := p.listLatestRVs(ctx)
if err != nil {
@@ -174,7 +165,7 @@ func (p *pollingNotifier) poller(ctx context.Context, since groupResourceRV, str
}
func (p *pollingNotifier) poll(ctx context.Context, grp string, res string, since int64, stream chan<- *resource.WrittenEvent) (int64, error) {
ctx, span := p.tracer.Start(ctx, tracePrefix+"poll")
ctx, span := tracer.Start(ctx, "sql.pollingNotifier.poll")
defer span.End()
start := time.Now()