Comments (12)
The long term solution is to have the middleware directly add all http metadata to the root segment generated by Lambda worker. The SDK currently doesn't have access to this segment right now and we don't have an ETA yet.
The workaround is to have middleware to only generate subsegments when running on Lambda. This causes a problem in the service graph. The color of the Lambda function node in the service graph is decided by status code in lambda segments. And this status code only indicates if the lambda function runs or not. It doesn't respect the actual status code returned by your web application running within that lambda function. If you have correct IAM role setup and no syntax error on your application code, most likely you will always see an all green service graph node despite a lot of 4xx returned by your web app.
This workaround makes it difficult to discover issues and we cannot call this workaround "support for serverless". But we are open to here any suggestions. If such workaround is acceptable we can make it an opt-in so that at least FacadeSegmentMutationException is avoided.
from aws-xray-sdk-python.
patching the libraries seemed to solve this issue for me, also using lambda, flask, & zappa.
from aws_xray_sdk.core import xray_recorder, patch_all
from aws_xray_sdk.core.context import Context
from aws_xray_sdk.ext.flask.middleware import XRayMiddleware
patch_all()
and then this was how i wrapped it inside the flask application:
xray_recorder.configure(service='Your Service Name', sampling=False, context=Context())
XRayMiddleware(app, xray_recorder)
from aws-xray-sdk-python.
Good news! Serverless support has been merged into the master branch!
#127
from aws-xray-sdk-python.
Hi, which serverless framework are you using?
from aws-xray-sdk-python.
I use zappa , and python flask framework.
from aws-xray-sdk-python.
also enabled in zappa config checkout: https://github.com/Miserlou/Zappa#aws-x-ray
from aws-xray-sdk-python.
For others running into this issue, @Sniedes722's combination of patching and enabling x-ray in Zappa worked for me. I'm not sure why, but it didn't work until I added the sampling=False, context=Context()
stuff.
from aws-xray-sdk-python.
@iandees I can also confirm that @haotianw465 is completely correct about getting green OK status codes in x-ray when the API is returning 400 statuses with this workaround
from aws-xray-sdk-python.
@haotianw465 What are the consequences if we use our own Context()
instead of using SDK-provided Lambda context?
from aws-xray-sdk-python.
@xplorld the recorder class intentionally exposes an API to allow users to configure their own context management https://github.com/aws/aws-xray-sdk-python/blob/master/aws_xray_sdk/core/recorder.py#L75.
You can have your own implementation of the context()
used in Lambda container which creates another type of facadesegment which can be modified freely and replicate everything it has to a child subsegment.
Please let me know if you need any help on implementing a customized context management that specifically fits your use case.
from aws-xray-sdk-python.
Hi all, API Gateway with active X-Ray integration is launched. You can see more details here: https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-xray.html.
Feel free to leave any feedback on the new customer experience and we are happy to discuss a workaround based on those new feedback. We will also be working with Lambda team based on those new feedback to better improve the overall experience. Thank you for your patience.
from aws-xray-sdk-python.
I see the a dangling subsegment even when calling configure before patching third party libraries.
from`aws_xray_sdk.core import xray_recorder, patch_all
from aws_xray_sdk.core.context import Context
from aws_xray_sdk.ext.flask.middleware import XRayMiddleware
app = connexion.App(__name__, specification_dir='./swagger/')
app.app.json_encoder = encoder.JSONEncoder
app.add_api('swagger.yaml', arguments={'title': 'Swagger Petstore'})
xray_recorder.configure(service=' python-flask-se-development', sampling=False, context=Context())
XRayMiddleware(app.app, xray_recorder)
patch_all()
from aws-xray-sdk-python.
Related Issues (20)
- aws-xray-sdk 2.11.0 removes causes from exceptions HOT 1
- ERROR: cannot find the current segment/subsegment when segment is open and uploading file to s3. HOT 3
- Installing SDK without botocore and other transitive dependencies HOT 4
- Custom emitter based on boto3 creates an infinite loop in the SDK HOT 3
- Bug: nested subsegments don't work across threads HOT 4
- IndexError when using AWS X-Ray SDK with SQLAlchemy HOT 1
- EKSPlugin HOT 1
- Very rare ReferenceError HOT 2
- Support for psycopg3 HOT 2
- Link a Textract async operation with downstream process HOT 1
- Current tox versions do not like how testenv.passenv is set
- aws_xray_sdk.core.exceptions.exceptions.SegmentNameMissingException: Segment name is required. HOT 1
- Using psycopg2 connection_factory throws exceptions HOT 4
- Documentation for patch_all HOT 2
- Sampling configuration should discuss DefaultSampler vs. LocalSampler HOT 1
- Flask middleware errors when an earlier Flask extension throws an exception in a before_request method HOT 1
- Patched DB cursor and template may record outside of XRayMiddleware HOT 2
- Segment not propgated when subsegment metadata is sufficiently long HOT 4
- sqlalchemy_core patch errors for unencoded special characters in db url HOT 1
- Error when using AsyncContext in python 3.11.5 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-xray-sdk-python.