Skip to content

feat(oracledb): propagate context using V$SESSION.ACTION#3226

Merged
pichlermarc merged 6 commits intoopen-telemetry:mainfrom
mhennoch:oracledb-context
Jan 30, 2026
Merged

feat(oracledb): propagate context using V$SESSION.ACTION#3226
pichlermarc merged 6 commits intoopen-telemetry:mainfrom
mhennoch:oracledb-context

Conversation

@mhennoch
Copy link
Copy Markdown
Contributor

@mhennoch mhennoch commented Nov 17, 2025

Adds context propagation via V$SESSION.ACTION. Spec. It seems that requestHook doesn't have access to the connection so I couldn't use that.

@pichlermarc
Copy link
Copy Markdown
Member

cc @sudarshan12s @sharadraju (component owners) please review 🙂

@trentm
Copy link
Copy Markdown
Contributor

trentm commented Dec 3, 2025

Correct link for the "Spec", I think: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/db/oracledb.md#vsessionaction
Not sure if it moved recently.

@mhennoch
Copy link
Copy Markdown
Contributor Author

@sudarshan12s @sharadraju any chance you could take a look?

export function buildTraceparent(
spanContext: SpanContext
): string | undefined {
return `00-${spanContext.traceId}-${spanContext.spanId}-0${Number(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

traceFlags is already a number , we do not need to use Number right?

I think we can use below?


(spanContext.traceFlags ?? TraceFlags.NONE)
    .toString(16)
    .padStart(2, '0');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could but I used the same one that is used in tedious which is from here. Probably should extract it to somewhere and use the same one. I'd say let this be and I'll unify it in some other PR.

*
* @default false
*/
traceContextPropagation?: boolean;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The database wire protocol latest version supports passing the traceContext from client to server. The DB server can then start a child span of the corresponding client span.

I have plans to add it in this module after few node-oracledb driver changes..

The ACTION field could be used by application and hence the native change of wire protocol would resolve that issue (also the limit of 64 bytes with ACTION field)

Hence can we rename this attribute to
propagateTraceContextToSessionAction , so that when a wire protocol change is added, we can use this flag, traceContextPropagation ?

Also can we add the same in README.md

| propagateTraceContextToSessionAction | boolean | true | If true, injects the W3C Trace Context into the Oracle V$SESSION.ACTION field. This allows the OpenTelemetry Collector to correlate application traces with database server spans. |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tedious uses enableTraceContextPropagation so to be honest I am not sure why didn't use the same one here. Spec doesn't specify it so we can use whatever. Would make sense for all DBs to use the same one tho. I guess oracledb only one who will use action for this so I'll use propagateTraceContextToSessionAction.

@sudarshan12s
Copy link
Copy Markdown
Contributor

@sudarshan12s @sharadraju any chance you could take a look?

Sorry for delay in checking this. Thanks for the changes.

Copy link
Copy Markdown
Contributor

@sudarshan12s sudarshan12s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I see some lint issue, minor formatting fixes:


npx prettier --write \
  packages/instrumentation-oracledb/src/OracleTelemetryTraceHandler.ts \
  packages/instrumentation-oracledb/test/oracle.test.ts

@mhennoch
Copy link
Copy Markdown
Contributor Author

@pichlermarc

Copy link
Copy Markdown

@sharadraju sharadraju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proxy-approving for component owners.

@pichlermarc pichlermarc merged commit 402bac6 into open-telemetry:main Jan 30, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants