Skip to content

Continue updating database terminology to match stable semconv (statement -> query)#16074

Merged
trask merged 3 commits intoopen-telemetry:mainfrom
trask:statement-rename
Feb 10, 2026
Merged

Continue updating database terminology to match stable semconv (statement -> query)#16074
trask merged 3 commits intoopen-telemetry:mainfrom
trask:statement-rename

Conversation

@trask
Copy link
Copy Markdown
Member

@trask trask commented Jan 30, 2026

Related to #12608

Renames:

  • SqlStatementInfo -> SqlQuery
  • SqlStatementSanitizer -> SqlQuerySanitizer

Deprecated old classes and updated their implementation to delegate to new classes.

Didn't introduce new tests, since the old tests cover the new classes via the delegation pattern.

When deprecated classes are removed, tests will be updated to point to the new classes.

Copy link
Copy Markdown
Member Author

@trask trask left a comment

Choose a reason for hiding this comment

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

File copy/rename annotations with diffs

@@ -0,0 +1,96 @@
/*
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copied from SqlStatementInfo.java

$ git diff upstream/main:instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlStatementInfo.java instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQuery.java

index 9f67d55c80..cf852fc827 100644
--- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlStatementInfo.java
+++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQuery.java
@@ -9,27 +9,27 @@ import com.google.auto.value.AutoValue;
 import javax.annotation.Nullable;
 
 @AutoValue
-public abstract class SqlStatementInfo {
+public abstract class SqlQuery {
 
   private static final String SQL_CALL = "CALL";
   private static final int QUERY_SUMMARY_MAX_LENGTH = 255;
 
-  /** Creates a SqlStatementInfo for stable semconv (uses querySummary). */
-  public static SqlStatementInfo createWithSummary(
+  /** Creates a SqlQuery for stable semconv (uses querySummary). */
+  public static SqlQuery createWithSummary(
       @Nullable String queryText,
       @Nullable String storedProcedureName,
       @Nullable String querySummary) {
     String truncatedQuerySummary = truncateQuerySummary(querySummary);
     // In stable semconv: operationName and collectionName are always null
-    return new AutoValue_SqlStatementInfo(
+    return new AutoValue_SqlQuery(
         queryText, null, null, storedProcedureName, truncatedQuerySummary);
   }
 
   /**
-   * Creates a SqlStatementInfo for old semconv (no querySummary). Package-private for backward
+   * Creates a SqlQuery for old semconv (no querySummary). Package-private for backward
    * compatibility with old jflex-generated sanitizer.
    */
-  public static SqlStatementInfo create(
+  public static SqlQuery create(
       @Nullable String queryText, @Nullable String operationName, @Nullable String target) {
     // AutoValue constructor: (queryText, operationName, collectionName, storedProcedureName,
     // querySummary)
@@ -38,7 +38,7 @@ public abstract class SqlStatementInfo {
         SQL_CALL.equals(operationName) || "EXECUTE".equals(operationName) ? null : target;
     String storedProcedureName =
         SQL_CALL.equals(operationName) || "EXECUTE".equals(operationName) ? target : null;
-    return new AutoValue_SqlStatementInfo(
+    return new AutoValue_SqlQuery(
         queryText, operationName, collectionName, storedProcedureName, null);
   }

@@ -0,0 +1,101 @@
/*
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copied from SqlStatementSanitizer.java

$ git diff upstream/main:instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlStatementSanitizer.java instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQuerySanitizer.java

index d6302e64d8..6e0cc45162 100644
--- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlStatementSanitizer.java
+++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQuerySanitizer.java
@@ -16,32 +16,31 @@ import javax.annotation.Nullable;
  * This class is responsible for masking potentially sensitive parameters in SQL (and SQL-like)
  * statements and queries.
  */
-public final class SqlStatementSanitizer {
+public final class SqlQuerySanitizer {
   private static final SupportabilityMetrics supportability = SupportabilityMetrics.instance();
-  private static final Cache<CacheKey, SqlStatementInfo> sqlToStatementInfoCache =
-      Cache.bounded(1000);
-  private static final Cache<CacheKey, SqlStatementInfo> sqlToStatementInfoCacheWithSummary =
+  private static final Cache<CacheKey, SqlQuery> sqlToStatementInfoCache = Cache.bounded(1000);
+  private static final Cache<CacheKey, SqlQuery> sqlToStatementInfoCacheWithSummary =
       Cache.bounded(1000);
   private static final int LARGE_STATEMENT_THRESHOLD = 10 * 1024;
 
-  public static SqlStatementSanitizer create(boolean statementSanitizationEnabled) {
-    return new SqlStatementSanitizer(statementSanitizationEnabled);
+  public static SqlQuerySanitizer create(boolean statementSanitizationEnabled) {
+    return new SqlQuerySanitizer(statementSanitizationEnabled);
   }
 
   private final boolean statementSanitizationEnabled;
 
-  private SqlStatementSanitizer(boolean statementSanitizationEnabled) {
+  private SqlQuerySanitizer(boolean statementSanitizationEnabled) {
     this.statementSanitizationEnabled = statementSanitizationEnabled;
   }
 
-  public SqlStatementInfo sanitize(@Nullable String statement) {
+  public SqlQuery sanitize(@Nullable String statement) {
     return sanitize(statement, SqlDialect.DEFAULT);
   }
 
-  public SqlStatementInfo sanitize(@Nullable String statement, SqlDialect dialect) {
+  public SqlQuery sanitize(@Nullable String statement, SqlDialect dialect) {
     if (!statementSanitizationEnabled || statement == null) {
-      return SqlStatementInfo.create(statement, null, null);
+      return SqlQuery.create(statement, null, null);
     }
     // sanitization result will not be cached for statements larger than the threshold to avoid
     // cache growing too large
@@ -53,20 +52,20 @@ public final class SqlStatementSanitizer {
         CacheKey.create(statement, dialect), k -> sanitizeImpl(statement, dialect));
   }
 
-  private static SqlStatementInfo sanitizeImpl(String statement, SqlDialect dialect) {
+  private static SqlQuery sanitizeImpl(String statement, SqlDialect dialect) {
     supportability.incrementCounter(SQL_STATEMENT_SANITIZER_CACHE_MISS);
     return AutoSqlSanitizer.sanitize(statement, dialect);
   }
 
   /** Sanitize and extract query summary. */
-  public SqlStatementInfo sanitizeWithSummary(@Nullable String statement) {
+  public SqlQuery sanitizeWithSummary(@Nullable String statement) {
     return sanitizeWithSummary(statement, SqlDialect.DEFAULT);
   }
 
   /** Sanitize and extract query summary. */
-  public SqlStatementInfo sanitizeWithSummary(@Nullable String statement, SqlDialect dialect) {
+  public SqlQuery sanitizeWithSummary(@Nullable String statement, SqlDialect dialect) {
     if (!statementSanitizationEnabled || statement == null) {
-      return SqlStatementInfo.createWithSummary(statement, null, null);
+      return SqlQuery.createWithSummary(statement, null, null);
     }
     // sanitization result will not be cached for statements larger than the threshold to avoid
     // cache growing too large
@@ -78,7 +77,7 @@ public final class SqlStatementSanitizer {
         CacheKey.create(statement, dialect), k -> sanitizeWithSummaryImpl(statement, dialect));
   }
 
-  private static SqlStatementInfo sanitizeWithSummaryImpl(String statement, SqlDialect dialect) {
+  private static SqlQuery sanitizeWithSummaryImpl(String statement, SqlDialect dialect) {
     supportability.incrementCounter(SQL_STATEMENT_SANITIZER_CACHE_MISS);
     return AutoSqlSanitizerWithSummary.sanitize(statement, dialect);
   }
@@ -92,7 +91,7 @@ public final class SqlStatementSanitizer {
   abstract static class CacheKey {
 
     static CacheKey create(String queryText, SqlDialect dialect) {
-      return new AutoValue_SqlStatementSanitizer_CacheKey(queryText, dialect);
+      return new AutoValue_SqlQuerySanitizer_CacheKey(queryText, dialect);
     }
 
     abstract String getQueryText();

@trask trask marked this pull request as ready for review January 31, 2026 18:00
@trask trask requested a review from a team as a code owner January 31, 2026 18:00
// querySummary)
// For old semconv: derive collectionName and storedProcedureName from target based on operation
String collectionName =
SQL_CALL.equals(operationName) || "EXECUTE".equals(operationName) ? null : target;
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.

could put SQL_CALL.equals(operationName) || "EXECUTE".equals(operationName) into a variable

@trask trask enabled auto-merge (squash) February 10, 2026 17:24
@trask trask merged commit 22b99d9 into open-telemetry:main Feb 10, 2026
85 checks passed
@trask trask deleted the statement-rename branch February 10, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants