Merge pull request 'fix(telemetry): db.system on SQL spans for SigNoz's service map' (#103) from fix/telemetry-db-system into main
ci / shared (push) Successful in 15s
ci / test (push) Successful in 26m53s
ci / image (push) Successful in 40s

This commit was merged in pull request #103.
This commit is contained in:
sharang committed 2026-10-29 09:55:32 +00:00
commit 4ab258c4b2
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())
}