當前位置: 首頁>>代碼示例>>Python>>正文


Python Baseplate.configure_metrics方法代碼示例

本文整理匯總了Python中baseplate.Baseplate.configure_metrics方法的典型用法代碼示例。如果您正苦於以下問題:Python Baseplate.configure_metrics方法的具體用法?Python Baseplate.configure_metrics怎麽用?Python Baseplate.configure_metrics使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在baseplate.Baseplate的用法示例。


在下文中一共展示了Baseplate.configure_metrics方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: make_wsgi_app

# 需要導入模塊: from baseplate import Baseplate [as 別名]
# 或者: from baseplate.Baseplate import configure_metrics [as 別名]
def make_wsgi_app(app_config):
    cfg = config.parse_config(app_config)
    signer = MessageSigner(cfg.ads_tracking.click_secret)

    metrics_client = make_metrics_client(app_config)

    baseplate = Baseplate()
    baseplate.configure_logging()
    baseplate.configure_metrics(metrics_client)
    baseplate.add_to_context("events", events.EventQueue("production"))
    baseplate.add_to_context("events_test", events.EventQueue("test"))

    configurator = Configurator(settings=app_config)

    baseplate_configurator = BaseplateConfigurator(baseplate)
    configurator.include(baseplate_configurator.includeme)

    controller = TrackingService(
        signer=signer,
    )
    configurator.add_route("health", "/health", request_method="GET")
    configurator.add_view(
        controller.is_healthy, route_name="health", renderer="json")

    configurator.add_route("click", "/click", request_method="GET")
    configurator.add_view(
        controller.track_click, route_name="click", renderer="json")

    return configurator.make_wsgi_app()
開發者ID:reddit,項目名稱:reddit-service-ads-tracking,代碼行數:31,代碼來源:__init__.py

示例2: make_wsgi_app

# 需要導入模塊: from baseplate import Baseplate [as 別名]
# 或者: from baseplate.Baseplate import configure_metrics [as 別名]
def make_wsgi_app(app_config):
    cfg = config.parse_config(app_config, {
        "session": {
            "secret": config.Base64,
        }
    })

    # configure pyramid
    configurator = Configurator(settings=app_config)
    configurator.include("pyramid_jinja2")

    configurator.set_default_csrf_options(require_csrf=True)
    configurator.set_session_factory(SignedCookieSessionFactory(cfg.session.secret))

    authn_policy = RemoteUserAuthenticationPolicy(environ_key="HTTP_AUTHENTICATED_USER")
    authz_policy = ACLAuthorizationPolicy()
    configurator.set_authentication_policy(authn_policy)
    configurator.set_authorization_policy(authz_policy)
    configurator.add_request_method(get_authenticated_user, "user", reify=True)

    configurator.add_static_view(name="static", path="condor:static/")
    configurator.add_route("home", "/")
    configurator.add_route("polls", "/polls")
    configurator.add_route("poll", "/polls/{id:\d+}")
    configurator.scan("condor.views")

    # configure baseplate
    metrics_client = make_metrics_client(app_config)

    baseplate = Baseplate()
    baseplate.configure_logging()
    baseplate.configure_metrics(metrics_client)

    engine = engine_from_config(app_config, prefix="database.")
    baseplate.add_to_context("db", SQLAlchemySessionContextFactory(engine))

    baseplate_configurator = BaseplateConfigurator(baseplate)
    configurator.include(baseplate_configurator.includeme)

    return configurator.make_wsgi_app()
開發者ID:spladug,項目名稱:condor,代碼行數:42,代碼來源:__init__.py


注:本文中的baseplate.Baseplate.configure_metrics方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。