Module glean.metrics.string
Expand source code
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from typing import Optional
from .._uniffi import CommonMetricData
from .._uniffi import StringMetric
from ..testing import ErrorType
class StringMetricType:
"""
This implements the developer facing API for recording string metrics.
Instances of this class type are automatically generated by
`glean.load_metrics`, allowing developers to record values that were
previously registered in the metrics.yaml file.
The string API only exposes the `StringMetricType.set` method, which
takes care of validating the input data and making sure that limits are
enforced.
"""
def __init__(self, common_metric_data: CommonMetricData):
self._inner = StringMetric(common_metric_data)
def set(self, value: str) -> None:
"""
Set a string value.
Args:
value (str): This is a user-defined string value. If the length of
the string exceeds the maximum length, it will be truncated.
"""
if value is None:
return
self._inner.set(value)
def test_get_value(self, ping_name: Optional[str] = None) -> Optional[str]:
return self._inner.test_get_value(ping_name)
def test_get_num_recorded_errors(self, error_type: ErrorType) -> int:
return self._inner.test_get_num_recorded_errors(error_type)
__all__ = ["StringMetricType"]
Classes
class StringMetricType (common_metric_data: glean._uniffi.glean.CommonMetricData)
-
This implements the developer facing API for recording string metrics.
Instances of this class type are automatically generated by
load_metrics()
, allowing developers to record values that were previously registered in the metrics.yaml file.The string API only exposes the
StringMetricType.set()
method, which takes care of validating the input data and making sure that limits are enforced.Expand source code
class StringMetricType: """ This implements the developer facing API for recording string metrics. Instances of this class type are automatically generated by `glean.load_metrics`, allowing developers to record values that were previously registered in the metrics.yaml file. The string API only exposes the `StringMetricType.set` method, which takes care of validating the input data and making sure that limits are enforced. """ def __init__(self, common_metric_data: CommonMetricData): self._inner = StringMetric(common_metric_data) def set(self, value: str) -> None: """ Set a string value. Args: value (str): This is a user-defined string value. If the length of the string exceeds the maximum length, it will be truncated. """ if value is None: return self._inner.set(value) def test_get_value(self, ping_name: Optional[str] = None) -> Optional[str]: return self._inner.test_get_value(ping_name) def test_get_num_recorded_errors(self, error_type: ErrorType) -> int: return self._inner.test_get_num_recorded_errors(error_type)
Methods
def set(self, value: str) ‑> None
-
Set a string value.
Args
value
:str
- This is a user-defined string value. If the length of the string exceeds the maximum length, it will be truncated.
Expand source code
def set(self, value: str) -> None: """ Set a string value. Args: value (str): This is a user-defined string value. If the length of the string exceeds the maximum length, it will be truncated. """ if value is None: return self._inner.set(value)
def test_get_num_recorded_errors(self, error_type: glean._uniffi.glean.ErrorType) ‑> int
-
Expand source code
def test_get_num_recorded_errors(self, error_type: ErrorType) -> int: return self._inner.test_get_num_recorded_errors(error_type)
def test_get_value(self, ping_name: Optional[str] = None) ‑> Optional[str]
-
Expand source code
def test_get_value(self, ping_name: Optional[str] = None) -> Optional[str]: return self._inner.test_get_value(ping_name)