-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lambda instrumentation implementation #32
Conversation
…; improve LambdaEmitter test
Also, created this project that deploys a Lambda function that demonstrates the forked gem. |
All requested changes made and confirmed to be working in https://github.com/bonybrown/aws-lambda-ruby-xray-demo. |
Hi @bonybrown , Are you seeing this empty trace as well? |
Just tried, and yes, I'm seeing the same behaviour. Interesting that with Active Tracing disabled in the console, the REPORT output still shows an XRay trace id:
I'll investigate and get back to you. |
ref_counter and subsegment_size mutators on FacadeSegment must be implemented so that adding sub-subsegments works.
Hi @srprash - problem identified and fixed. In doing so, identified another problem, now also fixed. |
Hi @srprash, any update on the progress of this PR? I believe all the issues raised have been addressed. |
Hi @bonybrown , Thanks, |
lib/aws-xray-sdk/facets/net_http.rb
Outdated
@@ -16,12 +16,18 @@ def new(*options) | |||
module HTTPInstanceInterceptor | |||
include XRay::Facets::Helper | |||
|
|||
# Pattern matches the path of requests from the AWS Lambda Ruby Runtime. | |||
# We do not want to capture these | |||
LAMBDA_RUNTIME_PATH_PATTERN = /\A\/[0-9-]{10}\/runtime\/invocation\//.freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using regex for pattern matching, I think we can fetch the value of AWS_LAMBDA_RUNTIME_API
environment variable and check if the req.path begins with this value. I just came across this env variable in lambda runtime and we can avoid using regex matching altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
req.path
would only give the partial path that does not include the host information. Instead req.uri
gives the complete url http://127.0.0.1:9001/.....
. Doing a start_with?
check on req.uri
would work better. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to test against the AWS_LAMBDA_RUNTIME_API
environment variable.
Tested in sample app and seems to be working fine.
…ironment variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep getting "ERROR -- : can not find the current context." while running the lambda function. Are you getting this too?
Sorry, seems that my demo project was using the prior version of Have fixed and added tests of # Test begin_segment - should report warning, but not create segment
XRay.recorder.begin_segment 'my_segment'
puts "in segment - begin_segment call should have logged a warning"
# Test end_segment - should report warning
XRay.recorder.end_segment
# Test begin_subsegment, should result in subsegment created
XRay.recorder.begin_subsegment 'sub-segment'
puts "in subsegment"
dynamo_client.list_tables
uri = URI 'https://ip-ranges.amazonaws.com/ip-ranges.json'
http_connection.request(uri).body
XRay.recorder.end_subsegment Using aws-xray-sdk 0.11.2 from https://github.com/bonybrown/aws-xray-sdk-ruby.git (at lambda-instrumentation@d2d7223) and updated demo project I now get this output:
I don't get |
Looks good and ready to be merged! |
Issue #20
Description of changes:
aws-xray-sdk/lambda.rb
to be used in lambda functions to initialise and configure XRay.recorder.This work is based off the implementation of the python xray-sdk for lambda.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. ✔️