Skip to content

Commit

Permalink
feat: aws_lambda update
Browse files Browse the repository at this point in the history
  • Loading branch information
xuan-cao-swi committed Mar 25, 2024
1 parent 4381f30 commit 8f187c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def call_wrapped(event:, context:)
parent_context = extract_parent_context(event)

span_kind = nil
span_kind = if event['Records'] && ['aws:sqs', 'aws:s3', 'aws:sns', 'aws:dynamodb'].include?(event['Records'].dig(0,'eventSource'))
span_kind = if event['Records'] && ['aws:sqs', 'aws:s3', 'aws:sns', 'aws:dynamodb'].include?(event['Records'].dig(0, 'eventSource'))
:consumer
else
:server
Expand Down Expand Up @@ -186,16 +186,14 @@ def otel_attributes(event, context)
end

# sqs spec for lambda: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/faas/aws-lambda.md#sqs
# current there is no spec for 'aws:sns', 'aws:s3' and 'aws:dynamodb'
def trigger_type_attributes(event)
attributes = {}
case event['Records'].dig(0,'eventSource')
case event['Records'].dig(0, 'eventSource')
when 'aws:sqs'
attributes[OpenTelemetry::SemanticConventions::Trace::FAAS_TRIGGER] = 'pubsub'
attributes[OpenTelemetry::SemanticConventions::Trace::MESSAGING_OPERATION] = 'process'
attributes[OpenTelemetry::SemanticConventions::Trace::MESSAGING_SYSTEM] = 'AmazonSQS'
when 'aws:sns'
when 'aws:s3'
when 'aws:dynamodb'
end
attributes
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
_(last_span.kind).must_equal :server

_(last_span.status.code).must_equal 2
_(last_span.status.description).must_equal 'Original lambda handler exception: StandardError. Please check if you have correct handler setting or code in lambda function.'
_(last_span.status.description).must_equal 'Original lambda handler exception: StandardError. Please check if you have the correct handler setting and code in your lambda function.'
_(last_span.hex_parent_span_id).must_equal '0000000000000000'

_(last_span.events[0].name).must_equal 'exception'
Expand Down

0 comments on commit 8f187c9

Please sign in to comment.