chore(unified-storage): align how we do tracing (#114998)
This commit is contained in:
@@ -14,9 +14,9 @@ import (
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/lib/pq"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.opentelemetry.io/otel/trace/noop"
|
||||
"go.uber.org/atomic"
|
||||
"google.golang.org/protobuf/proto"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
@@ -35,7 +35,8 @@ import (
|
||||
"github.com/grafana/grafana/pkg/util/debouncer"
|
||||
)
|
||||
|
||||
const tracePrefix = "sql.resource."
|
||||
var tracer = otel.Tracer("github.com/grafana/grafana/pkg/storage/unified/sql")
|
||||
|
||||
const defaultPollingInterval = 100 * time.Millisecond
|
||||
const defaultWatchBufferSize = 100 // number of events to buffer in the watch stream
|
||||
const defaultPrunerHistoryLimit = 20
|
||||
@@ -56,7 +57,6 @@ type Backend interface {
|
||||
|
||||
type BackendOptions struct {
|
||||
DBProvider db.DBProvider
|
||||
Tracer trace.Tracer
|
||||
Reg prometheus.Registerer
|
||||
PollingInterval time.Duration
|
||||
WatchBufferSize int
|
||||
@@ -74,9 +74,6 @@ func NewBackend(opts BackendOptions) (Backend, error) {
|
||||
if opts.DBProvider == nil {
|
||||
return nil, errors.New("no db provider")
|
||||
}
|
||||
if opts.Tracer == nil {
|
||||
opts.Tracer = noop.NewTracerProvider().Tracer("sql-backend")
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
if opts.PollingInterval == 0 {
|
||||
@@ -90,7 +87,6 @@ func NewBackend(opts BackendOptions) (Backend, error) {
|
||||
done: ctx.Done(),
|
||||
cancel: cancel,
|
||||
log: logging.DefaultLogger.With("logger", "sql-resource-server"),
|
||||
tracer: opts.Tracer,
|
||||
reg: opts.Reg,
|
||||
dbProvider: opts.DBProvider,
|
||||
pollingInterval: opts.PollingInterval,
|
||||
@@ -114,7 +110,6 @@ type backend struct {
|
||||
|
||||
// o11y
|
||||
log logging.Logger
|
||||
tracer trace.Tracer
|
||||
reg prometheus.Registerer
|
||||
storageMetrics *resource.StorageMetrics
|
||||
|
||||
@@ -171,7 +166,6 @@ func (b *backend) initLocked(ctx context.Context) error {
|
||||
rvManager, err := NewResourceVersionManager(ResourceManagerOptions{
|
||||
Dialect: b.dialect,
|
||||
DB: b.db,
|
||||
Tracer: b.tracer,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create resource version manager: %w", err)
|
||||
@@ -264,7 +258,7 @@ func (b *backend) Stop(_ context.Context) error {
|
||||
|
||||
// GetResourceStats implements Backend.
|
||||
func (b *backend) GetResourceStats(ctx context.Context, nsr resource.NamespacedResource, minCount int) ([]resource.ResourceStats, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"GetResourceStats", trace.WithAttributes(
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.GetResourceStats", trace.WithAttributes(
|
||||
attribute.String("namespace", nsr.Namespace),
|
||||
attribute.String("group", nsr.Group),
|
||||
attribute.String("resource", nsr.Resource),
|
||||
@@ -304,7 +298,7 @@ func (b *backend) GetResourceStats(ctx context.Context, nsr resource.NamespacedR
|
||||
}
|
||||
|
||||
func (b *backend) WriteEvent(ctx context.Context, event resource.WriteEvent) (int64, error) {
|
||||
_, span := b.tracer.Start(ctx, tracePrefix+"WriteEvent")
|
||||
_, span := tracer.Start(ctx, "sql.backend.WriteEvent")
|
||||
defer span.End()
|
||||
// TODO: validate key ?
|
||||
switch event.Type {
|
||||
@@ -320,7 +314,7 @@ func (b *backend) WriteEvent(ctx context.Context, event resource.WriteEvent) (in
|
||||
}
|
||||
|
||||
func (b *backend) create(ctx context.Context, event resource.WriteEvent) (int64, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"Create")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.create")
|
||||
defer span.End()
|
||||
|
||||
folder := ""
|
||||
@@ -408,7 +402,7 @@ func IsRowAlreadyExistsError(err error) bool {
|
||||
}
|
||||
|
||||
func (b *backend) update(ctx context.Context, event resource.WriteEvent) (int64, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"Update")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.update")
|
||||
defer span.End()
|
||||
|
||||
folder := ""
|
||||
@@ -468,7 +462,7 @@ func (b *backend) update(ctx context.Context, event resource.WriteEvent) (int64,
|
||||
}
|
||||
|
||||
func (b *backend) delete(ctx context.Context, event resource.WriteEvent) (int64, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"Delete")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.delete")
|
||||
defer span.End()
|
||||
|
||||
folder := ""
|
||||
@@ -547,7 +541,7 @@ func (b *backend) checkConflict(res db.Result, key *resourcepb.ResourceKey, rv i
|
||||
}
|
||||
|
||||
func (b *backend) ReadResource(ctx context.Context, req *resourcepb.ReadRequest) *resource.BackendReadResponse {
|
||||
_, span := b.tracer.Start(ctx, tracePrefix+".Read")
|
||||
_, span := tracer.Start(ctx, "sql.backend.ReadResource")
|
||||
defer span.End()
|
||||
|
||||
// TODO: validate key ?
|
||||
@@ -580,7 +574,7 @@ func (b *backend) ReadResource(ctx context.Context, req *resourcepb.ReadRequest)
|
||||
}
|
||||
|
||||
func (b *backend) ListIterator(ctx context.Context, req *resourcepb.ListRequest, cb func(resource.ListIterator) error) (int64, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"List")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.ListIterator")
|
||||
defer span.End()
|
||||
|
||||
if err := resource.MigrateListRequestVersionMatch(req, b.log); err != nil {
|
||||
@@ -602,7 +596,7 @@ func (b *backend) ListIterator(ctx context.Context, req *resourcepb.ListRequest,
|
||||
}
|
||||
|
||||
func (b *backend) ListHistory(ctx context.Context, req *resourcepb.ListRequest, cb func(resource.ListIterator) error) (int64, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"ListHistory")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.ListHistory")
|
||||
defer span.End()
|
||||
|
||||
return b.getHistory(ctx, req, cb)
|
||||
@@ -610,7 +604,7 @@ func (b *backend) ListHistory(ctx context.Context, req *resourcepb.ListRequest,
|
||||
|
||||
// listLatest fetches the resources from the resource table.
|
||||
func (b *backend) listLatest(ctx context.Context, req *resourcepb.ListRequest, cb func(resource.ListIterator) error) (int64, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"listLatest")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.listLatest")
|
||||
defer span.End()
|
||||
|
||||
if req.NextPageToken != "" {
|
||||
@@ -724,7 +718,7 @@ func (b *backend) ListModifiedSince(ctx context.Context, key resource.Namespaced
|
||||
|
||||
// listAtRevision fetches the resources from the resource_history table at a specific revision.
|
||||
func (b *backend) listAtRevision(ctx context.Context, req *resourcepb.ListRequest, cb func(resource.ListIterator) error) (int64, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"listAtRevision")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.listAtRevision")
|
||||
defer span.End()
|
||||
|
||||
// Get the RV
|
||||
@@ -784,7 +778,7 @@ func (b *backend) listAtRevision(ctx context.Context, req *resourcepb.ListReques
|
||||
|
||||
// readHistory fetches the resource history from the resource_history table.
|
||||
func (b *backend) readHistory(ctx context.Context, key *resourcepb.ResourceKey, rv int64) *resource.BackendReadResponse {
|
||||
_, span := b.tracer.Start(ctx, tracePrefix+".ReadHistory")
|
||||
_, span := tracer.Start(ctx, "sql.backend.readHistory")
|
||||
defer span.End()
|
||||
|
||||
readReq := &sqlResourceHistoryReadRequest{
|
||||
@@ -815,7 +809,7 @@ func (b *backend) readHistory(ctx context.Context, key *resourcepb.ResourceKey,
|
||||
|
||||
// getHistory fetches the resource history from the resource_history table.
|
||||
func (b *backend) getHistory(ctx context.Context, req *resourcepb.ListRequest, cb func(resource.ListIterator) error) (int64, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"getHistory")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.getHistory")
|
||||
defer span.End()
|
||||
listReq := sqlGetHistoryRequest{
|
||||
SQLTemplate: sqltemplate.New(b.dialect),
|
||||
@@ -903,7 +897,7 @@ func (b *backend) WatchWriteEvents(ctx context.Context) (<-chan *resource.Writte
|
||||
|
||||
// listLatestRVs returns the latest resource version for each (Group, Resource) pair.
|
||||
func (b *backend) listLatestRVs(ctx context.Context) (groupResourceRV, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"listLatestRVs")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.listLatestRVs")
|
||||
defer span.End()
|
||||
var grvs []*groupResourceVersion
|
||||
err := b.db.WithTx(ctx, ReadCommittedRO, func(ctx context.Context, tx db.Tx) error {
|
||||
@@ -932,7 +926,7 @@ func (b *backend) listLatestRVs(ctx context.Context) (groupResourceRV, error) {
|
||||
|
||||
// fetchLatestRV returns the current maximum RV in the resource table
|
||||
func (b *backend) fetchLatestRV(ctx context.Context, x db.ContextExecer, d sqltemplate.Dialect, group, resource string) (int64, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"fetchLatestRV")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.fetchLatestRV")
|
||||
defer span.End()
|
||||
res, err := dbutil.QueryRow(ctx, x, sqlResourceVersionGet, sqlResourceVersionGetRequest{
|
||||
SQLTemplate: sqltemplate.New(d),
|
||||
@@ -951,7 +945,7 @@ func (b *backend) fetchLatestRV(ctx context.Context, x db.ContextExecer, d sqlte
|
||||
|
||||
// fetchLatestHistoryRV returns the current maximum RV in the resource_history table
|
||||
func (b *backend) fetchLatestHistoryRV(ctx context.Context, x db.ContextExecer, d sqltemplate.Dialect, key *resourcepb.ResourceKey, eventType resourcepb.WatchEvent_Type) (int64, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"fetchLatestHistoryRV")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.fetchLatestHistoryRV")
|
||||
defer span.End()
|
||||
res, err := dbutil.QueryRow(ctx, x, sqlResourceHistoryReadLatestRV, sqlResourceHistoryReadLatestRVRequest{
|
||||
SQLTemplate: sqltemplate.New(d),
|
||||
@@ -973,7 +967,7 @@ func (b *backend) fetchLatestHistoryRV(ctx context.Context, x db.ContextExecer,
|
||||
const limitLastImportTimesDeletion = 1 * time.Hour
|
||||
|
||||
func (b *backend) GetResourceLastImportTimes(ctx context.Context) iter.Seq2[resource.ResourceLastImportTime, error] {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"GetLastImportTimes")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.GetResourceLastImportTimes")
|
||||
defer span.End()
|
||||
|
||||
// Delete old entries, if configured, and if enough time has passed since last deletion.
|
||||
|
||||
@@ -27,7 +27,7 @@ func (b *backend) SupportsSignedURLs() bool {
|
||||
}
|
||||
|
||||
func (b *backend) PutResourceBlob(ctx context.Context, req *resourcepb.PutBlobRequest) (*resourcepb.PutBlobResponse, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"PutResourceBlob")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.PutResourceBlob")
|
||||
defer span.End()
|
||||
|
||||
if req.Method == resourcepb.PutBlobRequest_HTTP {
|
||||
@@ -83,7 +83,7 @@ func (b *backend) PutResourceBlob(ctx context.Context, req *resourcepb.PutBlobRe
|
||||
}
|
||||
|
||||
func (b *backend) GetResourceBlob(ctx context.Context, key *resourcepb.ResourceKey, info *utils.BlobInfo, mustProxy bool) (*resourcepb.GetBlobResponse, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"GetResourceBlob")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.GetResourceBlob")
|
||||
defer span.End()
|
||||
|
||||
if info == nil {
|
||||
|
||||
@@ -28,7 +28,6 @@ func newNotifier(b *backend) (eventNotifier, error) {
|
||||
pollingInterval: b.pollingInterval,
|
||||
watchBufferSize: b.watchBufferSize,
|
||||
log: b.log,
|
||||
tracer: b.tracer,
|
||||
bulkLock: b.bulkLock,
|
||||
listLatestRVs: b.listLatestRVs,
|
||||
storageMetrics: b.storageMetrics,
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
|
||||
"github.com/grafana/grafana-app-sdk/logging"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.opentelemetry.io/otel/trace/noop"
|
||||
|
||||
"github.com/grafana/grafana/pkg/storage/unified/resourcepb"
|
||||
"github.com/grafana/grafana/pkg/storage/unified/sql/sqltemplate"
|
||||
@@ -30,7 +29,6 @@ func TestPollingNotifierConfig(t *testing.T) {
|
||||
},
|
||||
listLatestRVs: func(ctx context.Context) (groupResourceRV, error) { return nil, nil },
|
||||
bulkLock: &bulkLock{},
|
||||
tracer: noop.NewTracerProvider().Tracer("test"),
|
||||
log: &logging.NoOpLogger{},
|
||||
watchBufferSize: 10,
|
||||
pollingInterval: time.Second,
|
||||
@@ -44,7 +42,6 @@ func TestPollingNotifierConfig(t *testing.T) {
|
||||
config: &pollingNotifierConfig{
|
||||
listLatestRVs: func(ctx context.Context) (groupResourceRV, error) { return nil, nil },
|
||||
bulkLock: &bulkLock{},
|
||||
tracer: noop.NewTracerProvider().Tracer("test"),
|
||||
log: &logging.NoOpLogger{},
|
||||
watchBufferSize: 10,
|
||||
pollingInterval: time.Second,
|
||||
@@ -60,7 +57,6 @@ func TestPollingNotifierConfig(t *testing.T) {
|
||||
return nil, nil
|
||||
},
|
||||
bulkLock: &bulkLock{},
|
||||
tracer: noop.NewTracerProvider().Tracer("test"),
|
||||
log: &logging.NoOpLogger{},
|
||||
watchBufferSize: 10,
|
||||
pollingInterval: time.Second,
|
||||
@@ -76,7 +72,6 @@ func TestPollingNotifierConfig(t *testing.T) {
|
||||
return nil, nil
|
||||
},
|
||||
listLatestRVs: func(ctx context.Context) (groupResourceRV, error) { return nil, nil },
|
||||
tracer: noop.NewTracerProvider().Tracer("test"),
|
||||
log: &logging.NoOpLogger{},
|
||||
watchBufferSize: 10,
|
||||
pollingInterval: time.Second,
|
||||
@@ -85,22 +80,6 @@ func TestPollingNotifierConfig(t *testing.T) {
|
||||
},
|
||||
expectedErr: errBulkLockRequired,
|
||||
},
|
||||
{
|
||||
name: "missing tracer",
|
||||
config: &pollingNotifierConfig{
|
||||
historyPoll: func(ctx context.Context, grp string, res string, since int64) ([]*historyPollResponse, error) {
|
||||
return nil, nil
|
||||
},
|
||||
listLatestRVs: func(ctx context.Context) (groupResourceRV, error) { return nil, nil },
|
||||
bulkLock: &bulkLock{},
|
||||
log: &logging.NoOpLogger{},
|
||||
watchBufferSize: 10,
|
||||
pollingInterval: time.Second,
|
||||
done: make(chan struct{}),
|
||||
dialect: sqltemplate.SQLite,
|
||||
},
|
||||
expectedErr: errTracerRequired,
|
||||
},
|
||||
{
|
||||
name: "missing logger",
|
||||
config: &pollingNotifierConfig{
|
||||
@@ -109,7 +88,6 @@ func TestPollingNotifierConfig(t *testing.T) {
|
||||
},
|
||||
listLatestRVs: func(ctx context.Context) (groupResourceRV, error) { return nil, nil },
|
||||
bulkLock: &bulkLock{},
|
||||
tracer: noop.NewTracerProvider().Tracer("test"),
|
||||
watchBufferSize: 10,
|
||||
pollingInterval: time.Second,
|
||||
done: make(chan struct{}),
|
||||
@@ -125,7 +103,6 @@ func TestPollingNotifierConfig(t *testing.T) {
|
||||
},
|
||||
listLatestRVs: func(ctx context.Context) (groupResourceRV, error) { return nil, nil },
|
||||
bulkLock: &bulkLock{},
|
||||
tracer: noop.NewTracerProvider().Tracer("test"),
|
||||
log: &logging.NoOpLogger{},
|
||||
watchBufferSize: 0,
|
||||
pollingInterval: time.Second,
|
||||
@@ -142,7 +119,6 @@ func TestPollingNotifierConfig(t *testing.T) {
|
||||
},
|
||||
listLatestRVs: func(ctx context.Context) (groupResourceRV, error) { return nil, nil },
|
||||
bulkLock: &bulkLock{},
|
||||
tracer: noop.NewTracerProvider().Tracer("test"),
|
||||
log: &logging.NoOpLogger{},
|
||||
watchBufferSize: 10,
|
||||
pollingInterval: 0,
|
||||
@@ -159,7 +135,6 @@ func TestPollingNotifierConfig(t *testing.T) {
|
||||
},
|
||||
listLatestRVs: func(ctx context.Context) (groupResourceRV, error) { return nil, nil },
|
||||
bulkLock: &bulkLock{},
|
||||
tracer: noop.NewTracerProvider().Tracer("test"),
|
||||
log: &logging.NoOpLogger{},
|
||||
watchBufferSize: 10,
|
||||
pollingInterval: time.Second,
|
||||
@@ -175,7 +150,6 @@ func TestPollingNotifierConfig(t *testing.T) {
|
||||
},
|
||||
listLatestRVs: func(ctx context.Context) (groupResourceRV, error) { return nil, nil },
|
||||
bulkLock: &bulkLock{},
|
||||
tracer: noop.NewTracerProvider().Tracer("test"),
|
||||
log: &logging.NoOpLogger{},
|
||||
watchBufferSize: 10,
|
||||
pollingInterval: time.Second,
|
||||
@@ -255,7 +229,6 @@ func TestPollingNotifier(t *testing.T) {
|
||||
pollingInterval: 10 * time.Millisecond,
|
||||
watchBufferSize: 10,
|
||||
log: &logging.NoOpLogger{},
|
||||
tracer: noop.NewTracerProvider().Tracer("test"),
|
||||
bulkLock: &bulkLock{},
|
||||
listLatestRVs: listLatestRVs,
|
||||
historyPoll: historyPoll,
|
||||
@@ -309,7 +282,6 @@ func TestPollingNotifier(t *testing.T) {
|
||||
pollingInterval: 10 * time.Millisecond,
|
||||
watchBufferSize: 10,
|
||||
log: &logging.NoOpLogger{},
|
||||
tracer: noop.NewTracerProvider().Tracer("test"),
|
||||
bulkLock: &bulkLock{},
|
||||
listLatestRVs: listLatestRVs,
|
||||
historyPoll: historyPoll,
|
||||
@@ -343,7 +315,6 @@ func TestPollingNotifier(t *testing.T) {
|
||||
pollingInterval: 10 * time.Millisecond,
|
||||
watchBufferSize: 10,
|
||||
log: &logging.NoOpLogger{},
|
||||
tracer: noop.NewTracerProvider().Tracer("test"),
|
||||
bulkLock: &bulkLock{},
|
||||
listLatestRVs: func(ctx context.Context) (groupResourceRV, error) { return nil, nil },
|
||||
historyPoll: func(ctx context.Context, grp string, res string, since int64) ([]*historyPollResponse, error) {
|
||||
@@ -380,7 +351,6 @@ func TestPollingNotifier(t *testing.T) {
|
||||
pollingInterval: 10 * time.Millisecond,
|
||||
watchBufferSize: 10,
|
||||
log: &logging.NoOpLogger{},
|
||||
tracer: noop.NewTracerProvider().Tracer("test"),
|
||||
bulkLock: &bulkLock{},
|
||||
listLatestRVs: func(ctx context.Context) (groupResourceRV, error) { return nil, nil },
|
||||
historyPoll: func(ctx context.Context, grp string, res string, since int64) ([]*historyPollResponse, error) {
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.opentelemetry.io/otel/trace/noop"
|
||||
|
||||
"github.com/grafana/grafana/pkg/storage/unified/resourcepb"
|
||||
"github.com/grafana/grafana/pkg/storage/unified/sql/db"
|
||||
@@ -66,7 +65,6 @@ const (
|
||||
type resourceVersionManager struct {
|
||||
dialect sqltemplate.Dialect
|
||||
db db.DB
|
||||
tracer trace.Tracer
|
||||
batchMu sync.RWMutex
|
||||
batchChMap map[string]chan *writeOp
|
||||
|
||||
@@ -98,7 +96,6 @@ type ResourceManagerOptions struct {
|
||||
DB db.DB // The database to use
|
||||
MaxBatchSize int // The maximum number of operations to batch together
|
||||
MaxBatchWaitTime time.Duration // The maximum time to wait for a batch to be ready
|
||||
Tracer trace.Tracer // The tracer to use for tracing
|
||||
}
|
||||
|
||||
// NewResourceVersionManager creates a new ResourceVersionManager
|
||||
@@ -109,9 +106,6 @@ func NewResourceVersionManager(opts ResourceManagerOptions) (*resourceVersionMan
|
||||
if opts.MaxBatchWaitTime == 0 {
|
||||
opts.MaxBatchWaitTime = defaultMaxBatchWaitTime
|
||||
}
|
||||
if opts.Tracer == nil {
|
||||
opts.Tracer = noop.NewTracerProvider().Tracer("resource-version-manager")
|
||||
}
|
||||
if opts.Dialect == nil {
|
||||
return nil, errors.New("dialect is required")
|
||||
}
|
||||
@@ -121,7 +115,6 @@ func NewResourceVersionManager(opts ResourceManagerOptions) (*resourceVersionMan
|
||||
return &resourceVersionManager{
|
||||
dialect: opts.Dialect,
|
||||
db: opts.DB,
|
||||
tracer: opts.Tracer,
|
||||
batchChMap: make(map[string]chan *writeOp),
|
||||
maxBatchSize: opts.MaxBatchSize,
|
||||
maxBatchWaitTime: opts.MaxBatchWaitTime,
|
||||
@@ -143,7 +136,7 @@ func (m *resourceVersionManager) ExecWithRV(ctx context.Context, key *resourcepb
|
||||
}))
|
||||
defer timer.ObserveDuration()
|
||||
|
||||
ctx, span := m.tracer.Start(ctx, "sql.rvmanager.ExecWithRV")
|
||||
ctx, span := tracer.Start(ctx, "sql.resourceVersionManager.ExecWithRV")
|
||||
defer span.End()
|
||||
|
||||
span.SetAttributes(
|
||||
@@ -223,7 +216,7 @@ func (m *resourceVersionManager) startBatchProcessor(group, resource string) {
|
||||
}
|
||||
|
||||
func (m *resourceVersionManager) execBatch(ctx context.Context, group, resource string, batch []writeOp) {
|
||||
ctx, span := m.tracer.Start(ctx, "sql.rvmanager.execBatch")
|
||||
ctx, span := tracer.Start(ctx, "sql.resourceVersionManager.execBatch")
|
||||
defer span.End()
|
||||
|
||||
// Add batch size attribute
|
||||
|
||||
@@ -18,7 +18,7 @@ var _ resourcepb.ResourceIndexServer = &backend{}
|
||||
// GetStats implements resource.ResourceIndexServer.
|
||||
// This will use the SQL index to count values
|
||||
func (b *backend) GetStats(ctx context.Context, req *resourcepb.ResourceStatsRequest) (*resourcepb.ResourceStatsResponse, error) {
|
||||
ctx, span := b.tracer.Start(ctx, tracePrefix+"GetStats")
|
||||
ctx, span := tracer.Start(ctx, "sql.backend.GetStats")
|
||||
defer span.End()
|
||||
|
||||
sreq := &sqlStatsRequest{
|
||||
|
||||
@@ -70,7 +70,7 @@ func NewResourceServer(opts ServerOptions) (resource.ResourceServer, error) {
|
||||
SecureValues: opts.SecureValues,
|
||||
}
|
||||
if opts.AccessClient != nil {
|
||||
serverOptions.AccessClient = resource.NewAuthzLimitedClient(opts.AccessClient, resource.AuthzOptions{Tracer: opts.Tracer, Registry: opts.Reg})
|
||||
serverOptions.AccessClient = resource.NewAuthzLimitedClient(opts.AccessClient, resource.AuthzOptions{Registry: opts.Reg})
|
||||
}
|
||||
// Support local file blob
|
||||
if strings.HasPrefix(serverOptions.Blob.URL, "./data/") {
|
||||
@@ -102,7 +102,6 @@ func NewResourceServer(opts ServerOptions) (resource.ResourceServer, error) {
|
||||
|
||||
backend, err := NewBackend(BackendOptions{
|
||||
DBProvider: eDB,
|
||||
Tracer: opts.Tracer,
|
||||
Reg: opts.Reg,
|
||||
IsHA: isHA,
|
||||
storageMetrics: opts.StorageMetrics,
|
||||
|
||||
@@ -260,7 +260,7 @@ func (s *service) starting(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
searchOptions, err := search.NewSearchOptions(s.features, s.cfg, s.tracing, s.docBuilders, s.indexMetrics, s.OwnsIndex)
|
||||
searchOptions, err := search.NewSearchOptions(s.features, s.cfg, s.docBuilders, s.indexMetrics, s.OwnsIndex)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ func TestIntegrationSearchAndStorage(t *testing.T) {
|
||||
search, err := search.NewBleveBackend(search.BleveOptions{
|
||||
FileThreshold: 0,
|
||||
Root: t.TempDir(),
|
||||
}, tracing.NewNoopTracerService(), nil)
|
||||
}, nil)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, search)
|
||||
t.Cleanup(search.Stop)
|
||||
|
||||
Reference in New Issue
Block a user