Skip to content

Commit

Permalink
Fix metrics asan and tsan CI (#1562)
Browse files Browse the repository at this point in the history
  • Loading branch information
esigo authored Aug 11, 2022
1 parent 6c240fd commit 1b9aa31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
5 changes: 4 additions & 1 deletion sdk/test/metrics/async_metric_storage_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# include "opentelemetry/sdk/metrics/state/observable_registry.h"

# include <gtest/gtest.h>
# include <memory>
# include <vector>

using namespace opentelemetry::sdk::metrics;
Expand Down Expand Up @@ -99,8 +100,10 @@ TEST_P(WritableMetricStorageTestFixture, TestAggregation)
collectors.push_back(collector);
size_t count_attributes = 0;

std::unique_ptr<AttributesProcessor> default_attributes_processor{
new DefaultAttributesProcessor{}};
opentelemetry::sdk::metrics::AsyncMetricStorage storage(
instr_desc, AggregationType::kSum, new DefaultAttributesProcessor(),
instr_desc, AggregationType::kSum, default_attributes_processor.get(),
std::shared_ptr<opentelemetry::sdk::metrics::AggregationConfig>{});
long get_count = 20l;
long put_count = 10l;
Expand Down
17 changes: 9 additions & 8 deletions sdk/test/metrics/attributes_hashmap_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ void BM_AttributseHashMap(benchmark::State &state)
std::vector<MetricAttributes> attributes = {{{"k1", "v1"}, {"k2", "v2"}},
{{"k1", "v1"}, {"k2", "v2"}, {"k3", "v3"}}};

std::function<std::unique_ptr<Aggregation>()> create_default_aggregation =
[]() -> std::unique_ptr<Aggregation> {
return std::unique_ptr<Aggregation>(new DropAggregation);
auto work = [&attributes, &hash_map](const size_t i) {
std::function<std::unique_ptr<Aggregation>()> create_default_aggregation =
[]() -> std::unique_ptr<Aggregation> {
return std::unique_ptr<Aggregation>(new DropAggregation);
};

hash_map.GetOrSetDefault(attributes[i % 2], create_default_aggregation)->Aggregate(1l);
benchmark::DoNotOptimize(hash_map.Has(attributes[i % 2]));
};

while (state.KeepRunning())
{
for (size_t i = 0; i < MAX_THREADS; i++)
{
workers.push_back(std::thread([&]() {
hash_map.GetOrSetDefault(attributes[i % 2], create_default_aggregation)->Aggregate(1l);
benchmark::DoNotOptimize(hash_map.Has(attributes[i % 2]));
}));
workers.push_back(std::thread(work, i));
}
}

Expand Down

1 comment on commit 1b9aa31

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp sdk Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 1b9aa31 Previous: 6c240fd Ratio
BM_BaselineBuffer/2 15918767.45223999 ns/iter 5689607.381820679 ns/iter 2.80

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.