Unistore Chore: Add database-level observability (#92266)

* add testing harness

* fix mockery and linters

* WIP

* wip

* fix transactions

* fix transaction tracing; add tracing by default

* rename package

* move WithTx to simplify logic of DB implementations

* fix potential issue with context deadline

* add db instrumentation to dbutil

* add otel tests

* improve naming

* minor fix in semantics and add comprehensive OTel testing

* fix naming

* instrument resourceVersionAtomicInc

* provide a default testing tracer

* fix docs

* fix typo in docs

* add semconv for k8s
This commit is contained in:
Diego Augusto Molina
2024-10-18 00:32:08 -03:00
committed by GitHub
parent 9125f0df20
commit 3e1f5559a6
7 changed files with 851 additions and 22 deletions
+7 -2
View File
@@ -10,11 +10,13 @@ import (
"strings"
"text/template"
"go.opentelemetry.io/otel/attribute"
"github.com/grafana/grafana/pkg/storage/unified/sql/db"
"github.com/grafana/grafana/pkg/storage/unified/sql/db/otel"
"github.com/grafana/grafana/pkg/storage/unified/sql/sqltemplate"
)
//nolint:unused
const (
otelAttrBaseKey = "dbutil_"
otelAttrTemplateNameKey = otelAttrBaseKey + "template"
@@ -22,7 +24,10 @@ const (
)
func withOtelAttrs(ctx context.Context, tmplName, dialectName string) context.Context {
return ctx // TODO: in next PR
return otel.SetAttributes(ctx,
attribute.String(otelAttrTemplateNameKey, tmplName),
attribute.String(otelAttrDialectKey, dialectName),
)
}
// SQLError is an error returned by the database, which includes additionally