-
Notifications
You must be signed in to change notification settings - Fork 146
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: correlation ID's propagation #129
Comments
In the case of tracing, should this ID in the name of the segment or as an annotation of the segment? |
Thanks for asking @dreamorosi, I envision it/them as an annotation(s) of the segment |
My thoughts on the problem statement:
I don't think I'm familiar with the best practices yet. Will collect more info on the way. If you know any good links, please link them in this issue :)
This sounds like we can start with an MVP where we generate our own correlation ID, and then expand to allow a custom ID.
This sounds like we would have a package like |
Updated the comment above, as it accidentally showed my comment as part of the quote. |
For metrics I think outputting the correlation ID into metadata makes sense. For logs I'd follow the correlation example in |
Thought some more about a good approach, and here's what understanding I have of a well rounded approach. This might repeat some of the initial post from @saragerion. Opt InCorrelation IDs should require opt in. As a customer I don't want the utility to just forward headers to other places. Instead I want to explicitly name correlation IDs, or allow a default set of correlation ID names. Examples:
As a result we would need a configurable function/constructor, which accepts ID PopulationThe function code should be able to add correlation IDs at any time during the functions request handling. Correlation IDs change from request to request, but I think are not found in function initialization. Examples:
To achieve this I think we need some memory storage that lives outside of the function calls. From Java I know Mapped Diagnostics Context, and I'm not sure if something similar exist in Node. The NPM package
This seems to be exactly what I'm looking for. To let anyone populate correlation IDs, the utility should expose methods to manage correlation IDs. That way the middle-ware can add incoming correlation headers, logging can print correlation IDs, and customers can decide to clear correlation IDs if they wish so. I will look into the approaches of the Logging and Metrics utilities, and try to follow their existing management approaches. Maybe there will also be some synergies. Why outside the function calls? Correlation IDs are not relevant to a function invocation, but are just passed along on the side as helpful diagnostics information. They usually don't influence functions. Injecting the Correlation IDAt any point in a request should we be able to use the correlation IDs, e.g. for printing logs, or forwarding them to other services. Therefore the correlation ID utility should provide a way to retrieve all available correlation IDs, based on the initial config during middle-ware or annotation based setup. There could be a method with the following signature, which allows retrieving all correlation IDs, or a subset:
We can then use this function in logging, metrics, monkey-patching to add more information. |
@saragerion can we implement something like this for typescript too? This is similar to how python allows for logging the event with the correlationId based a json path import { Logger, CorrelationPaths } from "@aws-lambda-powertools/logger";
import { LambdaInterface } from '@aws-lambda-powertools/commons';
const logger = new Logger();
class Lambda implements LambdaInterface {
@logger.injectLambdaContext(correlationIdPath=CorrelationPaths.API_GATEWAY_REST, logEvent=true)
public async handler(_event: any, _context: any): Promise<void> {
logger.info("This is an INFO log with some context");
}
}
export const func = new Lambda();
export const handler = func.handler; |
This comment was marked as outdated.
This comment was marked as outdated.
Hi everyone, if you arrive on this issue because you are interested in this feature or because you are looking to migrate from We are still considering this feature but we need more examples and to gather requirements to build a RFC. If you are interested, please leave a comment describing briefly your use case and how the correlation ID feature would work in terms of experience. It's fine also to point towards existing resources. If uncomfortable with sharing your use case publicly, you can also reach out to us privately at [email protected]. |
@dreamorosi my use case is function are that work under AWS EventBridge scheduler would be great if I can set custom or user define in correlation id and pass by dynamodb. However, If you have any idea to tracking transaction across functions that were trigger by EventBridge I welcome. thanks :) |
Have you considered using the Baggage standard (or something close to it) for this implementation? https://www.w3.org/TR/baggage/ |
Just wanted to give an update on this. This issue is currently our oldest issue that is still have open. While we acknowledge that over time it has garnered some demand, because of its scope being fairly broad it's a bit challenging for us to get a sense of which features within the many proposed above we should focus on. While this is not an area that we are actively prioritizing for the remainder of this year, we would like to better understand which parts of the correlation ID piece from DAZN people are particularly missing in Powertools for AWS. This will help us to create our backlog for next year. In the meantime, one feature that we can consider already today is allowing customers to set correlation IDs in Logger. This is a feature that Powertools for AWS Lambda (Python) already supports, so from a feature parity standpoint it still makes sense for us to add it sooner rather than later - you can track the progress around that effort in #2863. I'll revisit this in a few months and see if anything has changed in terms of engagement with the issue. |
Description of the feature request
Problem statement
The use of correlation ID's can be extremely helpful for debugging purposes and help developers understanding the lifecycle of user transactions as they are being handled by different microservices within a platform.
It would be good to help developers understand how they can use correlation ID's effectively and following the best practices, potentially allowing them to bring their own custom correlation ID's, and most importantly propagate correlation ID's through the different utilities to external dependencies of a service. This can be achieved through the implementation of a new dedicated utilities, new features within all utilities, adding examples and/or documentation.
For the scope of this Issue, we can identify 2 types of correlation ID's:
Summary of the feature
All utilities would be able to fetch out of the box correlation ID's coming from each different AWS service (Lambda Trigger), and propagate them to logs, metrics, traces, ....
Note that this feature and functionality should not necessarily be enabled by default, but it should be possible to enable it and turn it on if developers need it.
It should be also possible to define your own custom correlation ID's and be able to propagate them and use them in different utilities accordingly.
Implement this logic in all utilities. Research is needed to understand the best implementation strategy, how to not do code repetition.
Code examples
TBC. Happy to receive suggestions on this one.
Benefits for you and the wider AWS community
As discussed in a past meeting with @gsingh1 @loujaybee and @simontabor, the functionality of fetching and propagating correlation ID's, including custom user-defined ones, can be useful and especially relevant for developers who operate at scale and within big organisations, where you have a high number of teams responsible for microservices communicating to each other.
Describe alternatives you've considered
None that comes into mind apart from writing the code by yourself.
Additional context
See here a brief definition of a correlation ID.
Related issues, RFCs
Not at the moment.
The text was updated successfully, but these errors were encountered: