-
Notifications
You must be signed in to change notification settings - Fork 446
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
20 changed files
with
982 additions
and
268 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
76 changes: 76 additions & 0 deletions
76
exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.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,76 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
#ifndef ENABLE_METRICS_PREVIEW | ||
|
||
// clang-format off | ||
|
||
# include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" | ||
# include "opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h" | ||
# include "opentelemetry/common/spin_lock_mutex.h" | ||
# include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" | ||
|
||
// clang-format on | ||
|
||
# include "opentelemetry/exporters/otlp/otlp_environment.h" | ||
# include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h" | ||
# include "opentelemetry/sdk/metrics/metric_exporter.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace exporter | ||
{ | ||
namespace otlp | ||
{ | ||
|
||
/** | ||
* The OTLP exporter exports metrics data in OpenTelemetry Protocol (OTLP) format in gRPC. | ||
*/ | ||
class OtlpGrpcMetricsExporter : public opentelemetry::sdk::metrics::MetricExporter | ||
{ | ||
public: | ||
/** | ||
* Create an OtlpGrpcMetricsExporter using all default options. | ||
*/ | ||
OtlpGrpcMetricsExporter(); | ||
|
||
/** | ||
* Create an OtlpGrpcMetricsExporter using the given options. | ||
*/ | ||
explicit OtlpGrpcMetricsExporter(const OtlpGrpcMetricsExporterOptions &options); | ||
|
||
opentelemetry::sdk::common::ExportResult Export( | ||
const opentelemetry::sdk::metrics::ResourceMetrics &data) noexcept override; | ||
|
||
bool ForceFlush( | ||
std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; | ||
|
||
bool Shutdown( | ||
std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; | ||
|
||
private: | ||
// The configuration options associated with this exporter. | ||
const OtlpGrpcMetricsExporterOptions options_; | ||
|
||
// For testing | ||
friend class OtlpGrpcExporterTestPeer; | ||
|
||
// Store service stub internally. Useful for testing. | ||
std::unique_ptr<proto::collector::metrics::v1::MetricsService::StubInterface> | ||
metrics_service_stub_; | ||
|
||
/** | ||
* Create an OtlpGrpcMetricsExporter using the specified service stub. | ||
* Only tests can call this constructor directly. | ||
* @param stub the service stub to be used for exporting | ||
*/ | ||
OtlpGrpcMetricsExporter( | ||
std::unique_ptr<proto::collector::metrics::v1::MetricsService::StubInterface> stub); | ||
bool is_shutdown_ = false; | ||
mutable opentelemetry::common::SpinLockMutex lock_; | ||
bool isShutdown() const noexcept; | ||
}; | ||
} // namespace otlp | ||
} // namespace exporter | ||
OPENTELEMETRY_END_NAMESPACE | ||
#endif |
28 changes: 28 additions & 0 deletions
28
exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.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,28 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" | ||
#include "opentelemetry/sdk/metrics/instruments.h" | ||
|
||
#include <memory> | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace exporter | ||
{ | ||
namespace otlp | ||
{ | ||
|
||
/** | ||
* Struct to hold OTLP metrics exporter options. | ||
*/ | ||
struct OtlpGrpcMetricsExporterOptions : public OtlpGrpcExporterOptions | ||
{ | ||
opentelemetry::sdk::metrics::AggregationTemporality aggregation_temporality = | ||
opentelemetry::sdk::metrics::AggregationTemporality::kDelta; | ||
}; | ||
|
||
} // namespace otlp | ||
} // namespace exporter | ||
OPENTELEMETRY_END_NAMESPACE |
58 changes: 58 additions & 0 deletions
58
exporters/otlp/include/opentelemetry/exporters/otlp/otlp_metrics_utils.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,58 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" | ||
|
||
#include "opentelemetry/proto/collector/metrics/v1/metrics_service.pb.h" | ||
#include "opentelemetry/proto/metrics/v1/metrics.pb.h" | ||
#include "opentelemetry/proto/resource/v1/resource.pb.h" | ||
|
||
#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" | ||
|
||
#include "opentelemetry/sdk/metrics/export/metric_producer.h" | ||
|
||
#ifndef ENABLE_METRICS_PREVIEW | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace exporter | ||
{ | ||
namespace otlp | ||
{ | ||
/** | ||
* The OtlpMetricsUtils contains utility functions for OTLP metrics | ||
*/ | ||
class OtlpMetricsUtils | ||
{ | ||
public: | ||
static opentelemetry::sdk::metrics::AggregationType GetAggregationType( | ||
const opentelemetry::sdk::metrics::InstrumentType &instrument_type) noexcept; | ||
|
||
static proto::metrics::v1::AggregationTemporality GetProtoAggregationTemporality( | ||
const opentelemetry::sdk::metrics::AggregationTemporality &aggregation_temporality) noexcept; | ||
|
||
static void ConvertSumMetric(const opentelemetry::sdk::metrics::MetricData &metric_data, | ||
proto::metrics::v1::Sum *const sum) noexcept; | ||
|
||
static void ConvertHistogramMetric(const opentelemetry::sdk::metrics::MetricData &metric_data, | ||
proto::metrics::v1::Histogram *const histogram) noexcept; | ||
|
||
static void PopulateInstrumentationInfoMetric( | ||
const opentelemetry::sdk::metrics::MetricData &metric_data, | ||
proto::metrics::v1::Metric *metric) noexcept; | ||
|
||
static void PopulateResourceMetrics( | ||
const opentelemetry::sdk::metrics::ResourceMetrics &data, | ||
proto::metrics::v1::ResourceMetrics *proto_resource_metrics) noexcept; | ||
|
||
static void PopulateRequest( | ||
const opentelemetry::sdk::metrics::ResourceMetrics &data, | ||
proto::collector::metrics::v1::ExportMetricsServiceRequest *request) noexcept; | ||
}; | ||
|
||
} // namespace otlp | ||
} // namespace exporter | ||
OPENTELEMETRY_END_NAMESPACE | ||
|
||
#endif |
42 changes: 42 additions & 0 deletions
42
exporters/otlp/include/opentelemetry/exporters/otlp/otlp_populate_attribute_utils.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,42 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" | ||
#include "opentelemetry/proto/resource/v1/resource.pb.h" | ||
|
||
#include "opentelemetry/common/attribute_value.h" | ||
#include "opentelemetry/nostd/string_view.h" | ||
#include "opentelemetry/sdk/common/attribute_utils.h" | ||
#include "opentelemetry/sdk/resource/resource.h" | ||
#include "opentelemetry/version.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace exporter | ||
{ | ||
namespace otlp | ||
{ | ||
/** | ||
* The OtlpCommoneUtils contains utility functions to populate attributes | ||
*/ | ||
class OtlpPopulateAttributeUtils | ||
{ | ||
|
||
public: | ||
static void PopulateAttribute(opentelemetry::proto::resource::v1::Resource *proto, | ||
const opentelemetry::sdk::resource::Resource &resource) noexcept; | ||
|
||
static void PopulateAttribute(opentelemetry::proto::common::v1::KeyValue *attribute, | ||
nostd::string_view key, | ||
const opentelemetry::common::AttributeValue &value) noexcept; | ||
|
||
static void PopulateAttribute( | ||
opentelemetry::proto::common::v1::KeyValue *attribute, | ||
nostd::string_view key, | ||
const opentelemetry::sdk::common::OwnedAttributeValue &value) noexcept; | ||
}; | ||
|
||
} // namespace otlp | ||
} // namespace exporter | ||
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.
b285874
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/4
12559914.588928223
ns/iter5863099.098205566
ns/iter2.14
BM_AlwaysOffSamplerConstruction
3.4375936091421644
ns/iter1.627969129271147
ns/iter2.11
BM_AlwaysOnSamplerConstruction
3.38044651624186
ns/iter1.6460540320517012
ns/iter2.05
This comment was automatically generated by workflow using github-action-benchmark.