Skip to content

Run openserch asyn callbacks with parent context#19027

Merged
laurit merged 1 commit into
open-telemetry:mainfrom
laurit:opensearch-callback
Jun 17, 2026
Merged

Run openserch asyn callbacks with parent context#19027
laurit merged 1 commit into
open-telemetry:mainfrom
laurit:opensearch-callback

Conversation

@laurit

@laurit laurit commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Copilot AI review requested due to automatic review settings June 17, 2026 10:22
@laurit laurit requested a review from a team as a code owner June 17, 2026 10:22

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.

Pull request overview

This PR fixes the OpenSearch 3.0 async instrumentation to run user-attached callbacks with the parent context active, rather than the context of the OpenSearch span created for the operation. This aligns the behavior with other async instrumentations in the repository (e.g., Apache HTTP async client, Elasticsearch REST/transport, Vertx HTTP client) which all propagate the parent context to user callbacks.

Changes:

  • Adds a wrapFuture helper that creates a new CompletableFuture wrapper ensuring the parent context is active when downstream callbacks execute.
  • Updates test assertions in both AbstractOpenSearchTest and OpenSearchAwsSdk2TransportTest to expect the "callback" span to be parented to the root "client" span (index 0) instead of the OpenSearch operation span (index 1).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
instrumentation/opensearch/opensearch-java-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/opensearch/v3_0/OpenSearchTransportInstrumentation.java Stores parentContext in AdviceScope, adds static wrapFuture method to wrap the returned future with parent context propagation
instrumentation/opensearch/opensearch-java-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opensearch/v3_0/AbstractOpenSearchTest.java Updates async test to assert callback span is parented to the root span (index 0)
instrumentation/opensearch/opensearch-java-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opensearch/v3_0/OpenSearchAwsSdk2TransportTest.java Same parent assertion fix for the AWS SDK transport variant

@laurit laurit merged commit 0fe64a2 into open-telemetry:main Jun 17, 2026
182 of 184 checks passed
@laurit laurit deleted the opensearch-callback branch June 17, 2026 15:08
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.

3 participants