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

[apollo-usage-report] New plugin: send usage traces to Apollo GraphOS #3331

Merged
merged 12 commits into from
Aug 15, 2024

Conversation

EmrysMyrddin
Copy link
Collaborator

@EmrysMyrddin EmrysMyrddin commented Jun 25, 2024

This PR implement a new plugin that instrument the GraphQL request processing pipeline and send the traces to Apollo GraphOS usage report endpoint.

TODO:

  • btached operations support

This is a very minimal implementation. Namely, it doesn't support:

  • batched traces
  • compressed request
  • error handling and retry strategy
  • async iterable result, which means it's incompatible with @defer and @stream
  • stats (group of traces sumurized into a stat object)
  • sampling rate: traces are always generated
  • error handling: traces are lost on error, no retry
  • advanced Apollo options

Copy link

changeset-bot bot commented Jun 25, 2024

🦋 Changeset detected

Latest commit: d4c5410

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@graphql-yoga/plugin-apollo-inline-trace Major
graphql-yoga Minor
@graphql-yoga/plugin-sofa Major
@graphql-yoga/nestjs Major
@graphql-yoga/nestjs-federation Patch
@graphql-yoga/plugin-apollo-usage-report Major
@graphql-yoga/render-graphiql Major
@graphql-yoga/apollo-managed-federation Major
@graphql-yoga/plugin-apq Major
@graphql-yoga/plugin-csrf-prevention Major
@graphql-yoga/plugin-defer-stream Major
@graphql-yoga/plugin-disable-introspection Major
@graphql-yoga/plugin-graphql-sse Major
@graphql-yoga/plugin-jwt Major
@graphql-yoga/plugin-persisted-operations Major
@graphql-yoga/plugin-prometheus Major
@graphql-yoga/plugin-response-cache Major
apollo-federation-gateway-with-yoga Patch
apollo-subgraph-with-yoga Patch
graphql-lambda Patch
cloudflare-advanced Patch
cloudflare Patch
nextjs-app Patch
hello-world-benchmark Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@EmrysMyrddin EmrysMyrddin marked this pull request as draft June 25, 2024 08:04
Copy link
Contributor

github-actions bot commented Jun 25, 2024

Apollo Federation Subgraph Compatibility Results

Federation 1 Support Federation 2 Support
_service🟢
@key (single)🟢
@key (multi)🟢
@key (composite)🟢
repeatable @key🟢
@requires🟢
@provides🟢
federated tracing🟢
@link🟢
@shareable🟢
@tag🟢
@override🟢
@inaccessible🟢
@composeDirective🟢
@interfaceObject🟢

Learn more:

@EmrysMyrddin EmrysMyrddin force-pushed the grapphos-usage-report branch 2 times, most recently from 86ae099 to 0e18c8e Compare July 10, 2024 08:42
Copy link
Contributor

github-actions bot commented Jul 10, 2024

✅ Benchmark Results

     ✓ no_errors{mode:graphql}
     ✓ expected_result{mode:graphql}
     ✓ no_errors{mode:graphql-jit}
     ✓ expected_result{mode:graphql-jit}
     ✓ no_errors{mode:graphql-response-cache}
     ✓ expected_result{mode:graphql-response-cache}
     ✓ no_errors{mode:graphql-no-parse-validate-cache}
     ✓ expected_result{mode:graphql-no-parse-validate-cache}

     checks.......................................: 100.00% ✓ 418954      ✗ 0     
     data_received................................: 1.7 GB  14 MB/s
     data_sent....................................: 85 MB   705 kB/s
     http_req_blocked.............................: avg=1.48µs   min=971ns    med=1.3µs    max=7.23ms   p(90)=1.91µs   p(95)=2.11µs  
     http_req_connecting..........................: avg=2ns      min=0s       med=0s       max=145.48µs p(90)=0s       p(95)=0s      
     http_req_duration............................: avg=361.76µs min=221.53µs med=324.13µs max=14.94ms  p(90)=463.05µs p(95)=482.1µs 
       { expected_response:true }.................: avg=361.76µs min=221.53µs med=324.13µs max=14.94ms  p(90)=463.05µs p(95)=482.1µs 
     ✓ { mode:graphql-jit }.......................: avg=288.36µs min=221.53µs med=266.86µs max=14.94ms  p(90)=297.94µs p(95)=312.32µs
     ✓ { mode:graphql-no-parse-validate-cache }...: avg=486.28µs min=399.25µs med=458.86µs max=9.72ms   p(90)=498.75µs p(95)=532.04µs
     ✓ { mode:graphql-response-cache }............: avg=341.43µs min=267.29µs med=322.12µs max=6.9ms    p(90)=353.32µs p(95)=364.9µs 
     ✓ { mode:graphql }...........................: avg=365.62µs min=275.99µs med=333.44µs max=13.49ms  p(90)=377.15µs p(95)=414.14µs
     http_req_failed..............................: 0.00%   ✓ 0           ✗ 209477
     http_req_receiving...........................: avg=33.63µs  min=17.49µs  med=33.47µs  max=3.76ms   p(90)=39.25µs  p(95)=41.43µs 
     http_req_sending.............................: avg=8.14µs   min=5.94µs   med=7.19µs   max=4.22ms   p(90)=10.7µs   p(95)=11.44µs 
     http_req_tls_handshaking.....................: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting.............................: avg=319.98µs min=186.56µs med=282.98µs max=14.82ms  p(90)=420.85µs p(95)=437.77µs
     http_reqs....................................: 209477  1745.622266/s
     iteration_duration...........................: avg=568.06µs min=391.09µs med=527.38µs max=15.44ms  p(90)=673.21µs p(95)=697.67µs
     iterations...................................: 209477  1745.622266/s
     vus..........................................: 1       min=1         max=1   
     vus_max......................................: 2       min=2         max=2   

Copy link
Contributor

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-yoga/apollo-link 3.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/urql-exchange 3.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/graphiql 4.3.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
graphql-yoga 5.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/nestjs 3.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/nestjs-federation 3.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-apollo-inline-trace 3.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/apollo-managed-federation 0.3.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-apollo-usage-report 0.0.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-apq 3.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-csrf-prevention 3.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-defer-stream 3.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-disable-introspection 2.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-graphql-sse 3.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-jwt 2.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-persisted-operations 3.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-prometheus 5.3.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-response-cache 3.8.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-sofa 3.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎
@graphql-yoga/render-graphiql 5.6.1-alpha-20240710084647-0e18c8e7 npm ↗︎ unpkg ↗︎

Copy link
Contributor

github-actions bot commented Jul 10, 2024

💻 Website Preview

The latest changes are available as preview in: https://1c79801b.graphql-yoga.pages.dev

@ardatan ardatan marked this pull request as ready for review August 15, 2024 20:27
@ardatan ardatan merged commit 5dae4ab into main Aug 15, 2024
34 checks passed
@ardatan ardatan deleted the grapphos-usage-report branch August 15, 2024 22:26
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