Exemplo n.º 1
0
 def setUp(self):
     self.traced_app = TraceMiddleware(
         cherrypy,
         tracer=ddtrace.tracer,
         service="test.cherrypy.service",
         distributed_tracing=True,
     )
Exemplo n.º 2
0
 def setUp(self):
     super(TestCherrypy, self).setUp()
     self.traced_app = TraceMiddleware(
         cherrypy,
         self.tracer,
         service="test.cherrypy.service",
         distributed_tracing=True,
     )
Exemplo n.º 3
0
    def test_double_instrumentation(self):
        # ensure CherryPy is never instrumented twice when `ddtrace-run`
        # and `TraceMiddleware` are used together. `traced_app` MUST
        # be assigned otherwise it's not possible to reproduce the
        # problem (the test scope must keep a strong reference)
        traced_app = TraceMiddleware(cherrypy, self.tracer)  # noqa: F841
        self.getPage("/")
        time.sleep(0.1)
        self.assertHeader("Content-Type", "text/html;charset=utf-8")
        self.assertStatus("200 OK")

        spans = self.pop_spans()
        assert len(spans) == 1
Exemplo n.º 4
0
    def test_double_instrumentation_config(self):
        # ensure CherryPy uses the last set configuration to be sure
        # there are no breaking changes for who uses `ddtrace-run`
        # with the `TraceMiddleware`
        assert cherrypy.tools.tracer.service == "test.cherrypy.service"
        TraceMiddleware(
            cherrypy,
            self.tracer,
            service="new-intake",
        )
        self.getPage("/")
        time.sleep(0.1)
        self.assertHeader("Content-Type", "text/html;charset=utf-8")
        self.assertStatus("200 OK")

        spans = self.pop_spans()
        assert len(spans) == 1

        assert cherrypy.tools.tracer.service == "new-intake"