Skip to content

Add SQL commenter as context propagation for databases #2495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 36 commits into
base: main
Choose a base branch
from

Conversation

XSAM
Copy link
Member

@XSAM XSAM commented Jul 7, 2025

Part of #2162, Replace #2236. All previous commits are copied to this PR.

This PR focused solely on the SQL commenter, as #2363 has been merged.

XSAM/otelsql#512 is the prototype that demonstrates the SQL commenter with the text attributes propagator.

Changes

Add SQL commenter as context propagation for databases

@XSAM XSAM requested review from a team as code owners July 7, 2025 22:41
@XSAM XSAM requested a review from lmolkova July 16, 2025 00:47
@jsuereth jsuereth moved this from Untriaged to Awaiting codeowners approval in Semantic Conventions Triage Jul 28, 2025
@XSAM XSAM requested a review from trask July 31, 2025 06:35
@XSAM
Copy link
Member Author

XSAM commented Aug 4, 2025

@open-telemetry/semconv-db-approvers PTAL

@XSAM
Copy link
Member Author

XSAM commented Aug 7, 2025

@trask, I find all comments are resolved. Is that okay for you to approve this PR?


The instrumentation SHOULD allow users to pass a propagator to overwrite the global propagator.

If the propagator does not provide any value, the instrumentation SHOULD NOT inject any comment into the query.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
If the propagator does not provide any value, the instrumentation SHOULD NOT inject any comment into the query.
If the propagator is not provided, the instrumentation SHOULD NOT inject any comment into the query.

?

Copy link
Member Author

@XSAM XSAM Aug 8, 2025

Choose a reason for hiding this comment

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

This prevents injecting empty comments like /**/ when the propagator sets nothing.

So, we won’t see a query like this SELECT * FROM Users /**/

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps you meant something like this then

Suggested change
If the propagator does not provide any value, the instrumentation SHOULD NOT inject any comment into the query.
If the context is empty or invalid, the propagator SHOULD NOT inject any comment into the query.

?

But this sentence immediately follows "The instrumentation SHOULD allow users to pass a propagator to overwrite the global propagator.", it seems it intends to talk about propagator not being provided by the user.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can use this code as the example. In this example, even the propagator provides nothing, the comments will be injected.

https://github.com/XSAM/otelsql/blob/370716b2f8c317607879035937ba65cfc751dc5a/commenter.go#L66

return fmt.Sprintf("%s /*%s*/", query, cc.Marshal())

Since it is instrumentation's job to actually inject the comment, the instrumentation should be the one to be regulated for this, not the propagator.

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated this part on c0a6f4b. I think it is clear now.

@github-project-automation github-project-automation bot moved this from Awaiting codeowners approval to Needs More Approval in Semantic Conventions Triage Aug 8, 2025
XSAM and others added 2 commits August 7, 2025 18:48
Co-authored-by: Liudmila Molkova <[email protected]>
- Simplify wording about append/prepend to avoid confusion
- Clarify distinction between missing propagator vs empty context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:db enhancement New feature or request
Projects
Status: Needs More Approval
Development

Successfully merging this pull request may close these issues.