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


Python Gauge._samples方法代码示例

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


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

示例1: Summary

# 需要导入模块: from prometheus_client import Gauge [as 别名]
# 或者: from prometheus_client.Gauge import _samples [as 别名]

# prometheus metrics state
request_summary = Summary(
    'reststore_api_request_duration_seconds',
    'Time spent processing api request',
    ['resource', 'method']
)
request_timer = lambda *x: request_summary.labels(*x).time()

file_count_gauge = Gauge(
    'reststore_stored_files',
    'Number of files in reststore',
    ['store']
)
file_count_gauge._samples = lambda: _counts()

file_size_summary = Summary(
    'reststore_file_size_bytes',
    'Size of files stored/fetched in bytes',
    ['store', 'direction']
)

# unfortunately do not have a way to query for current
# filestores, so we accumulate them as requests are seen
known_file_stores = set()

def _counts():
    return [('', {'store': k}, len(_get_files(k))) \
        for k in known_file_stores]
开发者ID:provoke-vagueness,项目名称:reststore,代码行数:31,代码来源:webapp.py

示例2: Summary

# 需要导入模块: from prometheus_client import Gauge [as 别名]
# 或者: from prometheus_client.Gauge import _samples [as 别名]
from restq import config

# prometheus metrics state
request_summary = Summary(
    'restq_api_request_duration_seconds',
    'Time spent processing api request',
    ['resource', 'method']
)
request_timer = lambda *x: request_summary.labels(*x).time()

job_gauge = Gauge(
    'restq_queued_jobs',
    'Number of jobs in restq realms/queues',
    ['realm', 'queue']
)
job_gauge._samples = lambda: _get_job_stats()

tag_gauge = Gauge(
    'restq_queued_tags',
    'Number of tags in restq realms',
    ['realm']
)
tag_gauge._samples = lambda: _get_tag_stats()

def _get_job_stats():
    d = realms.get_status()
    return  [('', {'realm': name, 'queue': str(q)}, v) \
        for name, detail in d.items() for q, v in detail['queues'].items()]

def _get_tag_stats():
    d = realms.get_status()
开发者ID:provoke-vagueness,项目名称:restq,代码行数:33,代码来源:webapp.py


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