#!/usr/bin/env pmpython
'''
Performance Metrics Domain Agent exporting OpenMetrics endpoint metrics.
'''
#
# Copyright (c) 2017 Ronak Jain.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#

from prometheus_client import start_http_server, Summary, \
	Counter, Gauge, Histogram
import time
import sys

requests = Counter('requests_total', 'Total requests', ['type', 'agent'])
requests.labels(type='fetch', agent='openmetrics').inc()
requests.labels(type='store', agent='json').inc()
requests.labels(type='oneline', agent='docker').inc()

histogram = Histogram('request_latency_seconds', 'Sample histogram')
histogram.observe(4.7)

queue = Gauge('queue_size', 'Sample Gauge of queue size')
queue.set(100)
queue.dec(10)

summary = Summary('summary_requests', 'Sample summary of requests')
summary.observe(4.7)


if __name__ == '__main__':
	start_http_server(9090)
	try:
		time.sleep(1000)
	except:
		sys.exit(0)
