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(metrics): log warning on empty metrics #1397

Conversation

dreamorosi
Copy link
Contributor

Description of your changes

When using the logMetrics decorator or middleware users can pass a throwOnEmptyMetrics parameter to set the Metrics utility to throw an error when metrics are being flushed but no metric is actually present. In those cases when throwOnEmptyMetrics is set to false and no metric is added however the utility "fails silently" giving the user no way of detecting potentially missing metrics.

This PR introduces a new warning log that reads:

No application metrics to publish. The cold-start metric may be published if enabled. If application metrics should never be empty, consider using 'throwOnEmptyMetrics',

This warning will be logged whenever the user tries to flush metrics but no metric was stored and throwOnEmptyMetrics is set to false or not set.

Once merged this PR closes #1291.

Related issues, RFCs

Issue number: #1291

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
  • I have made corresponding changes to the examples
  • 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
  • The PR title follows the conventional commit semantics

Breaking change checklist

Is it a breaking change?: NO

  • I have documented the migration process
  • I have added, implemented necessary 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.

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

@dreamorosi dreamorosi self-assigned this Apr 5, 2023
@dreamorosi dreamorosi linked an issue Apr 5, 2023 that may be closed by this pull request
2 tasks
@pull-request-size pull-request-size bot added the size/M PR between 30-99 LOC label Apr 5, 2023
@github-actions github-actions bot added the feature PRs that introduce new features or minor changes label Apr 5, 2023
@dreamorosi dreamorosi merged commit 31ae936 into main Apr 6, 2023
@dreamorosi dreamorosi deleted the 1291-feature-request-log-a-warning-when-no-metric-is-emitted branch April 6, 2023 16:36
@revmischa
Copy link

It would be nice if there was a way to disable this warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature PRs that introduce new features or minor changes size/M PR between 30-99 LOC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: log a warning when no metric is emitted
2 participants