Skip to content

Commit

Permalink
Simplify SDK Configuration: Use View with default aggregation if no m…
Browse files Browse the repository at this point in the history
…atching View is configured (#1358)
  • Loading branch information
lalitb authored Apr 30, 2022
1 parent 3a4a3a3 commit f314522
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/metrics/view/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class View
public:
View(const std::string &name,
const std::string &description = "",
AggregationType aggregation_type = AggregationType::kDrop,
AggregationType aggregation_type = AggregationType::kDefault,
std::unique_ptr<opentelemetry::sdk::metrics::AttributesProcessor> attributes_processor =
std::unique_ptr<opentelemetry::sdk::metrics::AttributesProcessor>(
new opentelemetry::sdk::metrics::DefaultAttributesProcessor()))
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/metrics/view/view_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ViewRegistry
// return default view if none found;
if (!found)
{
static View view("");
static View view("otel-default-view");
if (!callback(view))
{
return false;
Expand Down
16 changes: 9 additions & 7 deletions sdk/test/metrics/view_registry_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ TEST(ViewRegistry, FindViewsEmptyRegistry)
InstrumentationLibrary::Create("default", "1.0.0", "https://opentelemetry.io/schemas/1.7.0");
int count = 0;
ViewRegistry registry;
auto status = registry.FindViews(default_instrument_descriptor,
*default_instrumentation_lib.get(), [&count](const View &view) {
count++;
EXPECT_EQ(view.GetName(), "");
EXPECT_EQ(view.GetDescription(), "");
return true;
});
auto status =
registry.FindViews(default_instrument_descriptor, *default_instrumentation_lib.get(),
[&count](const View &view) {
count++;
EXPECT_EQ(view.GetName(), "otel-default-view");
EXPECT_EQ(view.GetDescription(), "");
EXPECT_EQ(view.GetAggregationType(), AggregationType::kDefault);
return true;
});
EXPECT_EQ(count, 1);
EXPECT_EQ(status, true);
}
Expand Down

1 comment on commit f314522

@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: f314522 Previous: 3a4a3a3 Ratio
BM_BaselineBuffer/2 18597991.466522217 ns/iter 7643220.4246521 ns/iter 2.43
BM_BaselineBuffer/4 12749977.111816406 ns/iter 5616762.952984504 ns/iter 2.27

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

Please sign in to comment.