Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Enhancement suggestion: correlation id middleware combined with logger and sampler #9

Closed
marcioemiranda opened this issue Mar 17, 2020 · 10 comments
Labels
feature-request feature request help wanted Could use a second pair of eyes/hands

Comments

@marcioemiranda
Copy link

Hello Heitor,

Have you considered adding a correlation_id middleware like the one in DAZN power tools?

It could work together with the logger tool by adding correlation_id to the logs automatically, and also be used by the sampling feature (the whole transaction is sampled instead of each function invoke).

Regards,
Marcio.

@heitorlessa
Copy link
Contributor

Hey Marcio,

I did considered though I haven't been able to create a design document to flesh this out yet.

I'm currently working on another project until mid April, but if that's something you'd like to kick off I'd be super happy to contribute.

Thanks a lot for reaching out

@marcioemiranda
Copy link
Author

Hello Heitor,

I would like to contribute if you give me some pointers.

Regards,
Marcio

@heitorlessa heitorlessa added this to Backlog in Python - GA Mar 25, 2020
@heitorlessa
Copy link
Contributor

Absolutely @marcioemiranda - Here's a breakdown of how the logger works

I see two ways of implementing it:

  • A) Extending logger_inject_lambda_context to detect whether there's a correlation ID already (event object)
  • B) Create a separate module to both detect and hold that correlation ID in memory, so other future modules could make use of it (middleware kinda approach)

I personally prefer B as it's more extensible since we could also use the correlation ID data in Tracer to create an annotation, and in future modules like detecting retries, etc.

Regardless of the option, it'll have to add a new key correlation_id in this line: https://github.com/awslabs/aws-lambda-powertools/blob/develop/python/aws_lambda_powertools/logging/logger.py#L149

Happy to explain further but hopefully that makes sense

@heitorlessa
Copy link
Contributor

I've decided to look at this after GA - Logger can append additional keys, and custom middlewares can be created now.

I want to spend more time in the design phase to make this scalable to multiple event sources too. I'll ping here when I start working on a design to get your ideas too.

@heitorlessa heitorlessa removed this from Backlog in Python - GA May 12, 2020
@heitorlessa heitorlessa self-assigned this May 12, 2020
@heitorlessa heitorlessa added feature-request feature request and removed enhancement labels Jun 3, 2020
@keithrozario
Copy link
Contributor

This would be an awesome feature, and would be super useful for many folks.

@patrickwerz
Copy link

yes, definitely interested.

@heitorlessa heitorlessa removed their assignment Nov 27, 2020
@heitorlessa heitorlessa added the help wanted Could use a second pair of eyes/hands label Nov 27, 2020
@heitorlessa
Copy link
Contributor

Couldn't spend much quality time to think about the developer experience yet -- If anyone has the bandwidth, I'd appreciate a RFC for further discussion here.

@michaelbrewer
Copy link
Contributor

Yes, this would be super useful. I will see if i have the headspace for this :)

@michaelbrewer
Copy link
Contributor

I created a demo PR here:

@michaelbrewer
Copy link
Contributor

FYI @marcioemiranda @patrickwerz @keithrozario the PR was merged for the first part of this.

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
feature-request feature request help wanted Could use a second pair of eyes/hands
Projects
None yet
Development

No branches or pull requests

5 participants