Skip to content

feat(metrics): add default_dimensions to single_metric #1880

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

Merged
merged 3 commits into from
Feb 1, 2023

Conversation

prudnikov
Copy link
Contributor

Issue number: #1859

Summary

Changes

default_dimensions keyword argument was added to single_metric context manager. It accepts custom dimensions dictionary as well as metrics.default_dimensions.

Initial I proposed inherit_default_dimensions: bool = False, bug when started implementing decided to go with the similar to @metrics.log_metrics approach with specifying default_dimensions keyword argument.

User experience

It was not possible to reuse default dimensions. One of the common default dimensions is Environment, once it is defined on Metrics instance it can be reused in SingleMetric as well. It is also possible to provide any other dimensions as value to default_dimensions.

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change?

RFC issue number:

Checklist:

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

Acknowledgment

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

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@prudnikov prudnikov requested a review from a team as a code owner February 1, 2023 01:55
@prudnikov prudnikov requested review from rubenfonseca and removed request for a team February 1, 2023 01:55
@boring-cyborg boring-cyborg bot added documentation Improvements or additions to documentation metrics tests labels Feb 1, 2023
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 1, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Feb 1, 2023

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our AWS Lambda Powertools Discord: Invite link

@rubenfonseca rubenfonseca linked an issue Feb 1, 2023 that may be closed by this pull request
2 tasks
@github-actions github-actions bot added the feature New feature or functionality label Feb 1, 2023
@codecov-commenter
Copy link

codecov-commenter commented Feb 1, 2023

Codecov Report

Base: 97.51% // Head: 97.52% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (34a120d) compared to base (3314893).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1880   +/-   ##
========================================
  Coverage    97.51%   97.52%           
========================================
  Files          143      143           
  Lines         6570     6573    +3     
  Branches       466      468    +2     
========================================
+ Hits          6407     6410    +3     
  Misses         128      128           
  Partials        35       35           
Impacted Files Coverage Δ
aws_lambda_powertools/metrics/base.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@rubenfonseca rubenfonseca left a comment

Choose a reason for hiding this comment

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

This is a stellar PR, thank you so much for the great work! I believe the new solution is much simpler and easy to understand. Again, contributions like this one always make our day! Thanks!

@rubenfonseca rubenfonseca changed the title feat(metrics): Add default_dimensions to single_metric feat(metrics): add default_dimensions to single_metric Feb 1, 2023
@rubenfonseca rubenfonseca merged commit 14e00cc into aws-powertools:develop Feb 1, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Feb 1, 2023

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

heitorlessa added a commit to BakasuraRCE/aws-lambda-powertools-python that referenced this pull request Feb 7, 2023
* develop: (24 commits)
  chore(deps): bump docker/setup-buildx-action from 2.4.0 to 2.4.1 (aws-powertools#1903)
  chore(deps-dev): bump aws-cdk-lib from 2.63.0 to 2.63.2 (aws-powertools#1904)
  update changelog with latest changes
  docs(idempotency): add IAM permissions section (aws-powertools#1902)
  chore(deps-dev): bump mkdocs-material from 9.0.10 to 9.0.11 (aws-powertools#1896)
  chore(deps-dev): bump mypy-boto3-appconfig from 1.26.0.post1 to 1.26.63 (aws-powertools#1895)
  chore(maintainers): fix release workflow rename
  update changelog with latest changes
  docs(homepage): set url for end-of-support in announce block (aws-powertools#1893)
  chore(deps-dev): bump mkdocs-material from 9.0.9 to 9.0.10 (aws-powertools#1888)
  chore(deps-dev): bump mypy-boto3-s3 from 1.26.58 to 1.26.62 (aws-powertools#1889)
  chore(deps-dev): bump black from 22.12.0 to 23.1.0 (aws-powertools#1886)
  chore(deps-dev): bump aws-cdk-lib from 2.62.2 to 2.63.0 (aws-powertools#1887)
  update changelog with latest changes
  feat(metrics): add default_dimensions to single_metric (aws-powertools#1880)
  chore: update v2 layer ARN on documentation
  bump version to 2.7.1
  update changelog with latest changes
  docs(homepage): add banner for end-of-support v1 (aws-powertools#1879)
  fix(license): correction to MIT + MIT-0 (no proprietary anymore) (aws-powertools#1883)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature New feature or functionality metrics 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.

single_metric() to inherit default dimensions
3 participants