-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Metric SDK] Synchronous Instruments - Aggregation Storage(s) creatio…
…n for configured views (#1219)
- Loading branch information
Showing
15 changed files
with
322 additions
and
155 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
66 changes: 66 additions & 0 deletions
66
sdk/include/opentelemetry/sdk/metrics/state/multi_metric_storage.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,66 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
#ifndef ENABLE_METRICS_PREVIEW | ||
# include "opentelemetry/common/key_value_iterable_view.h" | ||
# include "opentelemetry/sdk/metrics/instruments.h" | ||
# include "opentelemetry/sdk/metrics/state/metric_storage.h" | ||
|
||
# include <memory> | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace metrics | ||
{ | ||
|
||
class MultiMetricStorage : public WritableMetricStorage | ||
{ | ||
public: | ||
void AddStorage(std::shared_ptr<WritableMetricStorage> storage) { storages_.push_back(storage); } | ||
|
||
virtual void RecordLong(long value) noexcept override | ||
{ | ||
for (auto &s : storages_) | ||
{ | ||
s->RecordLong(value); | ||
} | ||
} | ||
|
||
virtual void RecordLong( | ||
long value, | ||
const opentelemetry::common::KeyValueIterable &attributes) noexcept override | ||
{ | ||
for (auto &s : storages_) | ||
{ | ||
s->RecordLong(value, attributes); | ||
} | ||
} | ||
|
||
virtual void RecordDouble(double value) noexcept override | ||
{ | ||
for (auto &s : storages_) | ||
{ | ||
s->RecordDouble(value); | ||
} | ||
} | ||
|
||
virtual void RecordDouble( | ||
double value, | ||
const opentelemetry::common::KeyValueIterable &attributes) noexcept override | ||
{ | ||
for (auto &s : storages_) | ||
{ | ||
s->RecordDouble(value, attributes); | ||
} | ||
} | ||
|
||
private: | ||
std::vector<std::shared_ptr<WritableMetricStorage>> storages_; | ||
}; | ||
|
||
} // namespace metrics | ||
} // namespace sdk | ||
OPENTELEMETRY_END_NAMESPACE | ||
#endif |
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
Oops, something went wrong.