當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。