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 Histogram crash #1685

Merged
merged 10 commits into from
Oct 17, 2022
Merged

fix Histogram crash #1685

merged 10 commits into from
Oct 17, 2022

Conversation

esigo
Copy link
Member

@esigo esigo commented Oct 14, 2022

Fixes #1665 (issue)

Changes

One of the CreateAggregation overloads was not passing the aggregation config to the histogram ctors. Also replaced nostd with std::shared_ptr.

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

@codecov
Copy link

codecov bot commented Oct 14, 2022

Codecov Report

Merging #1685 (f6dee09) into main (8061423) will decrease coverage by 0.05%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1685      +/-   ##
==========================================
- Coverage   86.36%   86.31%   -0.04%     
==========================================
  Files         169      169              
  Lines        5152     5156       +4     
==========================================
+ Hits         4449     4450       +1     
- Misses        703      706       +3     
Impacted Files Coverage Δ
...metry/sdk/metrics/aggregation/aggregation_config.h 100.00% <ø> (ø)
...ry/sdk/metrics/aggregation/histogram_aggregation.h 90.00% <ø> (ø)
...telemetry/sdk/metrics/state/async_metric_storage.h 86.12% <ø> (ø)
...etry/sdk/metrics/aggregation/default_aggregation.h 75.48% <100.00%> (-0.89%) ⬇️
...ntelemetry/sdk/metrics/state/sync_metric_storage.h 64.11% <100.00%> (+0.95%) ⬆️
sdk/include/opentelemetry/sdk/metrics/view/view.h 100.00% <100.00%> (ø)
...k/src/metrics/aggregation/histogram_aggregation.cc 88.24% <100.00%> (+0.61%) ⬆️
sdk/src/metrics/state/temporal_metric_storage.cc 98.22% <100.00%> (ø)
ext/src/http/client/curl/http_client_curl.cc 80.31% <0.00%> (-1.13%) ⬇️

{
if (aggregation_config && aggregation_config->boundaries_.size())
auto ac = std::dynamic_pointer_cast<HistogramAggregationConfig>(aggregation_config);
Copy link
Member

Choose a reason for hiding this comment

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

Can we use static_pointer_case here, or use dynamic cast only if RTTI macro is enabled. Something similar to what we do here -

# ifdef OPENTELEMETRY_RTTI_ENABLED

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure yet if I want to keep the shard_ptr. The main issue was in the lambda that was passing the pointer.

Copy link
Member Author

Choose a reason for hiding this comment

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

using static cast now.

new opentelemetry::sdk::metrics::HistogramAggregationConfig};
static_cast<opentelemetry::sdk::metrics::HistogramAggregationConfig *>(aggregation_config.get())
->boundaries_ = std::list<double>{0.0, 50.0, 100.0, 250.0, 500.0, 750.0,
1000.0, 2500.0, 5000.0, 10000.0, 20000.0};
Copy link
Member

Choose a reason for hiding this comment

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

Oh I should have realized these changes to be done while converting boundaries to double. Sorry about that :(

Copy link
Member Author

Choose a reason for hiding this comment

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

I just changed them to introduce the crash into our CI :)

@esigo esigo marked this pull request as ready for review October 15, 2022 14:58
@esigo esigo requested a review from a team October 15, 2022 14:58
@esigo esigo added bug Something isn't working metrics labels Oct 15, 2022
Copy link
Member

@lalitb lalitb 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.

sdk/src/metrics/aggregation/histogram_aggregation.cc Outdated Show resolved Hide resolved
sdk/src/metrics/aggregation/histogram_aggregation.cc Outdated Show resolved Hide resolved
@esigo esigo enabled auto-merge (squash) October 17, 2022 17:13
@esigo esigo merged commit 7f37bc3 into open-telemetry:main Oct 17, 2022
@esigo esigo deleted the crash-1665 branch October 17, 2022 18:23
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
bug Something isn't working metrics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Histogram crashes with more than the default number of boundaries
2 participants