You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/database/database-spans.md
+34-1Lines changed: 34 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,8 @@ linkTitle: Spans
13
13
-[Notes and well-known identifiers for `db.system.name`](#notes-and-well-known-identifiers-for-dbsystemname)
14
14
-[Sanitization of `db.query.text`](#sanitization-of-dbquerytext)
15
15
-[Generating a summary of the query](#generating-a-summary-of-the-query)
16
+
-[Context propagation](#context-propagation)
17
+
-[SQL commenter](#sql-commenter)
16
18
-[Semantic conventions for specific database technologies](#semantic-conventions-for-specific-database-technologies)
17
19
18
20
<!-- tocstop -->
@@ -45,7 +47,7 @@ linkTitle: Spans
45
47
46
48
## Name
47
49
48
-
Database spans MUST follow the overall [guidelines for span names](https://github.com/open-telemetry/opentelemetry-specification/tree/v1.48.0/specification/trace/api.md#span).
50
+
Database spans MUST follow the overall [guidelines for span names](https://github.com/open-telemetry/opentelemetry-specification/tree/v1.46.0/specification/trace/api.md#span).
49
51
50
52
The **span name** SHOULD be `{db.query.summary}` if a summary is available.
51
53
@@ -478,6 +480,37 @@ Semantic conventions for individual database systems or specialized instrumentat
478
480
MAY specify a different `db.query.summary` format as long as produced summary remains
479
481
relatively short and its cardinality remains low comparing to the `db.query.text`.
480
482
483
+
## Context propagation
484
+
485
+
**Status**: [Development][DocumentStatus]
486
+
487
+
### SQL commenter
488
+
489
+
Instrumentations MAY propagate context using [SQL commenter](https://google.github.io/sqlcommenter/spec/) by injecting comments into SQL queries before execution. SQL commenter-based context propagation SHOULD NOT be enabled by default, but instrumentation MAY allow users to opt into it.
490
+
491
+
The instrumentation implementation SHOULD **append** the comment to the end of the query. Semantic conventions for individual database systems MAY specify different format, which may include different position, encoding, or schema, depending on the specific database system's requirements or preferences.
492
+
493
+
The instrumentation SHOULD allow users to pass a propagator to overwrite the global propagator. If no propagator is provided by the user, instrumentation SHOULD use the global propagator.
494
+
495
+
**Examples:**
496
+
497
+
- For a query `SELECT * FROM songs` with W3C TraceContext propagator:
498
+
499
+
```sql
500
+
SELECT * FROM songs /*traceparent='00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01',tracestate='congo%3Dt61rcWkgMzE%2Crojo%3D00f067aa0ba902b7'*/
501
+
```
502
+
503
+
Note that adding high cardinality comments, like`traceparent`and`tracestate`, to queries can impact the performance for some database systems, such as:
504
+
505
+
- Prepared statements in MySQL. See [this related issue](https://github.com/google/sqlcommenter/issues/284) for more details.
506
+
- Oracle and SQL Server for both prepared and non-prepared statements.
507
+
508
+
- For a query `SELECT * FROM songs` with a custom propagator that injects `service.name` into carrier where`service.name` is `shoppingcart`:
509
+
510
+
```sql
511
+
SELECT * FROM songs /*service.name='shoppingcart'*/
512
+
```
513
+
481
514
## Semantic conventions for specific database technologies
482
515
483
516
More specific Semantic Conventions are defined for the following database technologies:
0 commit comments