Skip to content

feat(metric): bring feature parity between decorator and utility function #291

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 1 commit into from
Dec 13, 2021

Conversation

flochaz
Copy link
Contributor

@flochaz flochaz commented Dec 12, 2021

Description of your changes

Bringing capture cold start metric and raise on empty metrics features to standard utility functions set.

How to verify this change

Now you can call captureColdStartMetric() and raiseOnEmptyMetrics() and get same behavior as of @metrics.logMetrics({captureColdStartMetric: true, raiseOnEmptyMetrics: true }) :


const metrics = new Metrics({ namespace: 'test' });

const handler = async (event: any, context: Context) => {
  metrics.captureColdStartMetric();
  metrics.raiseOnEmptyMetrics();
  // Logic goes here
  metrics.purgeStoredMetrics();
};

PR status

Is this ready for review?: YES
Is it a breaking change?: NO

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • I have added tests that prove my change is effective and works
  • New and existing unit tests pass locally and in Github Actions
  • Any dependent changes have been merged and published in downstream module
  • The PR title follows the conventional commit semantics

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

@dreamorosi dreamorosi added enhancement metrics This item relates to the Metrics Utility labels Dec 12, 2021
@dreamorosi dreamorosi added this to the beta-release milestone Dec 12, 2021
@dreamorosi dreamorosi self-requested a review December 12, 2021 15:20
Copy link
Contributor

@saragerion saragerion left a comment

Choose a reason for hiding this comment

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

LGTM.
Shall we also add these in:

  • examples folder
  • mkdocs
    What do you think?

Either in this PR or in a next one

@flochaz
Copy link
Contributor Author

flochaz commented Dec 13, 2021

LGTM. Shall we also add these in:

  • examples folder
  • mkdocs
    What do you think?

Either in this PR or in a next one

I have a PR updating mkdocs one will push the PR when this is merged. On examples, I plan a PR on refacto to make them more isolated and reusable so can include that

@flochaz flochaz merged commit 8d40471 into main Dec 13, 2021
@flochaz flochaz deleted the metrics/featParity branch December 13, 2021 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
metrics This item relates to the Metrics Utility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants