Skip to content

Commit 6db52d9

Browse files
[db] Add context propagation for Oracle (#2610)
Co-authored-by: Matt Hensley <[email protected]>
1 parent e9f37e2 commit 6db52d9

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use this changelog template to create an entry for release notes.
2+
#
3+
# If your change doesn't affect end users you should instead start
4+
# your pull request title with [chore] or use the "Skip Changelog" label.
5+
6+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
7+
change_type: enhancement
8+
9+
# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db)
10+
component: db
11+
12+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
13+
note: Add database context propagation via `V$SESSION.ACTION` for SQL Server
14+
15+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
16+
# The values here must be integers.
17+
issues: [2610]
18+
19+
# (Optional) One or more lines of additional information to render under the primary note.
20+
# These lines will be padded with 2 spaces and then inserted directly into the document.
21+
# Use pipe (|) for multiline entries.
22+
subtext:

docs/database/oracledb.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ linkTitle: Oracle Database
99
<!-- toc -->
1010

1111
- [Spans](#spans)
12+
- [Context propagation](#context-propagation)
13+
- [V$SESSION.ACTION](#vsessionaction)
1214
- [Metrics](#metrics)
1315

1416
<!-- tocstop -->
@@ -141,6 +143,38 @@ and SHOULD be provided **at span creation time** (if provided at all):
141143
<!-- END AUTOGENERATED TEXT -->
142144
<!-- endsemconv -->
143145

146+
## Context propagation
147+
148+
**Status**: [Development][DocumentStatus]
149+
150+
### V$SESSION.ACTION
151+
152+
Instrumentations MAY propagate context with a fixed-length, 64 byte value using [V$SESSION.ACTION](https://docs.oracle.com/en/database/oracle/oracle-database/23/refrn/V-SESSION.html) by injecting part of span context (trace-id, span-id, trace-flags, protocol version) before executing a query. For example, when using W3C Trace Context, only a string representation of [`traceparent`](https://www.w3.org/TR/trace-context/#traceparent-header) SHOULD be injected. Context injection SHOULD NOT be enabled by default, but instrumentation MAY allow users to opt into it.
153+
154+
Variable context parts (`tracestate`, `baggage`) SHOULD NOT be injected since `V$SESSION.ACTION` value length is limited to 64 bytes.
155+
156+
Instrumentations that propagate context MUST update `V$SESSION.ACTION` on the same physical connection as the SQL statement.
157+
158+
Example:
159+
160+
Note that Oracle database drivers in different languages may have different implementation to update `V$SESSION.ACTION`.
161+
162+
For a query `SELECT * FROM songs` where `traceparent` is `00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01`:
163+
164+
Run the following command on the same physical connection as the SQL statement:
165+
166+
```sql
167+
BEGIN
168+
DBMS_APPLICATION_INFO.SET_ACTION('00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01');
169+
END;
170+
```
171+
172+
Then run the query:
173+
174+
```sql
175+
SELECT * FROM songs;
176+
```
177+
144178
## Metrics
145179

146180
Oracle Database driver instrumentation SHOULD collect metrics according to the general

0 commit comments

Comments
 (0)