Skip to content

Commit

Permalink
Make the api mandatory in RESTfulPrometheusMetrics.for_app_factory
Browse files Browse the repository at this point in the history
Fixes #62
  • Loading branch information
rycus86 committed Jul 22, 2020
1 parent 9cfbbd6 commit a3ed550
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/restful-return-none/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
app = Flask(__name__)
restful_api = Api(app)

metrics = RESTfulPrometheusMetrics(app, restful_api)
metrics = RESTfulPrometheusMetrics.for_app_factory(restful_api)


class Test(Resource):
Expand All @@ -26,4 +26,5 @@ def get():


if __name__ == '__main__':
metrics.init_app(app)
app.run('0.0.0.0', 4000)
4 changes: 4 additions & 0 deletions prometheus_flask_exporter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,10 @@ def __init__(self, app, api, **kwargs):
kwargs['response_converter'] = self._create_response_converter(api)
super().__init__(app, **kwargs)

@classmethod
def for_app_factory(cls, api, **kwargs):
return cls(app=None, api=api, **kwargs)

@staticmethod
def _create_response_converter(api):
def _make_response(response):
Expand Down

0 comments on commit a3ed550

Please sign in to comment.