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
7 changes: 0 additions & 7 deletions instana/http_propagator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,16 @@ class HTTPPropagator():
HEADER_KEY_T = 'X-Instana-T'
HEADER_KEY_S = 'X-Instana-S'
HEADER_KEY_L = 'X-Instana-L'
HEADER_KEY_ST = 'Server-Timing'
LC_HEADER_KEY_T = 'x-instana-t'
LC_HEADER_KEY_S = 'x-instana-s'
LC_HEADER_KEY_L = 'x-instana-l'
LC_HEADER_KEY_ST = 'server-timing'

ALT_HEADER_KEY_T = 'HTTP_X_INSTANA_T'
ALT_HEADER_KEY_S = 'HTTP_X_INSTANA_S'
ALT_HEADER_KEY_L = 'HTTP_X_INSTANA_L'
ATL_HEADER_KEY_ST = 'HTTP_SERVER_TIMING'
ALT_LC_HEADER_KEY_T = 'http_x_instana_t'
ALT_LC_HEADER_KEY_S = 'http_x_instana_s'
ALT_LC_HEADER_KEY_L = 'http_x_instana_l'
ATL_LC_HEADER_KEY_ST = 'http_server_timing'

def inject(self, span_context, carrier):
try:
Expand All @@ -49,17 +45,14 @@ def inject(self, span_context, carrier):
carrier[self.HEADER_KEY_T] = trace_id
carrier[self.HEADER_KEY_S] = span_id
carrier[self.HEADER_KEY_L] = "1"
carrier[self.HEADER_KEY_ST] = "intid;desc=%s" % trace_id
elif type(carrier) is list:
carrier.append((self.HEADER_KEY_T, trace_id))
carrier.append((self.HEADER_KEY_S, span_id))
carrier.append((self.HEADER_KEY_L, "1"))
carrier.append((self.HEADER_KEY_ST, "intid;desc=%s" % trace_id))
elif hasattr(carrier, '__setitem__'):
carrier.__setitem__(self.HEADER_KEY_T, trace_id)
carrier.__setitem__(self.HEADER_KEY_S, span_id)
carrier.__setitem__(self.HEADER_KEY_L, "1")
carrier.__setitem__(self.HEADER_KEY_ST, "intid;desc=%s" % trace_id)
else:
raise Exception("Unsupported carrier type", type(carrier))

Expand Down
1 change: 1 addition & 0 deletions instana/instrumentation/aiohttp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ async def stan_middleware(request, handler):

scope.span.set_tag("http.status_code", response.status)
async_tracer.inject(scope.span.context, opentracing.Format.HTTP_HEADERS, response.headers)
response.headers['Server-Timing'] = "intid;desc=%s" % scope.span.context.trace_id

return response
except:
Expand Down
2 changes: 2 additions & 0 deletions instana/instrumentation/django/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def process_response(self, request, response):

request.iscope.span.set_tag(ext.HTTP_STATUS_CODE, response.status_code)
tracer.inject(request.iscope.span.context, ot.Format.HTTP_HEADERS, response)
response['Server-Timing'] = "intid;desc=%s" % request.iscope.span.context.trace_id

except Exception:
logger.debug("Instana middleware @ process_response", exc_info=True)
finally:
Expand Down
2 changes: 2 additions & 0 deletions instana/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def __call__(self, environ, start_response):
def new_start_response(status, headers, exc_info=None):
"""Modified start response with additional headers."""
tracer.inject(self.scope.span.context, ot.Format.HTTP_HEADERS, headers)
headers.append(('Server-Timing', "intid;desc=%s" % self.scope.span.context.trace_id))

res = start_response(status, headers, exc_info)

sc = status.split(' ')[0]
Expand Down
5 changes: 0 additions & 5 deletions tests/test_ot_propagators.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ def test_inject_with_dict():
assert_equals(carrier['X-Instana-S'], span.context.span_id)
assert 'X-Instana-L' in carrier
assert_equals(carrier['X-Instana-L'], "1")
assert 'Server-Timing' in carrier
server_timing_value = "intid;desc=%s" % span.context.trace_id
assert_equals(carrier['Server-Timing'], server_timing_value)


def test_inject_with_list():
Expand All @@ -51,8 +48,6 @@ def test_inject_with_list():
assert ('X-Instana-T', span.context.trace_id) in carrier
assert ('X-Instana-S', span.context.span_id) in carrier
assert ('X-Instana-L', "1") in carrier
server_timing_value = "intid;desc=%s" % span.context.trace_id
assert ('Server-Timing', server_timing_value) in carrier


def test_basic_extract():
Expand Down