Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion instana/instrumentation/aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def stan_request_end(session, trace_config_ctx, params):
if agent.options.extra_http_headers is not None:
for custom_header in agent.options.extra_http_headers:
if custom_header in params.response.headers:
scope.span.set_tag("http.%s" % custom_header, params.response.headers[custom_header])
scope.span.set_tag("http.header.%s" % custom_header, params.response.headers[custom_header])

if 500 <= params.response.status <= 599:
scope.span.mark_as_errored({"http.error": params.response.reason})
Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/aiohttp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def stan_middleware(request, handler):
if agent.options.extra_http_headers is not None:
for custom_header in agent.options.extra_http_headers:
if custom_header in request.headers:
scope.span.set_tag("http.%s" % custom_header, request.headers[custom_header])
scope.span.set_tag("http.header.%s" % custom_header, request.headers[custom_header])

response = None
try:
Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _extract_custom_headers(self, span, headers):
# Headers are in the following format: b'x-header-1'
for header_pair in headers:
if header_pair[0].decode('utf-8').lower() == custom_header.lower():
span.set_tag("http.%s" % custom_header, header_pair[1].decode('utf-8'))
span.set_tag("http.header.%s" % custom_header, header_pair[1].decode('utf-8'))
except Exception:
logger.debug("extract_custom_headers: ", exc_info=True)

Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/aws/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def capture_extra_headers(event, span, extra_headers):
for custom_header in extra_headers:
for key in event_headers:
if key.lower() == custom_header.lower():
span.set_tag("http.%s" % custom_header, event_headers[key])
span.set_tag("http.header.%s" % custom_header, event_headers[key])
except Exception:
logger.debug("capture_extra_headers: ", exc_info=True)

Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/django/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def process_request(self, request):
# Headers are available in this format: HTTP_X_CAPTURE_THIS
django_header = ('HTTP_' + custom_header.upper()).replace('-', '_')
if django_header in env:
request.iscope.span.set_tag("http.%s" % custom_header, env[django_header])
request.iscope.span.set_tag("http.header.%s" % custom_header, env[django_header])

request.iscope.span.set_tag(ext.HTTP_METHOD, request.method)
if 'PATH_INFO' in env:
Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/flask/vanilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def before_request_with_instana(*argv, **kwargs):
# Headers are available in this format: HTTP_X_CAPTURE_THIS
header = ('HTTP_' + custom_header.upper()).replace('-', '_')
if header in env:
span.set_tag("http.%s" % custom_header, env[header])
span.set_tag("http.header.%s" % custom_header, env[header])

span.set_tag(ext.HTTP_METHOD, flask.request.method)
if 'PATH_INFO' in env:
Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/flask/with_blinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def request_started_with_instana(sender, **extra):
# Headers are available in this format: HTTP_X_CAPTURE_THIS
header = ('HTTP_' + custom_header.upper()).replace('-', '_')
if header in env:
span.set_tag("http.%s" % custom_header, env[header])
span.set_tag("http.header.%s" % custom_header, env[header])

span.set_tag(ext.HTTP_METHOD, flask.request.method)
if 'PATH_INFO' in env:
Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/pyramid/tweens.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __call__(self, request):
# Headers are available in this format: HTTP_X_CAPTURE_THIS
h = ('HTTP_' + custom_header.upper()).replace('-', '_')
if h in request.headers:
scope.span.set_tag("http.%s" % custom_header, request.headers[h])
scope.span.set_tag("http.header.%s" % custom_header, request.headers[h])

if len(request.query_string):
scrubbed_params = strip_secrets_from_query(request.query_string, agent.options.secrets_matcher, agent.options.secrets_list)
Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/tornado/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def execute_with_instana(wrapped, instance, argv, kwargs):
if agent.options.extra_http_headers is not None:
for custom_header in agent.options.extra_http_headers:
if custom_header in instance.request.headers:
scope.span.set_tag("http.%s" % custom_header, instance.request.headers[custom_header])
scope.span.set_tag("http.header.%s" % custom_header, instance.request.headers[custom_header])

setattr(instance.request, "_instana", scope)

Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def collect_response(scope, response):
if agent.options.extra_http_headers is not None:
for custom_header in agent.options.extra_http_headers:
if custom_header in response.headers:
scope.span.set_tag("http.%s" % custom_header, response.headers[custom_header])
scope.span.set_tag("http.header.%s" % custom_header, response.headers[custom_header])

if 500 <= response.status <= 599:
scope.span.mark_as_errored()
Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/webapp2_inst.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def new_start_response(status, headers, exc_info=None):
# Headers are available in this format: HTTP_X_CAPTURE_THIS
wsgi_header = ('HTTP_' + custom_header.upper()).replace('-', '_')
if wsgi_header in env:
scope.span.set_tag("http.%s" % custom_header, env[wsgi_header])
scope.span.set_tag("http.header.%s" % custom_header, env[wsgi_header])

if 'PATH_INFO' in env:
scope.span.set_tag('http.path', env['PATH_INFO'])
Expand Down
2 changes: 1 addition & 1 deletion instana/instrumentation/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def new_start_response(status, headers, exc_info=None):
# Headers are available in this format: HTTP_X_CAPTURE_THIS
wsgi_header = ('HTTP_' + custom_header.upper()).replace('-', '_')
if wsgi_header in env:
self.scope.span.set_tag("http.%s" % custom_header, env[wsgi_header])
self.scope.span.set_tag("http.header.%s" % custom_header, env[wsgi_header])

if 'PATH_INFO' in env:
self.scope.span.set_tag('http.path', env['PATH_INFO'])
Expand Down
14 changes: 12 additions & 2 deletions instana/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,5 +467,15 @@ def _collect_http_tags(self, span):
self.data["http"]["path_tpl"] = span.tags.pop("http.path_tpl", None)
self.data["http"]["error"] = span.tags.pop('http.error', None)

if span.operation_name == "soap":
self.data["soap"]["action"] = span.tags.pop('soap.action', None)
if len(span.tags) > 0:
if span.operation_name == "soap":
self.data["soap"]["action"] = span.tags.pop('soap.action', None)

custom_headers = []
for key in span.tags:
if key[0:12] == "http.header.":
custom_headers.append(key)

for key in custom_headers:
trimmed_key = key[12:]
self.data["http"]["header"][trimmed_key] = span.tags.pop(key)
6 changes: 4 additions & 2 deletions tests/clients/test_urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def test_client_error(self):

def test_requestspkg_get(self):
self.recorder.clear_spans()

with tracer.start_active_span('test'):
r = requests.get(testenv["wsgi_server"] + '/', timeout=2)

Expand Down Expand Up @@ -706,7 +706,9 @@ def test_response_header_capture(self):
self.assertIsNotNone(urllib3_span.stack)
self.assertTrue(type(urllib3_span.stack) is list)
self.assertTrue(len(urllib3_span.stack) > 1)
self.assertTrue('http.X-Capture-This' in urllib3_span.data["custom"]["tags"])

assert "X-Capture-This" in urllib3_span.data["http"]["header"]
self.assertEqual("Ok", urllib3_span.data["http"]["header"]["X-Capture-This"])

agent.options.extra_http_headers = original_extra_http_headers

11 changes: 5 additions & 6 deletions tests/frameworks/test_aiohttp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,14 @@ async def test():

self.assertEqual("aiohttp-client", aiohttp_span.n)
self.assertEqual(200, aiohttp_span.data["http"]["status"])
self.assertEqual(
testenv["wsgi_server"] + "/response_headers", aiohttp_span.data["http"]["url"])
self.assertEqual(testenv["wsgi_server"] + "/response_headers", aiohttp_span.data["http"]["url"])
self.assertEqual("GET", aiohttp_span.data["http"]["method"])
self.assertIsNotNone(aiohttp_span.stack)
self.assertTrue(type(aiohttp_span.stack) is list)
self.assertTrue(len(aiohttp_span.stack) > 1)
self.assertTrue(
'http.X-Capture-This' in aiohttp_span.data["custom"]["tags"])

assert "X-Capture-This" in aiohttp_span.data["http"]["header"]
self.assertEqual("Ok", aiohttp_span.data["http"]["header"]["X-Capture-This"])

assert "X-Instana-T" in response.headers
self.assertEqual(response.headers["X-Instana-T"], traceId)
Expand All @@ -393,8 +393,7 @@ async def test():
assert "X-Instana-L" in response.headers
self.assertEqual(response.headers["X-Instana-L"], '1')
assert "Server-Timing" in response.headers
self.assertEqual(
response.headers["Server-Timing"], "intid;desc=%s" % traceId)
self.assertEqual(response.headers["Server-Timing"], "intid;desc=%s" % traceId)

agent.options.extra_http_headers = original_extra_http_headers

Expand Down
10 changes: 4 additions & 6 deletions tests/frameworks/test_aiohttp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,10 @@ async def test():
self.assertEqual(
response.headers["Server-Timing"], "intid;desc=%s" % traceId)

assert("http.X-Capture-This" in aioserver_span.data["custom"]["tags"])
self.assertEqual(
'this', aioserver_span.data["custom"]["tags"]['http.X-Capture-This'])
assert("http.X-Capture-That" in aioserver_span.data["custom"]["tags"])
self.assertEqual(
'that', aioserver_span.data["custom"]["tags"]['http.X-Capture-That'])
assert "X-Capture-This" in aioserver_span.data["http"]["header"]
self.assertEqual("this", aioserver_span.data["http"]["header"]["X-Capture-This"])
assert "X-Capture-That" in aioserver_span.data["http"]["header"]
self.assertEqual("that", aioserver_span.data["http"]["header"]["X-Capture-That"])

def test_server_get_401(self):
async def test():
Expand Down
8 changes: 4 additions & 4 deletions tests/frameworks/test_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ def test_custom_header_capture(self):
self.assertEqual('GET', django_span.data["http"]["method"])
self.assertEqual(200, django_span.data["http"]["status"])

self.assertEqual(True, "http.X-Capture-This" in django_span.data["custom"]['tags'])
self.assertEqual("this", django_span.data["custom"]['tags']["http.X-Capture-This"])
self.assertEqual(True, "http.X-Capture-That" in django_span.data["custom"]['tags'])
self.assertEqual("that", django_span.data["custom"]['tags']["http.X-Capture-That"])
assert "X-Capture-This" in django_span.data["http"]["header"]
self.assertEqual("this", django_span.data["http"]["header"]["X-Capture-This"])
assert "X-Capture-That" in django_span.data["http"]["header"]
self.assertEqual("that", django_span.data["http"]["header"]["X-Capture-That"])

def test_with_incoming_context(self):
request_headers = dict()
Expand Down
8 changes: 4 additions & 4 deletions tests/frameworks/test_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def test_custom_header_capture(server):
assert('http.error' not in asgi_span.data['sdk']['custom']['tags'])
assert('http.params' not in asgi_span.data['sdk']['custom']['tags'])

assert("http.X-Capture-This" in asgi_span.data["sdk"]["custom"]['tags'])
assert("this" == asgi_span.data["sdk"]["custom"]['tags']["http.X-Capture-This"])
assert("http.X-Capture-That" in asgi_span.data["sdk"]["custom"]['tags'])
assert("that" == asgi_span.data["sdk"]["custom"]['tags']["http.X-Capture-That"])
assert("http.header.X-Capture-This" in asgi_span.data["sdk"]["custom"]['tags'])
assert("this" == asgi_span.data["sdk"]["custom"]['tags']["http.header.X-Capture-This"])
assert("http.header.X-Capture-That" in asgi_span.data["sdk"]["custom"]['tags'])
assert("that" == asgi_span.data["sdk"]["custom"]['tags']["http.header.X-Capture-That"])
8 changes: 4 additions & 4 deletions tests/frameworks/test_starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def test_custom_header_capture(server):
assert('http.error' not in asgi_span.data['sdk']['custom']['tags'])
assert('http.params' not in asgi_span.data['sdk']['custom']['tags'])

assert("http.X-Capture-This" in asgi_span.data["sdk"]["custom"]['tags'])
assert("this" == asgi_span.data["sdk"]["custom"]['tags']["http.X-Capture-This"])
assert("http.X-Capture-That" in asgi_span.data["sdk"]["custom"]['tags'])
assert("that" == asgi_span.data["sdk"]["custom"]['tags']["http.X-Capture-That"])
assert("http.header.X-Capture-This" in asgi_span.data["sdk"]["custom"]['tags'])
assert("this" == asgi_span.data["sdk"]["custom"]['tags']["http.header.X-Capture-This"])
assert("http.header.X-Capture-That" in asgi_span.data["sdk"]["custom"]['tags'])
assert("that" == asgi_span.data["sdk"]["custom"]['tags']["http.header.X-Capture-That"])
12 changes: 6 additions & 6 deletions tests/frameworks/test_tornado_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async def test():
return await self.post(session, testenv["tornado_server"] + "/")

response = tornado.ioloop.IOLoop.current().run_sync(test)

spans = self.recorder.queued_spans()
self.assertEqual(3, len(spans))

Expand Down Expand Up @@ -176,7 +176,7 @@ async def test():
headers = {
'X-Instana-Synthetic': '1'
}

with async_tracer.start_active_span('test'):
async with aiohttp.ClientSession() as session:
return await self.fetch(session, testenv["tornado_server"] + "/", headers=headers)
Expand Down Expand Up @@ -598,7 +598,7 @@ async def test():
self.assertTrue("Server-Timing" in response.headers)
self.assertEqual(response.headers["Server-Timing"], "intid;desc=%s" % traceId)

self.assertTrue("http.X-Capture-This" in tornado_span.data["custom"]["tags"])
self.assertEqual('this', tornado_span.data["custom"]["tags"]['http.X-Capture-This'])
self.assertTrue("http.X-Capture-That" in tornado_span.data["custom"]["tags"])
self.assertEqual('that', tornado_span.data["custom"]["tags"]['http.X-Capture-That'])
assert "X-Capture-This" in tornado_span.data["http"]["header"]
self.assertEqual("this", tornado_span.data["http"]["header"]["X-Capture-This"])
assert "X-Capture-That" in tornado_span.data["http"]["header"]
self.assertEqual("that", tornado_span.data["http"]["header"]["X-Capture-That"])
8 changes: 4 additions & 4 deletions tests/frameworks/test_wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ def test_custom_header_capture(self):
self.assertIsNotNone(wsgi_span.stack)
self.assertEqual(2, len(wsgi_span.stack))

self.assertEqual(True, "http.X-Capture-This" in wsgi_span.data["custom"]['tags'])
self.assertEqual("this", wsgi_span.data["custom"]['tags']["http.X-Capture-This"])
self.assertEqual(True, "http.X-Capture-That" in wsgi_span.data["custom"]['tags'])
self.assertEqual("that", wsgi_span.data["custom"]['tags']["http.X-Capture-That"])
assert "X-Capture-This" in wsgi_span.data["http"]["header"]
self.assertEqual("this", wsgi_span.data["http"]["header"]["X-Capture-This"])
assert "X-Capture-That" in wsgi_span.data["http"]["header"]
self.assertEqual("that", wsgi_span.data["http"]["header"]["X-Capture-That"])

def test_secret_scrubbing(self):
with tracer.start_active_span('test'):
Expand Down