-
Notifications
You must be signed in to change notification settings - Fork 13
feat: Introduce trace ids to Tangle #66
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
base: master
Are you sure you want to change the base?
Conversation
**Changes:**
* Adds trace context helpers
* Add trace middleware to apply trace context to API requests
* This helps logging formatters pull trace ids out of context to set them in logs
* Sets the trace id on the response for client consumption
45fca00 to
c08c8f2
Compare
| # Process the request | ||
| response = await call_next(request) | ||
| # Add trace_id to response headers for client reference | ||
| response.headers["x-tangle-trace-id"] = trace_id |
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.
Note to self. This line should probably go above await call_next(request) in case an exception is raised
| # Restore trace_id from execution | ||
| trace_id = None | ||
| if queued_execution.extra_data: | ||
| trace_id = queued_execution.extra_data.get("trace_id") |
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 do not think the request trace IDs are relevant when processing execution nodes. Execution nodes already have their own IDs and they might work better as trace IDs.
|
Thank you for this PR. I'm reviewing the changes and I think we might want to design this slightly differently. On the other hand, API requests might benefit from trace IDs so that all logging messages that are generated when processing a single API call can be filtered and grouped together. |
This sounds good to me. I will make some adjustments. Thanks! |
Issue
#67
Changes:
extrasparameterextrasparameter, or creating a new one if None)Test pipeline notes:
ytest,starlette,httpx(e.g.pip3 install ...)