Skip to content

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

Closed

Description

@marcioemiranda

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.

Activity

  1. heitorlessa commented on Mar 19, 2020

    @heitorlessa
    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

  2. marcioemiranda commented on Mar 24, 2020

    @marcioemiranda
    Author

    Hello Heitor,

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

    Regards,
    Marcio

  3. heitorlessa commented on Mar 25, 2020

    @heitorlessa
    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

  4. heitorlessa commented on May 12, 2020

    @heitorlessa
    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.

  5. self-assigned this
    on May 12, 2020
  6. keithrozario commented on Jul 30, 2020

    @keithrozario

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

  7. patrickwerz commented on Oct 9, 2020

    @patrickwerz

    yes, definitely interested.

  8. removed their assignment
    on Nov 27, 2020
  9. heitorlessa commented on Jan 15, 2021

    @heitorlessa
    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.

  10. michaelbrewer commented on Mar 9, 2021

    @michaelbrewer
    Contributor

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

  11. michaelbrewer commented on Mar 9, 2021

    @michaelbrewer
    Contributor
  12. michaelbrewer commented on Mar 10, 2021

    @michaelbrewer
    Contributor

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

  13. locked and limited conversation to collaborators on Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestfeature requesthelp wantedCould use a second pair of eyes/hands

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions