Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

Implements db.query.summary attribute extraction for Geode instrumentation to support low-cardinality span names in stable semconv mode.

Changes

  • GeodeRequest: Stores SqlStatementInfo instead of raw query string, enabling access to both sanitized query text and query summary
  • GeodeDbAttributesGetter: Delegates to SqlStatementInfo for query text and implements getDbQuerySummary()
  • Test assertions: Updated to handle stable semconv mode where span names use query summary format and DB_QUERY_TEXT replaces DB_STATEMENT

Example

In stable semconv mode, Geode query spans now use the query summary for the span name:

// Query: "SELECT * FROM /test-region"
// Old span name: "query test-region"
// New span name: "SELECT test"  // Uses db.query.summary

// Attributes include:
// - db.query.text: "SELECT * FROM /test-region" 
// - db.query.summary: "SELECT test"
// - db.operation.name: "query"

Query summary extraction follows SQL semantic conventions, providing operation + collection name for improved observability with bounded cardinality.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • develocity.opentelemetry.io
    • Triggering command: /usr/lib/jvm/temurin-21-jdk-amd64/bin/java /usr/lib/jvm/temurin-21-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant (dns block)
  • scans-in.gradle.com
    • Triggering command: /usr/lib/jvm/temurin-21-jdk-amd64/bin/java /usr/lib/jvm/temurin-21-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Implementation Guide: Adding db.query.summary Support to Geode Instrumentation

Quick Start

This guide shows how to add db.query.summary support to Geode instrumentation (version 1.4).

Prerequisites

CRITICAL: You must cherry-pick changes from PR #15909 and PR #15896. PR #15909 adds support for using db.query.summary as the span name when available (in stable semconv mode). PR #15896 adds the SqlStatementInfo.getQuerySummary() method.

git fetch origin pull/15909/head
git cherry-pick FETCH_HEAD
git fetch origin pull/15896/head
git cherry-pick FETCH_HEAD

Current State

The Geode instrumentation uses SqlStatementSanitizer directly in GeodeDbAttributesGetter.getDbQueryText() to sanitize queries. Unlike other instrumentations, it doesn't store a SqlStatementInfo object. The GeodeDbAttributesGetter currently provides:

  • getDbSystemName() - returns "geode"
  • getDbNamespace() - returns the region name
  • getDbQueryText() - returns sanitized query text
  • getDbOperationName() - returns the operation (e.g., "get", "put", "query")

Implementation Steps

1. Store SqlStatementInfo in GeodeRequest

File: instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeRequest.java

Changes needed:

  1. Add a SqlStatementInfo field to store parsed query information
  2. Update the create() method to create SqlStatementInfo from the query parameter
  3. Add getter method for SqlStatementInfo

Example:

import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlStatementInfo;
import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlStatementSanitizer;
import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig;

@AutoValue
public abstract class GeodeRequest {

  private static final SqlStatementSanitizer sanitizer =
      SqlStatementSanitizer.create(AgentCommonConfig.get().isStatementSanitizationEnabled());

  public static GeodeRequest create(
      Region<?, ?> region,
      String operation,
      @Nullable String query) {
    SqlStatementInfo sqlStatementInfo = query != null ? sanitizer.sanitize(query) : null;
    return new AutoValue_GeodeRequest(region, operation, query, sqlStatementInfo);
  }

  public abstract Region<?, ?> getRegion();

  public abstract String getOperation();

  @Nullable
  abstract SqlStatementInfo getSqlStatementInfo();
}

2. Update GeodeRegionInstrumentation to Create SqlStatementInfo

File: instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeRegionInstrumentation.java

Changes needed:
Update the advice methods to pass the query to GeodeRequest.create(), which will handle creating SqlStatementInfo internally.

Example:

// In your advice method:
@Advice.OnMethodEnter(suppress = Throwable.class)
public static void onEnter(
    @Advice.This Region<?, ?> region,
    @Advice.Argument(0) @Nullable String query,
    @Advice.Local("otelRequest") GeodeRequest request,
    @Advice.Local("otelContext") Context context,
    @Advice.Local("otelScope") Scope scope) {
  
  Context parentContext = currentContext();
  request = GeodeRequest.create(region, "query", query);
  // ... rest of the advice
}

3. Update GeodeDbAttributesGetter

File: instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java

Changes needed:

  1. Remove the SqlStatementSanitizer field and direct usage in getDbQueryText()
  2. Update getDbQueryText() to delegate to SqlStatementInfo.getQueryText()
  3. Add getDbQuerySummary() method that delegates to SqlStatementInfo.getQuerySummary()
  4. Update any other callers that used request.getQuery() to use request.getSqlStatementInfo().getQueryText() instead

Example:

@Override
@Nullable
public String getDbQueryText(GeodeRequest request) {
  if (request.getSqlStatementInfo() == null) {
    return null;
  }
  return request.getSqlStatementInfo().getQueryText();
}

@Override
@Nullable
public String getDbOperationName(GeodeRequest request) {
  // For Geode, the operation is explicitly provided (not parsed from SQL)
  // So we can return it in both old and stable semconv modes
  return request.getOperation();
}

@Nullable
@Override
public String getDbQuerySummary(GeodeRequest request) {
  if (request.getSqlStatementInfo() == null) {
    return null;
  }
  return request.getSqlStatementInfo().getQuerySummary();
}

4. Update Tests for Stable Semconv

File: instrumentation/geode-1.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/geode/PutGetTest.java

Changes needed:

  1. Import DB_QUERY_SUMMARY and emitStableDatabaseSemconv()
  2. Update test assertions to include db.query.summary in stable semconv mode
  3. Update span name assertions when query summary is available
  4. Conditionally assert db.operation based on semcon...

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add db.query.summary support to Geode instrumentation Add db.query.summary support to Geode instrumentation Jan 19, 2026
Copilot AI requested a review from trask January 19, 2026 01:44
}

@SuppressWarnings("deprecation") // using deprecated semconv
void assertGeodeTrace(String verb, String query) {
Copy link
Member

Choose a reason for hiding this comment

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

sending PR first for this

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