feat: add getClusterMetricsAsJSON to cluster registries (#470) - #849
feat: add getClusterMetricsAsJSON to cluster registries (#470)#849amasen02 wants to merge 3 commits into
Conversation
Signed-off-by: amasen02 <amasen02@users.noreply.github.com>
68c7829 to
22f37a4
Compare
| this.contentType, | ||
| ).metrics(); | ||
| ); | ||
| return transform(registry); |
There was a problem hiding this comment.
One of the reasons I ended up contributing to Prometheus over OpenTelemetry is that it doesn't use inordinate levels of indirection for everything that make the code 1) slow as hell and 2) very very difficult to follow.
This indirection is unnecessary for a private function call. And a Rule of 3 violation. Just return the populated Registry and call the appropriate function.
There was a problem hiding this comment.
Thanks for the feedback @jdmarshall! Completely agree — updated in commit 4d4424b to remove the ransform parameter and indirection entirely. #gather now simply aggregates and returns the populated Registry directly.
…rometheus#470) * Remove transform parameter and indirection from #gather, returning populated Registry directly. * Address review feedback from @jdmarshall on prometheus#849. Signed-off-by: amasen02 <amasen02@users.noreply.github.com>
|
Gentle ping on getClusterMetricsAsJSON (603 tests passing). Glad to align with any registry API direction the maintainers prefer. |
| * metrics. | ||
| */ | ||
| async clusterMetrics() { | ||
| return this.#collect(registry => registry.metrics()); |
There was a problem hiding this comment.
You moved the Rule of Three violation one call up the tree, which is actually worse here because of the need for the thenable, which helps me understand how you were intending this before but it's still effectively the same problem.
const registry = await this.#collect();
return registry.metrics();
…eturned Registry directly
|
You're right — the thenable hop was the same indirection one level up. Reworked in 1e6aec7: One note: removing the extra Verification: |
| await Promise.all([promise, shutdown]); | ||
|
|
||
| expect(results).toEqual([1, 2]); | ||
| expect(results.sort()).toEqual([1, 2]); |
There was a problem hiding this comment.
This only proves that both fire and not in what order. If this needs to be changed then it's not ensuring that pending work is being retired prior to shutdown.
So something else needs to be asserted here instead. What we don't want is overlapping aggregate calls. So that's probably the thing to check instead.
Summary
Closes #470.
Verification
pm run lint\ (clean, 0 warnings/errors)
pm run check-prettier\ (all files formatted)
pm run compile-typescript\ (clean compilation)
pm run test-unit -- --coverage\ (31 suites passed, 603 tests passed, 34 snapshots passed)