-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Feature Request] Add support for X-Ray on SAM Local #217
Comments
Thanks for opening this. I believe the steps we need to take to add this to SAM Local are:
|
It would be nice to use X-Ray from lambdas run using AWS SAM Local BUT more important to me would be a way to silently discard X-Ray calls in the code. if (process.env.AWS_SAM_LOCAL) { |
+1 This will be a very valuable tool for us! |
Could we using sam local with X-Ray now? |
It appears not yet. I've been using the process.env check above as mentioned till then. Not a big issue for me either way. |
The primary use-case I have for enabling x-ray integration is really just so that I don't have to have different configuration in my local dev environment vs my production environment. I'd like to be able to have my code enable x-ray, and the SAM local simulation not dying or raising errors on me. I'm less opinionated about whether the requests actually get submitted to the x-ray service upstream, and care more about just being able to emulate it locally.
|
Any update on this? |
We are not looking to support X-Ray locally at this time. Closing. |
Not planing to have the feature and closing it instead moving it to a backlog to see how the priority should grow it's not the best way to handle the issue. You are simply saying here that the community feedback and customers using the aws-sam-cli doesn't matter. |
@hugoprudente thanks for the honest feedback, we appreciate it. I realize it is frustrating to have filed this issue 3 years ago and have it closed after all this time. We decided to close this issue as part of an effort on the team currently maintaining SAM cli to do a better job of communicating with community members about what our intentions are, even if the answer isn't the one you would prefer. Having said that, let's talk about it. If sam cli were to "support" X-Ray, what would your ideal dev experience be? The original report indicates you just don't want the lambda to crash - is that it, or do you want sam cli to actually behave like X-Ray in the cloud? |
A first point is prevent the crash and prevent us dev to create unnecessary handling as the production will have X-Ray so the sam-cli that we use as dev/test environments also should handle it. Supporting the feature is also necessary as what's the point to have something that I can't test my traces locally and only in production and if I need to test X-Ray locally I can't use SAM-CLI and do everything by hand so in the end it's better to do everything by hand as I have being doing instead wasting my time in the SAM-CLI as the effort of testing x-ray and adding and removing it to work with SAM-CLI doesn't make sense at all. X-Ray already works locally publishing it to the X-RAY service or being intercepted locally by any UDP handlers so having the SDK on a similar fashion s the Lambda have so users can try simulate the best of the Lambda features locally and understand how do X-Ray will work for their use case it's just a extra plus. From my use cases only if doesn't use X-Ray at all I have the SAM-CLI and if it has the probability of needing X-Ray in the feature I don't use it as the extra effort describing above of crating 2 lanes todo 1 thing I prefer to pay extra for the lambdas and test on the real environment than waste my developers time. |
* Release v1.0.0 (aws#2111) * feat: Use aws-sam-cli docker images (aws#2066) * Add Source for Docker Build Images (aws#2078) * chore: Bump AWS SAM CLI Version (aws#2079) * Version bump (aws#2080) * chore: Bump AWS SAM CLI Version * Change SAM CLI Version Number There is a conflict betweeen PyPi documentation which asks for the previous style https://packaging.python.org/guides/distributing-packages-using-setuptools/#pre-release-versioning and PEP 440 which proposes the style included in this change https://www.python.org/dev/peps/pep-0440/#pre-releases - our MSI build scripts failed on the pattern we were using before, this changes the pattern. * refactor: Build init.go with -s and -w flags to removed debug info (aws#2083) * refactor: Bake Rapid into image on the fly (aws#2100) * refactor: Bake Rapid into image on the fly * force chmod on init binary in container for windows * bake go debug bootstrap Co-authored-by: Jacob Fuss <[email protected]> * chore: Bump version to RC2 (aws#2104) * Remove liblzma and libxslt from AL2 build images (aws#2109) Discovered a regression where on Ruby 2.7, the `nokogiri` dependency would build without errors, but would not run on local testing or on AWS Lambda itself. On further investigation, it appears that `nokogiri` can compile with or without `liblzma` present, but if it is present in the build enviornment (pre-change) and it is not present on the invoke environment (true in AL2 runtimes), you will experience runtime failures attempting to require `nokogiri`. I have been able to verify that with these changes, `nokogiri` builds correctly for Ruby 2.7 and runs both locally and on AWS Lambda. * Build output dots (aws#2112) * Use Low-Level Docker Client Allows us to stream dots as a progress heartbeat. Pending unit tests and black formatting. * Get make pr Passing Co-authored-by: Jacob Fuss <[email protected]> Co-authored-by: Jacob Fuss <[email protected]> * chore: Bump aws-lambda-builders and SAM CLI to 1.0.0 (aws#2116) * fix: Update Python3.8 debug entrypoint (aws#2119) * chore: readme update with screenshot (aws#2117) * chore: readme update with screenshot * chore: remove beta in the title Co-authored-by: Alex Wood <[email protected]> * feature: Lambda Code Sign integration for SAM CLI * feature: Lambda Code Sign integration for SAM CLI (actual signing impl and unit tests) * Add details to print_deploy_args Add documentation for missing classes and methods * Update couple of prompts * Wording changes requested by UX & Docs Team Co-authored-by: Alex Wood <[email protected]> Co-authored-by: Jacob Fuss <[email protected]> Co-authored-by: Jacob Fuss <[email protected]> Co-authored-by: Sriram Madapusi Vasudevan <[email protected]>
* Code Sign Integration (#217) * Release v1.0.0 (#2111) * feat: Use aws-sam-cli docker images (#2066) * Add Source for Docker Build Images (#2078) * chore: Bump AWS SAM CLI Version (#2079) * Version bump (#2080) * chore: Bump AWS SAM CLI Version * Change SAM CLI Version Number There is a conflict betweeen PyPi documentation which asks for the previous style https://packaging.python.org/guides/distributing-packages-using-setuptools/#pre-release-versioning and PEP 440 which proposes the style included in this change https://www.python.org/dev/peps/pep-0440/#pre-releases - our MSI build scripts failed on the pattern we were using before, this changes the pattern. * refactor: Build init.go with -s and -w flags to removed debug info (#2083) * refactor: Bake Rapid into image on the fly (#2100) * refactor: Bake Rapid into image on the fly * force chmod on init binary in container for windows * bake go debug bootstrap Co-authored-by: Jacob Fuss <[email protected]> * chore: Bump version to RC2 (#2104) * Remove liblzma and libxslt from AL2 build images (#2109) Discovered a regression where on Ruby 2.7, the `nokogiri` dependency would build without errors, but would not run on local testing or on AWS Lambda itself. On further investigation, it appears that `nokogiri` can compile with or without `liblzma` present, but if it is present in the build enviornment (pre-change) and it is not present on the invoke environment (true in AL2 runtimes), you will experience runtime failures attempting to require `nokogiri`. I have been able to verify that with these changes, `nokogiri` builds correctly for Ruby 2.7 and runs both locally and on AWS Lambda. * Build output dots (#2112) * Use Low-Level Docker Client Allows us to stream dots as a progress heartbeat. Pending unit tests and black formatting. * Get make pr Passing Co-authored-by: Jacob Fuss <[email protected]> Co-authored-by: Jacob Fuss <[email protected]> * chore: Bump aws-lambda-builders and SAM CLI to 1.0.0 (#2116) * fix: Update Python3.8 debug entrypoint (#2119) * chore: readme update with screenshot (#2117) * chore: readme update with screenshot * chore: remove beta in the title Co-authored-by: Alex Wood <[email protected]> * feature: Lambda Code Sign integration for SAM CLI * feature: Lambda Code Sign integration for SAM CLI (actual signing impl and unit tests) * Add details to print_deploy_args Add documentation for missing classes and methods * Update couple of prompts * Wording changes requested by UX & Docs Team Co-authored-by: Alex Wood <[email protected]> Co-authored-by: Jacob Fuss <[email protected]> Co-authored-by: Jacob Fuss <[email protected]> Co-authored-by: Sriram Madapusi Vasudevan <[email protected]> * - Update code signer param to align with tags and parameter-override params. - Added additional unit tests * chore: merge public develop with code signer changes * feat: Code Signer integration tests * add zip only if package needs to be signed * chore: bump SAM CLI version, update sam-translator dependency and tests with 1.31.0 Co-authored-by: Alex Wood <[email protected]> Co-authored-by: Jacob Fuss <[email protected]> Co-authored-by: Jacob Fuss <[email protected]> Co-authored-by: Sriram Madapusi Vasudevan <[email protected]>
@hugoprudente Hi there, first of all unfortunately the reason that we said that we're not looking to support it is 1) some components just cannot support x-ray locally, example: https://github.com/aws/aws-lambda-runtime-interface-emulator#level-of-support 2) local tracing with x-ray doesn't work if the x-ray resource is not created yet. We really want to support the idea of having local runs to capture more Lambda features but x-ray isn't one that we can support yet. However, we are more than willing to communicate with you to provide a workaround locally so that you don't have to waste your time modifying your templates. Here are 2 options that we will try to provide: 1) we can generate warnings instead of errors for tracing property so that the local run wouldn't fail 2) we can mock what x-ray tracing does by printing to stdout locally. Please give us a feedback on which workaround idea makes more sense to you so we can improve your experience using sam-cli! |
Hi @qingchm, I didn't know which project was behind the creation of the AWS Lambda mock. The base support for this feature should be provided there it looks like. Regarding the X-Ray Resource is not created, which resource exactly you are referring to? As AWS X-Ray only needs the AWS X-Ray SDK in the code that is provided by AWS Lambda and bootstrapped together with the code that executes the lambda_handler in the same context. Regarding the options that you provided here are my observations:
Here is a little bit more context on how the AWS X-Ray works with AWS Lambda so we can trace the best approach to support minimal features on SAM CLI. The AWS Lambda code that executes the lambda_handler when X-Ray is enabled somehow loads the AWS X-RAY SDK Core in python will be this: from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core import patch_all
xray_recorder.configure(service='AWS SAM Local')
patch_all() Then when I execute my lambda_handler during the AWS Lambda execution the xray_recoreder will be on my context creating my segment. The aws_xray_sdk.core will automatically try to send the information to UDP2000 port, which may or not listen or do something with it. With a couple of lines of doc, It's easy on how to pick that information and sent it to AWS X-RAY Api or for a mock socket server for troubleshooting. The most important bit here is how can we bootstrap all the language supporting X-Ray to enable the X-Ray Recorder with the basic configuration and particularities like Segment not mutable. I'm not sure if this will be resolved here, or if it will be resolved on the AWS Lambda Runtime Interface Emulator. Either way, I will be glad to help add a wrapper to the executor to it but I'm sure that the AWS Lambda Team would be able to provide more insights on how they are wrapping it so this could be consistent, with production/edge and provide the same limitations to be as "real" as possible, as I know that some particularities that only happens on X-Ray SDK with AWS Lambda. Looking forward to hearing from you on which project will be responsible for the lambda_handler execution so I can help you with a simple example and we can plan the roadmap on how to add this feature in the upcoming future, as I'm sure I'm not the only one that put SAM-CLI a side due to this limitation. |
@hugoprudente Hi sorry for the confusion in my expressions, since I am studying on this issue just recently. But as for the first workaround, what I mean is to generate warning while skipping the requirement for the x-ray sdk. And by the creation what I mean is the daemon that the x-ray sdk communicates with. We need to integrate that into all environments as well in order for the sdk to work. Hopefully my words make better sense now. And to further address this issue, we are involving more discussions and I should be in touch with you soon! |
Hi @hugoprudente, @jabalsad, @svenemtell: |
This issue has not received a response in 14 days. |
I'm using 3.3.3 of the aws-sdk-xray nom package with 3.17.0 of the javascript sdk Including the following line will generate the below error when invoking locally with v1.23.0 of the sam-cli. The lambda function works fine when deployed to AWS and captures the SSM traffic in Xray.
|
I can confirm the exact same error as @Dazza65 with aws-sdk-xray-core 3.3.3 |
I'm also having this issue as well. I don't know how to use this feature without polluting my code. |
Based on @qingchm's earlier answer:
So I just opened this issue over on the Runtime Interface Emulator repo to get things moving on their end. If everybody goes and rants on that repo, maybe this feature will actually be implemented in the RIE, and then SAM CLI can support it as well. 😛 |
Is this still an issue with recent releases? I am using 1.61 locally and not seeing failures others are seeing here. I am using python but I could have a setup that doesn't trigger what others have seen. I am seeing warnings from the X-Ray Python SDK but my function still works locally (returns what I expected). If someone tries this in recent versions, can you try to add a fake |
I can still see the issue with the a newer version of SAM CLI (1.73.0). To reproduce it, it's not enough to just configure X-Ray, but you need to actually make an AWS call with X-Ray configured. The way I've reproduced this is to use the nodejs16.x "Serverless API" example, and change this line to get an X-Ray enabled DynamoDB client:
The other thing to take into account for the workaround for this error is that the fake |
Actually I just noticed that I was using a really old version of the X-Ray library |
I tried to reproduce the issue with Node16.x, but the error doesn't show up. I also tried with the java 11, then python 3.9 runtimes just to be very sure, but I was still able to invoke the functions without any errors. Based on that, I think we can safely close this issue |
Also confirmed it works in Go with |
|
Hi Team,
When trying to use the AWS SAM Local with Node.js per example it fails with the following error:
This happens as the X-Ray Lambda already have the traces as per documentation: http://docs.aws.amazon.com/xray/latest/devguide/xray-services-lambda.html
So when using SAM Local this Trace Header is a missing.
The text was updated successfully, but these errors were encountered: