open-telemetry / opentelemetry-go-instrumentation

OpenTelemetry Auto Instrumentation using eBPF
https://opentelemetry.io
Apache License 2.0
528 stars 81 forks source link

Audit and update `database/sql` instrumentation to comply with SQL semantic conventions #743

Open damemi opened 7 months ago

damemi commented 7 months ago

https://github.com/open-telemetry/semantic-conventions/blob/a04a1f4ba413d0a1f137c223fc243ea14fdcd89b/docs/database/sql.md

damemi commented 3 months ago

Latest semconv: https://github.com/open-telemetry/semantic-conventions/blob/21b8f4620d2029fe8abb98a4a06655da3232d11d/docs/database/sql.md

Required attributes:

Client calls semconv: https://github.com/open-telemetry/semantic-conventions/blob/21b8f4620d2029fe8abb98a4a06655da3232d11d/docs/database/database-spans.md

Name

Database spans MUST follow the overall guidelines for span names.

The span name SHOULD be {db.operation.name} {target} if there is a (low-cardinality) {db.operation.name} available (see below for the exact definition of the {target} placeholder).

If there is no (low-cardinality) db.operation.name available, database span names SHOULD be {target}.

If neither {db.operation.name} nor {target} are available, span name SHOULD be {db.system}.

Semantic conventions for individual database systems MAY specify different span name format.

The {target} SHOULD describe the entity that the operation is performed against and SHOULD adhere to one of the following values, provided they are accessible:

  • db.collection.name SHOULD be used for data manipulation operations or operations on database collections.
  • db.namespace SHOULD be used for operations on a specific database namespace.
  • server.address:server.port SHOULD be used for other operations not targeting any specific database(s) or collection(s)

If a corresponding {target} value is not available for a specific operation, the instrumentation SHOULD omit the {target}. For example, for an operation describing SQL query on an anonymous table like SELECT * FROM (SELECT * FROM table) t, span name should be SELECT.

We currently only set the span name to DB.

Required attributes (not including common attributes from the previous section):

Updates: