コード例 #1
0
def get_available_memory_metric():
    """ Returns a derived gauge for available memory

    Available memory is defined as memory that can be given instantly to
    processes without the system going into swap.

    :rtype: :class:`opencensus.metrics.export.gauge.DerivedLongGauge`
    :return: The gauge representing the available memory metric
    """
    gauge = DerivedLongGauge(AVAILABLE_MEMORY,
                             'Amount of available memory in bytes', 'byte', [])
    gauge.create_default_time_series(get_available_memory)
    return gauge
コード例 #2
0
def get_process_private_bytes_metric():
    """ Returns a derived gauge for private bytes for the current process

    Private bytes for the current process is measured by the Resident Set
    Size, which is the non-swapped physical memory a process has used.

    :rtype: :class:`opencensus.metrics.export.gauge.DerivedLongGauge`
    :return: The gauge representing the private bytes metric
    """
    gauge = DerivedLongGauge(PRIVATE_BYTES,
                             'Amount of memory process has used in bytes',
                             'byte', [])
    gauge.create_default_time_series(get_process_private_bytes)
    return gauge
コード例 #3
0
    def __call__(self):
        """ Returns a derived gauge for private bytes for the current process

        Private bytes for the current process is measured by the Resident Set
        Size, which is the non-swapped physical memory a process has used.

        :rtype: :class:`opencensus.metrics.export.gauge.DerivedLongGauge`
        :return: The gauge representing the private bytes metric
        """
        gauge = DerivedLongGauge(ProcessMemoryMetric.NAME,
                                 'Amount of memory process has used in bytes',
                                 'byte', [])
        gauge.create_default_time_series(ProcessMemoryMetric.get_value)
        return gauge
コード例 #4
0
    def __call__(self):
        """ Returns a derived gauge for available memory

        Available memory is defined as memory that can be given instantly to
        processes without the system going into swap.

        :rtype: :class:`opencensus.metrics.export.gauge.DerivedLongGauge`
        :return: The gauge representing the available memory metric
        """
        gauge = DerivedLongGauge(AvailableMemoryMetric.NAME,
                                 'Amount of available memory in bytes', 'byte',
                                 [])
        gauge.create_default_time_series(AvailableMemoryMetric.get_value)
        return gauge
コード例 #5
0
 def __init__(self, options):
     self._options = options
     self._instrumentation_key = options.instrumentation_key
     self._feature = _StatsbeatFeature.NONE
     if options.enable_local_storage:
         self._feature |= _StatsbeatFeature.DISK_RETRY
     if options.credential:
         self._feature |= _StatsbeatFeature.AAD
     self._stats_lock = threading.Lock()
     self._vm_data = {}
     self._vm_retry = True
     self._rp = _RP_NAMES[3]
     self._os_type = platform.system()
     # Attach metrics - metrics related to rp (resource provider)
     self._attach_metric = LongGauge(
         _ATTACH_METRIC_NAME,
         'Statsbeat metric related to rp integrations',
         'count',
         _get_attach_properties(),
     )
     # Keep track of how many iterations until long export
     self._long_threshold_count = 0
     # Network metrics - metrics related to request calls to Breeze
     self._network_metrics = {}
     # Map of gauge function -> metric
     # Gauge function is the callback used to populate the metric value
     self._network_metrics[_get_success_count_value] = DerivedLongGauge(
         _REQ_SUC_COUNT_NAME,
         'Statsbeat metric tracking request success count',
         'count',
         _get_network_properties(),
     )
     self._network_metrics[_get_failure_count_value] = DerivedLongGauge(
         _REQ_FAIL_COUNT_NAME,
         'Statsbeat metric tracking request failure count',
         'count',
         _get_network_properties(),
     )
     self._network_metrics[
         _get_average_duration_value] = DerivedDoubleGauge(  # noqa: E501
             _REQ_DURATION_NAME,
             'Statsbeat metric tracking average request duration',
             'count',
             _get_network_properties(),
         )
     self._network_metrics[_get_retry_count_value] = DerivedLongGauge(
         _REQ_RETRY_NAME,
         'Statsbeat metric tracking request retry count',
         'count',
         _get_network_properties(),
     )
     self._network_metrics[_get_throttle_count_value] = DerivedLongGauge(
         _REQ_THROTTLE_NAME,
         'Statsbeat metric tracking request throttle count',
         'count',
         _get_network_properties(),
     )
     self._network_metrics[_get_exception_count_value] = DerivedLongGauge(
         _REQ_EXCEPTION_NAME,
         'Statsbeat metric tracking request exception count',
         'count',
         _get_network_properties(),
     )
     # feature/instrumentation metrics
     # metrics related to what features and instrumentations are enabled
     self._feature_metric = LongGauge(
         _FEATURE_METRIC_NAME,
         'Statsbeat metric related to features enabled',  # noqa: E501
         'count',
         _get_feature_properties(),
     )
     # Instrumentation metric uses same name/properties as feature
     self._instrumentation_metric = LongGauge(
         _FEATURE_METRIC_NAME,
         'Statsbeat metric related to instrumentations enabled',  # noqa: E501
         'count',
         _get_feature_properties(),
     )