Skip to content

Commit

Permalink
Move db.table to SQL-specific call level attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfoote committed Oct 30, 2020
1 parent 5c05f92 commit 657670c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
35 changes: 22 additions & 13 deletions semantic_conventions/trace/database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,6 @@ groups:
If the statement has an ambiguous operation, or performs more than
one operation, this value may be omitted.
examples: ['findAndModify', 'HMSET', 'SELECT']
- id: table
tag: call-level
type: string
required:
conditional: Recommended if available.
brief: The name of the primary table, collection, segment, etc... that the operation is acting upon, including the schema name (if applicable).
note: >
It is not recommended to attempt any client-side parsing of
`db.statement` just to get this property, but it should be set if
it is provided by the library being instrumented.
If the operation is acting upon an anonymous table, or more than one table, this
value may be omitted.
examples: ['public.users', 'customers']
- ref: net.peer.name
tag: connection-level
required:
Expand Down Expand Up @@ -309,10 +296,32 @@ groups:
The collection being accessed within the database stated in `db.name`.
examples: [ 'customers', 'products' ]

- id: db.sql
prefix: 'db.sql'
extends: 'db'
brief: >
Call-level attrbiutes for SQL databases
attributes:
- id: table
tag: call-level-tech-specific
type: string
required:
conditional: Recommended if available.
brief: The name of the primary table that the operation is acting upon, including the schema name (if applicable).
note: >
It is not recommended to attempt any client-side parsing of
`db.statement` just to get this property, but it should be set if
it is provided by the library being instrumented.
If the operation is acting upon an anonymous table, or more than one table, this
value may be omitted.
examples: ['public.users', 'customers']


- id: db.tech
brief: "Semantic convention group for specific technologies"
constraints:
- include: 'db.cassandra'
- include: 'db.hbase'
- include: 'db.redis'
- include: 'db.mongodb'
- include: 'db.sql'
6 changes: 3 additions & 3 deletions specification/trace/semantic_conventions/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ Usually only one `db.name` will be used per connection though.
| `db.name` | string | If no [tech-specific attribute](#call-level-attributes-for-specific-technologies) is defined, this attribute is used to report the name of the database being accessed. For commands that switch the database, this should be set to the target database (even if the command fails). [1] | `customers`<br>`main` | Conditional [2] |
| `db.statement` | string | The database statement being executed. [3] | `SELECT * FROM wuser_table`<br>`SET mykey "WuValue"` | Conditional<br>Required if applicable. |
| `db.operation` | string | The name of the operation being executed, e.g. the [MongoDB command name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as `findAndModify`, or the SQL keyword. [4] | `findAndModify`<br>`HMSET`<br>`SELECT` | Conditional<br>Required, if `db.statement` is not applicable. |
| `db.table` | string | The name of the primary table, collection, segment, etc... that the operation is acting upon, including the schema name (if applicable). [5] | `public.users`<br>`customers` | Conditional<br>Recommended if available. |

**[1]:** In some SQL databases, the database name to be used is called "schema name".

Expand All @@ -145,8 +144,6 @@ Usually only one `db.name` will be used per connection though.
**[3]:** The value may be sanitized to exclude sensitive information.

**[4]:** It is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if the operation name is provided by the library being instrumented. If the statement has an ambiguous operation, or performs more than one operation, this value may be omitted.

**[5]:** It is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value may be omitted.
<!-- endsemconv -->

For **Redis**, the value provided for `db.statement` SHOULD correspond to the syntax of the Redis CLI.
Expand All @@ -168,8 +165,11 @@ For example, when retrieving a document, `db.operation` would be set to (literal
| `db.hbase.namespace` | string | The [HBase namespace](https://hbase.apache.org/book.html#_namespace) being accessed. To be used instead of the generic `db.name` attribute. | `default` | Yes |
| `db.redis.database_index` | number | The index of the database being accessed as used in the [`SELECT` command](https://redis.io/commands/select), provided as an integer. To be used instead of the generic `db.name` attribute. | `0`<br>`1`<br>`15` | Conditional [1] |
| `db.mongodb.collection` | string | The collection being accessed within the database stated in `db.name`. | `customers`<br>`products` | Yes |
| `db.sql.table` | string | The name of the primary table that the operation is acting upon, including the schema name (if applicable). [2] | `public.users`<br>`customers` | Conditional<br>Recommended if available. |

**[1]:** Required, if other than the default database (`0`).

**[2]:** It is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value may be omitted.
<!-- endsemconv -->

## Examples
Expand Down

0 comments on commit 657670c

Please sign in to comment.