bosagora / agora

POC Node implementation for CoinNet
https://bosagora.io
MIT License
37 stars 23 forks source link

Stats: Append scrape duration to the end of `/metrics` response #3248

Closed omerfirmak closed 2 years ago

Geod24 commented 2 years ago

Although https://dlang.org/phobos/std_datetime_stopwatch.html#StopWatch might be more suited

omerfirmak commented 2 years ago

Although https://dlang.org/phobos/std_datetime_stopwatch.html#StopWatch might be more suited

this was what docs suggested

// If stopping or resetting the StopWatch is not required, then
// MonoTime can easily be used by itself without StopWatch.
auto before = MonoTime.currTime;
// do stuff...
auto timeElapsed = MonoTime.currTime - before;
codecov[bot] commented 2 years ago

Codecov Report

Merging #3248 (1408b30) into v0.x.x (d360fd7) will decrease coverage by 1.13%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           v0.x.x    #3248      +/-   ##
==========================================
- Coverage   54.70%   53.57%   -1.14%     
==========================================
  Files         332      332              
  Lines       35811    35820       +9     
==========================================
- Hits        19592    19189     -403     
- Misses      16219    16631     +412     
Flag Coverage Δ
integration 23.74% <0.00%> (-6.40%) :arrow_down:
unittests 87.66% <100.00%> (+0.10%) :arrow_up:

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

Impacted Files Coverage Δ
source/agora/node/Runner.d 50.32% <ø> (-5.23%) :arrow_down:
source/agora/stats/CollectorRegistry.d 96.77% <100.00%> (+0.10%) :arrow_up:
source/agora/stats/Stats.d 100.00% <100.00%> (ø)
...modules/vibe-core/source/vibe/internal/allocator.d 37.50% <0.00%> (-62.50%) :arrow_down:
agora/submodules/vibe.d/http/vibe/http/client.d 0.24% <0.00%> (-52.78%) :arrow_down:
source/agora/network/VibeManager.d 10.00% <0.00%> (-35.72%) :arrow_down:
agora/submodules/vibe.d/web/vibe/web/rest.d 16.43% <0.00%> (-34.25%) :arrow_down:
...ra/submodules/vibe.d/stream/vibe/stream/counting.d 28.94% <0.00%> (-13.16%) :arrow_down:
agora/submodules/vibe.d/data/vibe/data/json.d 5.78% <0.00%> (-11.93%) :arrow_down:
agora/submodules/base32/src/base32.d 0.00% <0.00%> (-11.12%) :arrow_down:
... and 28 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9b1c6b1...1408b30. Read the comment docs.

Geod24 commented 2 years ago

Looking at this again, I have to question the motive. Do you expect scrape to take long ? I think that the delays you might be seeing is in Vibe.d handling the request, which means by the time we get to MonoTime.start, most of the delay has already passed.

omerfirmak commented 2 years ago

@Geod24, yeap I suspected the DB operations in /metrics to block the process for a long time occasionally. But havent seen anything proving that.