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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user