Skip to content

Instantly share code, notes, and snippets.

@AnotherKamila
Last active August 30, 2017 16:42
Show Gist options
  • Save AnotherKamila/9f2565f6671f833e9559e4c85de61185 to your computer and use it in GitHub Desktop.
Save AnotherKamila/9f2565f6671f833e9559e4c85de61185 to your computer and use it in GitHub Desktop.
Demo app for showing off the Prometheus monitoring server
#!/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()
prometheus-client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment