-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix attribute filtering for synchronous instruments. (#2472)
- Loading branch information
Showing
12 changed files
with
213 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
sdk/include/opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include <map> | ||
#include <string> | ||
#include "opentelemetry/sdk/common/attributemap_hash.h" | ||
#include "opentelemetry/version.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace metrics | ||
{ | ||
class AttributesProcessor; | ||
class FilteredOrderedAttributeMap : public opentelemetry::sdk::common::OrderedAttributeMap | ||
{ | ||
public: | ||
FilteredOrderedAttributeMap() = default; | ||
FilteredOrderedAttributeMap( | ||
std::initializer_list<std::pair<nostd::string_view, opentelemetry::common::AttributeValue>> | ||
attributes) | ||
: OrderedAttributeMap(attributes) | ||
{} | ||
FilteredOrderedAttributeMap(const opentelemetry::common::KeyValueIterable &attributes) | ||
: FilteredOrderedAttributeMap(attributes, nullptr) | ||
{} | ||
FilteredOrderedAttributeMap(const opentelemetry::common::KeyValueIterable &attributes, | ||
const opentelemetry::sdk::metrics::AttributesProcessor *processor); | ||
FilteredOrderedAttributeMap( | ||
std::initializer_list<std::pair<nostd::string_view, opentelemetry::common::AttributeValue>> | ||
attributes, | ||
const opentelemetry::sdk::metrics::AttributesProcessor *processor); | ||
}; | ||
} // namespace metrics | ||
} // namespace sdk | ||
OPENTELEMETRY_END_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" | ||
#include "opentelemetry/sdk/metrics/view/attributes_processor.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace metrics | ||
{ | ||
FilteredOrderedAttributeMap::FilteredOrderedAttributeMap( | ||
const opentelemetry::common::KeyValueIterable &attributes, | ||
const AttributesProcessor *processor) | ||
: OrderedAttributeMap() | ||
{ | ||
attributes.ForEachKeyValue( | ||
[&](nostd::string_view key, opentelemetry::common::AttributeValue value) noexcept { | ||
if (processor && processor->isPresent(key)) | ||
{ | ||
SetAttribute(key, value); | ||
} | ||
return true; | ||
}); | ||
} | ||
|
||
FilteredOrderedAttributeMap::FilteredOrderedAttributeMap( | ||
std::initializer_list<std::pair<nostd::string_view, opentelemetry::common::AttributeValue>> | ||
attributes, | ||
const AttributesProcessor *processor) | ||
: OrderedAttributeMap() | ||
{ | ||
for (auto &kv : attributes) | ||
{ | ||
if (processor && processor->isPresent(kv.first)) | ||
{ | ||
SetAttribute(kv.first, kv.second); | ||
} | ||
} | ||
} | ||
} // namespace metrics | ||
} // namespace sdk | ||
OPENTELEMETRY_END_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
cf5cdaa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.BM_BaselineBuffer/2
16782052.516937256
ns/iter5712235.450744629
ns/iter2.94
This comment was automatically generated by workflow using github-action-benchmark.