Skip to content

Reduce function indirection in histogram.js for easier debugging - #669

Merged
zbjornson merged 2 commits into
prometheus:masterfrom
jdmarshall:ergonomics
Jul 8, 2025
Merged

Reduce function indirection in histogram.js for easier debugging#669
zbjornson merged 2 commits into
prometheus:masterfrom
jdmarshall:ergonomics

Conversation

@jdmarshall

Copy link
Copy Markdown
Contributor

Also add missing benchmarks for startTimer(), since I'm mucking about in its innards.

In theory removing call() for arrow functions or straight calls improves performance, but I've never managed a benchmark that proves it. This change also reduces closure creation but GC is also difficult to benchmark. Make enough of these changes however and you can get yourself a little teeny tiny notch in your telemetry data that proves you did something (I think I clocked my test case at about .8%, because the calls were slow and so that added up to 5+ms).

So these are officially just about improving single step debugging.

One of the places where Prometheus can outshine OpenTelemetry is in trying to figure out why your metrics are confusing/missing/garbled. If you've ever tried to single-step through OTEL it's a maze of twisty little passages, all the same. prom-client has a fairly straightforward architecture and thus is already much better in this regard but I'm interested in making tools that need to 'just work' more approachable.

Comment thread lib/metrics/helpers/processMetricsHelpers.js

@SimenB SimenB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

makes sense to me 👍

mind addressing the ESLint warnings?

(I'm not an admin on this repo, so unable to have the actions trigger for first contributions 😅 since a bunch of your other changes have landed tho, it shouldn't be an issues once you push again)

@jdmarshall
jdmarshall force-pushed the ergonomics branch 2 times, most recently from d64ea6c to 4ad0bcf Compare July 1, 2025 14:48

@zbjornson zbjornson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

@zbjornson
zbjornson merged commit 4c6224d into prometheus:master Jul 8, 2025
12 checks passed
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.

3 participants