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
5 changes: 0 additions & 5 deletions instana/instrumentation/aws/lambda_inst.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ def lambda_handler_with_instana(wrapped, instance, args, kwargs):
result['headers']['Server-Timing'] = server_timing_value
elif 'multiValueHeaders' in result:
result['multiValueHeaders']['Server-Timing'] = [server_timing_value]
else:
# If both 'headers' and 'multiValueHeaders' aren't in result,
# then default to setting single value 'headers'
result['headers'] = dict()
result['headers']['Server-Timing'] = server_timing_value
except Exception as exc:
if scope.span:
scope.span.log_exception(exc)
Expand Down
30 changes: 21 additions & 9 deletions instana/instrumentation/aws/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from ...log import logger

STR_LAMBDA_TRIGGER = 'lambda.trigger'


def get_context(tracer, event):
# TODO: Search for more types of trigger context
Expand Down Expand Up @@ -83,7 +85,7 @@ def read_http_query_params(event):
return "&".join(params)
else:
return ""
except:
except Exception:
logger.debug("read_http_query_params: ", exc_info=True)
return ""

Expand All @@ -106,7 +108,7 @@ def capture_extra_headers(event, span, extra_headers):
for key in event_headers:
if key.lower() == custom_header.lower():
span.set_tag("http.%s" % custom_header, event_headers[key])
except:
except Exception:
logger.debug("capture_extra_headers: ", exc_info=True)


Expand All @@ -131,7 +133,8 @@ def enrich_lambda_span(agent, span, event, context):
return

if is_api_gateway_proxy_trigger(event):
span.set_tag('lambda.trigger', 'aws:api.gateway')
logger.debug("Detected as API Gateway Proxy Trigger")
span.set_tag(STR_LAMBDA_TRIGGER, 'aws:api.gateway')
span.set_tag('http.method', event["httpMethod"])
span.set_tag('http.url', event["path"])
span.set_tag('http.path_tpl', event["resource"])
Expand All @@ -141,7 +144,8 @@ def enrich_lambda_span(agent, span, event, context):
capture_extra_headers(event, span, agent.options.extra_http_headers)

elif is_application_load_balancer_trigger(event):
span.set_tag('lambda.trigger', 'aws:application.load.balancer')
logger.debug("Detected as Application Load Balancer Trigger")
span.set_tag(STR_LAMBDA_TRIGGER, 'aws:application.load.balancer')
span.set_tag('http.method', event["httpMethod"])
span.set_tag('http.url', event["path"])
span.set_tag('http.params', read_http_query_params(event))
Expand All @@ -150,7 +154,8 @@ def enrich_lambda_span(agent, span, event, context):
capture_extra_headers(event, span, agent.options.extra_http_headers)

elif is_cloudwatch_trigger(event):
span.set_tag('lambda.trigger', 'aws:cloudwatch.events')
logger.debug("Detected as Cloudwatch Trigger")
span.set_tag(STR_LAMBDA_TRIGGER, 'aws:cloudwatch.events')
span.set_tag('data.lambda.cw.events.id', event['id'])

resources = event['resources']
Expand All @@ -169,7 +174,8 @@ def enrich_lambda_span(agent, span, event, context):
span.set_tag('lambda.cw.events.resources', report)

elif is_cloudwatch_logs_trigger(event):
span.set_tag('lambda.trigger', 'aws:cloudwatch.logs')
logger.debug("Detected as Cloudwatch Logs Trigger")
span.set_tag(STR_LAMBDA_TRIGGER, 'aws:cloudwatch.logs')

try:
if 'awslogs' in event and 'data' in event['awslogs']:
Expand All @@ -196,7 +202,8 @@ def enrich_lambda_span(agent, span, event, context):
except Exception as e:
span.set_tag('lambda.cw.logs.decodingError', repr(e))
elif is_s3_trigger(event):
span.set_tag('lambda.trigger', 'aws:s3')
logger.debug("Detected as S3 Trigger")
span.set_tag(STR_LAMBDA_TRIGGER, 'aws:s3')

if "Records" in event:
events = []
Expand All @@ -218,12 +225,17 @@ def enrich_lambda_span(agent, span, event, context):
span.set_tag('lambda.s3.events', events)

elif is_sqs_trigger(event):
span.set_tag('lambda.trigger', 'aws:sqs')
logger.debug("Detected as SQS Trigger")
span.set_tag(STR_LAMBDA_TRIGGER, 'aws:sqs')

if "Records" in event:
events = []
for item in event["Records"][:3]:
events.append({'queue': item['eventSourceARN']})
span.set_tag('lambda.sqs.messages', events)
except:
else:
logger.debug("Detected as Unknown Trigger: %s" % event)
span.set_tag(STR_LAMBDA_TRIGGER, 'unknown')

except Exception:
logger.debug("enrich_lambda_span: ", exc_info=True)
4 changes: 2 additions & 2 deletions instana/instrumentation/urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def collect_response(scope, response):
def urlopen_with_instana(wrapped, instance, args, kwargs):
parent_span = tracer.active_span

# If we're not tracing, just return
if parent_span is None:
# If we're not tracing, just return; boto3 has it's own visibility
if parent_span is None or parent_span.operation_name == 'boto3':
return wrapped(*args, **kwargs)

with tracer.start_active_span("urllib3", child_of=parent_span) as scope:
Expand Down