| Index: infra_libs/ts_mon/interface.py
|
| diff --git a/infra_libs/ts_mon/interface.py b/infra_libs/ts_mon/interface.py
|
| index e24bf14d120309f21c77e967f35908a3c5d31741..f5af177b5ae6d93a27341a91b04615a269b4fbb1 100644
|
| --- a/infra_libs/ts_mon/interface.py
|
| +++ b/infra_libs/ts_mon/interface.py
|
| @@ -39,7 +39,7 @@ import time
|
|
|
| from monacq.proto import metrics_pb2
|
|
|
| -from infra_libs.ts_mon import errors
|
| +from infra_libs.ts_mon.common import errors
|
|
|
| # The maximum number of MetricsData messages to include in each HTTP request.
|
| # MetricsCollections larger than this will be split into multiple requests.
|
| @@ -111,19 +111,20 @@ def flush():
|
| def register(metric):
|
| """Adds the metric to the list of metrics sent by flush().
|
|
|
| - This is called automatically by Metric's constructor - you don't need to call
|
| - it manually.
|
| + This is called automatically by Metric's constructor.
|
| """
|
| # If someone is registering the same metric object twice, that's okay, but
|
| # registering two different metric objects with the same metric name is not.
|
| - if metric in state.metrics:
|
| - return
|
| + for m in state.metrics:
|
| + if metric == m:
|
| + state.metrics.remove(m)
|
| + state.metrics.add(metric)
|
| + return
|
| if any([metric._name == m._name for m in state.metrics]):
|
| raise errors.MonitoringDuplicateRegistrationError(metric._name)
|
|
|
| state.metrics.add(metric)
|
|
|
| -
|
| def unregister(metric):
|
| """Removes the metric from the list of metrics sent by flush()."""
|
| state.metrics.remove(metric)
|
|
|