claws / aioprometheus

A Prometheus Python client library for asyncio-based applications
175 stars 21 forks source link

Improve Starlette integration, fixes #72 #74

Closed claws closed 2 years ago

claws commented 2 years ago

This change improves Starlette integration by fixing #72.

The change involves delaying creation of the middleware metrics until a call is made through to the middleware to update a metric. This approached seemed like the best method for handling Starlette occasionally rebuilding the middleware stack - which, due to the middleware previously creating metrics in the __init__ method, was the cause of the exceptions being triggered.

This change also makes minor tweaks to some project files and bumps the version in preparation for a new release. The tweaks are:

codecov-commenter commented 2 years ago

Codecov Report

Merging #74 (5bb7dc8) into master (72d6bd2) will increase coverage by 0.03%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #74      +/-   ##
==========================================
+ Coverage   95.50%   95.54%   +0.03%     
==========================================
  Files          17       17              
  Lines         779      785       +6     
  Branches      114      115       +1     
==========================================
+ Hits          744      750       +6     
  Misses         19       19              
  Partials       16       16              
Impacted Files Coverage Δ
src/aioprometheus/__init__.py 100.00% <100.00%> (ø)
src/aioprometheus/asgi/middleware.py 88.57% <100.00%> (+1.07%) :arrow_up:

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 72d6bd2...5bb7dc8. Read the comment docs.