Ejemplo n.º 1
0
def app(elasticapm_client):
    class HelloHandler(tornado.web.RequestHandler):
        def get(self):
            with async_capture_span("test"):
                pass
            return self.write("Hello, world")

        post = get

    class RenderHandler(tornado.web.RequestHandler):
        def get(self):
            with async_capture_span("test"):
                pass
            items = ["Item 1", "Item 2", "Item 3"]
            return self.render("test.html",
                               title="Testing so hard",
                               items=items)

    class BoomHandler(tornado.web.RequestHandler):
        def get(self):
            raise tornado.web.HTTPError()

        post = get

    app = tornado.web.Application(
        [(r"/", HelloHandler), (r"/boom", BoomHandler),
         (r"/render", RenderHandler)],
        template_path=os.path.join(os.path.dirname(__file__), "templates"),
    )
    apm = ElasticAPM(app, elasticapm_client)
    yield app
    elasticapm.uninstrument()
Ejemplo n.º 2
0
 def initiate_tornado_apm_client(app):
     from elasticapm.contrib.tornado import ElasticAPM
     config = Utility.initiate_apm_client_config()
     if config:
         app.settings['ELASTIC_APM'] = config
         ElasticAPM(app)