Skip to content
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

feat(logger): add ALB correlation ID support #816

Merged

Conversation

heitorlessa
Copy link
Contributor

@heitorlessa heitorlessa commented Nov 12, 2021

Issue #, if available: #767

Description of changes:

from aws_lambda_powertools import Logger
from aws_lambda_powertools.logging import correlation_paths

logger = Logger(service="payment")


@logger.inject_lambda_context(correlation_id_path=correlation_paths.ALB)
def handler(event, context):
    logger.debug(f"Correlation ID => {logger.get_correlation_id()}")
    logger.info("Collecting payment")

Checklist

Breaking change checklist

RFC issue #:

  • Migration process documented
  • Implement warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 12, 2021
@heitorlessa heitorlessa added the feature New feature or functionality label Nov 12, 2021
@codecov-commenter
Copy link

Codecov Report

Merging #816 (b92074c) into develop (d62b0a0) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #816   +/-   ##
========================================
  Coverage    99.90%   99.90%           
========================================
  Files          118      118           
  Lines         5107     5108    +1     
  Branches       279      279           
========================================
+ Hits          5102     5103    +1     
  Misses           2        2           
  Partials         3        3           
Impacted Files Coverage Δ
aws_lambda_powertools/logging/correlation_paths.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d62b0a0...b92074c. Read the comment docs.

@heitorlessa heitorlessa merged commit 6c2f270 into aws-powertools:develop Nov 12, 2021
@heitorlessa heitorlessa deleted the feat/correlation-id-alb branch November 12, 2021 17:56
@michaelbrewer
Copy link
Contributor

@heitorlessa this won't work ie" "headers.x-amzn-trace-id"

@heitorlessa
Copy link
Contributor Author

Damn forgot the quotes there. I'll fix it tomorrow

@heitorlessa
Copy link
Contributor Author

heitorlessa commented Nov 12, 2021

And the naming to be more explicit.

Note to self: do not build quick PRs on Friday night before dinner without testing

heitorlessa added a commit to heitorlessa/aws-lambda-powertools-python that referenced this pull request Nov 13, 2021
@heitorlessa heitorlessa removed the feature New feature or functionality label Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants