Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a182761

Browse files
committedOct 27, 2021
Lambda is CONSUMER SQS trace if 'Records' key in Lambda event
1 parent f0687b1 commit a182761

File tree

1 file changed

+8
-3
lines changed
  • instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda

1 file changed

+8
-3
lines changed
 

‎instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,17 @@ def _instrumented_lambda_handler_call(
183183
lambda_event, event_context_extractor
184184
)
185185

186+
# See more:
187+
# https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html
188+
if "Records" in lambda_event:
189+
span_kind = SpanKind.CONSUMER
190+
else:
191+
span_kind = SpanKind.SERVER
192+
186193
tracer = get_tracer(__name__, __version__, tracer_provider)
187194

188195
with tracer.start_as_current_span(
189-
name=orig_handler_name,
190-
context=parent_context,
191-
kind=SpanKind.SERVER,
196+
name=orig_handler_name, context=parent_context, kind=span_kind,
192197
) as span:
193198
if span.is_recording():
194199
lambda_context = args[1]

0 commit comments

Comments
 (0)
Please sign in to comment.