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:1676 Segfault when short export period is used for metrics #1682

Merged
merged 10 commits into from
Oct 15, 2022

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented Oct 14, 2022

Fixes #1676

Changes

MeterContext::ForceFlush() is incorrectly setting shutdown latch. Later when MeterContext::Shutdown() is invoked, the latch is already set, and shutdown is not done.

The PR would have merge conflict with #1673.

@ahadnagy - If you would like to test the changes, I got the segfault with with your code during MeterProvider shutdown, and this fixes that. I am hoping it was the same crash you observed :)

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@lalitb lalitb requested a review from a team October 14, 2022 01:03
@codecov
Copy link

codecov bot commented Oct 14, 2022

Codecov Report

Merging #1682 (2768cc1) into main (47a897d) will increase coverage by 0.72%.
The diff coverage is 79.17%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1682      +/-   ##
==========================================
+ Coverage   85.59%   86.30%   +0.72%     
==========================================
  Files         169      169              
  Lines        5147     5152       +5     
==========================================
+ Hits         4405     4446      +41     
+ Misses        742      706      -36     
Impacted Files Coverage Δ
sdk/src/metrics/meter_context.cc 89.66% <75.00%> (+44.05%) ⬆️
sdk/src/metrics/meter_provider.cc 90.91% <100.00%> (+15.05%) ⬆️
ext/src/http/client/curl/http_client_curl.cc 80.31% <0.00%> (-1.13%) ⬇️
sdk/src/trace/batch_span_processor.cc 91.41% <0.00%> (+0.79%) ⬆️
sdk/src/metrics/metric_reader.cc 75.00% <0.00%> (+15.63%) ⬆️
sdk/src/metrics/state/metric_collector.cc 92.00% <0.00%> (+16.00%) ⬆️

Copy link
Member

@esigo esigo left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks for the fix :)
let's wait for #1650 to merge first.

Copy link
Contributor

@ahadnagy ahadnagy left a comment

Choose a reason for hiding this comment

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

@lalitb I had a chance to try this today, and looks like it's solved the issue! Thanks a lot for fixing it so quickly!

@lalitb
Copy link
Member Author

lalitb commented Oct 14, 2022

@lalitb I had a chance to try this today, and looks like it's solved the issue! Thanks a lot for fixing it so quickly!

Thanks for confirming. Also calling MeterProvider->Shutdown() is now optional, as it would be called as part of MeterProvider destruction. Have added that change in this PR.

@lalitb lalitb merged commit 8061423 into open-telemetry:main Oct 15, 2022
ays7 added a commit to ays7/opentelemetry-cpp that referenced this pull request Oct 29, 2022
…ad-local-stack

* commit '9acde87b08b225ce511fa8a20c6cba14f2921518': (36 commits)
  Prepare v1.7.0 release with Metrics API/SDK GA. (open-telemetry#1721)
  Fix: 1712 -  Validate Instrument meta data (name, unit, description) (open-telemetry#1713)
  Document libthrift 0.12.0 doesn't work with Jaeger exporter (open-telemetry#1714)
  Fix:1674, Add Monotonic Property to Sum Aggregation, and unit tests for Up Down Counter (open-telemetry#1675)
  [Metrics SDK] Move Metrics Exemplar processing behind feature flag (open-telemetry#1710)
  [Metrics API/SDK] Change Meter API/SDK to return nostd::unique_ptr for Sync Instruments (open-telemetry#1707)
  [Metrics] Switch to explicit 64 bit integers (open-telemetry#1686)
  Add metrics e2e test to asan & tsan CI (open-telemetry#1670)
  Add otlp-grpc example bazel (open-telemetry#1708)
  [Metrics SDK] Add support for Pull Metric Reader (open-telemetry#1701)
  Fix debug log of OTLP HTTP exporter and ES log exporter (open-telemetry#1703)
  [SEMANTIC CONVENTIONS] Upgrade to version 1.14.0 (open-telemetry#1697)
  Fix a potential precision loss on integer in ReservoirCellIndexFor (open-telemetry#1696)
  fix Histogram crash (open-telemetry#1685)
  Fix:1676 Segfault when short export period is used for metrics  (open-telemetry#1682)
  Add timeout support to MeterContext::ForceFlush (open-telemetry#1673)
  Add CMake OTELCPP_MAINTAINER_MODE (open-telemetry#1650)
  [DOCS] - Minor updates to OStream Metrics exporter documentation (open-telemetry#1679)
  Fix:open-telemetry#1575 API Documentation for Metrics SDK and API (open-telemetry#1678)
  Fixes open-telemetry#249 (open-telemetry#1677)
  ...
yxue pushed a commit to yxue/opentelemetry-cpp that referenced this pull request Dec 5, 2022
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.

[Metrics SDK] Segfault when short export period is used for metrics
3 participants