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


Python multiprocess.MultiProcessCollector方法代码示例

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


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

示例1: root

# 需要导入模块: from prometheus_client import multiprocess [as 别名]
# 或者: from prometheus_client.multiprocess import MultiProcessCollector [as 别名]
def root():
    # check access
    ip_whitelist = ip_network(current_app.config.get('PROMETHEUS_WHITELIST'))
    if ip_address(request.remote_addr) not in ip_whitelist:
        _jwt_required(current_app.config['JWT_DEFAULT_REALM'])

    MU = MetricUpdater()
    registry = CollectorRegistry()
    multiprocess.MultiProcessCollector(registry)

    data = generate_latest(registry)

    response = make_response(data)
    response.headers['Content-Type'] = CONTENT_TYPE_LATEST
    response.headers['Content-Length'] = str(len(data))
    logger.info('Kqueen metrics updating')
    MU.update_metrics()

    return response 
开发者ID:Mirantis,项目名称:kqueen,代码行数:21,代码来源:views.py

示例2: generate_latest

# 需要导入模块: from prometheus_client import multiprocess [as 别名]
# 或者: from prometheus_client.multiprocess import MultiProcessCollector [as 别名]
def generate_latest(self):
        """Generate a bytestring with metric values."""
        if self.registry is None:
            return

        registry = self.registry
        if registry is prom_cli.REGISTRY:
            # when using the global registry, setup up multiprocess
            # support. In this case, a separate registry needs to be used
            # for generating the samples.
            registry = prom_cli.CollectorRegistry()
            from prometheus_client import multiprocess

            multiprocess.MultiProcessCollector(registry)

        for handler in self._update_handlers:
            handler(self)
        return prom_cli.generate_latest(registry) 
开发者ID:maas,项目名称:maas,代码行数:20,代码来源:utils.py

示例3: metrics

# 需要导入模块: from prometheus_client import multiprocess [as 别名]
# 或者: from prometheus_client.multiprocess import MultiProcessCollector [as 别名]
def metrics():
    registry = CollectorRegistry()
    multiprocess.MultiProcessCollector(registry)
    data = generate_latest(registry)
    return Response(data, mimetype=CONTENT_TYPE_LATEST) 
开发者ID:jonashaag,项目名称:prometheus-multiprocessing-example,代码行数:7,代码来源:yourapp.py

示例4: ExportToDjangoView

# 需要导入模块: from prometheus_client import multiprocess [as 别名]
# 或者: from prometheus_client.multiprocess import MultiProcessCollector [as 别名]
def ExportToDjangoView(request):
    """Exports /metrics as a Django view.

    You can use django_prometheus.urls to map /metrics to this view.
    """
    if "prometheus_multiproc_dir" in os.environ:
        registry = prometheus_client.CollectorRegistry()
        multiprocess.MultiProcessCollector(registry)
    else:
        registry = prometheus_client.REGISTRY
    metrics_page = prometheus_client.generate_latest(registry)
    return HttpResponse(
        metrics_page, content_type=prometheus_client.CONTENT_TYPE_LATEST
    ) 
开发者ID:korfuri,项目名称:django-prometheus,代码行数:16,代码来源:exports.py

示例5: register_endpoint

# 需要导入模块: from prometheus_client import multiprocess [as 别名]
# 或者: from prometheus_client.multiprocess import MultiProcessCollector [as 别名]
def register_endpoint(self, path, app=None):
        """
        Register the metrics endpoint on the Flask application.

        :param path: the path of the endpoint
        :param app: the Flask application to register the endpoint on
            (by default it is the application registered with this class)
        """

        if is_running_from_reloader() and not os.environ.get('DEBUG_METRICS'):
            return

        if app is None:
            app = self.app or current_app

        @app.route(path)
        @self.do_not_track()
        def prometheus_metrics():
            # import these here so they don't clash with our own multiprocess module
            from prometheus_client import multiprocess, CollectorRegistry

            if 'prometheus_multiproc_dir' in os.environ:
                registry = CollectorRegistry()
            else:
                registry = self.registry

            if 'name[]' in request.args:
                registry = registry.restricted_registry(request.args.getlist('name[]'))

            if 'prometheus_multiproc_dir' in os.environ:
                multiprocess.MultiProcessCollector(registry)

            headers = {'Content-Type': CONTENT_TYPE_LATEST}
            return generate_latest(registry), 200, headers 
开发者ID:rycus86,项目名称:prometheus_flask_exporter,代码行数:36,代码来源:__init__.py

示例6: app

# 需要导入模块: from prometheus_client import multiprocess [as 别名]
# 或者: from prometheus_client.multiprocess import MultiProcessCollector [as 别名]
def app(environ, start_fn):
    REQUESTS.inc()
    if environ['PATH_INFO'] == '/metrics':
        registry = CollectorRegistry()
        multiprocess.MultiProcessCollector(registry)
        metrics_app = make_wsgi_app(registry)
        return metrics_app(environ, start_fn)
    start_fn('200 OK', [])
    return [b'Hello World'] 
开发者ID:prometheus-up-and-running,项目名称:examples,代码行数:11,代码来源:4-4-app.py


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