mongodb_exporter icon indicating copy to clipboard operation
mongodb_exporter copied to clipboard

Cache prometheusize rename between scrapes

Open vigno88 opened this issue 7 months ago • 12 comments

After profiling the exporter because it had a somewhat high cpu usage, it reported that the regexp operations in this function accounts for more than 10% of the cpu time.

More precisely, the first call to prometheusize uses 3.79%, the second 5.86% (in exporter.MakeMetrics) and lastly it 1.03% (in exporter.MakeRawMetrics)

This all goes to zero if we cache them.

vigno88 avatar May 09 '25 18:05 vigno88

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

:white_check_mark: vigno88
:white_check_mark: idoqo
:x: vigno99
You have signed the CLA already but the status is still pending? Let us recheck it.

it-percona-cla avatar May 09 '25 18:05 it-percona-cla

Hi @vigno88 looks like tests are still failing - also looks like the profile you shared was from before the change - will be nice to have both to see how they compare.

idoqo avatar May 10 '25 11:05 idoqo

Hi, thanks for the quick response.

I'll take a look at the tests and yes i will provide a new profile.

Nathan AV

vigno88 avatar May 10 '25 11:05 vigno88

Hi, please also make sure that it's thread-safe.

BupycHuk avatar May 11 '25 14:05 BupycHuk

i've signed the CLA a lot of time last week and I tried again today. It says that the signature was made, but the status of the issue doesn't update..

vigno88 avatar May 12 '25 12:05 vigno88

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 65.50%. Comparing base (dc46ed5) to head (24099d3). Report is 104 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1080      +/-   ##
==========================================
- Coverage   70.88%   65.50%   -5.39%     
==========================================
  Files          28       29       +1     
  Lines        3569     3073     -496     
==========================================
- Hits         2530     2013     -517     
- Misses        904      922      +18     
- Partials      135      138       +3     
Flag Coverage Δ
agent 65.50% <100.00%> (-5.39%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar May 12 '25 12:05 codecov[bot]

There are other changes is this profile, but this show the cpu usage of prometheusize after the changes. https://flamegraph.com/share/a322d13f-2f3a-11f0-8b23-2a8f4480f552

vigno88 avatar May 12 '25 14:05 vigno88

All the test have passed, and the signature for my account has passed (vigno99 is the user of my computer)

vigno88 avatar May 13 '25 15:05 vigno88

Thanks a lot for your contribution, @vigno88. I'll check with our internal QA team about testing this, and then we can merge.

idoqo avatar May 13 '25 17:05 idoqo

Hi @vigno88 , ready to merge this now, but seems there were also some commits from @vigno99 , so the CLA needs to be signed by both accounts

idoqo avatar Jun 10 '25 08:06 idoqo

vigno99 looks like an autogenerated git user on my work computer. It's not linked to any github account.. I can't log to anything with it

vigno88 avatar Jun 10 '25 11:06 vigno88