Skip to content

Commit

Permalink
YAML parser for metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff committed Mar 5, 2024
1 parent ecf6f1c commit 9987f23
Show file tree
Hide file tree
Showing 15 changed files with 583 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <memory>

#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace configuration
{

class AggregationConfiguration
{
public:
AggregationConfiguration() = default;
virtual ~AggregationConfiguration() = default;
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <memory>

#include "opentelemetry/sdk/configuration/aggregation_configuration.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace configuration
{

class Base2ExponentialBucketHistogramAggregationConfiguration : public AggregationConfiguration
{
public:
Base2ExponentialBucketHistogramAggregationConfiguration() = default;
~Base2ExponentialBucketHistogramAggregationConfiguration() override = default;

size_t max_scale;
size_t max_size;
bool record_min_max;
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <memory>

#include "opentelemetry/sdk/configuration/aggregation_configuration.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace configuration
{

class DefaultAggregationConfiguration : public AggregationConfiguration
{
public:
DefaultAggregationConfiguration() = default;
~DefaultAggregationConfiguration() override = default;
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
2 changes: 2 additions & 0 deletions sdk/include/opentelemetry/sdk/configuration/document_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class DocumentNode
DocumentNode() = default;
virtual ~DocumentNode() = default;

virtual std::string Key() const = 0;

virtual bool AsBoolean() = 0;
virtual size_t AsInteger() = 0;
virtual double AsDouble() = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <memory>

#include "opentelemetry/sdk/configuration/aggregation_configuration.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace configuration
{

class DropAggregationConfiguration : public AggregationConfiguration
{
public:
DropAggregationConfiguration() = default;
~DropAggregationConfiguration() override = default;
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <memory>

#include "opentelemetry/sdk/configuration/aggregation_configuration.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace configuration
{

class ExplicitBucketHistogramAggregationConfiguration : public AggregationConfiguration
{
public:
ExplicitBucketHistogramAggregationConfiguration() = default;
~ExplicitBucketHistogramAggregationConfiguration() override = default;

std::vector<double> boundaries;
bool record_min_max;
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <memory>

#include "opentelemetry/sdk/configuration/aggregation_configuration.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace configuration
{

class LastValueAggregationConfiguration : public AggregationConfiguration
{
public:
LastValueAggregationConfiguration() = default;
~LastValueAggregationConfiguration() override = default;
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ namespace sdk
namespace configuration
{

enum enum_default_histogram_aggregation
{
explicit_bucket_histogram,
base2_exponential_bucket_histogram
};

class OtlpMetricExporterConfiguration : public MetricExporterConfiguration
{
public:
Expand All @@ -34,7 +40,7 @@ class OtlpMetricExporterConfiguration : public MetricExporterConfiguration
std::string compression;
size_t timeout;
std::string temporality_preference;
int default_histogram_aggregation; // FIXME enum
enum_default_histogram_aggregation default_histogram_aggregation;
bool insecure;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class RymlDocumentNode : public DocumentNode
RymlDocumentNode(ryml::ConstNodeRef node) : m_node(node) {}
~RymlDocumentNode() override = default;

std::string Key() const override;

bool AsBoolean() override;
size_t AsInteger() override;
double AsDouble() override;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <memory>

#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace configuration
{

enum enum_instrument_type
{
counter,
histogram,
observable_counter,
observable_gauge,
observable_up_down_counter,
up_down_counter
};

class SelectorConfiguration
{
public:
SelectorConfiguration() = default;
~SelectorConfiguration() = default;

std::string instrument_name;
enum_instrument_type instrument_type;
std::string unit;
std::string meter_name;
std::string meter_version;
std::string meter_schema_url;
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
31 changes: 31 additions & 0 deletions sdk/include/opentelemetry/sdk/configuration/stream_configuration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <memory>

#include "opentelemetry/sdk/configuration/aggregation_configuration.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace configuration
{

class StreamConfiguration
{
public:
StreamConfiguration() = default;
~StreamConfiguration() = default;

std::string name;
std::string description;
std::unique_ptr<AggregationConfiguration> aggregation;
std::vector<std::string> attribute_keys;
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <memory>

#include "opentelemetry/sdk/configuration/aggregation_configuration.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace configuration
{

class SumAggregationConfiguration : public AggregationConfiguration
{
public:
SumAggregationConfiguration() = default;
~SumAggregationConfiguration() override = default;
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <memory>

#include "opentelemetry/sdk/configuration/selector_configuration.h"
#include "opentelemetry/sdk/configuration/stream_configuration.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand All @@ -16,6 +18,11 @@ namespace configuration
class ViewConfiguration
{
public:
ViewConfiguration() = default;
~ViewConfiguration() = default;

std::unique_ptr<SelectorConfiguration> selector;
std::unique_ptr<StreamConfiguration> stream;
};

} // namespace configuration
Expand Down
Loading

0 comments on commit 9987f23

Please sign in to comment.