Skip to content

Emit available database response status codes - #20953

Draft
trask with Copilot wants to merge 31 commits into
mainfrom
copilot/trask-database-response-status
Draft

trask with Copilot wants to merge 31 commits into
mainfrom
copilot/trask-database-response-status

Conversation

Copilot AI commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Emit available db.response.status_code values for database operations, including client-provided synthetic statuses.

For example, a PostgreSQL syntax error emits:

db.response.status_code = "42601"
error.type = "42601"

JDBC spans also capture available statement warning codes on successful execution without marking the operation failed.

Elasticsearch and OpenSearch spans include available success and error response codes. Memcached emits codes only for failed operations, using client enum names such as ERR_2BIG; successful and expected non-error outcomes are omitted.

db.client.operation.duration retains the same extracted response codes as spans, including SQL warnings and successful Elasticsearch/OpenSearch responses. A separate semantic-conventions clarification makes this shared inclusion rule explicit. This adds a metric dimension and can split existing series by response status.

Existing error classification, exception fallback, and span-status behavior remain unchanged.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-10-27 04:44 UTC

Move out of draft to request review.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Copilot AI changed the title [WIP] Add database response status emission Emit available database response status codes on failed spans Oct 24, 2026
Copilot AI requested a review from trask October 24, 2026 23:48
@trask
trask requested a balanced review from Copilot October 24, 2026 23:53

Copilot AI left a comment

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.

🟡 Changes recommended

Response-status extraction has unresolved correctness gaps, and the default emission conflicts with the documented repository policy.

5 open issues
What changed in this PR

This PR extends shared database attribute extraction and status-aware instrumentations to emit available failure response codes alongside error.type, while aiming to preserve existing error classification and metric dimensions.

Changes:

  • Add a nullable response-status getter and shared end-of-operation emission.
  • Wire database clients to expose status codes, with exclusions for selected client-only failures.
  • Add getter regressions and update integration and metric assertions.
File Description
instrumentation/​vertx/​vertx-sql-client/​vertx-sql-client-common-4.0/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​vertx/​sqlclient/​common/​v4_0/​VertxSqlClientAttributesGetter.java Extract SQL status codes with an Oracle transport exclusion.
instrumentation/​vertx/​vertx-sql-client/​vertx-sql-client-5.0/​javaagent/​src/​unitTests/​java/​io/​opentelemetry/​javaagent/​instrumentation/​vertx/​sqlclient/​common/​v4_0/​VertxSqlClientAttributesGetterTest.java Test Oracle failures and cyclic causes.
instrumentation/​vertx/​vertx-sql-client/​vertx-sql-client-5.0/​javaagent/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​vertx/​sqlclient/​v5_0/​VertxSqlClientTest.java Assert SQL failure statuses and transport omission.
instrumentation/​vertx/​vertx-sql-client/​vertx-sql-client-4.0/​javaagent/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​vertx/​sqlclient/​v4_0/​VertxSqlClientTest.java Assert SQL failure statuses.
instrumentation/​vertx/​vertx-redis-client/​vertx-redis-client-4.0/​javaagent/​src/​unitTests/​java/​io/​opentelemetry/​javaagent/​instrumentation/​vertx/​redisclient/​v4_0/​VertxRedisClientAttributesGetterTest.java Test captured server-error prefixes.
instrumentation/​vertx/​vertx-redis-client/​vertx-redis-client-4.0/​javaagent/​src/​testShared/​java/​io/​opentelemetry/​javaagent/​instrumentation/​vertx/​redisclient/​v4_0/​VertxRedisClientErrorTest.java Extend shared error telemetry assertions.
instrumentation/​vertx/​vertx-redis-client/​vertx-redis-client-4.0/​javaagent/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​vertx/​redisclient/​v4_0/​VertxRedisClientTest.java Assert Redis response statuses.
instrumentation/​vertx/​vertx-redis-client/​vertx-redis-client-4.0/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​vertx/​redisclient/​v4_0/​VertxRedisClientAttributesGetter.java Expose captured Redis server codes.
instrumentation/​spymemcached-2.12/​javaagent/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​spymemcached/​v2_12/​SpymemcachedTest.java Assert version-dependent rejection status.
instrumentation/​spymemcached-2.12/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​spymemcached/​v2_12/​SpymemcachedAttributesGetter.java Extract statuses while excluding client failures.
instrumentation/​spymemcached-2.12/​javaagent-unit-tests/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​spymemcached/​v2_12/​SpymemcachedAttributesGetterTest.java Test server and client status distinctions.
instrumentation/​rediscala-1.8/​javaagent/​src/​test/​scala/​io/​opentelemetry/​javaagent/​instrumentation/​rediscala/​v1_8/​RediscalaClientTest.scala Assert standard and custom Redis codes.
instrumentation/​rediscala-1.8/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​rediscala/​v1_8/​RediscalaAttributesGetter.java Reuse server-error extraction for status codes.
instrumentation/​rediscala-1.8/​javaagent-unit-tests/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​rediscala/​v1_8/​RediscalaAttributesGetterTest.java Test server prefixes and unavailable statuses.
instrumentation/​r2dbc-1.0/​library/​src/​test/​java/​io/​opentelemetry/​instrumentation/​r2dbc/​v1_0/​R2dbcSqlAttributesGetterTest.java Test SQLSTATE extraction and omission.
instrumentation/​r2dbc-1.0/​library/​src/​main/​java/​io/​opentelemetry/​instrumentation/​r2dbc/​v1_0/​internal/​R2dbcSqlAttributesGetter.java Expose SQLSTATE as response status.
instrumentation/​opensearch/​opensearch-rest-common-1.0/​testing/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​opensearch/​rest/​common/​AbstractOpenSearchRestTest.java Add non-throwing HEAD 404 coverage.
instrumentation/​opensearch/​opensearch-rest-common-1.0/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​opensearch/​rest/​common/​v1_0/​OpenSearchRestAttributesGetter.java Extract failure statuses from REST responses.
instrumentation/​opensearch/​opensearch-rest-common-1.0/​javaagent-unit-tests/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​opensearch/​rest/​common/​v1_0/​OpenSearchRestAttributesGetterTest.java Test response-status filtering.
instrumentation/​opensearch/​opensearch-java-3.0/​javaagent/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​opensearch/​v3_0/​OpenSearchApacheHttpClient5TransportTest.java Assert response status on failed requests.
instrumentation/​opensearch/​opensearch-java-3.0/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​opensearch/​v3_0/​OpenSearchAttributesGetter.java Share exception-status extraction.
instrumentation/​opensearch/​opensearch-java-3.0/​javaagent-unit-tests/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​opensearch/​v3_0/​OpenSearchAttributesGetterTest.java Test wrapped exceptions and status filtering.
instrumentation/​mongo/​mongo-common/​testing/​src/​main/​java/​io/​opentelemetry/​instrumentation/​mongo/​testing/​AbstractMongoClientTest.java Assert write-failure response codes.
instrumentation/​mongo/​mongo-3.1/​library/​src/​test/​java/​io/​opentelemetry/​instrumentation/​mongo/​v3_1/​internal/​MongoDbAttributesGetterTest.java Extend server-code and omission coverage.
instrumentation/​mongo/​mongo-3.1/​library/​src/​main/​java/​io/​opentelemetry/​instrumentation/​mongo/​v3_1/​internal/​MongoDbAttributesGetter.java Share MongoDB response-code extraction.
instrumentation/​lettuce/​lettuce-5.1/​testing/​src/​main/​java/​io/​opentelemetry/​instrumentation/​lettuce/​v5_1/​AbstractLettuceReactiveClientTest.java Assert version-dependent reactive error statuses.
instrumentation/​lettuce/​lettuce-5.1/​library/​src/​test/​java/​io/​opentelemetry/​instrumentation/​lettuce/​v5_1/​LettuceDbAttributesGetterTest.java Test statuses separately from error fallbacks.
instrumentation/​lettuce/​lettuce-5.1/​library/​src/​main/​java/​io/​opentelemetry/​instrumentation/​lettuce/​v5_1/​LettuceDbAttributesGetter.java Extract server codes from Lettuce responses.
instrumentation/​lettuce/​lettuce-5.0/​javaagent/​src/​unitTests/​java/​io/​opentelemetry/​javaagent/​instrumentation/​lettuce/​v5_0/​LettuceAttributesGetterTest.java Test command and batch status extraction.
instrumentation/​lettuce/​lettuce-5.0/​javaagent/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​lettuce/​v5_0/​LettuceAsyncClientTest.java Assert command and batch failure statuses.
instrumentation/​lettuce/​lettuce-5.0/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​lettuce/​v5_0/​LettuceDbAttributesGetter.java Expose Redis command error codes.
instrumentation/​lettuce/​lettuce-5.0/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​lettuce/​v5_0/​LettuceBatchAttributesGetter.java Expose Redis batch error codes.
instrumentation/​lettuce/​lettuce-4.0/​javaagent/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​lettuce/​v4_0/​LettuceAsyncClientTest.java Assert command and batch failure statuses.
instrumentation/​lettuce/​lettuce-4.0/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​lettuce/​v4_0/​LettuceDbAttributesGetter.java Expose Redis command error codes.
instrumentation/​lettuce/​lettuce-4.0/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​lettuce/​v4_0/​LettuceBatchAttributesGetter.java Expose Redis batch error codes.
instrumentation/​lettuce/​lettuce-4.0/​javaagent-unit-tests/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​lettuce/​v4_0/​LettuceDbAttributesGetterTest.java Test server-code extraction and client omissions.
instrumentation/​jdbc/​testing/​src/​main/​java/​io/​opentelemetry/​instrumentation/​jdbc/​testing/​AbstractJdbcInstrumentationTest.java Add failed-transaction status assertions.
instrumentation/​jdbc/​library/​src/​test/​java/​io/​opentelemetry/​instrumentation/​jdbc/​internal/​JdbcAttributesGetterTest.java Test vendor codes and Oracle exclusions.
instrumentation/​jdbc/​library/​src/​test/​java/​io/​opentelemetry/​instrumentation/​jdbc/​datasource/​JdbcTelemetryTest.java Assert response statuses independently of fallback names.
instrumentation/​jdbc/​library/​src/​main/​java/​io/​opentelemetry/​instrumentation/​jdbc/​internal/​JdbcAttributesGetter.java Extract JDBC codes with Oracle local-error exclusions.
instrumentation/​elasticsearch/​elasticsearch-rest-common-5.0/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​elasticsearch/​rest/​common/​v5_0/​ElasticsearchDbAttributesGetter.java Extract failure statuses from REST responses.
instrumentation/​elasticsearch/​elasticsearch-rest-common-5.0/​javaagent-unit-tests/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​elasticsearch/​rest/​common/​v5_0/​ElasticsearchDbAttributesGetterTest.java Test response-status filtering and missing responses.
instrumentation/​elasticsearch/​elasticsearch-rest-5.0/​javaagent/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​elasticsearch/​rest/​v5_0/​ElasticsearchRest5Test.java Add non-throwing HEAD 404 coverage.
instrumentation/​clickhouse/​clickhouse-client-v2-0.8/​javaagent/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​clickhouse/​clientv2/​v0_8/​ClickHouseClientV2Test.java Assert server-exception status codes.
instrumentation/​clickhouse/​clickhouse-client-v1-0.5/​javaagent/​src/​unitTests/​java/​io/​opentelemetry/​javaagent/​instrumentation/​clickhouse/​clientv1/​v0_5/​ClickHouseErrorCodeExtractorTest.java Test overlapping server and client codes.
instrumentation/​clickhouse/​clickhouse-client-v1-0.5/​javaagent/​src/​test/​java/​io/​opentelemetry/​javaagent/​instrumentation/​clickhouse/​clientv1/​v0_5/​ClickHouseClientV1Test.java Cover server codes and connection-failure omission.
instrumentation/​clickhouse/​clickhouse-client-v1-0.5/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​clickhouse/​clientv1/​v0_5/​ClickHouseErrorCodeExtractor.java Separate response codes from client error classification.
instrumentation/​clickhouse/​clickhouse-client-v1-0.5/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​clickhouse/​clientv1/​v0_5/​ClickHouseClientV1Singletons.java Wire separate error and response extractors.
instrumentation/​clickhouse/​clickhouse-client-v1-0.5/​javaagent/​build.gradle.kts Register focused unit tests.
instrumentation/​clickhouse/​clickhouse-client-common-0.5/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​clickhouse/​client/​common/​v0_5/​ClickHouseInstrumenterFactory.java Accept a separate response-status extractor.
instrumentation/​clickhouse/​clickhouse-client-common-0.5/​javaagent/​src/​main/​java/​io/​opentelemetry/​javaagent/​instrumentation/​clickhouse/​client/​common/​v0_5/​ClickHouseAttributesGetter.java Delegate response-status extraction.
instrumentation/​aws-sdk/​aws-sdk-2.2/​library/​src/​test/​java/​io/​opentelemetry/​instrumentation/​awssdk/​v2_2/​internal/​DynamoDbErrorsTest.java Test service codes and missing-code omission.
instrumentation/​aws-sdk/​aws-sdk-2.2/​library/​src/​main/​java/​io/​opentelemetry/​instrumentation/​awssdk/​v2_2/​internal/​DynamoDbAttributesGetter.java Expose DynamoDB service error codes.
instrumentation-api-incubator/​src/​test/​java/​io/​opentelemetry/​instrumentation/​api/​incubator/​semconv/​db/​SqlClientAttributesExtractorTest.java Test combined SQL status and error attributes.
instrumentation-api-incubator/​src/​test/​java/​io/​opentelemetry/​instrumentation/​api/​incubator/​semconv/​db/​DbClientMetricsTest.java Verify response statuses do not add metric dimensions.
instrumentation-api-incubator/​src/​test/​java/​io/​opentelemetry/​instrumentation/​api/​incubator/​semconv/​db/​DbClientAttributesExtractorTest.java Test independent status extraction and fallbacks.
instrumentation-api-incubator/​src/​main/​java/​io/​opentelemetry/​instrumentation/​api/​incubator/​semconv/​db/​DbClientAttributesGetter.java Add the nullable response-status contract.
instrumentation-api-incubator/​src/​main/​java/​io/​opentelemetry/​instrumentation/​api/​incubator/​semconv/​db/​DbClientAttributesExtractor.java Emit response status during shared operation completion.

Review effort: Balanced

Copilot AI left a comment

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.

🟡 Changes recommended

OpenSearch REST exception-response recovery changes existing error classification and duration-metric grouping despite the stated compatibility requirement.

2 open issues
4 resolved since last review

Review effort: Balanced

Copilot AI left a comment

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.

🔵 Needs a closer look

Distinguishing server-returned codes from client-generated failures across 17 version-dependent getters warrants final maintainer validation.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

Copilot AI requested a review from trask October 25, 2026 03:57
@trask
trask requested a balanced review from Copilot October 25, 2026 04:00
Copilot AI and others added 12 commits October 27, 2026 11:38
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: trask <218610+trask@users.noreply.github.com>

Copilot AI left a comment

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.

🟡 Changes recommended

The ClickHouse unitTests suite is excluded from the shared scheduling limit, and three helper tests are placed in separate projects rather than the required in-module unitTests suites wired into check.

2 open issues

Review effort: Balanced

Co-authored-by: trask <218610+trask@users.noreply.github.com>

Copilot AI left a comment

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.

🟡 Changes recommended

Spymemcached still suppresses available success and expected-outcome status codes, while failed-operation metrics gain a dimension that can split series despite the stated compatibility promise.

4 open issues

Review effort: Balanced

Co-authored-by: trask <218610+trask@users.noreply.github.com>

Copilot AI left a comment

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.

🟡 Changes recommended

The shared metrics hot path unnecessarily rebuilds attributes for every successful database operation, even when no response status is present, adding avoidable allocation and copying overhead.

2 open issues
3 resolved since last review

Review effort: Balanced

Co-authored-by: trask <218610+trask@users.noreply.github.com>

Copilot AI left a comment

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.

🟢 Approval recommended

No active review issues are reported for the database response-status telemetry changes.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

Co-authored-by: trask <218610+trask@users.noreply.github.com>

Copilot AI left a comment

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.

🔵 Needs a closer look

Calling Statement.getWarnings() after every successful JDBC execution needs real-driver validation for active streaming and multi-result statements, since the added tests cover only synthetic statements.

No open issues 🎉

Review effort: Balanced

Co-authored-by: trask <218610+trask@users.noreply.github.com>

Copilot AI left a comment

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.

🔵 Needs a closer look

Capturing JDBC warnings adds a driver call after every successful statement, requiring broader driver and runtime validation of streaming and multiple-result behavior beyond the added MySQL scenarios.

No open issues 🎉

Review effort: Balanced

This branch has not been deployed

No deployments
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.

4 participants