Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions occameracontrol/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from occameracontrol.agent import Agent
from occameracontrol.camera import Camera
from occameracontrol.metrics import start_metrics_exporter, RequestErrorHandler
from occameracontrol.metrics import RequestErrorHandler

from occameracontrol.camera_control_server import start_camera_control_server

Expand Down Expand Up @@ -134,9 +134,6 @@ def main():
threads.append(control_thread)
control_thread.start()

# Start delivering metrics
start_metrics_exporter()

# Start camera control server
auth = (config_rt(str, 'basic_auth', 'username'),
config_rt(str, 'basic_auth', 'password'))
Expand Down
25 changes: 0 additions & 25 deletions occameracontrol/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
import requests
import time

from confygure import config_t
from prometheus_client import Counter, Gauge
from prometheus_client import start_http_server


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -118,26 +116,3 @@ def register_camera_expectation(camera: str, position: int):
:param position: New camera position
'''
camera_position_expected.labels(camera).set(position)


def start_metrics_exporter():
'''Start the web server for the metrics exporter endpoint if it is enabled
in the configuration.
'''
if not config_t(bool, 'metrics', 'enabled'):
return

supported_args = start_http_server.__code__.co_varnames
if 'certfile' in supported_args:
start_http_server(
port=config_t(int, 'metrics', 'port') or 8000,
addr=config_t(str, 'metrics', 'addr') or '127.0.0.1',
certfile=config_t(str, 'metrics', 'certfile'),
keyfile=config_t(str, 'metrics', 'keyfile'))
else:
if config_t(str, 'metrics', 'certfile'):
logger.warn('Old version of Prometheus client library does not yet'
' support TLS. Provided certificate will be ignored.')
start_http_server(
port=config_t(int, 'metrics', 'port') or 8000,
addr=config_t(str, 'metrics', 'addr') or '127.0.0.1')