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

🐛⚗️Prometheus instrumentation incorrectly setup #6398

Merged

Conversation

sanderegg
Copy link
Member

@sanderegg sanderegg commented Sep 19, 2024

What do these changes do?

Here is probably what was happening:

  • in tests we use asgi-lifespan to emulate what fastapi does (this is how fastapi recommend of doing)
  • since the tracing was introduced, it seems that initialization phase in the tests takes longer, and times-out sometimes (default is 5 seconds)
  • the prometheus_fastapi_instrumentator library introduced by @bisgaard-itis a long time ago uses a global CollectorRegistry, and is initialized,
  • after the time out happen, this is not cleaned up (since global are 👿 ),
  • all subsequent tests fail, as the global registry is already full.

This PR does:

  • creates a collector registry,
  • increases the timeouts in the lifespan manager,
  • does some cleaning

Related issue/s

How to test

Dev-ops checklist

@sanderegg sanderegg added the a:services-library issues on packages/service-libs label Sep 19, 2024
@sanderegg sanderegg added this to the MartinKippenberger milestone Sep 19, 2024
@sanderegg sanderegg self-assigned this Sep 19, 2024
Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 51.51515% with 16 lines in your changes missing coverage. Please review.

Project coverage is 87.9%. Comparing base (cafbf96) to head (e7cbb8b).
Report is 561 commits behind head on master.

Files with missing lines Patch % Lines
...c/servicelib/fastapi/prometheus_instrumentation.py 0.0% 9 Missing ⚠️
.../service-library/src/servicelib/instrumentation.py 0.0% 6 Missing ⚠️
.../service-library/src/servicelib/fastapi/tracing.py 83.3% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #6398      +/-   ##
=========================================
+ Coverage    84.5%   87.9%    +3.3%     
=========================================
  Files          10    1170    +1160     
  Lines         214   51580   +51366     
  Branches       25     930     +905     
=========================================
+ Hits          181   45340   +45159     
- Misses         23    6065    +6042     
- Partials       10     175     +165     
Flag Coverage Δ
integrationtests 64.7% <100.0%> (?)
unittests 85.4% <51.5%> (+0.8%) ⬆️

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

Files with missing lines Coverage Δ
...rvice_autoscaling/modules/instrumentation/_core.py 91.6% <100.0%> (ø)
...ice_autoscaling/modules/instrumentation/_models.py 100.0% <100.0%> (ø)
...vice_autoscaling/modules/instrumentation/_utils.py 100.0% <100.0%> (ø)
...ice_director_v2/modules/instrumentation/_models.py 100.0% <100.0%> (ø)
.../service-library/src/servicelib/fastapi/tracing.py 87.5% <83.3%> (ø)
.../service-library/src/servicelib/instrumentation.py 0.0% <0.0%> (ø)
...c/servicelib/fastapi/prometheus_instrumentation.py 0.0% <0.0%> (ø)

... and 1173 files with indirect coverage changes

@sanderegg sanderegg changed the title Autoscaling/collector registry issue 🐛⚗️Prometheus instrumentation incorrectly setup Sep 19, 2024
@sanderegg sanderegg marked this pull request as ready for review September 19, 2024 11:53
@sanderegg sanderegg requested a review from pcrespov as a code owner September 19, 2024 11:53
@sanderegg sanderegg added the t:maintenance Some planned maintenance work label Sep 19, 2024
Copy link
Contributor

@matusdrobuliak66 matusdrobuliak66 left a comment

Choose a reason for hiding this comment

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

Thanks a lot!!

@sanderegg sanderegg requested a review from GitHK September 19, 2024 12:51
Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

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

🎉

@sanderegg sanderegg force-pushed the autoscaling/collector-registry-issue branch from 44fa24e to bbe033c Compare September 19, 2024 13:11
Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

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

Thanks! Please also apply the same changes to director-v2's metrics module

Copy link

@sanderegg sanderegg merged commit 1327f2e into ITISFoundation:master Sep 19, 2024
57 checks passed
@sanderegg sanderegg deleted the autoscaling/collector-registry-issue branch September 19, 2024 21:11
@GitHK
Copy link
Contributor

GitHK commented Sep 20, 2024

Thanks for the changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:services-library issues on packages/service-libs t:maintenance Some planned maintenance work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

directorv-2: use a non global registry
4 participants