def test_http_response_header_tracing(self): config.aiohttp.http.trace_headers(["my-response-header"]) request = yield from self.client.request("GET", "/response_headers/") yield from request.text() traces = self.tracer.writer.pop_traces() assert 1 == len(traces) assert 1 == len(traces[0]) request_span = traces[0][0] assert request_span.service == "aiohttp-web" assert request_span.get_tag( "http.response.headers.my-response-header") == "my_response_value"
def test_user_specified_service(self): """ When a service name is specified by the user The aiohttp integration should use it as the service name """ request = yield from self.client.request("GET", "/template/") yield from request.text() traces = self.tracer.writer.pop_traces() assert 1 == len(traces) assert 2 == len(traces[0]) request_span = traces[0][0] assert request_span.service == "mysvc" template_span = traces[0][1] assert template_span.service == "mysvc"
def test_full_request(self): # it should create a root span when there is a handler hit # with the proper tags request = yield from self.client.request('GET', '/template/') eq_(200, request.status) yield from request.text() # the trace is created traces = self.tracer.writer.pop_traces() eq_(1, len(traces)) eq_(2, len(traces[0])) request_span = traces[0][0] template_span = traces[0][1] # request eq_('aiohttp-web', request_span.service) eq_('aiohttp.request', request_span.name) eq_('GET /template/', request_span.resource) # template eq_('aiohttp-web', template_span.service) eq_('aiohttp.template', template_span.name) eq_('aiohttp.template', template_span.resource)
def test_full_request(self): # it should create a root span when there is a handler hit # with the proper tags request = yield from self.client.request('GET', '/template/') assert 200 == request.status yield from request.text() # the trace is created traces = self.tracer.writer.pop_traces() assert 1 == len(traces) assert 2 == len(traces[0]) request_span = traces[0][0] template_span = traces[0][1] # request assert 'aiohttp-web' == request_span.service assert 'aiohttp.request' == request_span.name assert 'GET /template/' == request_span.resource # template assert 'aiohttp-web' == template_span.service assert 'aiohttp.template' == template_span.name assert 'aiohttp.template' == template_span.resource
def test_full_request(self): # it should create a root span when there is a handler hit # with the proper tags request = yield from self.client.request('GET', '/template/') eq_(200, request.status) yield from request.text() # the trace is created traces = self.tracer.writer.pop_traces() eq_(1, len(traces)) eq_(2, len(traces[0])) request_span = traces[0][0] template_span = traces[0][1] # request eq_('aiohttp-web', request_span.service) eq_('aiohttp.request', request_span.name) eq_('/template/', request_span.resource) # template eq_('aiohttp-web', template_span.service) eq_('aiohttp.template', template_span.name) eq_('aiohttp.template', template_span.resource)
def test_full_request(self): # it should create a root span when there is a handler hit # with the proper tags request = yield from self.client.request("GET", "/template/") assert 200 == request.status yield from request.text() # the trace is created traces = self.pop_traces() assert 1 == len(traces) assert 2 == len(traces[0]) request_span = traces[0][0] template_span = traces[0][1] # request assert_is_measured(request_span) assert "aiohttp-web" == request_span.service assert "aiohttp.request" == request_span.name assert "GET /template/" == request_span.resource # template assert "aiohttp-web" == template_span.service assert "aiohttp.template" == template_span.name assert "aiohttp.template" == template_span.resource
def test_event_sample_rate(self): # it should create a root span when there is a handler hit # with the proper tags with self.override_config('aiohttp', dict(event_sample_rate=1)): request = yield from self.client.request('GET', '/template/') eq_(200, request.status) yield from request.text() # Assert root span sets the appropriate metric root = self.get_root_span() root.assert_matches( name='aiohttp.request', metrics={ EVENT_SAMPLE_RATE_KEY: 1, }, ) # Assert non-root spans do not have this metric set for span in self.spans: if span == root: continue self.assertIsNone(span.get_metric(EVENT_SAMPLE_RATE_KEY))