当前位置: 首页>>代码示例>>Python>>正文


Python prometheus_client.Summary方法代码示例

本文整理汇总了Python中prometheus_client.Summary方法的典型用法代码示例。如果您正苦于以下问题:Python prometheus_client.Summary方法的具体用法?Python prometheus_client.Summary怎么用?Python prometheus_client.Summary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在prometheus_client的用法示例。


在下文中一共展示了prometheus_client.Summary方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_metric

# 需要导入模块: import prometheus_client [as 别名]
# 或者: from prometheus_client import Summary [as 别名]
def create_metric(self):
        # record app conf
        self.conf_info = Info('celery_conf_info','APP_CONF')
        self.conf_info_c = CollectorRegistry()

        # monitor worker info
        self.workers_info = Info('celery_workers_info', 'WORKER_INFO')
        self.workers_info_c = CollectorRegistry()

        # monitor worker info real-time
        self.workers_state = Gauge('celery_workers_state', 'WORKER_STATE', ['worker'])
        self.workers_state_c = CollectorRegistry()
        self.workers_processed = Gauge('celery_processed_tasks_total', 'WORKER_TASKS_PROCESSED', ['worker'])
        self.workers_processed_c = CollectorRegistry()
        self.workers_active = Gauge('celery_active_tasks_total', 'WORKER_TASKS_ACTIVE', ['worker'])
        self.workers_active_c = CollectorRegistry()

        # monitor tasks info
        self.tasks_counter = Counter('celery_tasks_total', 'TASK_COUNT_INFO', ['worker','task','result'])
        self.tasks_counter_c = CollectorRegistry()
        self.tasks_runtime = Summary('celery_tasks_seconds', 'TASK_RUNTIME', ['worker', 'task'])
        self.tasks_runtime_c = CollectorRegistry()
        self.tasks_info = Info('celery_tasks_info', 'TASK_INFO')
        self.tasks_info_c = CollectorRegistry() 
开发者ID:adrianyoung,项目名称:CrawlerMonitor,代码行数:26,代码来源:monitor.py

示例2: start_http_server

# 需要导入模块: import prometheus_client [as 别名]
# 或者: from prometheus_client import Summary [as 别名]
def start_http_server(config, port, address=''):
    """
    Start a HTTP API server for Proxmox VE prometheus collector.
    """

    duration = Summary(
        'pve_collection_duration_seconds',
        'Duration of collections by the PVE exporter',
        ['module'],
    )
    errors = Counter(
        'pve_request_errors_total',
        'Errors in requests to PVE exporter',
        ['module'],
    )

    # Initialize metrics.
    for module in config.keys():
        # pylint: disable=no-member
        errors.labels(module)
        # pylint: disable=no-member
        duration.labels(module)

    app = PveExporterApplication(config, duration, errors)
    run_simple(address, port, app, threaded=True) 
开发者ID:prometheus-pve,项目名称:prometheus-pve-exporter,代码行数:27,代码来源:http.py

示例3: summary

# 需要导入模块: import prometheus_client [as 别名]
# 或者: from prometheus_client import Summary [as 别名]
def summary(self, name, description, labels=None, **kwargs):
        """
        Use a Summary to track the execution time and invocation count
        of the method.

        :param name: the name of the metric
        :param description: the description of the metric
        :param labels: a dictionary of `{labelname: callable_or_value}` for labels
        :param kwargs: additional keyword arguments for creating the Summary
        """

        return self._track(
            Summary,
            lambda metric, time: metric.observe(time),
            kwargs, name, description, labels,
            registry=self.registry
        ) 
开发者ID:rycus86,项目名称:prometheus_flask_exporter,代码行数:19,代码来源:__init__.py

示例4: summary_observe

# 需要导入模块: import prometheus_client [as 别名]
# 或者: from prometheus_client import Summary [as 别名]
def summary_observe(name, observation, description="", **kwargs):
    global metrics, enabled

    if not enabled:
        return True

    try:
        if name not in metrics:
            metrics[name] = Summary(name, description, list(kwargs.keys()))

        if kwargs:
            metrics[name].labels(**kwargs).observe(observation)
        else:
            metrics[name].observe(observation)

    except Exception as err:
        logger.warn("adding metric failed - exception: " + str(err))

    return True 
开发者ID:anchore,项目名称:anchore-engine,代码行数:21,代码来源:metrics.py

示例5: _get_default_metric

# 需要导入模块: import prometheus_client [as 别名]
# 或者: from prometheus_client import Summary [as 别名]
def _get_default_metric():
    global _METRIC
    if _METRIC is None:
        _METRIC = Summary(
            'graph_field_time',
            'Graph field time (seconds)',
            ['graph', 'node', 'field'],
        )
    return _METRIC 
开发者ID:vmagamedov,项目名称:hiku,代码行数:11,代码来源:prometheus.py

示例6: test_prometheus_summary

# 需要导入模块: import prometheus_client [as 别名]
# 或者: from prometheus_client import Summary [as 别名]
def test_prometheus_summary():
    @solid(required_resource_keys={'prometheus'})
    def prometheus_solid(context):
        s = Summary(
            'request_latency_seconds',
            'Description of summary',
            registry=context.resources.prometheus.registry,
        )
        s.observe(4.7)
        request_time = Summary(
            'response_latency_seconds',
            'Response latency (seconds)',
            registry=context.resources.prometheus.registry,
        )

        with request_time.time():
            time.sleep(1)

        recorded = context.resources.prometheus.registry.get_sample_value(
            'request_latency_seconds_sum'
        )
        assert abs(4.7 - recorded) < EPS

        recorded = context.resources.prometheus.registry.get_sample_value(
            'response_latency_seconds_sum'
        )
        assert abs(1.0 - recorded) < 1.0

    assert execute_solid(prometheus_solid, run_config=ENV, mode_def=MODE).success 
开发者ID:dagster-io,项目名称:dagster,代码行数:31,代码来源:test_resources.py

示例7: get_summary_obj

# 需要导入模块: import prometheus_client [as 别名]
# 或者: from prometheus_client import Summary [as 别名]
def get_summary_obj(name, description="", **kwargs):
    global metrics, enabled

    if not enabled:
        return None

    ret = None
    try:
        if name not in metrics:
            metrics[name] = Summary(name, description, list(kwargs.keys()))
        ret = metrics[name]
    except:
        logger.warn("could not create/get named metric (" + str(name) + ")")

    return ret 
开发者ID:anchore,项目名称:anchore-engine,代码行数:17,代码来源:metrics.py


注:本文中的prometheus_client.Summary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。