Skip to content

Commit

Permalink
Avoid registering Flask endpoint in forked debug mode, Fixes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
rycus86 committed Mar 20, 2018
1 parent 957fa44 commit 019b93d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion prometheus_flask_exporter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from flask import request, make_response
from flask import Flask, Response
from werkzeug.serving import is_running_from_reloader
from werkzeug.exceptions import HTTPException
from prometheus_client import Counter, Histogram, Gauge, Summary
from prometheus_client import generate_latest, CONTENT_TYPE_LATEST
Expand Down Expand Up @@ -99,6 +100,9 @@ def register_endpoint(self, path, app=None):
(by default it is the application registered with this class)
"""

if is_running_from_reloader():
return

if app is None:
app = self.app

Expand All @@ -124,6 +128,9 @@ def start_http_server(self, port, host='0.0.0.0', endpoint='/metrics'):
(default: `/metrics`)
"""

if is_running_from_reloader():
return

app = Flask('prometheus-flask-exporter-%d' % port)
self.register_endpoint(endpoint, app)

Expand Down Expand Up @@ -423,4 +430,4 @@ def info(self, name, description, labelnames=None, labelvalues=None, **labels):
return gauge


__version__ = '0.2.0'
__version__ = '0.2.1'
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
setup(
name='prometheus_flask_exporter',
packages=['prometheus_flask_exporter'],
version='0.2.0',
version='0.2.1',
description='Prometheus metrics exporter for Flask',
long_description=long_description,
license='MIT',
author='Viktor Adam',
author_email='[email protected]',
url='https://github.com/rycus86/prometheus_flask_exporter',
download_url='https://github.com/rycus86/prometheus_flask_exporter/archive/0.2.0.tar.gz',
download_url='https://github.com/rycus86/prometheus_flask_exporter/archive/0.2.1.tar.gz',
keywords=['prometheus', 'flask', 'monitoring', 'exporter'],
classifiers=[
'Development Status :: 4 - Beta',
Expand Down

0 comments on commit 019b93d

Please sign in to comment.