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

add metrics tracking the V8 heap usage #5781

Merged
merged 14 commits into from
Aug 20, 2024
Merged

add metrics tracking the V8 heap usage #5781

merged 14 commits into from
Aug 20, 2024

Conversation

Geal
Copy link
Contributor

@Geal Geal commented Aug 6, 2024

This adds new gauge metrics tracking V8 memory usage:

  • apollo.router.v8.heap.used
  • apollo.router.v8.heap.total

This uses code introduced in the router-bridge in apollographql/federation-rs#558

Due to the way we release the router-bridge, this updates the federation version to 2.8.3


ROUTER-671
Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Tests added and passing3
    • Unit Tests
    • Integration Tests
    • Manual Tests

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

This comment has been minimized.

@router-perf
Copy link

router-perf bot commented Aug 6, 2024

CI performance tests

  • const - Basic stress test that runs with a constant number of users
  • demand-control-instrumented - A copy of the step test, but with demand control monitoring and metrics enabled
  • demand-control-uninstrumented - A copy of the step test, but with demand control monitoring enabled
  • enhanced-signature - Enhanced signature enabled
  • events - Stress test for events with a lot of users and deduplication ENABLED
  • events_big_cap_high_rate - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity
  • events_big_cap_high_rate_callback - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity using callback mode
  • events_callback - Stress test for events with a lot of users and deduplication ENABLED in callback mode
  • events_without_dedup - Stress test for events with a lot of users and deduplication DISABLED
  • events_without_dedup_callback - Stress test for events with a lot of users and deduplication DISABLED using callback mode
  • extended-reference-mode - Extended reference mode enabled
  • large-request - Stress test with a 1 MB request payload
  • no-tracing - Basic stress test, no tracing
  • reload - Reload test over a long period of time at a constant rate of users
  • step-jemalloc-tuning - Clone of the basic stress test for jemalloc tuning
  • step-local-metrics - Field stats that are generated from the router rather than FTV1
  • step-with-prometheus - A copy of the step test with the Prometheus metrics exporter enabled
  • step - Basic stress test that steps up the number of users over time
  • xlarge-request - Stress test with 10 MB request payload
  • xxlarge-request - Stress test with 100 MB request payload

@Geal Geal marked this pull request as ready for review August 6, 2024 16:40
@Geal Geal requested review from a team as code owners August 6, 2024 16:40
Copy link
Contributor

@shorgi shorgi left a comment

Choose a reason for hiding this comment

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

docs LGTM

.changesets/feat_geal_v8_heap_statistics.md Outdated Show resolved Hide resolved
Geal and others added 2 commits August 19, 2024 18:08
Copy link
Contributor

@BrynCooke BrynCooke left a comment

Choose a reason for hiding this comment

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

Looks great.
@shorgi Could we look at separately creating some sort of troubleshooting docs that talk about when this is useful?

let current_heap_used_for_gauge = current_heap_used.clone();
let heap_used_gauge = meter
.u64_observable_gauge("apollo.router.v8.heap.used")
.with_description("V8 heap used, in bytes")
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also set a unit. Sometimes in some apms it's required to display the metrics properly

let current_heap_total_for_gauge = current_heap_total.clone();
let heap_total_gauge = meter
.u64_observable_gauge("apollo.router.v8.heap.total")
.with_description("V8 heap total, in bytes")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same for the unit

let pool_size_gauge = meter_provider()
.meter("apollo/router")
let meter = meter_provider().meter("apollo/router");
let pool_size_gauge = meter
.u64_observable_gauge("apollo.router.query_planning.queued")
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it existed before but could you add description and unit please ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what kind of unit do we set here? Is there a convention for the expected units in otel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(asking because I don't see many examples of setting units in our metrics)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes there are. At different places but for example for memory you can find an example here https://opentelemetry.io/docs/specs/semconv/system/hardware-metrics/#hwmemory---memory-module-metrics and more generally you can take examples from here there are some conventions too

Copy link
Contributor

Choose a reason for hiding this comment

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

For this on I would suggest using query

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

@Geal
Copy link
Contributor Author

Geal commented Aug 20, 2024

@bnjjj is that the correct way to set units? 9e710a5

@Geal Geal requested a review from bnjjj August 20, 2024 07:27
@bnjjj
Copy link
Contributor

bnjjj commented Aug 20, 2024

@Geal yes except that for bytes it's usually By Check example here

@Geal
Copy link
Contributor Author

Geal commented Aug 20, 2024

@bnjjj ok, it's fixed!

@Geal Geal merged commit 32fa87e into dev Aug 20, 2024
13 checks passed
@Geal Geal deleted the geal/v8-heap-statistics branch August 20, 2024 08:38
@abernix abernix mentioned this pull request Aug 28, 2024
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.

5 participants