Last active
August 30, 2017 16:42
-
-
Save AnotherKamila/9f2565f6671f833e9559e4c85de61185 to your computer and use it in GitHub Desktop.
Demo app for showing off the Prometheus monitoring server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import prometheus_client as prom | |
import random | |
import time | |
import sys | |
T = float(sys.argv[1]) if len(sys.argv) > 1 else 0.1 | |
REQUEST_TIME = prom.Summary('processing_time_seconds', 'Time spent processing request') | |
@REQUEST_TIME.time() | |
def do_something(): | |
t = T + random.random()/10 | |
print(t) | |
time.sleep(t) | |
if __name__ == '__main__': | |
prom.start_http_server(8047) | |
while True: | |
do_something() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prometheus-client |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment