Preserve SQL query summary operation case#18930
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the SQL query summary lexer to preserve the original case of operation keywords (e.g., select vs SELECT) when building stable query summaries, and expands test coverage to validate case preservation across supported summary operations and nested SELECT scenarios.
Changes:
- Switched query-summary operation tokens to use the lexer’s matched text (
yytext()) instead of hard-coded uppercase keywords. - Updated nested/embedded
SELECThandling to propagate the matched operation text throughhandleSelect(...). - Added/updated tests to assert query summaries preserve the input operation keyword case across many operations (including nested SELECTs and top-level VALUES).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| instrumentation-api-incubator/src/main/jflex/SqlSanitizerWithSummary.jflex | Uses matched lexer text for operation keywords and threads original SELECT token text through operation handling to preserve case in summaries. |
| instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQueryAnalyzerTest.java | Adds a parameterized test for operation-case preservation and updates existing summary expectations to reflect case-preserving behavior. |
trask
force-pushed
the
fix-stable-sql-summary-case
branch
from
June 8, 2026 02:50
d549bc9 to
61a9870
Compare
trask
force-pushed
the
fix-stable-sql-summary-case
branch
from
June 8, 2026 03:24
5dc9919 to
d857c00
Compare
SQL query summaries now preserve the operation casing from the original statement. Stable database semconv tests were still expecting canonical uppercase summaries and span names for lowercase generated SQL, causing the CI failures. Update the affected Camel, Hibernate, and Vert.x expectations to match the preserved case while leaving uppercase native SQL expectations unchanged. Validation: .\gradlew.bat :instrumentation-api-incubator:test --tests io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlQueryAnalyzerTest --tests io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlQuerySummaryEdgeCasesTest; .\gradlew.bat :instrumentation:hibernate:hibernate-6.0:javaagent:hibernate6TestStableSemconv; .\gradlew.bat :instrumentation:camel-2.20:javaagent-unit-tests:testStableSemconv :instrumentation:camel-2.20:javaagent:testStableSemconv :instrumentation:hibernate:hibernate-6.0:javaagent:hibernate6TestStableSemconv :instrumentation:hibernate:hibernate-6.0:spring-testing:testStableSemconv :instrumentation:hibernate:hibernate-reactive-1.0:javaagent:hibernateReactive1TestStableSemconv :instrumentation:vertx:vertx-sql-client:vertx-sql-client-4.0:javaagent:testStableSemconv; .\gradlew.bat spotlessCheck
Stable database semantic convention query summaries are emitted with lowercase SQL operation names by the updated SQL analyzer. Several Hibernate, ClickHouse, and Spring Data tests still expected uppercase stable span names or db.query.summary values, causing the CI testStableSemconv jobs to fail. Update the affected expectations to match the emitted stable semconv values while preserving legacy-mode expectations. Validation: ./gradlew.bat :instrumentation:hibernate:hibernate-6.0:javaagent:test --tests io.opentelemetry.javaagent.instrumentation.hibernate.v6_0.CriteriaTest --tests io.opentelemetry.javaagent.instrumentation.hibernate.v6_0.EntityManagerTest.testNoResultExceptionIgnored ./gradlew.bat :instrumentation:hibernate:hibernate-6.0:javaagent:testStableSemconv --tests io.opentelemetry.javaagent.instrumentation.hibernate.v6_0.CriteriaTest --tests io.opentelemetry.javaagent.instrumentation.hibernate.v6_0.EntityManagerTest.testNoResultExceptionIgnored ./gradlew.bat :instrumentation:hibernate:hibernate-6.0:spring-testing:test --tests spring.jpa.SpringJpaTest ./gradlew.bat :instrumentation:hibernate:hibernate-4.0:javaagent:testStableSemconv --tests io.opentelemetry.javaagent.instrumentation.hibernate.v4_0.CriteriaTest --tests io.opentelemetry.javaagent.instrumentation.hibernate.v4_0.EntityManagerTest.testNoResultExceptionIgnored --tests io.opentelemetry.javaagent.instrumentation.hibernate.v4_0.QueryTest.testHibernateQuerySingleCall ./gradlew.bat :instrumentation:hibernate:hibernate-3.3:javaagent:testStableSemconv --tests io.opentelemetry.javaagent.instrumentation.hibernate.v3_3.QueryTest ./gradlew.bat :instrumentation:clickhouse:clickhouse-client-v2-0.8:javaagent:testStableSemconv --tests io.opentelemetry.javaagent.instrumentation.clickhouse.clientv2.v0_8.ClickHouseClientV2Test ./gradlew.bat :instrumentation:spring:spring-data:spring-data-1.8:javaagent:testStableSemconv
Stable database semconv lowercases generated HQL/ORM query summaries and span names, while native SQL keeps its SQL operation casing. The Hibernate tests mixed those expectations, causing stable-semconv and latest-deps CI failures after the PR changed the expected assertions. Update the affected Hibernate 4 and 6 tests to expect lowercase generated query names and preserve uppercase native SQL names, and run Spotless for the logged formatting issue. Validation: .\gradlew.bat :instrumentation:hibernate:hibernate-4.0:javaagent:testStableSemconv :instrumentation:hibernate:hibernate-6.0:javaagent:testStableSemconv .\gradlew.bat :instrumentation:hibernate:hibernate-4.0:javaagent:testStableSemconv :instrumentation:hibernate:hibernate-6.0:javaagent:testStableSemconv -PtestLatestDeps=true .\gradlew.bat :instrumentation:hibernate:hibernate-3.3:javaagent:spotlessCheck :instrumentation:hibernate:hibernate-4.0:javaagent:spotlessCheck :instrumentation:hibernate:hibernate-6.0:javaagent:spotlessCheck
The Hibernate 6 and 7 SessionTest query-state assertions always expected stable-semconv lowercase HQL span names, but the failing CI jobs run legacy database semconv mode where the instrumentation emits uppercase SELECT names. The tests now derive the expected query span name from the active semconv mode. Validation: .\gradlew.bat :instrumentation:hibernate:hibernate-6.0:javaagent:hibernate6Test :instrumentation:hibernate:hibernate-6.0:javaagent:hibernate7Test --tests *SessionTest .\gradlew.bat :instrumentation:hibernate:hibernate-6.0:javaagent:hibernate7Test --tests *SessionTest -PtestLatestDeps=true Co-authored-by: Copilot <[email protected]>
trask
commented
Jun 8, 2026
|
|
||
| // hibernate/jpa query language | ||
| Arguments.of("FROM TABLE WHERE FIELD=1234", "FROM TABLE WHERE FIELD=?", "SELECT TABLE")); | ||
| Arguments.of("from TABLE WHERE FIELD=1234", "from TABLE WHERE FIELD=?", "select TABLE")); |
Member
Author
There was a problem hiding this comment.
changing FROM to from isn't relevant, but it does match what's seen from hibernate, so seems more realistic example data
trask
marked this pull request as ready for review
June 9, 2026 02:51
laurit
approved these changes
Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Preserve the original case of SQL operation keywords when building stable query summaries. This switches matched operation tokens to use the lexer text consistently, including nested SELECTs and top-level VALUES, and adds coverage across supported summary operations.