Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/jupyter_server/prometheus/metrics.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

8 statements  

1""" 

2Prometheus metrics exported by Jupyter Server 

3 

4Read https://prometheus.io/docs/practices/naming/ for naming 

5conventions for metrics & labels. 

6""" 

7 

8try: 

9 # Jupyter Notebook also defines these metrics. Re-defining them results in a ValueError. 

10 # Try to de-duplicate by using the ones in Notebook if available. 

11 # See https://github.com/jupyter/jupyter_server/issues/209 

12 from notebook.prometheus.metrics import ( 

13 HTTP_REQUEST_DURATION_SECONDS, 

14 KERNEL_CURRENTLY_RUNNING_TOTAL, 

15 TERMINAL_CURRENTLY_RUNNING_TOTAL, 

16 ) 

17 

18except ImportError: 

19 from prometheus_client import Gauge, Histogram 

20 

21 HTTP_REQUEST_DURATION_SECONDS = Histogram( 

22 "http_request_duration_seconds", 

23 "duration in seconds for all HTTP requests", 

24 ["method", "handler", "status_code"], 

25 ) 

26 

27 TERMINAL_CURRENTLY_RUNNING_TOTAL = Gauge( 

28 "terminal_currently_running_total", 

29 "counter for how many terminals are running", 

30 ) 

31 

32 KERNEL_CURRENTLY_RUNNING_TOTAL = Gauge( 

33 "kernel_currently_running_total", 

34 "counter for how many kernels are running labeled by type", 

35 ["type"], 

36 ) 

37 

38 

39__all__ = [ 

40 "HTTP_REQUEST_DURATION_SECONDS", 

41 "TERMINAL_CURRENTLY_RUNNING_TOTAL", 

42 "KERNEL_CURRENTLY_RUNNING_TOTAL", 

43]