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

fix(sdk-metrics) Don't Export from PeriodicExportingMetricReader with No Metrics #5288

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

JacksonWeber
Copy link
Contributor

@JacksonWeber JacksonWeber commented Dec 19, 2024

Which problem is this PR solving?

We should not attempt to export without metrics to export from the PeriodiicExportingMetricReader.

Fixes #5234

Short description of the changes

Adds a check to ensure that scope metrics are populated and updates related tests.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • should not export without populated scope metrics

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added

@JacksonWeber JacksonWeber requested a review from a team as a code owner December 19, 2024 21:13
Copy link

codecov bot commented Dec 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.56%. Comparing base (6864c2f) to head (b620d49).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5288   +/-   ##
=======================================
  Coverage   94.56%   94.56%           
=======================================
  Files         322      322           
  Lines        8132     8134    +2     
  Branches     1715     1716    +1     
=======================================
+ Hits         7690     7692    +2     
  Misses        442      442           
Files with missing lines Coverage Δ
...etrics/src/export/PeriodicExportingMetricReader.ts 98.27% <100.00%> (+0.06%) ⬆️

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

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

you have a lint error, otherwise LGTM

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@hectorhdzg hectorhdzg left a comment

Choose a reason for hiding this comment

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

LGTM

throw new Error(
`PeriodicExportingMetricReader: metrics export failed (error ${result.error})`
);
if (resourceMetrics.scopeMetrics.length > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

nit (feel free to ignore): I like having guard clauses that just return - reduces nesting and it also makes it easier to see if we hit the branch in in the coverage report.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented, thanks for the suggestion!

@pichlermarc pichlermarc added this pull request to the merge queue Jan 10, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PeriodicExportingMetricReader tries to export when there's no data
4 participants