fix(telemetry): db.system on SQL spans for SigNoz's service map
ci / shared (pull_request) Successful in 12s
ci / test (pull_request) Successful in 25m2s
ci / image (pull_request) Skipped

The service map draws database nodes from the pre-1.26 db.system key
(dependency_graph_minutes_db_calls_mv_v2); the spans set only
db.system.name, so the registry's Postgres never appeared on the map.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-10-29 10:54:35 +01:00
1 parent 7d3e4a656d
commit 81f291b81e
2 files changed
+6

No files matched your search

+3
View File
@@ -26,6 +26,9 @@ func (QueryTracer) TraceQueryStart(ctx context.Context, _ *pgx.Conn, data pgx.Tr
op := operation(data.SQL)
ctx, span := tracer().Start(ctx, "db "+op, trace.WithSpanKind(trace.SpanKindClient), trace.WithAttributes(
attribute.String("db.system.name", "postgresql"),
// The pre-1.26 key as well: SigNoz's service map draws database nodes
// from db.system (dependency_graph_minutes_db_calls_mv_v2).
attribute.String("db.system", "postgresql"),
attribute.String("db.operation.name", op),
attribute.String("db.query.text", truncate(strings.TrimSpace(data.SQL), maxStatement)),
))
+3
View File
@@ -290,6 +290,9 @@ func TestQueryTracer(t *testing.T) {
if spans[0].Name() != "db SELECT" {
t.Errorf("name = %q", spans[0].Name())
}
if v, _ := attr(spans[0], "db.system"); v.AsString() != "postgresql" {
t.Errorf("db.system = %q, the service map needs it", v.AsString())
}
if v, _ := attr(spans[0], "db.query.text"); v.AsString() != "select id from tenants where slug = $1" {
t.Errorf("db.query.text = %q", v.AsString())
}