Skip to content

Commit dc43c08

Browse files
string_view fix
1 parent f0ecb7e commit dc43c08

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

sdk/include/opentelemetry/sdk/metrics/view/attributes_processor.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class FilteringAttributesProcessor : public AttributesProcessor
8080
MetricAttributes result;
8181
attributes.ForEachKeyValue(
8282
[&](nostd::string_view key, opentelemetry::common::AttributeValue value) noexcept {
83-
if (allowed_attribute_keys_.find(key.data()) != allowed_attribute_keys_.end())
83+
if (allowed_attribute_keys_.find(std::string(key)) != allowed_attribute_keys_.end())
8484
{
8585
result.SetAttribute(key, value);
8686
return true;
@@ -94,7 +94,7 @@ class FilteringAttributesProcessor : public AttributesProcessor
9494

9595
bool isPresent(nostd::string_view key) const noexcept override
9696
{
97-
return (allowed_attribute_keys_.find(key.data()) != allowed_attribute_keys_.end());
97+
return (allowed_attribute_keys_.find(std::string(key)) != allowed_attribute_keys_.end());
9898
}
9999

100100
private:
@@ -106,7 +106,7 @@ class FilteringAttributesProcessor : public AttributesProcessor
106106
* present in the exclude list
107107
*/
108108

109-
class FilteringExcludeAttributesProcessor : AttributesProcessor
109+
class FilteringExcludeAttributesProcessor : public AttributesProcessor
110110
{
111111
public:
112112
FilteringExcludeAttributesProcessor(std::unordered_map<std::string, bool> &&exclude_list = {})
@@ -124,7 +124,7 @@ class FilteringExcludeAttributesProcessor : AttributesProcessor
124124
MetricAttributes result;
125125
attributes.ForEachKeyValue(
126126
[&](nostd::string_view key, opentelemetry::common::AttributeValue value) noexcept {
127-
if (exclude_list_.find(key.data()) == exclude_list_.end())
127+
if (exclude_list_.find(std::string(key)) == exclude_list_.end())
128128
{
129129
result.SetAttribute(key, value);
130130
return true;
@@ -138,7 +138,7 @@ class FilteringExcludeAttributesProcessor : AttributesProcessor
138138

139139
bool isPresent(nostd::string_view key) const noexcept override
140140
{
141-
return (exclude_list_.find(key.data()) == exclude_list_.end());
141+
return (exclude_list_.find(std::string(key)) == exclude_list_.end());
142142
}
143143

144144
private:

sdk/test/metrics/attributes_processor_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ TEST(AttributesProcessor, FilteringExcludeAttributesProcessor)
7373
EXPECT_EQ(filter.size(), kNumFilterAttributes);
7474
}
7575

76-
TEST(AttributesProcessor, FilteringExcludeAllAtrributesProcessor)
76+
TEST(AttributesProcessor, FilteringExcludeAllAttributesProcessor)
7777
{
7878
const int kNumFilterAttributes = 0;
7979
std::unordered_map<std::string, bool> filter = {};

0 commit comments

Comments
 (0)