Skip to content

Conversation

@theJC
Copy link
Contributor

@theJC theJC commented Mar 14, 2023

What Does This Do

Instruments async data fetchers by adding an additional CompletionStage which finishes the span at the time the future completes

Fixes: #4051
Datadog issue: https://help.datadoghq.com/hc/en-us/requests/986538

Motivation

To allow async fetcher's timeframes be properly represented in APM traces, so that Indeed can retire our custom instrumentation and leverage Datadog's graphql instrumentation instead.

Additional Notes

@theJC theJC requested a review from a team as a code owner March 14, 2023 07:27
@theJC theJC force-pushed the GraphqlCompletableFutureFetcherFix branch 2 times, most recently from abadf3c to 17cae4a Compare March 14, 2023 08:59
@theJC theJC force-pushed the GraphqlCompletableFutureFetcherFix branch 6 times, most recently from ed3c4bf to 2d044cc Compare March 25, 2023 05:04
@theJC
Copy link
Contributor Author

theJC commented Mar 25, 2023

@ygree -- Can I please ask y'all to take a look at this one and see if there is anything else I've missed that is absolutely required to be added before merging this change? I've tried to scope it as small and limited to just the minimal capability we need improved for our needs.

I believe after this, there is only one or two last issues before Indeed can transition off its own instrumentation libraries, and just use Datadog's GraphQL tracing instrumentation alone.

@theJC theJC changed the title Properly support async data fetchers returning CompletableFuture Support async data fetchers returning CompletableFuture Mar 25, 2023
fieldSpan.finish();
throw e;
}
if (dataValue instanceof CompletableFuture<?>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest using CompletionStage instead of CompletableFuture to make this instrumentation work with any CompletionStage implementations other than CompletableFuture.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks for the recommendation.

@ygree
Copy link
Contributor

ygree commented Mar 28, 2023

@ygree -- Can I please ask y'all to take a look at this one and see if there is anything else I've missed that is absolutely required to be added before merging this change? I've tried to scope it as small and limited to just the minimal capability we need improved for our needs.

Thank you for your contribution! I suggest using CompletionStage instead of CompletableFuture to support other types that implement the CompletionStage interface. Other than that your solution looks good!

@theJC theJC force-pushed the GraphqlCompletableFutureFetcherFix branch from 2d044cc to cf5a7fe Compare March 28, 2023 03:47
@theJC theJC changed the title Support async data fetchers returning CompletableFuture graphql: Support async data fetchers returning CompletableFuture Mar 28, 2023
@theJC theJC changed the title graphql: Support async data fetchers returning CompletableFuture graphql: Support async data fetchers returning CompletionStage Mar 28, 2023
@theJC
Copy link
Contributor Author

theJC commented Mar 28, 2023

I've made updates to address all of your feedback and I think we should be all set unless there is feedback on implementation of the updates. Thanks Yury!

Copy link
Contributor

@ygree ygree left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks again for your contribution!

@ygree ygree merged commit 8ded15c into DataDog:master Mar 28, 2023
@bantonsson bantonsson added the inst: others All other instrumentations label Mar 29, 2023
@bantonsson bantonsson added this to the 1.12.0 milestone Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: others All other instrumentations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GraphQL Instrumentation - Support for async data fetchers returning CompletableFuture

3 participants