mirror of
https://github.com/mozilla-services/syncstorage-rs.git
synced 2026-05-05 04:06:16 +02:00
fix: correctly read the SYNC_STATSD_HOST/PORT settings (#1601)
Closes SYNC-4417
This commit is contained in:
parent
be23e39135
commit
3675c9387b
@ -181,18 +181,7 @@ def main(args=None):
|
||||
help="Control verbosity of log messages")
|
||||
parser.add_option("", "--human_logs", action="store_true",
|
||||
help="Human readable logs")
|
||||
parser.add_option(
|
||||
"",
|
||||
"--metric_host",
|
||||
default=None,
|
||||
help="Metric host name"
|
||||
)
|
||||
parser.add_option(
|
||||
"",
|
||||
"--metric_port",
|
||||
default=None,
|
||||
help="Metric host port"
|
||||
)
|
||||
util.add_metric_options(parser)
|
||||
|
||||
opts, args = parser.parse_args(args)
|
||||
# set up logging
|
||||
|
||||
@ -386,18 +386,7 @@ def main(args=None):
|
||||
action="store_true",
|
||||
help="Human readable logs"
|
||||
)
|
||||
parser.add_option(
|
||||
"",
|
||||
"--metric_host",
|
||||
default=None,
|
||||
help="Metric host name"
|
||||
)
|
||||
parser.add_option(
|
||||
"",
|
||||
"--metric_port",
|
||||
default=None,
|
||||
help="Metric host port"
|
||||
)
|
||||
util.add_metric_options(parser)
|
||||
|
||||
opts, args = parser.parse_args(args)
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ import sys
|
||||
import time
|
||||
import logging
|
||||
import base64
|
||||
import optparse
|
||||
import os
|
||||
import json
|
||||
from datetime import datetime
|
||||
@ -104,13 +105,27 @@ class Metrics():
|
||||
options = dict(
|
||||
namespace=namespace,
|
||||
statsd_namespace=namespace,
|
||||
statsd_host=getattr(
|
||||
opts, "metric_host", os.environ.get("SYNC_STATSD_HOST")),
|
||||
statsd_port=getattr(
|
||||
opts, "metric_port", os.environ.get("SYNC_STATSD_PORT")),
|
||||
statsd_host=getattr(opts, "metric_host"),
|
||||
statsd_port=getattr(opts, "metric_port"),
|
||||
)
|
||||
self.prefix = options.get("namespace")
|
||||
initialize(**options)
|
||||
|
||||
def incr(self, label, tags=None):
|
||||
statsd.increment(label, tags=tags)
|
||||
|
||||
|
||||
def add_metric_options(parser: optparse.OptionParser):
|
||||
"""Add generic metric related options to an OptionParser"""
|
||||
parser.add_option(
|
||||
"",
|
||||
"--metric_host",
|
||||
default=os.environ.get("SYNC_STATSD_HOST"),
|
||||
help="Metric host name"
|
||||
)
|
||||
parser.add_option(
|
||||
"",
|
||||
"--metric_port",
|
||||
default=os.environ.get("SYNC_STATSD_PORT"),
|
||||
help="Metric host port"
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user