Skip to content

Commit 198eb12

Browse files
authored
fix(db): Clarify db.query.text and db.query.summary attributes (#208)
* fix(db): Clarify `db.query.text` and `db.query.summary` attributes * changelog * single example, generate, format * leave changelog as-is
1 parent d93968e commit 198eb12

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

generated/attributes/all.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ Total attributes: 423
4949
| [`db.namespace`](./db.md#dbnamespace) | The name of the database being accessed. |
5050
| [`db.operation.name`](./db.md#dboperationname) | The name of the operation being executed. |
5151
| [`db.query.parameter.\<key\>`](./db.md#dbqueryparameterkey) | A query parameter used in db.query.text, with <key> being the parameter name, and the attribute value being a string representation of the parameter value. |
52-
| [`db.query.summary`](./db.md#dbquerysummary) | A database query being executed. Should be paramaterized. The full version of the query is in `db.query.text`. |
53-
| [`db.query.text`](./db.md#dbquerytext) | The database query being executed. Should be the full query, not a parameterized version. The parameterized version is in `db.query.summary`. |
52+
| [`db.query.summary`](./db.md#dbquerysummary) | A shortened representation of operation(s) in the full query. This attribute must be low-cardinality and should only contain the operation table names. |
53+
| [`db.query.text`](./db.md#dbquerytext) | The database parameterized query being executed. Any parameter values (filters, insertion values, etc) should be replaced with parameter placeholders. If applicable, use `db.query.parameter.<key>` to add the parameter value. |
5454
| [`db.redis.connection`](./db.md#dbredisconnection) | The redis connection name. |
5555
| [`db.redis.parameters`](./db.md#dbredisparameters) | The array of command parameters given to a redis command. |
5656
| [`db.system.name`](./db.md#dbsystemname) | An identifier for the database management system (DBMS) product being used. See [OpenTelemetry docs](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/database/database-spans.md#notes-and-well-known-identifiers-for-dbsystem) for a list of well-known identifiers. |

generated/attributes/db.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,25 @@ A query parameter used in db.query.text, with \<key\> being the parameter name,
7171

7272
### db.query.summary
7373

74-
A database query being executed. Should be paramaterized. The full version of the query is in `db.query.text`.
74+
A shortened representation of operation(s) in the full query. This attribute must be low-cardinality and should only contain the operation table names.
7575

7676
| Property | Value |
7777
| --- | --- |
7878
| Type | `string` |
7979
| Has PII | maybe |
8080
| Exists in OpenTelemetry | Yes |
81-
| Example | `SELECT * FROM users` |
81+
| Example | `SELECT users;` |
8282

8383
### db.query.text
8484

85-
The database query being executed. Should be the full query, not a parameterized version. The parameterized version is in `db.query.summary`.
85+
The database parameterized query being executed. Any parameter values (filters, insertion values, etc) should be replaced with parameter placeholders. If applicable, use `db.query.parameter.\<key\>` to add the parameter value.
8686

8787
| Property | Value |
8888
| --- | --- |
8989
| Type | `string` |
9090
| Has PII | maybe |
9191
| Exists in OpenTelemetry | Yes |
92-
| Example | `SELECT * FROM users` |
92+
| Example | `SELECT * FROM users WHERE id = $1` |
9393
| Aliases | `db.statement` |
9494

9595
### db.redis.connection

javascript/sentry-conventions/src/attributes.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,15 +1391,15 @@ export type DB_QUERY_PARAMETER_KEY_TYPE = string;
13911391
// Path: model/attributes/db/db__query__summary.json
13921392

13931393
/**
1394-
* A database query being executed. Should be paramaterized. The full version of the query is in `db.query.text`. `db.query.summary`
1394+
* A shortened representation of operation(s) in the full query. This attribute must be low-cardinality and should only contain the operation table names. `db.query.summary`
13951395
*
13961396
* Attribute Value Type: `string` {@link DB_QUERY_SUMMARY_TYPE}
13971397
*
13981398
* Contains PII: maybe
13991399
*
14001400
* Attribute defined in OTEL: Yes
14011401
*
1402-
* @example "SELECT * FROM users"
1402+
* @example "SELECT users;"
14031403
*/
14041404
export const DB_QUERY_SUMMARY = 'db.query.summary';
14051405

@@ -1411,7 +1411,7 @@ export type DB_QUERY_SUMMARY_TYPE = string;
14111411
// Path: model/attributes/db/db__query__text.json
14121412

14131413
/**
1414-
* The database query being executed. Should be the full query, not a parameterized version. The parameterized version is in `db.query.summary`. `db.query.text`
1414+
* The database parameterized query being executed. Any parameter values (filters, insertion values, etc) should be replaced with parameter placeholders. If applicable, use `db.query.parameter.<key>` to add the parameter value. `db.query.text`
14151415
*
14161416
* Attribute Value Type: `string` {@link DB_QUERY_TEXT_TYPE}
14171417
*
@@ -1421,7 +1421,7 @@ export type DB_QUERY_SUMMARY_TYPE = string;
14211421
*
14221422
* Aliases: {@link DB_STATEMENT} `db.statement`
14231423
*
1424-
* @example "SELECT * FROM users"
1424+
* @example "SELECT * FROM users WHERE id = $1"
14251425
*/
14261426
export const DB_QUERY_TEXT = 'db.query.text';
14271427

@@ -10408,23 +10408,23 @@ export const ATTRIBUTE_METADATA: Record<AttributeName, AttributeMetadata> = {
1040810408
},
1040910409
[DB_QUERY_SUMMARY]: {
1041010410
brief:
10411-
'A database query being executed. Should be paramaterized. The full version of the query is in `db.query.text`.',
10411+
'A shortened representation of operation(s) in the full query. This attribute must be low-cardinality and should only contain the operation table names.',
1041210412
type: 'string',
1041310413
pii: {
1041410414
isPii: 'maybe',
1041510415
},
1041610416
isInOtel: true,
10417-
example: 'SELECT * FROM users',
10417+
example: 'SELECT users;',
1041810418
},
1041910419
[DB_QUERY_TEXT]: {
1042010420
brief:
10421-
'The database query being executed. Should be the full query, not a parameterized version. The parameterized version is in `db.query.summary`.',
10421+
'The database parameterized query being executed. Any parameter values (filters, insertion values, etc) should be replaced with parameter placeholders. If applicable, use `db.query.parameter.<key>` to add the parameter value.',
1042210422
type: 'string',
1042310423
pii: {
1042410424
isPii: 'maybe',
1042510425
},
1042610426
isInOtel: true,
10427-
example: 'SELECT * FROM users',
10427+
example: 'SELECT * FROM users WHERE id = $1',
1042810428
aliases: [DB_STATEMENT],
1042910429
},
1043010430
[DB_REDIS_CONNECTION]: {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"key": "db.query.summary",
3-
"brief": "A database query being executed. Should be paramaterized. The full version of the query is in `db.query.text`.",
3+
"brief": "A shortened representation of operation(s) in the full query. This attribute must be low-cardinality and should only contain the operation table names.",
44
"type": "string",
55
"pii": {
66
"key": "maybe"
77
},
88
"is_in_otel": true,
9-
"example": "SELECT * FROM users"
9+
"example": "SELECT users;"
1010
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"key": "db.query.text",
3-
"brief": "The database query being executed. Should be the full query, not a parameterized version. The parameterized version is in `db.query.summary`.",
3+
"brief": "The database parameterized query being executed. Any parameter values (filters, insertion values, etc) should be replaced with parameter placeholders. If applicable, use `db.query.parameter.<key>` to add the parameter value.",
44
"type": "string",
55
"pii": {
66
"key": "maybe"
77
},
88
"is_in_otel": true,
9-
"example": "SELECT * FROM users",
9+
"example": "SELECT * FROM users WHERE id = $1",
1010
"alias": ["db.statement"]
1111
}

python/src/sentry_conventions/attributes.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -901,23 +901,23 @@ class ATTRIBUTE_NAMES(metaclass=_AttributeNamesMeta):
901901

902902
# Path: model/attributes/db/db__query__summary.json
903903
DB_QUERY_SUMMARY: Literal["db.query.summary"] = "db.query.summary"
904-
"""A database query being executed. Should be paramaterized. The full version of the query is in `db.query.text`.
904+
"""A shortened representation of operation(s) in the full query. This attribute must be low-cardinality and should only contain the operation table names.
905905
906906
Type: str
907907
Contains PII: maybe
908908
Defined in OTEL: Yes
909-
Example: "SELECT * FROM users"
909+
Example: "SELECT users;"
910910
"""
911911

912912
# Path: model/attributes/db/db__query__text.json
913913
DB_QUERY_TEXT: Literal["db.query.text"] = "db.query.text"
914-
"""The database query being executed. Should be the full query, not a parameterized version. The parameterized version is in `db.query.summary`.
914+
"""The database parameterized query being executed. Any parameter values (filters, insertion values, etc) should be replaced with parameter placeholders. If applicable, use `db.query.parameter.<key>` to add the parameter value.
915915
916916
Type: str
917917
Contains PII: maybe
918918
Defined in OTEL: Yes
919919
Aliases: db.statement
920-
Example: "SELECT * FROM users"
920+
Example: "SELECT * FROM users WHERE id = $1"
921921
"""
922922

923923
# Path: model/attributes/db/db__redis__connection.json
@@ -5367,18 +5367,18 @@ class ATTRIBUTE_NAMES(metaclass=_AttributeNamesMeta):
53675367
example="db.query.parameter.foo='123'",
53685368
),
53695369
"db.query.summary": AttributeMetadata(
5370-
brief="A database query being executed. Should be paramaterized. The full version of the query is in `db.query.text`.",
5370+
brief="A shortened representation of operation(s) in the full query. This attribute must be low-cardinality and should only contain the operation table names.",
53715371
type=AttributeType.STRING,
53725372
pii=PiiInfo(isPii=IsPii.MAYBE),
53735373
is_in_otel=True,
5374-
example="SELECT * FROM users",
5374+
example="SELECT users;",
53755375
),
53765376
"db.query.text": AttributeMetadata(
5377-
brief="The database query being executed. Should be the full query, not a parameterized version. The parameterized version is in `db.query.summary`.",
5377+
brief="The database parameterized query being executed. Any parameter values (filters, insertion values, etc) should be replaced with parameter placeholders. If applicable, use `db.query.parameter.<key>` to add the parameter value.",
53785378
type=AttributeType.STRING,
53795379
pii=PiiInfo(isPii=IsPii.MAYBE),
53805380
is_in_otel=True,
5381-
example="SELECT * FROM users",
5381+
example="SELECT * FROM users WHERE id = $1",
53825382
aliases=["db.statement"],
53835383
),
53845384
"db.redis.connection": AttributeMetadata(

0 commit comments

Comments
 (0)