Skip to content

Commit

Permalink
Lambda is CONSUMER SQS trace if 'Records' key in Lambda event
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanielRN committed Oct 27, 2021
1 parent f0687b1 commit a182761
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,17 @@ def _instrumented_lambda_handler_call(
lambda_event, event_context_extractor
)

# See more:
# https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html
if "Records" in lambda_event:
span_kind = SpanKind.CONSUMER
else:
span_kind = SpanKind.SERVER

tracer = get_tracer(__name__, __version__, tracer_provider)

with tracer.start_as_current_span(
name=orig_handler_name,
context=parent_context,
kind=SpanKind.SERVER,
name=orig_handler_name, context=parent_context, kind=span_kind,
) as span:
if span.is_recording():
lambda_context = args[1]
Expand Down

0 comments on commit a182761

Please sign in to comment.