本文整理汇总了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()
示例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)
示例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
)
示例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
示例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
示例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
示例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