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): await export when async attributes are pending #5126

Conversation

pichlermarc
Copy link
Member

@pichlermarc pichlermarc commented Nov 7, 2024

Which problem is this PR solving?

When async attributes are pending, we don't await the export, which means that a shutdown() following a forceFlush() will shut down the exporter before forceFlush() is completed and the export will be cancelled.

Fixes #5116

Type of change

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

How Has This Been Tested?

  • Existing tests
  • Added tests

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.20%. Comparing base (4b5c21c) to head (09fb9d8).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5126      +/-   ##
==========================================
+ Coverage   93.17%   93.20%   +0.03%     
==========================================
  Files         315      315              
  Lines        8086     8084       -2     
  Branches     1617     1616       -1     
==========================================
+ Hits         7534     7535       +1     
+ Misses        552      549       -3     
Files with missing lines Coverage Δ
...etrics/src/export/PeriodicExportingMetricReader.ts 98.18% <100.00%> (+5.19%) ⬆️

@pichlermarc pichlermarc force-pushed the fix/await-when-async-is-pending branch from e81e944 to 617305a Compare November 8, 2024 11:14
@pichlermarc pichlermarc force-pushed the fix/await-when-async-is-pending branch from e3476c0 to 8b372cb Compare November 8, 2024 11:42
@pichlermarc pichlermarc marked this pull request as ready for review November 8, 2024 11:48
@pichlermarc pichlermarc requested a review from a team as a code owner November 8, 2024 11:48
@pichlermarc pichlermarc added bug Something isn't working priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect pkg:sdk-metrics labels Nov 8, 2024
await resourceMetrics.resource.waitForAsyncAttributes?.();
} catch (e) {
api.diag.debug('Error while resolving async portion of resource: ', e);
globalErrorHandler(e);
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL about globalErrorHandler.

Copy link
Member

Choose a reason for hiding this comment

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

globalErrorHandler is a poorly understood and (in my opinion) poorly thought out spec. I'd probably get rid of it if i had the chance.

dyladan
dyladan previously requested changes Nov 8, 2024
Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

I'm only requesting changes as a test. I'll dismiss this immediately

@dyladan dyladan dismissed their stale review November 8, 2024 21:42

It was only a test

doc/troubleshooting.md Outdated Show resolved Hide resolved
@pichlermarc pichlermarc added this pull request to the merge queue Nov 11, 2024
Merged via the queue into open-telemetry:main with commit 8483b68 Nov 11, 2024
21 checks passed
@pichlermarc pichlermarc deleted the fix/await-when-async-is-pending branch November 11, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:sdk-metrics priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OTLPMetricExporter forceFlush() doesn't flush metrics
3 participants