Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(graphql): graphql instrumentation throw for sync calls #1254

Merged
merged 3 commits into from
Oct 28, 2022

Conversation

blumamir
Copy link
Member

Which problem is this PR solving?

The issue is that graphql resolvers can either be a promise or a sync function. Instrumentation wrapped each result with a promise (using asyncSafeExecuteInTheMiddle) which was confusing graphql, making it fail for sync runs, and changing the span times in a way that doesn't make sense (sync calls now overlapped).

Short description of the changes

  • When wrapping graphql resolver, check if the result is a promise and handle promise and sync response accordingly.

I added test and run test-all-versions on the PR

@blumamir blumamir requested a review from a team October 26, 2022 11:38
@github-actions github-actions bot requested a review from obecny October 26, 2022 11:38
@codecov
Copy link

codecov bot commented Oct 26, 2022

Codecov Report

Merging #1254 (1b2d308) into main (180b336) will decrease coverage by 2.29%.
The diff coverage is 86.20%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1254      +/-   ##
==========================================
- Coverage   96.08%   93.79%   -2.30%     
==========================================
  Files          14        7       -7     
  Lines         893      467     -426     
  Branches      191       89     -102     
==========================================
- Hits          858      438     -420     
+ Misses         35       29       -6     
Impacted Files Coverage Δ
...opentelemetry-instrumentation-graphql/src/utils.ts 92.85% <85.71%> (ø)
...try-instrumentation-graphql/src/instrumentation.ts 91.66% <100.00%> (ø)
...trumentation-document-load/src/enums/EventNames.ts
...ation-user-interaction/src/enums/AttributeNames.ts
...y-instrumentation-long-task/src/instrumentation.ts
...lugin-react-load/src/BaseOpenTelemetryComponent.ts
...entation-document-load/src/enums/AttributeNames.ts
...etry-plugin-react-load/src/enums/AttributeNames.ts
...metry-propagator-aws-xray/src/AWSXRayPropagator.ts
...etapackages/auto-instrumentations-web/src/utils.ts
... and 13 more

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

lgtm

@blumamir blumamir merged commit 524d98e into open-telemetry:main Oct 28, 2022
@dyladan dyladan mentioned this pull request Oct 28, 2022
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.

@opentelemetry/instrumentation-graphql Error when running synchronously
2 participants