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