-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
641 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
#ifndef ENABLE_METRICS_PREVIEW | ||
# include "opentelemetry/nostd/string_view.h" | ||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace metrics | ||
{ | ||
enum class InstrumentType | ||
{ | ||
kCounter, | ||
kHistogram, | ||
kUpDownCounter, | ||
kObservableCounter, | ||
kObservableGauge, | ||
kObservableUpDownCounter | ||
}; | ||
|
||
enum class InstrumentValueType | ||
{ | ||
kInt, | ||
kLong, | ||
kFloat, | ||
kDouble | ||
}; | ||
|
||
struct InstrumentDescriptor | ||
{ | ||
std::string name_; | ||
std::string description_; | ||
std::string unit_; | ||
InstrumentType type_; | ||
InstrumentValueType valueType_; | ||
}; | ||
|
||
/*class InstrumentSelector { | ||
public: | ||
InstrumentSelector(opentelemetry::nostd::string_view name, | ||
opentelemetry::sdk::metrics::InstrumentType type): name_(name.data()), type_(type) {} InstrumentType | ||
GetType(){return type_;} std::string GetNameFilter() { return name_;} | ||
private: | ||
std::string name_; | ||
InstrumentType type_; | ||
};*/ | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
#ifndef ENABLE_METRICS_PREVIEW | ||
|
||
# include <memory> | ||
# include "opentelemetry/sdk/metrics/aggregator/aggregator.h" | ||
# include "opentelemetry/sdk/metrics/instruments.h" | ||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace metrics | ||
{ | ||
class Aggregation | ||
{ | ||
public: | ||
virtual ~Aggregation() = default; | ||
virtual opentelemetry::sdk::metrics::Aggregator &CreateAggregator( | ||
opentelemetry::sdk::metrics::InstrumentDescriptor instrument_descriptor) noexcept = 0; | ||
}; | ||
|
||
class NoOpAggregation : public Aggregation | ||
{ | ||
|
||
opentelemetry::sdk::metrics::Aggregator &CreateAggregator( | ||
opentelemetry::sdk::metrics::InstrumentDescriptor instrument_descriptor) noexcept override | ||
{ | ||
static opentelemetry::sdk::metrics::NoOpAggregator noop_aggregator; | ||
return noop_aggregator; | ||
} | ||
}; | ||
|
||
class DefaultAggregation : public Aggregation | ||
{ | ||
|
||
opentelemetry::sdk::metrics::Aggregator &CreateAggregator( | ||
opentelemetry::sdk::metrics::InstrumentDescriptor instrument_descriptor) noexcept override | ||
{ | ||
// TBD - This shouldn't return noop_aggregator | ||
static opentelemetry::sdk::metrics::NoOpAggregator noop_aggregator; | ||
return noop_aggregator; | ||
} | ||
}; | ||
|
||
} // namespace metrics | ||
} // namespace sdk | ||
OPENTELEMETRY_END_NAMESPACE | ||
#endif |
34 changes: 34 additions & 0 deletions
34
sdk/include/opentelemetry/sdk/metrics/view/attributes_processor.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,34 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
#ifndef ENABLE_METRICS_PREVIEW | ||
# include "opentelemetry/sdk/common/attribute_utils.h" | ||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace metrics | ||
{ | ||
using MetricAttributes = opentelemetry::sdk::common::AttributeMap; | ||
|
||
class AttributesProcessor | ||
{ | ||
public: | ||
virtual MetricAttributes process( | ||
const opentelemetry::common::KeyValueIterable &attributes) noexcept = 0; | ||
}; | ||
|
||
class DefaultAttributesProcessor : public AttributesProcessor | ||
{ | ||
MetricAttributes process( | ||
const opentelemetry::common::KeyValueIterable &attributes) noexcept override | ||
{ | ||
MetricAttributes result(attributes); | ||
return result; | ||
} | ||
}; | ||
|
||
} // namespace metrics | ||
} // namespace sdk | ||
OPENTELEMETRY_END_NAMESPACE | ||
#endif |
36 changes: 36 additions & 0 deletions
36
sdk/include/opentelemetry/sdk/metrics/view/instrument_selector.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,36 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
#ifndef ENABLE_METRICS_PREVIEW | ||
# include "opentelemetry/nostd/string_view.h" | ||
# include "opentelemetry/sdk/metrics/instruments.h" | ||
# include "opentelemetry/sdk/metrics/view/predicate_factory.h" | ||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace metrics | ||
{ | ||
class InstrumentSelector | ||
{ | ||
public: | ||
InstrumentSelector(opentelemetry::sdk::metrics::InstrumentType instrument_type, | ||
opentelemetry::nostd::string_view name) | ||
: name_filter_{std::move(PredicateFactory::GetPredicate(name, PredicateType::kPattern))}, | ||
instrument_type_{instrument_type} | ||
{} | ||
|
||
// Returns name filter predicate. This shouldn't be deleted | ||
const opentelemetry::sdk::metrics::Predicate *const GetNameFilter() { return name_filter_.get(); } | ||
|
||
// Returns instrument filter. | ||
InstrumentType GetInstrumentType() { return instrument_type_; } | ||
|
||
private: | ||
opentelemetry::sdk::metrics::InstrumentType instrument_type_; | ||
std::unique_ptr<opentelemetry::sdk::metrics::Predicate> name_filter_; | ||
}; | ||
} // namespace metrics | ||
} // namespace sdk | ||
OPENTELEMETRY_END_NAMESPACE | ||
#endif |
47 changes: 47 additions & 0 deletions
47
sdk/include/opentelemetry/sdk/metrics/view/meter_selector.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,47 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
#include "opentelemetry/nostd/string_view.h" | ||
#include "opentelemetry/sdk/metrics/view/predicate_factory.h" | ||
#ifndef ENABLE_METRICS_PREVIEW | ||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace metrics | ||
{ | ||
class MeterSelector | ||
{ | ||
public: | ||
MeterSelector(opentelemetry::nostd::string_view name, | ||
opentelemetry::nostd::string_view version, | ||
opentelemetry::nostd::string_view schema) | ||
: name_filter_{std::move(PredicateFactory::GetPredicate(name, PredicateType::kExact))}, | ||
version_filter_{std::move(PredicateFactory::GetPredicate(version, PredicateType::kExact))}, | ||
schema_filter_{std::move(PredicateFactory::GetPredicate(schema, PredicateType::kExact))} | ||
{} | ||
|
||
// Returns name filter predicate. This shouldn't be deleted | ||
const opentelemetry::sdk::metrics::Predicate *const GetNameFilter() { return name_filter_.get(); } | ||
|
||
// Returns version filter predicate. This shouldn't be deleted | ||
const opentelemetry::sdk::metrics::Predicate *const GetVersionFilter() | ||
{ | ||
return version_filter_.get(); | ||
} | ||
|
||
// Returns schema filter predicate. This shouldn't be deleted | ||
const opentelemetry::sdk::metrics::Predicate *const GetSchemaFilter() | ||
{ | ||
return schema_filter_.get(); | ||
} | ||
|
||
private: | ||
std::unique_ptr<opentelemetry::sdk::metrics::Predicate> name_filter_; | ||
std::unique_ptr<opentelemetry::sdk::metrics::Predicate> version_filter_; | ||
std::unique_ptr<opentelemetry::sdk::metrics::Predicate> schema_filter_; | ||
}; | ||
} // namespace metrics | ||
} // namespace sdk | ||
OPENTELEMETRY_END_NAMESPACE | ||
#endif |
Oops, something went wrong.