fix(telemetry): db.system on SQL spans for SigNoz's service map #103
No files matched your search
@@ -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)),
|
||||
))
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user