Skip to content

Commit

Permalink
Merge pull request #86 from edina/add-metrics
Browse files Browse the repository at this point in the history
Add a prometheus metrics handler
  • Loading branch information
BertR committed Apr 23, 2021
2 parents 30b9462 + c3e6b6b commit 0fcc150
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion nbexchange/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from nbexchange.handlers.auth.naas_user_handler import NaasUserHandler
from nbexchange.handlers.auth.user_handler import BaseUserHandler

from tornado_prometheus import PrometheusMixIn, MetricsHandler

ROOT = os.path.dirname(__file__)
STATIC_FILES_DIR = os.path.join(ROOT, "static")
Expand Down Expand Up @@ -57,7 +58,7 @@ def default(self, obj=None):
}


class NbExchange(Application):
class NbExchange(PrometheusMixIn, Application):
"""The nbexchange application"""

name = "nbexchange"
Expand Down Expand Up @@ -251,6 +252,8 @@ def init_handlers(self):
for url in handler.urls:
self.handlers.append((url_path_join(self.base_url, url), handler))

self.handlers.append((r"/metrics", MetricsHandler))

self.handlers.append((r".*", base.Template404))
self.log.debug("##### ALL HANDLERS" + str(self.handlers))

Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@
REQUIRED = [
"alembic",
"aiocontextvars",
"tornado",
"tornado==6.1",
"psycopg2-binary",
"ipykernel==5.5.0",
"jupyterhub",
"sentry-sdk==1.0.0",
"sqlalchemy>=1.4.3",
"nbgrader==0.7.0.dev0",
"urllib3==1.25.11", # Pinned because of requests depdendency conflict
"urllib3==1.25.11", # Pinned because of requests dependency conflict
"pyjwt",
"tornado-prometheus==0.1.1",
]

# What packages are required for testing?
Expand Down

0 comments on commit 0fcc150

Please sign in to comment.