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 get_correlation_id method #516

Merged
merged 7 commits into from
Jul 19, 2021

Conversation

michaelbrewer
Copy link
Contributor

@michaelbrewer michaelbrewer commented Jul 9, 2021

Issue #, if available:

Description of changes:

  • Call remove_keys["correlation_id"] when the correlation_id is set to None.
  • Add get_correlation_id call
from aws_lambda_powertools import Logger

logger = Logger()
logger.set_correlation_id("Foo")
assert "Foo" == logger.get_correlation_id()
logger.set_correlation_id(None)
assert logger.get_correlation_id() is None

Checklist

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

Call remove_keys when the correlation_id is set to None
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 9, 2021
@codecov-commenter
Copy link

codecov-commenter commented Jul 9, 2021

Codecov Report

Merging #516 (3630d1d) into develop (5b87bb1) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #516   +/-   ##
========================================
  Coverage    99.23%   99.23%           
========================================
  Files          113      113           
  Lines         4468     4472    +4     
  Branches       243      244    +1     
========================================
+ Hits          4434     4438    +4     
  Misses          22       22           
  Partials        12       12           
Impacted Files Coverage Δ
aws_lambda_powertools/logging/logger.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 5b87bb1...3630d1d. Read the comment docs.

Copy link

@Nr18 Nr18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ;-)

@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 10, 2021
@michaelbrewer michaelbrewer changed the title feat(logger): add option to remove correlation_id feat(logger): add option to remove and get correlation_id Jul 10, 2021
@michaelbrewer
Copy link
Contributor Author

@heitorlessa should we go ahead with this feature?

@heitorlessa
Copy link
Contributor

I've just added a comment in the RFC.

TL;DR: Definitely yes for Getter, perhaps even a generic one to grab any key. Not yet for the remove correlation ID method.

Copy link
Contributor

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aws_lambda_powertools/logging/logger.py Outdated Show resolved Hide resolved
@michaelbrewer
Copy link
Contributor Author

@heitorlessa made the changes. the diff is much more minimal, but still meet the needs of the original RFC

@heitorlessa heitorlessa added this to the 1.18.0 milestone Jul 19, 2021
@heitorlessa heitorlessa added the feature New feature or functionality label Jul 19, 2021
@heitorlessa
Copy link
Contributor

Thanks a lot again @michaelbrewer !

@heitorlessa heitorlessa changed the title feat(logger): add option to remove and get correlation_id feat(logger): add get_correlation_id method Jul 19, 2021
@heitorlessa heitorlessa merged commit f6a5b2a into aws-powertools:develop Jul 19, 2021
heitorlessa added a commit to whardier/aws-lambda-powertools-python that referenced this pull request Jul 19, 2021
…ent-subclass

* develop:
  refactor(feature-toggles): Code coverage and housekeeping (aws-powertools#530)
  feat(logger): add get_correlation_id method (aws-powertools#516)
@michaelbrewer michaelbrewer deleted the feat-correlation-id-remove branch August 3, 2021 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or functionality size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants