From 0803e6a8f26458df4c987c5fcc19823ca530cc41 Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Mon, 2 Oct 2023 14:21:01 -0400 Subject: [PATCH 01/29] prometheus exporter: Add otel_scope_name and otel_scope_version labels (#2293) --- CHANGELOG.md | 3 + .../exporters/prometheus/exporter_utils.h | 8 ++- exporters/prometheus/src/exporter_utils.cc | 67 ++++++++++++++----- .../prometheus/test/exporter_utils_test.cc | 22 +++--- 4 files changed, 72 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f2ce9e4d0..57307f67fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,9 @@ Increment the: [#2224](https://github.com/open-telemetry/opentelemetry-cpp/pull/2224) * [REMOVAL] Drop C++11 support [#2342](https://github.com/open-telemetry/opentelemetry-cpp/pull/2342) +* [EXPORTER] Add otel_scope_name and otel_scope_version labels to the prometheus + exporter. + [#2293](https://github.com/open-telemetry/opentelemetry-cpp/pull/2293) Important changes: diff --git a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h index 07d2c396c6..76c62d58ba 100644 --- a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h +++ b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h @@ -48,6 +48,7 @@ class PrometheusExporterUtils template static void SetData(std::vector values, const opentelemetry::sdk::metrics::PointAttributes &labels, + const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope, ::prometheus::MetricType type, ::prometheus::MetricFamily *metric_family); @@ -60,13 +61,16 @@ class PrometheusExporterUtils const std::vector &boundaries, const std::vector &counts, const opentelemetry::sdk::metrics::PointAttributes &labels, + const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope, ::prometheus::MetricFamily *metric_family); /** * Set time and labels to metric data */ - static void SetMetricBasic(::prometheus::ClientMetric &metric, - const opentelemetry::sdk::metrics::PointAttributes &labels); + static void SetMetricBasic( + ::prometheus::ClientMetric &metric, + const opentelemetry::sdk::metrics::PointAttributes &labels, + const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope); /** * Convert attribute value to string diff --git a/exporters/prometheus/src/exporter_utils.cc b/exporters/prometheus/src/exporter_utils.cc index a840b087ff..c0f034ffe5 100644 --- a/exporters/prometheus/src/exporter_utils.cc +++ b/exporters/prometheus/src/exporter_utils.cc @@ -22,6 +22,10 @@ namespace metrics { namespace { + +static constexpr const char *kScopeNameKey = "otel_scope_name"; +static constexpr const char *kScopeVersionKey = "otel_scope_version"; + /** * Sanitize the given metric name by replacing invalid characters with _, * ensuring that multiple consecutive _ characters are collapsed to a single _. @@ -150,7 +154,7 @@ std::vector PrometheusExporterUtils::TranslateT sum = nostd::get(histogram_point_data.sum_); } SetData(std::vector{sum, (double)histogram_point_data.count_}, boundaries, counts, - point_data_attr.attributes, &metric_family); + point_data_attr.attributes, instrumentation_info.scope_, &metric_family); } else if (type == prometheus_client::MetricType::Gauge) { @@ -160,14 +164,16 @@ std::vector PrometheusExporterUtils::TranslateT auto last_value_point_data = nostd::get(point_data_attr.point_data); std::vector values{last_value_point_data.value_}; - SetData(values, point_data_attr.attributes, type, &metric_family); + SetData(values, point_data_attr.attributes, instrumentation_info.scope_, type, + &metric_family); } else if (nostd::holds_alternative(point_data_attr.point_data)) { auto sum_point_data = nostd::get(point_data_attr.point_data); std::vector values{sum_point_data.value_}; - SetData(values, point_data_attr.attributes, type, &metric_family); + SetData(values, point_data_attr.attributes, instrumentation_info.scope_, type, + &metric_family); } else { @@ -183,7 +189,8 @@ std::vector PrometheusExporterUtils::TranslateT auto sum_point_data = nostd::get(point_data_attr.point_data); std::vector values{sum_point_data.value_}; - SetData(values, point_data_attr.attributes, type, &metric_family); + SetData(values, point_data_attr.attributes, instrumentation_info.scope_, type, + &metric_family); } else { @@ -257,14 +264,16 @@ prometheus_client::MetricType PrometheusExporterUtils::TranslateType( * sum => Prometheus Counter */ template -void PrometheusExporterUtils::SetData(std::vector values, - const metric_sdk::PointAttributes &labels, - prometheus_client::MetricType type, - prometheus_client::MetricFamily *metric_family) +void PrometheusExporterUtils::SetData( + std::vector values, + const metric_sdk::PointAttributes &labels, + const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope, + prometheus_client::MetricType type, + prometheus_client::MetricFamily *metric_family) { metric_family->metric.emplace_back(); prometheus_client::ClientMetric &metric = metric_family->metric.back(); - SetMetricBasic(metric, labels); + SetMetricBasic(metric, labels, scope); SetValue(values, type, &metric); } @@ -273,23 +282,27 @@ void PrometheusExporterUtils::SetData(std::vector values, * Histogram => Prometheus Histogram */ template -void PrometheusExporterUtils::SetData(std::vector values, - const std::vector &boundaries, - const std::vector &counts, - const metric_sdk::PointAttributes &labels, - prometheus_client::MetricFamily *metric_family) +void PrometheusExporterUtils::SetData( + std::vector values, + const std::vector &boundaries, + const std::vector &counts, + const metric_sdk::PointAttributes &labels, + const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope, + prometheus_client::MetricFamily *metric_family) { metric_family->metric.emplace_back(); prometheus_client::ClientMetric &metric = metric_family->metric.back(); - SetMetricBasic(metric, labels); + SetMetricBasic(metric, labels, scope); SetValue(values, boundaries, counts, &metric); } /** * Set labels to metric data */ -void PrometheusExporterUtils::SetMetricBasic(prometheus_client::ClientMetric &metric, - const metric_sdk::PointAttributes &labels) +void PrometheusExporterUtils::SetMetricBasic( + prometheus_client::ClientMetric &metric, + const metric_sdk::PointAttributes &labels, + const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope) { if (labels.empty()) { @@ -300,7 +313,7 @@ void PrometheusExporterUtils::SetMetricBasic(prometheus_client::ClientMetric &me // Note that attribute keys are sorted, but sanitized keys can be out-of-order. // We could sort the sanitized keys again, but this seems too expensive to do // in this hot code path. Instead, we ignore out-of-order keys and emit a warning. - metric.label.reserve(labels.size()); + metric.label.reserve(labels.size() + 2); std::string previous_key; for (auto const &label : labels) { @@ -324,6 +337,24 @@ void PrometheusExporterUtils::SetMetricBasic(prometheus_client::ClientMetric &me << "'. Ignoring this label."); } } + if (!scope) + { + return; + } + auto scope_name = scope->GetName(); + if (!scope_name.empty()) + { + metric.label.emplace_back(); + metric.label.back().name = kScopeNameKey; + metric.label.back().value = std::move(scope_name); + } + auto scope_version = scope->GetVersion(); + if (!scope_version.empty()) + { + metric.label.emplace_back(); + metric.label.back().name = kScopeVersionKey; + metric.label.back().value = std::move(scope_version); + } } std::string PrometheusExporterUtils::AttributeValueToString( diff --git a/exporters/prometheus/test/exporter_utils_test.cc b/exporters/prometheus/test/exporter_utils_test.cc index c2a6273397..3c945c6735 100644 --- a/exporters/prometheus/test/exporter_utils_test.cc +++ b/exporters/prometheus/test/exporter_utils_test.cc @@ -105,7 +105,7 @@ TEST(PrometheusExporterUtils, TranslateToPrometheusIntegerCounter) auto metric1 = translated[0]; std::vector vals = {10}; - assert_basic(metric1, "library_name", "description", prometheus_client::MetricType::Counter, 1, + assert_basic(metric1, "library_name", "description", prometheus_client::MetricType::Counter, 3, vals); } @@ -119,7 +119,7 @@ TEST(PrometheusExporterUtils, TranslateToPrometheusIntegerLastValue) auto metric1 = translated[0]; std::vector vals = {10}; - assert_basic(metric1, "library_name", "description", prometheus_client::MetricType::Gauge, 1, + assert_basic(metric1, "library_name", "description", prometheus_client::MetricType::Gauge, 3, vals); } @@ -133,7 +133,7 @@ TEST(PrometheusExporterUtils, TranslateToPrometheusHistogramNormal) auto metric = translated[0]; std::vector vals = {3, 900.5, 4}; - assert_basic(metric, "library_name", "description", prometheus_client::MetricType::Histogram, 1, + assert_basic(metric, "library_name", "description", prometheus_client::MetricType::Histogram, 3, vals); assert_histogram(metric, std::list{10.1, 20.2, 30.2}, {200, 300, 400, 500}); } @@ -211,20 +211,26 @@ class AttributeCollisionTest : public ::testing::Test TEST_F(AttributeCollisionTest, SeparatesDistinctKeys) { - CheckTranslation({{"foo.a", "value1"}, {"foo.b", "value2"}}, - {{"foo_a", "value1"}, {"foo_b", "value2"}}); + CheckTranslation({{"foo.a", "value1"}, {"foo.b", "value2"}}, {{"foo_a", "value1"}, + {"foo_b", "value2"}, + {"otel_scope_name", "library_name"}, + {"otel_scope_version", "1.2.0"}}); } TEST_F(AttributeCollisionTest, JoinsCollidingKeys) { - CheckTranslation({{"foo.a", "value1"}, {"foo_a", "value2"}}, // - {{"foo_a", "value1;value2"}}); + CheckTranslation({{"foo.a", "value1"}, {"foo_a", "value2"}}, {{"foo_a", "value1;value2"}, + {"otel_scope_name", "library_name"}, + {"otel_scope_version", "1.2.0"}}); } TEST_F(AttributeCollisionTest, DropsInvertedKeys) { CheckTranslation({{"foo.a", "value1"}, {"foo.b", "value2"}, {"foo__a", "value3"}}, - {{"foo_a", "value1"}, {"foo_b", "value2"}}); + {{"foo_a", "value1"}, + {"foo_b", "value2"}, + {"otel_scope_name", "library_name"}, + {"otel_scope_version", "1.2.0"}}); } OPENTELEMETRY_END_NAMESPACE From 0eaa7944e1f2ef407f3fea6b94f24ed16cdb1fb6 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Wed, 4 Oct 2023 03:47:27 +0800 Subject: [PATCH 02/29] Export resource for prometheus (#2301) --- CHANGELOG.md | 2 + .../exporters/prometheus/collector.h | 3 +- .../exporters/prometheus/exporter_options.h | 3 + .../exporters/prometheus/exporter_utils.h | 31 +++- exporters/prometheus/src/collector.cc | 11 +- exporters/prometheus/src/exporter.cc | 3 +- exporters/prometheus/src/exporter_utils.cc | 102 ++++++++++--- exporters/prometheus/test/collector_test.cc | 4 +- .../prometheus/test/exporter_utils_test.cc | 134 ++++++++++++++++-- .../sdk/metrics/export/metric_producer.h | 32 ++++- 10 files changed, 282 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57307f67fa..f889a287f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ Increment the: * [DEPRECATION] Deprecate ZPAGES [#2291](https://github.com/open-telemetry/opentelemetry-cpp/pull/2291) +* [EXPORTER] Prometheus exporter emit resource attributes + [#2301](https://github.com/open-telemetry/opentelemetry-cpp/pull/2301) * [EXPORTER] Remove explicit timestamps from metric points exported by Prometheus [#2324](https://github.com/open-telemetry/opentelemetry-cpp/pull/2324) * [EXPORTER] Handle attribute key collisions caused by sanitation diff --git a/exporters/prometheus/include/opentelemetry/exporters/prometheus/collector.h b/exporters/prometheus/include/opentelemetry/exporters/prometheus/collector.h index 46d270905b..5dfa983088 100644 --- a/exporters/prometheus/include/opentelemetry/exporters/prometheus/collector.h +++ b/exporters/prometheus/include/opentelemetry/exporters/prometheus/collector.h @@ -31,7 +31,7 @@ class PrometheusCollector : public prometheus_client::Collectable * This constructor initializes the collection for metrics to export * in this class with default capacity */ - explicit PrometheusCollector(sdk::metrics::MetricReader *reader); + explicit PrometheusCollector(sdk::metrics::MetricReader *reader, bool populate_target_info); /** * Collects all metrics data from metricsToCollect collection. @@ -42,6 +42,7 @@ class PrometheusCollector : public prometheus_client::Collectable private: sdk::metrics::MetricReader *reader_; + bool populate_target_info_; /* * Lock when operating the metricsToCollect collection diff --git a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h index 76a08d2a4a..3f36d780ee 100644 --- a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h +++ b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h @@ -22,6 +22,9 @@ struct PrometheusExporterOptions // The endpoint the Prometheus backend can collect metrics from std::string url; + + // Populating target_info + bool populate_target_info = true; }; } // namespace metrics diff --git a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h index 76c62d58ba..96c7ac8826 100644 --- a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h +++ b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h @@ -26,12 +26,25 @@ class PrometheusExporterUtils * to Prometheus metrics data collection * * @param records a collection of metrics in OpenTelemetry + * @param populate_target_info whether to populate target_info * @return a collection of translated metrics that is acceptable by Prometheus */ static std::vector<::prometheus::MetricFamily> TranslateToPrometheus( - const sdk::metrics::ResourceMetrics &data); + const sdk::metrics::ResourceMetrics &data, + bool populate_target_info = true); private: + /** + * Append key-value pair to prometheus labels. + * + * @param name label name + * @param value label value + * @param labels target labels + */ + static void AddPrometheusLabel(std::string name, + std::string value, + std::vector<::prometheus::ClientMetric::Label> *labels); + static opentelemetry::sdk::metrics::AggregationType getAggregationType( const opentelemetry::sdk::metrics::PointType &point_type); @@ -41,6 +54,13 @@ class PrometheusExporterUtils static ::prometheus::MetricType TranslateType(opentelemetry::sdk::metrics::AggregationType kind, bool is_monotonic = true); + /** + * Add a target_info metric to collect resource attributes + */ + static void SetTarget(const sdk::metrics::ResourceMetrics &data, + const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope, + std::vector<::prometheus::MetricFamily> *output); + /** * Set metric data for: * Counter => Prometheus Counter @@ -50,7 +70,8 @@ class PrometheusExporterUtils const opentelemetry::sdk::metrics::PointAttributes &labels, const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope, ::prometheus::MetricType type, - ::prometheus::MetricFamily *metric_family); + ::prometheus::MetricFamily *metric_family, + const opentelemetry::sdk::resource::Resource *resource); /** * Set metric data for: @@ -62,7 +83,8 @@ class PrometheusExporterUtils const std::vector &counts, const opentelemetry::sdk::metrics::PointAttributes &labels, const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope, - ::prometheus::MetricFamily *metric_family); + ::prometheus::MetricFamily *metric_family, + const opentelemetry::sdk::resource::Resource *resource); /** * Set time and labels to metric data @@ -70,7 +92,8 @@ class PrometheusExporterUtils static void SetMetricBasic( ::prometheus::ClientMetric &metric, const opentelemetry::sdk::metrics::PointAttributes &labels, - const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope); + const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope, + const opentelemetry::sdk::resource::Resource *resource); /** * Convert attribute value to string diff --git a/exporters/prometheus/src/collector.cc b/exporters/prometheus/src/collector.cc index 29c0bc8db2..33b9a9b8c8 100644 --- a/exporters/prometheus/src/collector.cc +++ b/exporters/prometheus/src/collector.cc @@ -17,7 +17,10 @@ namespace metrics * This constructor initializes the collection for metrics to export * in this class with default capacity */ -PrometheusCollector::PrometheusCollector(sdk::metrics::MetricReader *reader) : reader_(reader) {} +PrometheusCollector::PrometheusCollector(sdk::metrics::MetricReader *reader, + bool populate_target_info) + : reader_(reader), populate_target_info_(populate_target_info) +{} /** * Collects all metrics data from metricsToCollect collection. @@ -36,8 +39,10 @@ std::vector PrometheusCollector::Collect() cons collection_lock_.lock(); std::vector result; - reader_->Collect([&result](sdk::metrics::ResourceMetrics &metric_data) { - auto prometheus_metric_data = PrometheusExporterUtils::TranslateToPrometheus(metric_data); + + reader_->Collect([&result, this](sdk::metrics::ResourceMetrics &metric_data) { + auto prometheus_metric_data = + PrometheusExporterUtils::TranslateToPrometheus(metric_data, this->populate_target_info_); for (auto &data : prometheus_metric_data) result.emplace_back(data); return true; diff --git a/exporters/prometheus/src/exporter.cc b/exporters/prometheus/src/exporter.cc index 7691e32f39..6022c2c33b 100644 --- a/exporters/prometheus/src/exporter.cc +++ b/exporters/prometheus/src/exporter.cc @@ -30,7 +30,8 @@ PrometheusExporter::PrometheusExporter(const PrometheusExporterOptions &options) Shutdown(); // set MetricReader in shutdown state. return; } - collector_ = std::shared_ptr(new PrometheusCollector(this)); + collector_ = std::shared_ptr( + new PrometheusCollector(this, options_.populate_target_info)); exposer_->RegisterCollectable(collector_); } diff --git a/exporters/prometheus/src/exporter_utils.cc b/exporters/prometheus/src/exporter_utils.cc index c0f034ffe5..42fafc6336 100644 --- a/exporters/prometheus/src/exporter_utils.cc +++ b/exporters/prometheus/src/exporter_utils.cc @@ -1,14 +1,22 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include #include +#include +#include +#include #include #include + #include "prometheus/metric_family.h" +#include "prometheus/metric_type.h" -#include #include "opentelemetry/exporters/prometheus/exporter_utils.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/resource/semantic_conventions.h" +#include "opentelemetry/trace/semantic_conventions.h" #include "opentelemetry/sdk/common/global_log_handler.h" @@ -111,11 +119,25 @@ std::string SanitizeName(std::string name) * @return a collection of translated metrics that is acceptable by Prometheus */ std::vector PrometheusExporterUtils::TranslateToPrometheus( - const sdk::metrics::ResourceMetrics &data) + const sdk::metrics::ResourceMetrics &data, + bool populate_target_info) { // initialize output vector + std::size_t reserve_size = 1; + for (const auto &instrumentation_info : data.scope_metric_data_) + { + reserve_size += instrumentation_info.metric_data_.size(); + } + std::vector output; + output.reserve(reserve_size); + + // Append target_info as the first metric + if (populate_target_info && !data.scope_metric_data_.empty()) + { + SetTarget(data, (*data.scope_metric_data_.begin()).scope_, &output); + } for (const auto &instrumentation_info : data.scope_metric_data_) { @@ -151,10 +173,11 @@ std::vector PrometheusExporterUtils::TranslateT } else { - sum = nostd::get(histogram_point_data.sum_); + sum = static_cast(nostd::get(histogram_point_data.sum_)); } SetData(std::vector{sum, (double)histogram_point_data.count_}, boundaries, counts, - point_data_attr.attributes, instrumentation_info.scope_, &metric_family); + point_data_attr.attributes, instrumentation_info.scope_, &metric_family, + data.resource_); } else if (type == prometheus_client::MetricType::Gauge) { @@ -165,7 +188,7 @@ std::vector PrometheusExporterUtils::TranslateT nostd::get(point_data_attr.point_data); std::vector values{last_value_point_data.value_}; SetData(values, point_data_attr.attributes, instrumentation_info.scope_, type, - &metric_family); + &metric_family, data.resource_); } else if (nostd::holds_alternative(point_data_attr.point_data)) { @@ -173,7 +196,7 @@ std::vector PrometheusExporterUtils::TranslateT nostd::get(point_data_attr.point_data); std::vector values{sum_point_data.value_}; SetData(values, point_data_attr.attributes, instrumentation_info.scope_, type, - &metric_family); + &metric_family, data.resource_); } else { @@ -190,7 +213,7 @@ std::vector PrometheusExporterUtils::TranslateT nostd::get(point_data_attr.point_data); std::vector values{sum_point_data.value_}; SetData(values, point_data_attr.attributes, instrumentation_info.scope_, type, - &metric_family); + &metric_family, data.resource_); } else { @@ -206,6 +229,17 @@ std::vector PrometheusExporterUtils::TranslateT return output; } +void PrometheusExporterUtils::AddPrometheusLabel( + std::string name, + std::string value, + std::vector<::prometheus::ClientMetric::Label> *labels) +{ + prometheus_client::ClientMetric::Label prometheus_label; + prometheus_label.name = std::move(name); + prometheus_label.value = std::move(value); + labels->emplace_back(std::move(prometheus_label)); +} + metric_sdk::AggregationType PrometheusExporterUtils::getAggregationType( const metric_sdk::PointType &point_type) { @@ -259,6 +293,37 @@ prometheus_client::MetricType PrometheusExporterUtils::TranslateType( } } +void PrometheusExporterUtils::SetTarget( + const sdk::metrics::ResourceMetrics &data, + const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope, + std::vector<::prometheus::MetricFamily> *output) +{ + if (output == nullptr || data.resource_ == nullptr) + { + return; + } + + prometheus_client::MetricFamily metric_family; + metric_family.name = "target"; + metric_family.help = "Target metadata"; + metric_family.type = prometheus_client::MetricType::Info; + metric_family.metric.emplace_back(); + + prometheus_client::ClientMetric &metric = metric_family.metric.back(); + metric.info.value = 1.0; + + metric_sdk::PointAttributes empty_attributes; + SetMetricBasic(metric, empty_attributes, scope, data.resource_); + + for (auto &label : data.resource_->GetAttributes()) + { + AddPrometheusLabel(SanitizeName(label.first), AttributeValueToString(label.second), + &metric.label); + } + + output->emplace_back(std::move(metric_family)); +} + /** * Set metric data for: * sum => Prometheus Counter @@ -269,11 +334,12 @@ void PrometheusExporterUtils::SetData( const metric_sdk::PointAttributes &labels, const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope, prometheus_client::MetricType type, - prometheus_client::MetricFamily *metric_family) + prometheus_client::MetricFamily *metric_family, + const opentelemetry::sdk::resource::Resource *resource) { metric_family->metric.emplace_back(); prometheus_client::ClientMetric &metric = metric_family->metric.back(); - SetMetricBasic(metric, labels, scope); + SetMetricBasic(metric, labels, scope, resource); SetValue(values, type, &metric); } @@ -288,11 +354,12 @@ void PrometheusExporterUtils::SetData( const std::vector &counts, const metric_sdk::PointAttributes &labels, const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope, - prometheus_client::MetricFamily *metric_family) + prometheus_client::MetricFamily *metric_family, + const opentelemetry::sdk::resource::Resource *resource) { metric_family->metric.emplace_back(); prometheus_client::ClientMetric &metric = metric_family->metric.back(); - SetMetricBasic(metric, labels, scope); + SetMetricBasic(metric, labels, scope, resource); SetValue(values, boundaries, counts, &metric); } @@ -302,9 +369,10 @@ void PrometheusExporterUtils::SetData( void PrometheusExporterUtils::SetMetricBasic( prometheus_client::ClientMetric &metric, const metric_sdk::PointAttributes &labels, - const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope) + const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope, + const opentelemetry::sdk::resource::Resource *resource) { - if (labels.empty()) + if (labels.empty() && nullptr == resource) { return; } @@ -410,7 +478,7 @@ void PrometheusExporterUtils::SetValue(std::vector values, const auto &value_var = values[0]; if (nostd::holds_alternative(value_var)) { - value = nostd::get(value_var); + value = static_cast(nostd::get(value_var)); } else { @@ -445,9 +513,9 @@ void PrometheusExporterUtils::SetValue(std::vector values, const std::vector &counts, prometheus_client::ClientMetric *metric) { - metric->histogram.sample_sum = values[0]; - metric->histogram.sample_count = values[1]; - int cumulative = 0; + metric->histogram.sample_sum = static_cast(values[0]); + metric->histogram.sample_count = static_cast(values[1]); + std::uint64_t cumulative = 0; std::vector buckets; uint32_t idx = 0; for (const auto &boundary : boundaries) diff --git a/exporters/prometheus/test/collector_test.cc b/exporters/prometheus/test/collector_test.cc index 8947dcfd27..578e01d8f8 100644 --- a/exporters/prometheus/test/collector_test.cc +++ b/exporters/prometheus/test/collector_test.cc @@ -73,12 +73,12 @@ TEST(PrometheusCollector, BasicTests) MockMetricReader *reader = new MockMetricReader(); MockMetricProducer *producer = new MockMetricProducer(); reader->SetMetricProducer(producer); - PrometheusCollector collector(reader); + PrometheusCollector collector(reader, true); auto data = collector.Collect(); // Collection size should be the same as the size // of the records collection produced by MetricProducer. - ASSERT_EQ(data.size(), 1); + ASSERT_EQ(data.size(), 2); delete reader; delete producer; } diff --git a/exporters/prometheus/test/exporter_utils_test.cc b/exporters/prometheus/test/exporter_utils_test.cc index 3c945c6735..8ff324d7ac 100644 --- a/exporters/prometheus/test/exporter_utils_test.cc +++ b/exporters/prometheus/test/exporter_utils_test.cc @@ -6,11 +6,11 @@ #include "prometheus/metric_type.h" #include "opentelemetry/exporters/prometheus/exporter_utils.h" +#include "opentelemetry/sdk/resource/resource.h" #include "prometheus_test_helper.h" using opentelemetry::exporter::metrics::PrometheusExporterUtils; namespace metric_sdk = opentelemetry::sdk::metrics; -namespace metric_api = opentelemetry::metrics; namespace prometheus_client = ::prometheus; OPENTELEMETRY_BEGIN_NAMESPACE @@ -20,7 +20,7 @@ void assert_basic(prometheus_client::MetricFamily &metric, const std::string &sanitized_name, const std::string &description, prometheus_client::MetricType type, - int label_num, + size_t label_num, std::vector vals) { ASSERT_EQ(metric.name, sanitized_name + "_unit"); // name sanitized @@ -97,45 +97,130 @@ TEST(PrometheusExporterUtils, TranslateToPrometheusEmptyInputReturnsEmptyCollect TEST(PrometheusExporterUtils, TranslateToPrometheusIntegerCounter) { + + opentelemetry::sdk::resource::Resource resource = opentelemetry::sdk::resource::Resource::Create( + {{"service.name", "test_service"}, + {"service.namespace", "test_namespace"}, + {"service.instance.id", "localhost:8000"}, + {"custom_resource_attr", "custom_resource_value"}}); TestDataPoints dp; metric_sdk::ResourceMetrics metrics_data = dp.CreateSumPointData(); + metrics_data.resource_ = &resource; auto translated = PrometheusExporterUtils::TranslateToPrometheus(metrics_data); - ASSERT_EQ(translated.size(), 1); + ASSERT_EQ(translated.size(), 2); - auto metric1 = translated[0]; + auto metric1 = translated[1]; std::vector vals = {10}; assert_basic(metric1, "library_name", "description", prometheus_client::MetricType::Counter, 3, vals); + + int checked_label_num = 0; + for (auto &label : translated[0].metric[0].label) + { + if (label.name == "service_namespace") + { + ASSERT_EQ(label.value, "test_namespace"); + checked_label_num++; + } + else if (label.name == "service_name") + { + ASSERT_EQ(label.value, "test_service"); + checked_label_num++; + } + else if (label.name == "service_instance_id") + { + ASSERT_EQ(label.value, "localhost:8000"); + checked_label_num++; + } + else if (label.name == "custom_resource_attr") + { + ASSERT_EQ(label.value, "custom_resource_value"); + checked_label_num++; + } + } + ASSERT_EQ(checked_label_num, 4); } TEST(PrometheusExporterUtils, TranslateToPrometheusIntegerLastValue) { + opentelemetry::sdk::resource::Resource resource = opentelemetry::sdk::resource::Resource::Create( + {{"service.name", "test_service"}, + {"service.instance.id", "localhost:8000"}, + {"custom_resource_attr", "custom_resource_value"}}); TestDataPoints dp; metric_sdk::ResourceMetrics metrics_data = dp.CreateLastValuePointData(); + metrics_data.resource_ = &resource; auto translated = PrometheusExporterUtils::TranslateToPrometheus(metrics_data); - ASSERT_EQ(translated.size(), 1); + ASSERT_EQ(translated.size(), 2); - auto metric1 = translated[0]; + auto metric1 = translated[1]; std::vector vals = {10}; assert_basic(metric1, "library_name", "description", prometheus_client::MetricType::Gauge, 3, vals); + + int checked_label_num = 0; + for (auto &label : translated[0].metric[0].label) + { + if (label.name == "service_name") + { + ASSERT_EQ(label.value, "test_service"); + checked_label_num++; + } + else if (label.name == "service_instance_id") + { + ASSERT_EQ(label.value, "localhost:8000"); + checked_label_num++; + } + else if (label.name == "custom_resource_attr") + { + ASSERT_EQ(label.value, "custom_resource_value"); + checked_label_num++; + } + } + ASSERT_EQ(checked_label_num, 3); } TEST(PrometheusExporterUtils, TranslateToPrometheusHistogramNormal) { + opentelemetry::sdk::resource::Resource resource = opentelemetry::sdk::resource::Resource::Create( + {{"service.instance.id", "localhost:8001"}, + {"custom_resource_attr", "custom_resource_value"}}); TestDataPoints dp; metric_sdk::ResourceMetrics metrics_data = dp.CreateHistogramPointData(); + metrics_data.resource_ = &resource; auto translated = PrometheusExporterUtils::TranslateToPrometheus(metrics_data); - ASSERT_EQ(translated.size(), 1); + ASSERT_EQ(translated.size(), 2); - auto metric = translated[0]; + auto metric = translated[1]; std::vector vals = {3, 900.5, 4}; assert_basic(metric, "library_name", "description", prometheus_client::MetricType::Histogram, 3, vals); assert_histogram(metric, std::list{10.1, 20.2, 30.2}, {200, 300, 400, 500}); + + int checked_label_num = 0; + for (auto &label : translated[0].metric[0].label) + { + if (label.name == "service_name") + { + // default service name is "unknown_service" + ASSERT_EQ(label.value, "unknown_service"); + checked_label_num++; + } + else if (label.name == "service_instance_id") + { + ASSERT_EQ(label.value, "localhost:8001"); + checked_label_num++; + } + else if (label.name == "custom_resource_attr") + { + ASSERT_EQ(label.value, "custom_resource_value"); + checked_label_num++; + } + } + ASSERT_EQ(checked_label_num, 3); } class SanitizeTest : public ::testing::Test @@ -152,7 +237,11 @@ class SanitizeTest : public ::testing::Test metric_sdk::InstrumentValueType::kDouble}; std::vector result = PrometheusExporterUtils::TranslateToPrometheus( {&resource_, - {{instrumentation_scope_.get(), {{instrument_descriptor, {}, {}, {}, {{{}, {}}}}}}}}); + std::vector{ + {instrumentation_scope_.get(), + std::vector{ + {{instrument_descriptor, {}, {}, {}, {{{}, {}}}}}}}}}, + false); EXPECT_EQ(result.begin()->name, sanitized + "_unit"); } @@ -163,8 +252,11 @@ class SanitizeTest : public ::testing::Test metric_sdk::InstrumentValueType::kDouble}; std::vector result = PrometheusExporterUtils::TranslateToPrometheus( {&resource_, - {{instrumentation_scope_.get(), - {{instrument_descriptor, {}, {}, {}, {{{{original, "value"}}, {}}}}}}}}); + std::vector{ + {instrumentation_scope_.get(), + std::vector{ + {instrument_descriptor, {}, {}, {}, {{{{original, "value"}}, {}}}}}}}}, + false); EXPECT_EQ(result.begin()->metric.begin()->label.begin()->name, sanitized); } }; @@ -204,8 +296,24 @@ class AttributeCollisionTest : public ::testing::Test { std::vector result = PrometheusExporterUtils::TranslateToPrometheus( {&resource_, - {{instrumentation_scope_.get(), {{instrument_descriptor_, {}, {}, {}, {{attrs, {}}}}}}}}); - EXPECT_EQ(result.begin()->metric.begin()->label, expected); + std::vector{ + {instrumentation_scope_.get(), + std::vector{ + {instrument_descriptor_, {}, {}, {}, {{attrs, {}}}}}}}}, + false); + for (auto &expected_kv : expected) + { + bool found = false; + for (auto &found_kv : result.begin()->metric.begin()->label) + { + if (found_kv.name == expected_kv.name) + { + EXPECT_EQ(found_kv.value, expected_kv.value); + found = true; + } + } + EXPECT_TRUE(found); + } } }; diff --git a/sdk/include/opentelemetry/sdk/metrics/export/metric_producer.h b/sdk/include/opentelemetry/sdk/metrics/export/metric_producer.h index 2a0c87fcaa..11eb113e1e 100644 --- a/sdk/include/opentelemetry/sdk/metrics/export/metric_producer.h +++ b/sdk/include/opentelemetry/sdk/metrics/export/metric_producer.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include "opentelemetry/nostd/function_ref.h" @@ -31,14 +32,41 @@ namespace metrics */ struct ScopeMetrics { - const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope_; + const opentelemetry::sdk::instrumentationscope::InstrumentationScope *scope_ = nullptr; std::vector metric_data_; + + template + inline ScopeMetrics(ScopePtr &&scope, MetricDataType &&metric) + : scope_{std::forward(scope)}, metric_data_{std::forward(metric)} + {} + + inline ScopeMetrics() {} + inline ScopeMetrics(const ScopeMetrics &) = default; + inline ScopeMetrics(ScopeMetrics &&) = default; + + inline ScopeMetrics &operator=(const ScopeMetrics &) = default; + + inline ScopeMetrics &operator=(ScopeMetrics &&) = default; }; struct ResourceMetrics { - const opentelemetry::sdk::resource::Resource *resource_; + const opentelemetry::sdk::resource::Resource *resource_ = nullptr; std::vector scope_metric_data_; + + template + inline ResourceMetrics(ResourcePtr &&resource, ScopeMetricsType &&scope_metric_data) + : resource_{std::forward(resource)}, + scope_metric_data_{std::forward(scope_metric_data)} + {} + + inline ResourceMetrics() {} + inline ResourceMetrics(const ResourceMetrics &) = default; + inline ResourceMetrics(ResourceMetrics &&) = default; + + inline ResourceMetrics &operator=(const ResourceMetrics &) = default; + + inline ResourceMetrics &operator=(ResourceMetrics &&) = default; }; /** From 05b26cae87acab7cdf3156941ece03acf8bd045f Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Tue, 10 Oct 2023 01:30:27 +0200 Subject: [PATCH 03/29] =?UTF-8?q?[BUILD]=20error:=20read-only=20reference?= =?UTF-8?q?=20=E2=80=98value=E2=80=99=20used=20as=20=E2=80=98asm=E2=80=99?= =?UTF-8?q?=20output=20(#2354)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/test/trace/sampler_benchmark.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sdk/test/trace/sampler_benchmark.cc b/sdk/test/trace/sampler_benchmark.cc index 42de190980..ec188b84a1 100644 --- a/sdk/test/trace/sampler_benchmark.cc +++ b/sdk/test/trace/sampler_benchmark.cc @@ -42,6 +42,11 @@ void BM_AlwaysOnSamplerConstruction(benchmark::State &state) } BENCHMARK(BM_AlwaysOnSamplerConstruction); +/* + Fails to build with GCC. + See upstream bug: https://github.com/google/benchmark/issues/1675 +*/ +#if 0 void BM_ParentBasedSamplerConstruction(benchmark::State &state) { while (state.KeepRunning()) @@ -59,6 +64,7 @@ void BM_TraceIdRatioBasedSamplerConstruction(benchmark::State &state) } } BENCHMARK(BM_TraceIdRatioBasedSamplerConstruction); +#endif // Sampler Helper Function void BenchmarkShouldSampler(Sampler &sampler, benchmark::State &state) From 18a27df365e0c347bd54db47341575e6b232dba0 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Tue, 10 Oct 2023 08:59:03 +0200 Subject: [PATCH 04/29] Fixes #2352 (#2353) --- exporters/otlp/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index 8a93d34acc..adab87ff02 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -342,7 +342,8 @@ if(BUILD_TESTING) ${GMOCK_LIB} opentelemetry_exporter_otlp_http_log opentelemetry_logs - opentelemetry_http_client_nosend) + opentelemetry_http_client_nosend + nlohmann_json::nlohmann_json) gtest_add_tests( TARGET otlp_http_log_record_exporter_test TEST_PREFIX exporter.otlp. From df96b7429a635349ec5aa355716548ce4f184d90 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 11 Oct 2023 11:17:26 +0200 Subject: [PATCH 05/29] [BUILD] Upgrade libcurl to version 8.4.0 (#2358) --- bazel/repository.bzl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bazel/repository.bzl b/bazel/repository.bzl index dd02fc98fc..7e09e299cf 100644 --- a/bazel/repository.bzl +++ b/bazel/repository.bzl @@ -145,11 +145,11 @@ def opentelemetry_cpp_deps(): http_archive, name = "curl", build_file = "@io_opentelemetry_cpp//bazel:curl.BUILD", - sha256 = "ba98332752257b47b9dea6d8c0ad25ec1745c20424f1dd3ff2c99ab59e97cf91", - strip_prefix = "curl-7.73.0", + sha256 = "816e41809c043ff285e8c0f06a75a1fa250211bbfb2dc0a037eeef39f1a9e427", + strip_prefix = "curl-8.4.0", urls = [ - "https://curl.haxx.se/download/curl-7.73.0.tar.gz", - "https://github.com/curl/curl/releases/download/curl-7_73_0/curl-7.73.0.tar.gz", + "https://curl.haxx.se/download/curl-8.4.0.tar.gz", + "https://github.com/curl/curl/releases/download/curl-8_4_0/curl-8.4.0.tar.gz", ], ) From 2c4b2a910c56ec60bcce0ba86a3296d59d121061 Mon Sep 17 00:00:00 2001 From: andremarianiello Date: Wed, 11 Oct 2023 13:18:32 -0400 Subject: [PATCH 06/29] Fix behavior of opentracing-shim when added as subdirectory of a larger project (#2356) --- opentracing-shim/CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/opentracing-shim/CMakeLists.txt b/opentracing-shim/CMakeLists.txt index 5f83de5474..b77b9c1985 100644 --- a/opentracing-shim/CMakeLists.txt +++ b/opentracing-shim/CMakeLists.txt @@ -14,10 +14,13 @@ target_include_directories( "$") if(OPENTRACING_DIR) - include_directories( - "${CMAKE_BINARY_DIR}/${OPENTRACING_DIR}/include" - "${CMAKE_SOURCE_DIR}/${OPENTRACING_DIR}/include" - "${CMAKE_SOURCE_DIR}/${OPENTRACING_DIR}/3rd_party/include") + target_include_directories( + ${this_target} + PUBLIC + "$" + "$" + "$" + ) target_link_libraries(${this_target} opentelemetry_api opentracing) else() target_link_libraries(${this_target} opentelemetry_api From 3ff4b4c1f7e25c192ce0ebd1d27c611f7c081e04 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Sat, 14 Oct 2023 19:35:10 +0800 Subject: [PATCH 07/29] Fix protoc searching with non-imported protobuf::protoc target. (#2362) --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10c1a0ab6f..f57ce47779 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -430,6 +430,11 @@ if(WITH_OTLP_GRPC OR WITH_OTLP_HTTP) if(TARGET protobuf::protoc) project_build_tools_get_imported_location(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc) + # If protobuf::protoc is not a imported target, then we use the target + # directly for fallback + if(NOT PROTOBUF_PROTOC_EXECUTABLE) + set(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc) + endif() elseif(Protobuf_PROTOC_EXECUTABLE) # Some versions of FindProtobuf.cmake uses mixed case instead of uppercase set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE}) From cbee4de0ece961396742850ad426c9d9df830702 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Mon, 16 Oct 2023 15:00:24 +0800 Subject: [PATCH 08/29] [BUILD] Support to use different cmake package CONFIG of dependencies. (#2263) --- CMakeLists.txt | 1 + cmake/patch-imported-config.cmake | 141 ++++++++++++++++++++++++++++++ cmake/tools.cmake | 80 +++++++++++++++++ 3 files changed, 222 insertions(+) create mode 100644 cmake/patch-imported-config.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f57ce47779..4af81bf0e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -688,6 +688,7 @@ if(NOT WITH_API_ONLY) endif() include(cmake/opentelemetry-build-external-component.cmake) +include(cmake/patch-imported-config.cmake) if(OPENTELEMETRY_INSTALL) # Export cmake config and support find_packages(opentelemetry-cpp CONFIG) diff --git a/cmake/patch-imported-config.cmake b/cmake/patch-imported-config.cmake new file mode 100644 index 0000000000..ec68d74099 --- /dev/null +++ b/cmake/patch-imported-config.cmake @@ -0,0 +1,141 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +# Some prebuilt or installed targets may have different CONFIG settings than +# what we use to configure otel-cpp. This file applies patches to the imported +# targets in order to use compatible CONFIG settings for fallback. + +# Common dependencies +project_build_tools_patch_default_imported_config(ZLIB::ZLIB) + +# protobuf targets +if(Protobuf_FOUND OR PROTOBUF_FOUND) + project_build_tools_patch_default_imported_config( + utf8_range::utf8_range utf8_range::utf8_validity protobuf::libprotobuf-lite + protobuf::libprotobuf protobuf::libprotoc) +endif() + +# cares targets +if(TARGET c-ares::cares) + project_build_tools_patch_default_imported_config(c-ares::cares) +endif() + +# curl targets +if(TARGET CURL::libcurl) + project_build_tools_patch_default_imported_config(CURL::libcurl) +endif() + +# abseil targets +if(WITH_ABSEIL) + project_build_tools_patch_default_imported_config( + absl::bad_variant_access + absl::raw_logging_internal + absl::log_severity + absl::log_internal_check_op + absl::log_internal_nullguard + absl::strings + absl::strings_internal + absl::base + absl::spinlock_wait + absl::int128 + absl::throw_delegate + absl::log_internal_message + absl::examine_stack + absl::stacktrace + absl::debugging_internal + absl::symbolize + absl::demangle_internal + absl::malloc_internal + absl::log_internal_format + absl::log_internal_globals + absl::time + absl::civil_time + absl::time_zone + absl::str_format_internal + absl::log_internal_proto + absl::log_internal_log_sink_set + absl::log_globals + absl::hash + absl::city + absl::bad_optional_access + absl::low_level_hash + absl::log_entry + absl::log_sink + absl::synchronization + absl::graphcycles_internal + absl::strerror + absl::log_internal_conditions + absl::cord + absl::cord_internal + absl::crc_cord_state + absl::crc32c + absl::crc_cpu_detect + absl::crc_internal + absl::cordz_functions + absl::exponential_biased + absl::cordz_info + absl::cordz_handle + absl::leak_check + absl::die_if_null + absl::flags + absl::flags_commandlineflag + absl::flags_commandlineflag_internal + absl::flags_config + absl::flags_program_name + absl::flags_internal + absl::flags_marshalling + absl::flags_reflection + absl::flags_private_handle_accessor + absl::raw_hash_set + absl::hashtablez_sampler + absl::log_initialize + absl::status + absl::statusor) +endif() + +# gRPC targets +if(TARGET gRPC::grpc++) + project_build_tools_patch_default_imported_config( + gRPC::cares + gRPC::re2 + gRPC::ssl + gRPC::crypto + gRPC::zlibstatic + gRPC::address_sorting + gRPC::gpr + gRPC::grpc + gRPC::grpc_unsecure + gRPC::grpc++ + gRPC::grpc++_alts + gRPC::grpc++_error_details + gRPC::grpc++_reflection + gRPC::grpc++_unsecure + gRPC::grpc_authorization_provider + gRPC::grpc_plugin_support + gRPC::grpcpp_channelz + gRPC::upb) +endif() + +# prometheus targets +if(TARGET prometheus-cpp::core) + project_build_tools_patch_default_imported_config( + prometheus-cpp::core prometheus-cpp::pull prometheus-cpp::push) +endif() + +# civetweb targets +if(TARGET civetweb::civetweb) + project_build_tools_patch_default_imported_config( + civetweb::civetweb civetweb::server civetweb::civetweb-cpp) +endif() + +if(BUILD_TESTING) + project_build_tools_patch_default_imported_config( + GTest::gtest + GTest::gtest_main + GTest::gmock + GTest::gmock_main + GTest::GTest + GTest::Main + benchmark::benchmark + benchmark::benchmark_main) +endif() diff --git a/cmake/tools.cmake b/cmake/tools.cmake index 345fc88ff7..ee191121ca 100644 --- a/cmake/tools.cmake +++ b/cmake/tools.cmake @@ -117,3 +117,83 @@ function(project_build_tools_get_imported_location OUTPUT_VAR_NAME TARGET_NAME) PARENT_SCOPE) endif() endfunction() + +#[[ +If we build third party packages with a different CONFIG setting from building +otel-cpp, cmake may not find a suitable file in imported targets (#705, #1359) +when linking. But on some platforms, different CONFIG settings can be used when +these CONFIG settings have the same ABI. For example, on Linux, we can build +gRPC and protobuf with -DCMAKE_BUILD_TYPE=Release, but build otel-cpp with +-DCMAKE_BUILD_TYPE=Debug and link these libraries together. +The properties of imported targets can be found here: +https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-targets +]] +function(project_build_tools_patch_default_imported_config) + set(PATCH_VARS + IMPORTED_IMPLIB + IMPORTED_LIBNAME + IMPORTED_LINK_DEPENDENT_LIBRARIES + IMPORTED_LINK_INTERFACE_LANGUAGES + IMPORTED_LINK_INTERFACE_LIBRARIES + IMPORTED_LINK_INTERFACE_MULTIPLICITY + IMPORTED_LOCATION + IMPORTED_NO_SONAME + IMPORTED_OBJECTS + IMPORTED_SONAME) + foreach(TARGET_NAME ${ARGN}) + if(TARGET ${TARGET_NAME}) + get_target_property(IS_IMPORTED_TARGET ${TARGET_NAME} IMPORTED) + if(NOT IS_IMPORTED_TARGET) + continue() + endif() + + if(CMAKE_VERSION VERSION_LESS "3.19.0") + get_target_property(TARGET_TYPE_NAME ${TARGET_NAME} TYPE) + if(TARGET_TYPE_NAME STREQUAL "INTERFACE_LIBRARY") + continue() + endif() + endif() + + get_target_property(DO_NOT_OVERWRITE ${TARGET_NAME} IMPORTED_LOCATION) + if(DO_NOT_OVERWRITE) + continue() + endif() + + # MSVC's STL and debug level must match the target, so we can only move + # out IMPORTED_LOCATION_NOCONFIG + if(MSVC) + set(PATCH_IMPORTED_CONFIGURATION "NOCONFIG") + else() + get_target_property(PATCH_IMPORTED_CONFIGURATION ${TARGET_NAME} + IMPORTED_CONFIGURATIONS) + endif() + + if(NOT PATCH_IMPORTED_CONFIGURATION) + continue() + endif() + + get_target_property(PATCH_TARGET_LOCATION ${TARGET_NAME} + "IMPORTED_LOCATION_${PATCH_IMPORTED_CONFIGURATION}") + if(NOT PATCH_TARGET_LOCATION) + continue() + endif() + + foreach(PATCH_IMPORTED_KEY IN LISTS PATCH_VARS) + get_target_property( + PATCH_IMPORTED_VALUE ${TARGET_NAME} + "${PATCH_IMPORTED_KEY}_${PATCH_IMPORTED_CONFIGURATION}") + if(PATCH_IMPORTED_VALUE) + set_target_properties( + ${TARGET_NAME} PROPERTIES "${PATCH_IMPORTED_KEY}" + "${PATCH_IMPORTED_VALUE}") + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + message( + STATUS + "Patch: ${TARGET_NAME} ${PATCH_IMPORTED_KEY} will use ${PATCH_IMPORTED_KEY}_${PATCH_IMPORTED_CONFIGURATION}(\"${PATCH_IMPORTED_VALUE}\") by default." + ) + endif() + endif() + endforeach() + endif() + endforeach() +endfunction() From f2cbf02ec167729cedb177f4b85133121513a796 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 16 Oct 2023 09:38:30 +0200 Subject: [PATCH 09/29] [SEMANTIC CONVENTION] Upgrade to semconv 1.22.0 (#2368) --- .../trace/semantic_conventions.h | 1832 ++++++++++------- buildscripts/semantic-convention/generate.sh | 4 +- examples/grpc/client.cc | 4 +- .../sdk/resource/semantic_conventions.h | 496 +++-- 4 files changed, 1370 insertions(+), 966 deletions(-) diff --git a/api/include/opentelemetry/trace/semantic_conventions.h b/api/include/opentelemetry/trace/semantic_conventions.h index c46b41bc52..16d6562ee9 100644 --- a/api/include/opentelemetry/trace/semantic_conventions.h +++ b/api/include/opentelemetry/trace/semantic_conventions.h @@ -22,285 +22,291 @@ namespace SemanticConventions /** * The URL of the OpenTelemetry schema for these keys and values. */ -static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.21.0"; +static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.22.0"; /** - * Client address - unix domain socket name, IPv4 or IPv6 address. + * Client address - domain name if available without reverse DNS lookup, otherwise IP address or + Unix domain socket name. * *

Notes:

  • When observed from the server side, and when communicating through an intermediary, - {@code client.address} SHOULD represent client address behind any intermediaries (e.g. proxies) if - it's available.
+ {@code client.address} SHOULD represent the client address behind any intermediaries (e.g. proxies) + if it's available. */ static constexpr const char *kClientAddress = "client.address"; /** - * Client port number + * Client port number. * *

Notes:

  • When observed from the server side, and when communicating through an intermediary, - {@code client.port} SHOULD represent client port behind any intermediaries (e.g. proxies) if it's - available.
+ {@code client.port} SHOULD represent the client port behind any intermediaries (e.g. proxies) if + it's available. */ static constexpr const char *kClientPort = "client.port"; /** - * Immediate client peer address - unix domain socket name, IPv4 or IPv6 address. - */ -static constexpr const char *kClientSocketAddress = "client.socket.address"; - -/** - * Immediate client peer port number + * Deprecated, use {@code server.address}. + * + * @deprecated Deprecated, use `server.address`. */ -static constexpr const char *kClientSocketPort = "client.socket.port"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetHostName = "net.host.name"; /** - * Deprecated, use {@code http.request.method} instead. + * Deprecated, use {@code server.port}. * - * @deprecated Deprecated, use `http.request.method` instead. + * @deprecated Deprecated, use `server.port`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpMethod = "http.method"; +static constexpr const char *kNetHostPort = "net.host.port"; /** - * Deprecated, use {@code http.response.status_code} instead. + * Deprecated, use {@code server.address} on client spans and {@code client.address} on server + * spans. * - * @deprecated Deprecated, use `http.response.status_code` instead. + * @deprecated Deprecated, use `server.address` on client spans and `client.address` on server + * spans. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpStatusCode = "http.status_code"; +static constexpr const char *kNetPeerName = "net.peer.name"; /** - * Deprecated, use {@code url.scheme} instead. + * Deprecated, use {@code server.port} on client spans and {@code client.port} on server spans. * - * @deprecated Deprecated, use `url.scheme` instead. + * @deprecated Deprecated, use `server.port` on client spans and `client.port` on server spans. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpScheme = "http.scheme"; +static constexpr const char *kNetPeerPort = "net.peer.port"; /** - * Deprecated, use {@code url.full} instead. + * Deprecated, use {@code network.protocol.name}. * - * @deprecated Deprecated, use `url.full` instead. + * @deprecated Deprecated, use `network.protocol.name`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpUrl = "http.url"; +static constexpr const char *kNetProtocolName = "net.protocol.name"; /** - * Deprecated, use {@code url.path} and {@code url.query} instead. + * Deprecated, use {@code network.protocol.version}. * - * @deprecated Deprecated, use `url.path` and `url.query` instead. + * @deprecated Deprecated, use `network.protocol.version`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpTarget = "http.target"; +static constexpr const char *kNetProtocolVersion = "net.protocol.version"; /** - * Deprecated, use {@code http.request.body.size} instead. + * Deprecated, use {@code network.transport} and {@code network.type}. * - * @deprecated Deprecated, use `http.request.body.size` instead. + * @deprecated Deprecated, use `network.transport` and `network.type`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpRequestContentLength = "http.request_content_length"; +static constexpr const char *kNetSockFamily = "net.sock.family"; /** - * Deprecated, use {@code http.response.body.size} instead. + * Deprecated, use {@code network.local.address}. * - * @deprecated Deprecated, use `http.response.body.size` instead. + * @deprecated Deprecated, use `network.local.address`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpResponseContentLength = "http.response_content_length"; +static constexpr const char *kNetSockHostAddr = "net.sock.host.addr"; /** - * Deprecated, use {@code server.socket.domain} on client spans. + * Deprecated, use {@code network.local.port}. * - * @deprecated Deprecated, use `server.socket.domain` on client spans. + * @deprecated Deprecated, use `network.local.port`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockPeerName = "net.sock.peer.name"; +static constexpr const char *kNetSockHostPort = "net.sock.host.port"; /** - * Deprecated, use {@code server.socket.address} on client spans and {@code client.socket.address} - * on server spans. + * Deprecated, use {@code network.peer.address}. * - * @deprecated Deprecated, use `server.socket.address` on client spans and `client.socket.address` - * on server spans. + * @deprecated Deprecated, use `network.peer.address`. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kNetSockPeerAddr = "net.sock.peer.addr"; /** - * Deprecated, use {@code server.socket.port} on client spans and {@code client.socket.port} on - * server spans. + * Deprecated, no replacement at this time. * - * @deprecated Deprecated, use `server.socket.port` on client spans and `client.socket.port` on - * server spans. + * @deprecated Deprecated, no replacement at this time. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockPeerPort = "net.sock.peer.port"; +static constexpr const char *kNetSockPeerName = "net.sock.peer.name"; /** - * Deprecated, use {@code server.address} on client spans and {@code client.address} on server - * spans. + * Deprecated, use {@code network.peer.port}. * - * @deprecated Deprecated, use `server.address` on client spans and `client.address` on server - * spans. + * @deprecated Deprecated, use `network.peer.port`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetPeerName = "net.peer.name"; +static constexpr const char *kNetSockPeerPort = "net.sock.peer.port"; /** - * Deprecated, use {@code server.port} on client spans and {@code client.port} on server spans. + * Deprecated, use {@code network.transport}. * - * @deprecated Deprecated, use `server.port` on client spans and `client.port` on server spans. + * @deprecated Deprecated, use `network.transport`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetPeerPort = "net.peer.port"; +static constexpr const char *kNetTransport = "net.transport"; /** - * Deprecated, use {@code server.address}. + * Destination address - domain name if available without reverse DNS lookup, otherwise IP address + or Unix domain socket name. * - * @deprecated Deprecated, use `server.address`. + *

Notes: +

  • When observed from the source side, and when communicating through an intermediary, + {@code destination.address} SHOULD represent the destination address behind any intermediaries + (e.g. proxies) if it's available.
*/ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetHostName = "net.host.name"; +static constexpr const char *kDestinationAddress = "destination.address"; /** - * Deprecated, use {@code server.port}. - * - * @deprecated Deprecated, use `server.port`. + * Destination port number */ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetHostPort = "net.host.port"; +static constexpr const char *kDestinationPort = "destination.port"; /** - * Deprecated, use {@code server.socket.address}. + * Describes a class of error the operation ended with. * - * @deprecated Deprecated, use `server.socket.address`. + *

Notes: +

  • The {@code error.type} SHOULD be predictable and SHOULD have low cardinality. +Instrumentations SHOULD document the list of errors they report.
  • The cardinality of {@code +error.type} within one instrumentation library SHOULD be low, but telemetry consumers that aggregate +data from multiple instrumentation libraries and applications should be prepared for {@code +error.type} to have high cardinality at query time, when no additional filters are +applied.
  • If the operation has completed successfully, instrumentations SHOULD NOT set {@code +error.type}.
  • If a specific domain defines its own set of error codes (such as HTTP or gRPC +status codes), it's RECOMMENDED to use a domain-specific attribute and also set {@code error.type} +to capture all errors, regardless of whether they are defined within the domain-specific set or +not.
*/ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockHostAddr = "net.sock.host.addr"; +static constexpr const char *kErrorType = "error.type"; /** - * Deprecated, use {@code server.socket.port}. - * - * @deprecated Deprecated, use `server.socket.port`. + * The exception message. */ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockHostPort = "net.sock.host.port"; +static constexpr const char *kExceptionMessage = "exception.message"; /** - * Deprecated, use {@code network.transport}. - * - * @deprecated Deprecated, use `network.transport`. + * A stacktrace as a string in the natural representation for the language runtime. The + * representation is to be determined and documented by each language SIG. */ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetTransport = "net.transport"; +static constexpr const char *kExceptionStacktrace = "exception.stacktrace"; /** - * Deprecated, use {@code network.protocol.name}. - * - * @deprecated Deprecated, use `network.protocol.name`. + * The type of the exception (its fully-qualified class name, if applicable). The dynamic type of + * the exception should be preferred over the static type in languages that support it. */ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetProtocolName = "net.protocol.name"; +static constexpr const char *kExceptionType = "exception.type"; /** - * Deprecated, use {@code network.protocol.version}. + * The name of the invoked function. * - * @deprecated Deprecated, use `network.protocol.version`. + *

Notes: +

  • SHOULD be equal to the {@code faas.name} resource attribute of the invoked function.
  • +
*/ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetProtocolVersion = "net.protocol.version"; +static constexpr const char *kFaasInvokedName = "faas.invoked_name"; /** - * Deprecated, use {@code network.transport} and {@code network.type}. + * The cloud provider of the invoked function. * - * @deprecated Deprecated, use `network.transport` and `network.type`. + *

Notes: +

  • SHOULD be equal to the {@code cloud.provider} resource attribute of the invoked + function.
*/ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockFamily = "net.sock.family"; +static constexpr const char *kFaasInvokedProvider = "faas.invoked_provider"; /** - * The domain name of the destination system. + * The cloud region of the invoked function. * *

Notes: -

  • This value may be a host name, a fully qualified domain name, or another host naming - format.
+
  • SHOULD be equal to the {@code cloud.region} resource attribute of the invoked + function.
*/ -static constexpr const char *kDestinationDomain = "destination.domain"; +static constexpr const char *kFaasInvokedRegion = "faas.invoked_region"; /** - * Peer address, for example IP address or UNIX socket name. + * Type of the trigger which caused this function invocation. */ -static constexpr const char *kDestinationAddress = "destination.address"; +static constexpr const char *kFaasTrigger = "faas.trigger"; /** - * Peer port number + * The {@code service.name} of the remote service. + * SHOULD be equal to the actual {@code service.name} resource attribute of the remote service if + * any. */ -static constexpr const char *kDestinationPort = "destination.port"; +static constexpr const char *kPeerService = "peer.service"; /** - * The type of the exception (its fully-qualified class name, if applicable). The dynamic type of - * the exception should be preferred over the static type in languages that support it. + * Username or client_id extracted from the access token or Authorization header in the inbound + * request from outside the system. */ -static constexpr const char *kExceptionType = "exception.type"; +static constexpr const char *kEnduserId = "enduser.id"; /** - * The exception message. + * Actual/assumed role the client is making the request under extracted from token or application + * security context. */ -static constexpr const char *kExceptionMessage = "exception.message"; +static constexpr const char *kEnduserRole = "enduser.role"; /** - * A stacktrace as a string in the natural representation for the language runtime. The - * representation is to be determined and documented by each language SIG. + * Scopes or granted authorities the client currently possesses extracted from token or application + * security context. The value would come from the scope associated with an OAuth 2.0 Access Token or an attribute + * value in a SAML 2.0 + * Assertion. */ -static constexpr const char *kExceptionStacktrace = "exception.stacktrace"; +static constexpr const char *kEnduserScope = "enduser.scope"; /** - * HTTP request method. - * - *

Notes: -

  • HTTP request method value SHOULD be "known" to the instrumentation. -By default, this convention defines "known" methods as the ones listed in RFC9110 and the PATCH method -defined in RFC5789.
  • If the HTTP -request method is not known to instrumentation, it MUST set the {@code http.request.method} -attribute to {@code _OTHER} and, except if reporting a metric, MUST set the exact method received in -the request line as value of the {@code http.request.method_original} attribute.
  • If the HTTP -instrumentation could end up converting valid HTTP request methods to {@code _OTHER}, then it MUST -provide a way to override the list of known HTTP methods. If this override is done via environment -variable, then the environment variable MUST be named OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS and -support a comma-separated list of case-sensitive known HTTP methods (this list MUST be a full -override of the default known method, it is not a list of known methods in addition to the -defaults).
  • HTTP method names are case-sensitive and {@code http.request.method} attribute -value MUST match a known HTTP method name exactly. Instrumentations for specific web frameworks that -consider HTTP methods to be case insensitive, SHOULD populate a canonical equivalent. Tracing -instrumentations that do so, MUST also set {@code http.request.method_original} to the original -value.
+ * Whether the thread is daemon or not. */ -static constexpr const char *kHttpRequestMethod = "http.request.method"; +static constexpr const char *kThreadDaemon = "thread.daemon"; /** - * HTTP response status code. + * Current "managed" thread ID (as opposed to OS thread ID). */ -static constexpr const char *kHttpResponseStatusCode = "http.response.status_code"; +static constexpr const char *kThreadId = "thread.id"; /** - * The matched route (path template in the format used by the respective server framework). See note -below - * - *

Notes: -

  • MUST NOT be populated when this is not supported by the HTTP server framework as the -route attribute should have low-cardinality and the URI path can NOT substitute it. SHOULD include -the application root if there is -one.
+ * Current thread name. */ -static constexpr const char *kHttpRoute = "http.route"; +static constexpr const char *kThreadName = "thread.name"; /** - * The name identifies the event. + * The column number in {@code code.filepath} best representing the operation. It SHOULD point + * within the code unit named in {@code code.function}. */ -static constexpr const char *kEventName = "event.name"; +static constexpr const char *kCodeColumn = "code.column"; + +/** + * The source code file name that identifies the code unit as uniquely as possible (preferably an + * absolute file path). + */ +static constexpr const char *kCodeFilepath = "code.filepath"; + +/** + * The method or function name, or equivalent (usually rightmost part of the code unit's name). + */ +static constexpr const char *kCodeFunction = "code.function"; + +/** + * The line number in {@code code.filepath} best representing the operation. It SHOULD point within + * the code unit named in {@code code.function}. + */ +static constexpr const char *kCodeLineno = "code.lineno"; + +/** + * The "namespace" within which {@code code.function} is defined. Usually the qualified + * class or module name, such that {@code code.namespace} + some separator + {@code code.function} + * form a unique identifier for the code unit. + */ +static constexpr const char *kCodeNamespace = "code.namespace"; /** * The domain identifies the business context for the events. @@ -311,6 +317,11 @@ unrelated events. */ static constexpr const char *kEventDomain = "event.domain"; +/** + * The name identifies the event. + */ +static constexpr const char *kEventName = "event.name"; + /** * A unique identifier for the Log Record. * @@ -333,14 +344,14 @@ static constexpr const char *kLogIostream = "log.iostream"; static constexpr const char *kLogFileName = "log.file.name"; /** - * The full path to the file. + * The basename of the file, with symlinks resolved. */ -static constexpr const char *kLogFilePath = "log.file.path"; +static constexpr const char *kLogFileNameResolved = "log.file.name_resolved"; /** - * The basename of the file, with symlinks resolved. + * The full path to the file. */ -static constexpr const char *kLogFileNameResolved = "log.file.name_resolved"; +static constexpr const char *kLogFilePath = "log.file.path"; /** * The full path to the file, with symlinks resolved. @@ -348,9 +359,27 @@ static constexpr const char *kLogFileNameResolved = "log.file.name_resolved"; static constexpr const char *kLogFilePathResolved = "log.file.path_resolved"; /** - * The type of memory. + * The name of the connection pool; unique within the instrumented application. In case the + * connection pool implementation does not provide a name, then the db.connection_string + * should be used + */ +static constexpr const char *kPoolName = "pool.name"; + +/** + * The state of a connection in the pool + */ +static constexpr const char *kState = "state"; + +/** + * Name of the buffer pool. + * + *

Notes: +

*/ -static constexpr const char *kType = "type"; +static constexpr const char *kJvmBufferPoolName = "jvm.buffer.pool.name"; /** * Name of the memory pool. @@ -360,570 +389,669 @@ static constexpr const char *kType = "type"; href="https://docs.oracle.com/en/java/javase/11/docs/api/java.management/java/lang/management/MemoryPoolMXBean.html#getName()">MemoryPoolMXBean#getName(). */ -static constexpr const char *kPool = "pool"; +static constexpr const char *kJvmMemoryPoolName = "jvm.memory.pool.name"; /** - * Logical server hostname, matches server FQDN if available, and IP or socket address if FQDN is - * not known. + * The type of memory. */ -static constexpr const char *kServerAddress = "server.address"; +static constexpr const char *kJvmMemoryType = "jvm.memory.type"; /** - * Logical server port number + * The device identifier */ -static constexpr const char *kServerPort = "server.port"; +static constexpr const char *kSystemDevice = "system.device"; /** - * The domain name of an immediate peer. - * - *

Notes: -

  • Typically observed from the client side, and represents a proxy or other intermediary - domain name.
+ * The logical CPU number [0..n-1] */ -static constexpr const char *kServerSocketDomain = "server.socket.domain"; +static constexpr const char *kSystemCpuLogicalNumber = "system.cpu.logical_number"; /** - * Physical server IP address or Unix socket address. If set from the client, should simply use the - * socket's peer address, and not attempt to find any actual server IP (i.e., if set from client, - * this may represent some proxy server instead of the logical server). + * The state of the CPU */ -static constexpr const char *kServerSocketAddress = "server.socket.address"; +static constexpr const char *kSystemCpuState = "system.cpu.state"; /** - * Physical server port. + * The memory state */ -static constexpr const char *kServerSocketPort = "server.socket.port"; +static constexpr const char *kSystemMemoryState = "system.memory.state"; /** - * The domain name of the source system. - * - *

Notes: -

  • This value may be a host name, a fully qualified domain name, or another host naming - format.
+ * The paging access direction */ -static constexpr const char *kSourceDomain = "source.domain"; +static constexpr const char *kSystemPagingDirection = "system.paging.direction"; /** - * Source address, for example IP address or Unix socket name. + * The memory paging state */ -static constexpr const char *kSourceAddress = "source.address"; +static constexpr const char *kSystemPagingState = "system.paging.state"; /** - * Source port number + * The memory paging type */ -static constexpr const char *kSourcePort = "source.port"; +static constexpr const char *kSystemPagingType = "system.paging.type"; /** - * The full invoked ARN as provided on the {@code Context} passed to the function ({@code - Lambda-Runtime-Invoked-Function-Arn} header on the {@code /runtime/invocation/next} applicable). - * - *

Notes: -

  • This may be different from {@code cloud.resource_id} if an alias is involved.
+ * The disk operation direction */ -static constexpr const char *kAwsLambdaInvokedArn = "aws.lambda.invoked_arn"; +static constexpr const char *kSystemDiskDirection = "system.disk.direction"; /** - * The event_id - * uniquely identifies the event. + * The filesystem mode */ -static constexpr const char *kCloudeventsEventId = "cloudevents.event_id"; +static constexpr const char *kSystemFilesystemMode = "system.filesystem.mode"; /** - * The source - * identifies the context in which an event happened. + * The filesystem mount path */ -static constexpr const char *kCloudeventsEventSource = "cloudevents.event_source"; +static constexpr const char *kSystemFilesystemMountpoint = "system.filesystem.mountpoint"; /** - * The version of - * the CloudEvents specification which the event uses. + * The filesystem state */ -static constexpr const char *kCloudeventsEventSpecVersion = "cloudevents.event_spec_version"; +static constexpr const char *kSystemFilesystemState = "system.filesystem.state"; /** - * The event_type - * contains a value describing the type of event related to the originating occurrence. + * The filesystem type */ -static constexpr const char *kCloudeventsEventType = "cloudevents.event_type"; +static constexpr const char *kSystemFilesystemType = "system.filesystem.type"; /** - * The subject of - * the event in the context of the event producer (identified by source). + * */ -static constexpr const char *kCloudeventsEventSubject = "cloudevents.event_subject"; +static constexpr const char *kSystemNetworkDirection = "system.network.direction"; /** - * Parent-child Reference type - * - *

Notes: -

  • The causal relationship between a child Span and a parent Span.
+ * A stateless protocol MUST NOT set this attribute */ -static constexpr const char *kOpentracingRefType = "opentracing.ref_type"; +static constexpr const char *kSystemNetworkState = "system.network.state"; /** - * An identifier for the database management system (DBMS) product being used. See below for a list - * of well-known identifiers. + * The process state, e.g., Linux Process State + * Codes */ -static constexpr const char *kDbSystem = "db.system"; +static constexpr const char *kSystemProcessesStatus = "system.processes.status"; /** - * The connection string used to connect to the database. It is recommended to remove embedded - * credentials. + * Local address of the network connection - IP address or Unix domain socket name. */ -static constexpr const char *kDbConnectionString = "db.connection_string"; +static constexpr const char *kNetworkLocalAddress = "network.local.address"; /** - * Username for accessing the database. + * Local port number of the network connection. */ -static constexpr const char *kDbUser = "db.user"; +static constexpr const char *kNetworkLocalPort = "network.local.port"; /** - * The fully-qualified class name of the Java Database Connectivity - * (JDBC) driver used to connect. + * Peer address of the network connection - IP address or Unix domain socket name. */ -static constexpr const char *kDbJdbcDriverClassname = "db.jdbc.driver_classname"; +static constexpr const char *kNetworkPeerAddress = "network.peer.address"; /** - * This attribute is used to report the name of the database being accessed. For commands that - switch the database, this should be set to the target database (even if the command fails). + * Peer port number of the network connection. + */ +static constexpr const char *kNetworkPeerPort = "network.peer.port"; + +/** + * OSI application layer or non-OSI + equivalent. * *

Notes: -

  • In some SQL databases, the database name to be used is called "schema name". In - case there are multiple layers that could be considered for database name (e.g. Oracle instance - name and schema name), the database name to be used is the more specific layer (e.g. Oracle schema - name).
+
  • The value SHOULD be normalized to lowercase.
*/ -static constexpr const char *kDbName = "db.name"; +static constexpr const char *kNetworkProtocolName = "network.protocol.name"; /** - * The database statement being executed. + * Version of the protocol specified in {@code network.protocol.name}. + * + *

Notes: +

  • {@code network.protocol.version} refers to the version of the protocol used and might be + different from the protocol client's version. If the HTTP client used has a version of {@code + 0.27.2}, but sends HTTP version {@code 1.1}, this attribute should be set to {@code 1.1}.
  • +
*/ -static constexpr const char *kDbStatement = "db.statement"; +static constexpr const char *kNetworkProtocolVersion = "network.protocol.version"; /** - * The name of the operation being executed, e.g. the MongoDB command - name such as {@code findAndModify}, or the SQL keyword. + * OSI transport layer or inter-process communication +method. * *

Notes: -

  • When setting this to an SQL keyword, it is not recommended to attempt any client-side - parsing of {@code db.statement} just to get this property, but it should be set if the operation - name is provided by the library being instrumented. If the SQL statement has an ambiguous - operation, or performs more than one operation, this value may be omitted.
+
  • The value SHOULD be normalized to lowercase.
  • Consider always setting the +transport when setting a port number, since a port number is ambiguous without knowing the +transport, for example different processes could be listening on TCP port 12345 and UDP port +12345.
*/ -static constexpr const char *kDbOperation = "db.operation"; +static constexpr const char *kNetworkTransport = "network.transport"; /** - * The Microsoft SQL Server instance - name connecting to. This name is used to determine the port of a named instance. + * OSI network layer or non-OSI equivalent. * *

Notes: -

  • If setting a {@code db.mssql.instance_name}, {@code server.port} is no longer required - (but still recommended if non-standard).
+
  • The value SHOULD be normalized to lowercase.
*/ -static constexpr const char *kDbMssqlInstanceName = "db.mssql.instance_name"; +static constexpr const char *kNetworkType = "network.type"; /** - * The fetch size used for paging, i.e. how many rows will be returned at once. + * The ISO 3166-1 alpha-2 2-character country code associated with the mobile carrier network. */ -static constexpr const char *kDbCassandraPageSize = "db.cassandra.page_size"; +static constexpr const char *kNetworkCarrierIcc = "network.carrier.icc"; /** - * The consistency level of the query. Based on consistency values from CQL. + * The mobile carrier country code. */ -static constexpr const char *kDbCassandraConsistencyLevel = "db.cassandra.consistency_level"; +static constexpr const char *kNetworkCarrierMcc = "network.carrier.mcc"; /** - * The name of the primary table that the operation is acting upon, including the keyspace name (if - applicable). + * The mobile carrier network code. + */ +static constexpr const char *kNetworkCarrierMnc = "network.carrier.mnc"; + +/** + * The name of the mobile carrier. + */ +static constexpr const char *kNetworkCarrierName = "network.carrier.name"; + +/** + * This describes more details regarding the connection.type. It may be the type of cell technology + * connection, but it could be used for describing details about a wifi connection. + */ +static constexpr const char *kNetworkConnectionSubtype = "network.connection.subtype"; + +/** + * The internet connection type. + */ +static constexpr const char *kNetworkConnectionType = "network.connection.type"; + +/** + * Deprecated, use {@code http.request.method} instead. * - *

Notes: -

  • This mirrors the db.sql.table attribute but references cassandra rather than sql. It is - not recommended to attempt any client-side parsing of {@code db.statement} just to get this - property, but it should be set if it is provided by the library being instrumented. If the - operation is acting upon an anonymous table, or more than one table, this value MUST NOT be - set.
+ * @deprecated Deprecated, use `http.request.method` instead. */ -static constexpr const char *kDbCassandraTable = "db.cassandra.table"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpMethod = "http.method"; /** - * Whether or not the query is idempotent. + * Deprecated, use {@code http.request.body.size} instead. + * + * @deprecated Deprecated, use `http.request.body.size` instead. */ -static constexpr const char *kDbCassandraIdempotence = "db.cassandra.idempotence"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpRequestContentLength = "http.request_content_length"; /** - * The number of times a query was speculatively executed. Not set or {@code 0} if the query was not - * executed speculatively. + * Deprecated, use {@code http.response.body.size} instead. + * + * @deprecated Deprecated, use `http.response.body.size` instead. */ -static constexpr const char *kDbCassandraSpeculativeExecutionCount = - "db.cassandra.speculative_execution_count"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpResponseContentLength = "http.response_content_length"; /** - * The ID of the coordinating node for a query. + * Deprecated, use {@code url.scheme} instead. + * + * @deprecated Deprecated, use `url.scheme` instead. */ -static constexpr const char *kDbCassandraCoordinatorId = "db.cassandra.coordinator.id"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpScheme = "http.scheme"; /** - * The data center of the coordinating node for a query. + * Deprecated, use {@code http.response.status_code} instead. + * + * @deprecated Deprecated, use `http.response.status_code` instead. */ -static constexpr const char *kDbCassandraCoordinatorDc = "db.cassandra.coordinator.dc"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpStatusCode = "http.status_code"; /** - * The index of the database being accessed as used in the {@code SELECT} command, provided as an integer. To be - * used instead of the generic {@code db.name} attribute. + * Deprecated, use {@code url.path} and {@code url.query} instead. + * + * @deprecated Deprecated, use `url.path` and `url.query` instead. */ -static constexpr const char *kDbRedisDatabaseIndex = "db.redis.database_index"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpTarget = "http.target"; /** - * The collection being accessed within the database stated in {@code db.name}. + * Deprecated, use {@code url.full} instead. + * + * @deprecated Deprecated, use `url.full` instead. */ -static constexpr const char *kDbMongodbCollection = "db.mongodb.collection"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpUrl = "http.url"; /** - * The name of the primary table that the operation is acting upon, including the database name (if - applicable). + * The size of the request payload body in bytes. This is the number of bytes transferred excluding + * headers and is often, but not always, present as the Content-Length + * header. For requests using transport encoding, this should be the compressed size. + */ +static constexpr const char *kHttpRequestBodySize = "http.request.body.size"; + +/** + * HTTP request method. * *

Notes: -

  • It is not recommended to attempt any client-side parsing of {@code db.statement} just to - get this property, but it should be set if it is provided by the library being instrumented. If the - operation is acting upon an anonymous table, or more than one table, this value MUST NOT be - set.
+
  • HTTP request method value SHOULD be "known" to the instrumentation. +By default, this convention defines "known" methods as the ones listed in RFC9110 and the PATCH method +defined in RFC5789.
  • If the HTTP +request method is not known to instrumentation, it MUST set the {@code http.request.method} +attribute to {@code _OTHER}.
  • If the HTTP instrumentation could end up converting valid HTTP +request methods to {@code _OTHER}, then it MUST provide a way to override the list of known HTTP +methods. If this override is done via environment variable, then the environment variable MUST be +named OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS and support a comma-separated list of case-sensitive +known HTTP methods (this list MUST be a full override of the default known method, it is not a list +of known methods in addition to the defaults).
  • HTTP method names are case-sensitive and +{@code http.request.method} attribute value MUST match a known HTTP method name exactly. +Instrumentations for specific web frameworks that consider HTTP methods to be case insensitive, +SHOULD populate a canonical equivalent. Tracing instrumentations that do so, MUST also set {@code +http.request.method_original} to the original value.
*/ -static constexpr const char *kDbSqlTable = "db.sql.table"; +static constexpr const char *kHttpRequestMethod = "http.request.method"; /** - * Unique Cosmos client instance id. + * Original HTTP method sent by the client in the request line. */ -static constexpr const char *kDbCosmosdbClientId = "db.cosmosdb.client_id"; +static constexpr const char *kHttpRequestMethodOriginal = "http.request.method_original"; /** - * CosmosDB Operation Type. + * The ordinal number of request resending attempt (for any reason, including redirects). + * + *

Notes: +

  • The resend count SHOULD be updated each time an HTTP request gets resent by the client, + regardless of what was the cause of the resending (e.g. redirection, authorization failure, 503 + Server Unavailable, network issues, or any other).
*/ -static constexpr const char *kDbCosmosdbOperationType = "db.cosmosdb.operation_type"; +static constexpr const char *kHttpResendCount = "http.resend_count"; /** - * Cosmos client connection mode. + * The size of the response payload body in bytes. This is the number of bytes transferred excluding + * headers and is often, but not always, present as the Content-Length + * header. For requests using transport encoding, this should be the compressed size. */ -static constexpr const char *kDbCosmosdbConnectionMode = "db.cosmosdb.connection_mode"; +static constexpr const char *kHttpResponseBodySize = "http.response.body.size"; /** - * Cosmos DB container name. + * HTTP response status code. */ -static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; +static constexpr const char *kHttpResponseStatusCode = "http.response.status_code"; /** - * Request payload size in bytes + * The matched route (path template in the format used by the respective server framework). See note +below + * + *

Notes: +

  • MUST NOT be populated when this is not supported by the HTTP server framework as the +route attribute should have low-cardinality and the URI path can NOT substitute it. SHOULD include +the application root if there is +one.
*/ -static constexpr const char *kDbCosmosdbRequestContentLength = "db.cosmosdb.request_content_length"; +static constexpr const char *kHttpRoute = "http.route"; /** - * Cosmos DB status code. + * Server address - domain name if available without reverse DNS lookup, otherwise IP address or +Unix domain socket name. + * + *

Notes: +

  • When observed from the client side, and when communicating through an intermediary, +{@code server.address} SHOULD represent the server address behind any intermediaries (e.g. proxies) +if it's available.
*/ -static constexpr const char *kDbCosmosdbStatusCode = "db.cosmosdb.status_code"; +static constexpr const char *kServerAddress = "server.address"; /** - * Cosmos DB sub status code. + * Server port number. + * + *

Notes: +

  • When observed from the client side, and when communicating through an intermediary, + {@code server.port} SHOULD represent the server port behind any intermediaries (e.g. proxies) if + it's available.
*/ -static constexpr const char *kDbCosmosdbSubStatusCode = "db.cosmosdb.sub_status_code"; +static constexpr const char *kServerPort = "server.port"; /** - * RU consumed for that operation + * A unique id to identify a session. */ -static constexpr const char *kDbCosmosdbRequestCharge = "db.cosmosdb.request_charge"; +static constexpr const char *kSessionId = "session.id"; /** - * Name of the code, either "OK" or "ERROR". MUST NOT be set if the status code - * is UNSET. + * Source address - domain name if available without reverse DNS lookup, otherwise IP address or + Unix domain socket name. + * + *

Notes: +

  • When observed from the destination side, and when communicating through an intermediary, + {@code source.address} SHOULD represent the source address behind any intermediaries (e.g. proxies) + if it's available.
*/ -static constexpr const char *kOtelStatusCode = "otel.status_code"; +static constexpr const char *kSourceAddress = "source.address"; /** - * Description of the Status if it has a value, otherwise not set. + * Source port number */ -static constexpr const char *kOtelStatusDescription = "otel.status_description"; +static constexpr const char *kSourcePort = "source.port"; /** - * Type of the trigger which caused this function invocation. + * The full invoked ARN as provided on the {@code Context} passed to the function ({@code + Lambda-Runtime-Invoked-Function-Arn} header on the {@code /runtime/invocation/next} applicable). * *

Notes: -

  • For the server/consumer span on the incoming side, -{@code faas.trigger} MUST be set.
  • Clients invoking FaaS instances usually cannot set {@code -faas.trigger}, since they would typically need to look in the payload to determine the event type. -If clients set it, it should be the same as the trigger that corresponding incoming would have -(i.e., this has nothing to do with the underlying transport used to make the API call to invoke the -lambda, which is often HTTP).
+
  • This may be different from {@code cloud.resource_id} if an alias is involved.
*/ -static constexpr const char *kFaasTrigger = "faas.trigger"; +static constexpr const char *kAwsLambdaInvokedArn = "aws.lambda.invoked_arn"; /** - * The invocation ID of the current function invocation. + * The event_id + * uniquely identifies the event. */ -static constexpr const char *kFaasInvocationId = "faas.invocation_id"; +static constexpr const char *kCloudeventsEventId = "cloudevents.event_id"; /** - * The name of the source on which the triggering operation was performed. For example, in Cloud - * Storage or S3 corresponds to the bucket name, and in Cosmos DB to the database name. + * The source + * identifies the context in which an event happened. */ -static constexpr const char *kFaasDocumentCollection = "faas.document.collection"; +static constexpr const char *kCloudeventsEventSource = "cloudevents.event_source"; /** - * Describes the type of the operation that was performed on the data. + * The version of + * the CloudEvents specification which the event uses. */ -static constexpr const char *kFaasDocumentOperation = "faas.document.operation"; +static constexpr const char *kCloudeventsEventSpecVersion = "cloudevents.event_spec_version"; /** - * A string containing the time when the data was accessed in the ISO 8601 format expressed in UTC. + * The subject of + * the event in the context of the event producer (identified by source). */ -static constexpr const char *kFaasDocumentTime = "faas.document.time"; +static constexpr const char *kCloudeventsEventSubject = "cloudevents.event_subject"; /** - * The document name/table subjected to the operation. For example, in Cloud Storage or S3 is the - * name of the file, and in Cosmos DB the table name. + * The event_type + * contains a value describing the type of event related to the originating occurrence. */ -static constexpr const char *kFaasDocumentName = "faas.document.name"; +static constexpr const char *kCloudeventsEventType = "cloudevents.event_type"; /** - * A string containing the function invocation time in the ISO 8601 format expressed in UTC. + * Parent-child Reference type + * + *

Notes: +

  • The causal relationship between a child Span and a parent Span.
*/ -static constexpr const char *kFaasTime = "faas.time"; +static constexpr const char *kOpentracingRefType = "opentracing.ref_type"; /** - * A string containing the schedule period as Cron - * Expression. + * The connection string used to connect to the database. It is recommended to remove embedded + * credentials. */ -static constexpr const char *kFaasCron = "faas.cron"; +static constexpr const char *kDbConnectionString = "db.connection_string"; /** - * A boolean that is true if the serverless function is executed for the first time (aka - * cold-start). + * The fully-qualified class name of the Java Database Connectivity + * (JDBC) driver used to connect. */ -static constexpr const char *kFaasColdstart = "faas.coldstart"; +static constexpr const char *kDbJdbcDriverClassname = "db.jdbc.driver_classname"; /** - * The name of the invoked function. + * This attribute is used to report the name of the database being accessed. For commands that + switch the database, this should be set to the target database (even if the command fails). * *

Notes: -

  • SHOULD be equal to the {@code faas.name} resource attribute of the invoked function.
  • -
+
  • In some SQL databases, the database name to be used is called "schema name". In + case there are multiple layers that could be considered for database name (e.g. Oracle instance + name and schema name), the database name to be used is the more specific layer (e.g. Oracle schema + name).
*/ -static constexpr const char *kFaasInvokedName = "faas.invoked_name"; +static constexpr const char *kDbName = "db.name"; /** - * The cloud provider of the invoked function. + * The name of the operation being executed, e.g. the MongoDB command + name such as {@code findAndModify}, or the SQL keyword. * *

Notes: -

  • SHOULD be equal to the {@code cloud.provider} resource attribute of the invoked - function.
+
  • When setting this to an SQL keyword, it is not recommended to attempt any client-side + parsing of {@code db.statement} just to get this property, but it should be set if the operation + name is provided by the library being instrumented. If the SQL statement has an ambiguous + operation, or performs more than one operation, this value may be omitted.
*/ -static constexpr const char *kFaasInvokedProvider = "faas.invoked_provider"; +static constexpr const char *kDbOperation = "db.operation"; /** - * The cloud region of the invoked function. + * The database statement being executed. + */ +static constexpr const char *kDbStatement = "db.statement"; + +/** + * An identifier for the database management system (DBMS) product being used. See below for a list + * of well-known identifiers. + */ +static constexpr const char *kDbSystem = "db.system"; + +/** + * Username for accessing the database. + */ +static constexpr const char *kDbUser = "db.user"; + +/** + * The Microsoft SQL Server instance + name connecting to. This name is used to determine the port of a named instance. * *

Notes: -

  • SHOULD be equal to the {@code cloud.region} resource attribute of the invoked - function.
+
  • If setting a {@code db.mssql.instance_name}, {@code server.port} is no longer required + (but still recommended if non-standard).
*/ -static constexpr const char *kFaasInvokedRegion = "faas.invoked_region"; +static constexpr const char *kDbMssqlInstanceName = "db.mssql.instance_name"; /** - * The unique identifier of the feature flag. + * The consistency level of the query. Based on consistency values from CQL. */ -static constexpr const char *kFeatureFlagKey = "feature_flag.key"; +static constexpr const char *kDbCassandraConsistencyLevel = "db.cassandra.consistency_level"; /** - * The name of the service provider that performs the flag evaluation. + * The data center of the coordinating node for a query. */ -static constexpr const char *kFeatureFlagProviderName = "feature_flag.provider_name"; +static constexpr const char *kDbCassandraCoordinatorDc = "db.cassandra.coordinator.dc"; /** - * SHOULD be a semantic identifier for a value. If one is unavailable, a stringified version of the -value can be used. + * The ID of the coordinating node for a query. + */ +static constexpr const char *kDbCassandraCoordinatorId = "db.cassandra.coordinator.id"; + +/** + * Whether or not the query is idempotent. + */ +static constexpr const char *kDbCassandraIdempotence = "db.cassandra.idempotence"; + +/** + * The fetch size used for paging, i.e. how many rows will be returned at once. + */ +static constexpr const char *kDbCassandraPageSize = "db.cassandra.page_size"; + +/** + * The number of times a query was speculatively executed. Not set or {@code 0} if the query was not + * executed speculatively. + */ +static constexpr const char *kDbCassandraSpeculativeExecutionCount = + "db.cassandra.speculative_execution_count"; + +/** + * The name of the primary table that the operation is acting upon, including the keyspace name (if + applicable). * *

Notes: -

  • A semantic identifier, commonly referred to as a variant, provides a means -for referring to a value without including the value itself. This can -provide additional context for understanding the meaning behind a value. -For example, the variant {@code red} maybe be used for the value {@code #c05543}.
  • A -stringified version of the value can be used in situations where a semantic identifier is -unavailable. String representation of the value should be determined by the implementer.
+
  • This mirrors the db.sql.table attribute but references cassandra rather than sql. It is + not recommended to attempt any client-side parsing of {@code db.statement} just to get this + property, but it should be set if it is provided by the library being instrumented. If the + operation is acting upon an anonymous table, or more than one table, this value MUST NOT be + set.
*/ -static constexpr const char *kFeatureFlagVariant = "feature_flag.variant"; +static constexpr const char *kDbCassandraTable = "db.cassandra.table"; /** - * OSI Transport Layer or Inter-process Communication - * method. The value SHOULD be normalized to lowercase. + * The index of the database being accessed as used in the {@code SELECT} command, provided as an integer. To be + * used instead of the generic {@code db.name} attribute. */ -static constexpr const char *kNetworkTransport = "network.transport"; +static constexpr const char *kDbRedisDatabaseIndex = "db.redis.database_index"; /** - * OSI Network Layer or non-OSI equivalent. The - * value SHOULD be normalized to lowercase. + * The collection being accessed within the database stated in {@code db.name}. */ -static constexpr const char *kNetworkType = "network.type"; +static constexpr const char *kDbMongodbCollection = "db.mongodb.collection"; /** - * OSI Application Layer or non-OSI - * equivalent. The value SHOULD be normalized to lowercase. + * Represents the identifier of an Elasticsearch cluster. */ -static constexpr const char *kNetworkProtocolName = "network.protocol.name"; +static constexpr const char *kDbElasticsearchClusterName = "db.elasticsearch.cluster.name"; + +/** + * Represents the human-readable identifier of the node/instance to which a request was routed. + */ +static constexpr const char *kDbElasticsearchNodeName = "db.elasticsearch.node.name"; /** - * Version of the application layer protocol used. See note below. + * The name of the primary table that the operation is acting upon, including the database name (if + applicable). * *

Notes: -

  • {@code network.protocol.version} refers to the version of the protocol used and might be - different from the protocol client's version. If the HTTP client used has a version of {@code - 0.27.2}, but sends HTTP version {@code 1.1}, this attribute should be set to {@code 1.1}.
  • -
+
  • It is not recommended to attempt any client-side parsing of {@code db.statement} just to + get this property, but it should be set if it is provided by the library being instrumented. If the + operation is acting upon an anonymous table, or more than one table, this value MUST NOT be + set.
*/ -static constexpr const char *kNetworkProtocolVersion = "network.protocol.version"; +static constexpr const char *kDbSqlTable = "db.sql.table"; /** - * The internet connection type. + * Unique Cosmos client instance id. */ -static constexpr const char *kNetworkConnectionType = "network.connection.type"; +static constexpr const char *kDbCosmosdbClientId = "db.cosmosdb.client_id"; /** - * This describes more details regarding the connection.type. It may be the type of cell technology - * connection, but it could be used for describing details about a wifi connection. + * Cosmos client connection mode. */ -static constexpr const char *kNetworkConnectionSubtype = "network.connection.subtype"; +static constexpr const char *kDbCosmosdbConnectionMode = "db.cosmosdb.connection_mode"; /** - * The name of the mobile carrier. + * Cosmos DB container name. */ -static constexpr const char *kNetworkCarrierName = "network.carrier.name"; +static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; /** - * The mobile carrier country code. + * CosmosDB Operation Type. */ -static constexpr const char *kNetworkCarrierMcc = "network.carrier.mcc"; +static constexpr const char *kDbCosmosdbOperationType = "db.cosmosdb.operation_type"; /** - * The mobile carrier network code. + * RU consumed for that operation */ -static constexpr const char *kNetworkCarrierMnc = "network.carrier.mnc"; +static constexpr const char *kDbCosmosdbRequestCharge = "db.cosmosdb.request_charge"; /** - * The ISO 3166-1 alpha-2 2-character country code associated with the mobile carrier network. + * Request payload size in bytes */ -static constexpr const char *kNetworkCarrierIcc = "network.carrier.icc"; +static constexpr const char *kDbCosmosdbRequestContentLength = "db.cosmosdb.request_content_length"; /** - * The {@code service.name} of the remote service. - * SHOULD be equal to the actual {@code service.name} resource attribute of the remote service if - * any. + * Cosmos DB status code. */ -static constexpr const char *kPeerService = "peer.service"; +static constexpr const char *kDbCosmosdbStatusCode = "db.cosmosdb.status_code"; /** - * Username or client_id extracted from the access token or Authorization header in the inbound - * request from outside the system. + * Cosmos DB sub status code. */ -static constexpr const char *kEnduserId = "enduser.id"; +static constexpr const char *kDbCosmosdbSubStatusCode = "db.cosmosdb.sub_status_code"; /** - * Actual/assumed role the client is making the request under extracted from token or application - * security context. + * Name of the code, either "OK" or "ERROR". MUST NOT be set if the status code + * is UNSET. */ -static constexpr const char *kEnduserRole = "enduser.role"; +static constexpr const char *kOtelStatusCode = "otel.status_code"; /** - * Scopes or granted authorities the client currently possesses extracted from token or application - * security context. The value would come from the scope associated with an OAuth 2.0 Access Token or an attribute - * value in a SAML 2.0 - * Assertion. + * Description of the Status if it has a value, otherwise not set. */ -static constexpr const char *kEnduserScope = "enduser.scope"; +static constexpr const char *kOtelStatusDescription = "otel.status_description"; /** - * Current "managed" thread ID (as opposed to OS thread ID). + * The invocation ID of the current function invocation. */ -static constexpr const char *kThreadId = "thread.id"; +static constexpr const char *kFaasInvocationId = "faas.invocation_id"; /** - * Current thread name. + * The name of the source on which the triggering operation was performed. For example, in Cloud + * Storage or S3 corresponds to the bucket name, and in Cosmos DB to the database name. */ -static constexpr const char *kThreadName = "thread.name"; +static constexpr const char *kFaasDocumentCollection = "faas.document.collection"; /** - * The method or function name, or equivalent (usually rightmost part of the code unit's name). + * The document name/table subjected to the operation. For example, in Cloud Storage or S3 is the + * name of the file, and in Cosmos DB the table name. */ -static constexpr const char *kCodeFunction = "code.function"; +static constexpr const char *kFaasDocumentName = "faas.document.name"; /** - * The "namespace" within which {@code code.function} is defined. Usually the qualified - * class or module name, such that {@code code.namespace} + some separator + {@code code.function} - * form a unique identifier for the code unit. + * Describes the type of the operation that was performed on the data. */ -static constexpr const char *kCodeNamespace = "code.namespace"; +static constexpr const char *kFaasDocumentOperation = "faas.document.operation"; /** - * The source code file name that identifies the code unit as uniquely as possible (preferably an - * absolute file path). + * A string containing the time when the data was accessed in the ISO 8601 format expressed in UTC. */ -static constexpr const char *kCodeFilepath = "code.filepath"; +static constexpr const char *kFaasDocumentTime = "faas.document.time"; /** - * The line number in {@code code.filepath} best representing the operation. It SHOULD point within - * the code unit named in {@code code.function}. + * A string containing the schedule period as Cron + * Expression. */ -static constexpr const char *kCodeLineno = "code.lineno"; +static constexpr const char *kFaasCron = "faas.cron"; /** - * The column number in {@code code.filepath} best representing the operation. It SHOULD point - * within the code unit named in {@code code.function}. + * A string containing the function invocation time in the ISO 8601 format expressed in UTC. */ -static constexpr const char *kCodeColumn = "code.column"; +static constexpr const char *kFaasTime = "faas.time"; /** - * Original HTTP method sent by the client in the request line. + * A boolean that is true if the serverless function is executed for the first time (aka + * cold-start). */ -static constexpr const char *kHttpRequestMethodOriginal = "http.request.method_original"; +static constexpr const char *kFaasColdstart = "faas.coldstart"; /** - * The size of the request payload body in bytes. This is the number of bytes transferred excluding - * headers and is often, but not always, present as the Content-Length - * header. For requests using transport encoding, this should be the compressed size. + * The unique identifier of the feature flag. */ -static constexpr const char *kHttpRequestBodySize = "http.request.body.size"; +static constexpr const char *kFeatureFlagKey = "feature_flag.key"; /** - * The size of the response payload body in bytes. This is the number of bytes transferred excluding - * headers and is often, but not always, present as the Content-Length - * header. For requests using transport encoding, this should be the compressed size. + * The name of the service provider that performs the flag evaluation. */ -static constexpr const char *kHttpResponseBodySize = "http.response.body.size"; +static constexpr const char *kFeatureFlagProviderName = "feature_flag.provider_name"; /** - * The ordinal number of request resending attempt (for any reason, including redirects). + * SHOULD be a semantic identifier for a value. If one is unavailable, a stringified version of the +value can be used. * *

Notes: -

  • The resend count SHOULD be updated each time an HTTP request gets resent by the client, - regardless of what was the cause of the resending (e.g. redirection, authorization failure, 503 - Server Unavailable, network issues, or any other).
+
  • A semantic identifier, commonly referred to as a variant, provides a means +for referring to a value without including the value itself. This can +provide additional context for understanding the meaning behind a value. +For example, the variant {@code red} maybe be used for the value {@code #c05543}.
  • A +stringified version of the value can be used in situations where a semantic identifier is +unavailable. String representation of the value should be determined by the implementer.
*/ -static constexpr const char *kHttpResendCount = "http.resend_count"; +static constexpr const char *kFeatureFlagVariant = "feature_flag.variant"; /** * The AWS request ID as returned in the response headers {@code x-amz-request-id} or {@code @@ -932,37 +1060,35 @@ static constexpr const char *kHttpResendCount = "http.resend_count"; static constexpr const char *kAwsRequestId = "aws.request_id"; /** - * The keys in the {@code RequestItems} object field. + * The value of the {@code AttributesToGet} request parameter. */ -static constexpr const char *kAwsDynamodbTableNames = "aws.dynamodb.table_names"; +static constexpr const char *kAwsDynamodbAttributesToGet = "aws.dynamodb.attributes_to_get"; /** - * The JSON-serialized value of each item in the {@code ConsumedCapacity} response field. + * The value of the {@code ConsistentRead} request parameter. */ -static constexpr const char *kAwsDynamodbConsumedCapacity = "aws.dynamodb.consumed_capacity"; +static constexpr const char *kAwsDynamodbConsistentRead = "aws.dynamodb.consistent_read"; /** - * The JSON-serialized value of the {@code ItemCollectionMetrics} response field. + * The JSON-serialized value of each item in the {@code ConsumedCapacity} response field. */ -static constexpr const char *kAwsDynamodbItemCollectionMetrics = - "aws.dynamodb.item_collection_metrics"; +static constexpr const char *kAwsDynamodbConsumedCapacity = "aws.dynamodb.consumed_capacity"; /** - * The value of the {@code ProvisionedThroughput.ReadCapacityUnits} request parameter. + * The value of the {@code IndexName} request parameter. */ -static constexpr const char *kAwsDynamodbProvisionedReadCapacity = - "aws.dynamodb.provisioned_read_capacity"; +static constexpr const char *kAwsDynamodbIndexName = "aws.dynamodb.index_name"; /** - * The value of the {@code ProvisionedThroughput.WriteCapacityUnits} request parameter. + * The JSON-serialized value of the {@code ItemCollectionMetrics} response field. */ -static constexpr const char *kAwsDynamodbProvisionedWriteCapacity = - "aws.dynamodb.provisioned_write_capacity"; +static constexpr const char *kAwsDynamodbItemCollectionMetrics = + "aws.dynamodb.item_collection_metrics"; /** - * The value of the {@code ConsistentRead} request parameter. + * The value of the {@code Limit} request parameter. */ -static constexpr const char *kAwsDynamodbConsistentRead = "aws.dynamodb.consistent_read"; +static constexpr const char *kAwsDynamodbLimit = "aws.dynamodb.limit"; /** * The value of the {@code ProjectionExpression} request parameter. @@ -970,24 +1096,26 @@ static constexpr const char *kAwsDynamodbConsistentRead = "aws.dynamodb.consiste static constexpr const char *kAwsDynamodbProjection = "aws.dynamodb.projection"; /** - * The value of the {@code Limit} request parameter. + * The value of the {@code ProvisionedThroughput.ReadCapacityUnits} request parameter. */ -static constexpr const char *kAwsDynamodbLimit = "aws.dynamodb.limit"; +static constexpr const char *kAwsDynamodbProvisionedReadCapacity = + "aws.dynamodb.provisioned_read_capacity"; /** - * The value of the {@code AttributesToGet} request parameter. + * The value of the {@code ProvisionedThroughput.WriteCapacityUnits} request parameter. */ -static constexpr const char *kAwsDynamodbAttributesToGet = "aws.dynamodb.attributes_to_get"; +static constexpr const char *kAwsDynamodbProvisionedWriteCapacity = + "aws.dynamodb.provisioned_write_capacity"; /** - * The value of the {@code IndexName} request parameter. + * The value of the {@code Select} request parameter. */ -static constexpr const char *kAwsDynamodbIndexName = "aws.dynamodb.index_name"; +static constexpr const char *kAwsDynamodbSelect = "aws.dynamodb.select"; /** - * The value of the {@code Select} request parameter. + * The keys in the {@code RequestItems} object field. */ -static constexpr const char *kAwsDynamodbSelect = "aws.dynamodb.select"; +static constexpr const char *kAwsDynamodbTableNames = "aws.dynamodb.table_names"; /** * The JSON-serialized value of each item of the {@code GlobalSecondaryIndexes} request field @@ -1017,24 +1145,24 @@ static constexpr const char *kAwsDynamodbTableCount = "aws.dynamodb.table_count" static constexpr const char *kAwsDynamodbScanForward = "aws.dynamodb.scan_forward"; /** - * The value of the {@code Segment} request parameter. + * The value of the {@code Count} response parameter. */ -static constexpr const char *kAwsDynamodbSegment = "aws.dynamodb.segment"; +static constexpr const char *kAwsDynamodbCount = "aws.dynamodb.count"; /** - * The value of the {@code TotalSegments} request parameter. + * The value of the {@code ScannedCount} response parameter. */ -static constexpr const char *kAwsDynamodbTotalSegments = "aws.dynamodb.total_segments"; +static constexpr const char *kAwsDynamodbScannedCount = "aws.dynamodb.scanned_count"; /** - * The value of the {@code Count} response parameter. + * The value of the {@code Segment} request parameter. */ -static constexpr const char *kAwsDynamodbCount = "aws.dynamodb.count"; +static constexpr const char *kAwsDynamodbSegment = "aws.dynamodb.segment"; /** - * The value of the {@code ScannedCount} response parameter. + * The value of the {@code TotalSegments} request parameter. */ -static constexpr const char *kAwsDynamodbScannedCount = "aws.dynamodb.scanned_count"; +static constexpr const char *kAwsDynamodbTotalSegments = "aws.dynamodb.total_segments"; /** * The JSON-serialized value of each item in the {@code AttributeDefinitions} request field. @@ -1060,6 +1188,33 @@ except {@code list-buckets}. */ static constexpr const char *kAwsS3Bucket = "aws.s3.bucket"; +/** + * The source object (in the form {@code bucket}/{@code key}) for the copy operation. + * + *

Notes: +

+ */ +static constexpr const char *kAwsS3CopySource = "aws.s3.copy_source"; + +/** + * The delete request container that specifies the objects to be deleted. + * + *

Notes: +

+ */ +static constexpr const char *kAwsS3Delete = "aws.s3.delete"; + /** * The S3 object key the request refers to. Corresponds to the {@code --key} parameter of the S3 API operations. @@ -1098,19 +1253,19 @@ href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.ht static constexpr const char *kAwsS3Key = "aws.s3.key"; /** - * The source object (in the form {@code bucket}/{@code key}) for the copy operation. + * The part number of the part being uploaded in a multipart-upload operation. This is a positive +integer between 1 and 10,000. * *

Notes: -

+ */ -static constexpr const char *kAwsS3CopySource = "aws.s3.copy_source"; +static constexpr const char *kAwsS3PartNumber = "aws.s3.part_number"; /** * Upload ID that identifies the multipart upload. @@ -1134,31 +1289,12 @@ href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.ht static constexpr const char *kAwsS3UploadId = "aws.s3.upload_id"; /** - * The delete request container that specifies the objects to be deleted. - * - *

Notes: -

- */ -static constexpr const char *kAwsS3Delete = "aws.s3.delete"; - -/** - * The part number of the part being uploaded in a multipart-upload operation. This is a positive -integer between 1 and 10,000. + * The GraphQL document being executed. * *

Notes: -

+
  • The value may be sanitized to exclude sensitive information.
*/ -static constexpr const char *kAwsS3PartNumber = "aws.s3.part_number"; +static constexpr const char *kGraphqlDocument = "graphql.document"; /** * The name of the operation being executed. @@ -1171,17 +1307,13 @@ static constexpr const char *kGraphqlOperationName = "graphql.operation.name"; static constexpr const char *kGraphqlOperationType = "graphql.operation.type"; /** - * The GraphQL document being executed. + * The size of the message body in bytes. * *

Notes: -

  • The value may be sanitized to exclude sensitive information.
- */ -static constexpr const char *kGraphqlDocument = "graphql.document"; - -/** - * A value used by the messaging system as an identifier for the message, represented as a string. +
  • This can refer to both the compressed or uncompressed body size. If both sizes are known, +the uncompressed body size should be used.
*/ -static constexpr const char *kMessagingMessageId = "messaging.message.id"; +static constexpr const char *kMessagingMessageBodySize = "messaging.message.body.size"; /** * The conversation ID identifying the conversation to which the @@ -1190,17 +1322,24 @@ static constexpr const char *kMessagingMessageId = "messaging.message.id"; static constexpr const char *kMessagingMessageConversationId = "messaging.message.conversation_id"; /** - * The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown - * whether the compressed or uncompressed payload size is reported. + * The size of the message body and metadata in bytes. + * + *

Notes: +

  • This can refer to both the compressed or uncompressed size. If both sizes are known, the +uncompressed size should be used.
+ */ +static constexpr const char *kMessagingMessageEnvelopeSize = "messaging.message.envelope.size"; + +/** + * A value used by the messaging system as an identifier for the message, represented as a string. */ -static constexpr const char *kMessagingMessagePayloadSizeBytes = - "messaging.message.payload_size_bytes"; +static constexpr const char *kMessagingMessageId = "messaging.message.id"; /** - * The compressed size of the message payload in bytes. + * A boolean that is true if the message destination is anonymous (could be unnamed or have + * auto-generated name). */ -static constexpr const char *kMessagingMessagePayloadCompressedSizeBytes = - "messaging.message.payload_compressed_size_bytes"; +static constexpr const char *kMessagingDestinationAnonymous = "messaging.destination.anonymous"; /** * The message destination name @@ -1227,27 +1366,25 @@ static constexpr const char *kMessagingDestinationTemplate = "messaging.destinat * A boolean that is true if the message destination is temporary and might not exist anymore after * messages are processed. */ -static constexpr const char *kMessagingDestinationTemporary = "messaging.destination.temporary"; - -/** - * A boolean that is true if the message destination is anonymous (could be unnamed or have - * auto-generated name). - */ -static constexpr const char *kMessagingDestinationAnonymous = "messaging.destination.anonymous"; +static constexpr const char *kMessagingDestinationTemporary = "messaging.destination.temporary"; /** - * A string identifying the messaging system. + * A boolean that is true if the publish message destination is anonymous (could be unnamed or have + * auto-generated name). */ -static constexpr const char *kMessagingSystem = "messaging.system"; +static constexpr const char *kMessagingDestinationPublishAnonymous = + "messaging.destination_publish.anonymous"; /** - * A string identifying the kind of messaging operation as defined in the Operation names section above. + * The name of the original destination the message was published to * *

Notes: -

  • If a custom value is used, it MUST be of low cardinality.
+
  • The name SHOULD uniquely identify a specific queue, topic, or other entity within the +broker. If the broker does not have such notion, the original destination name SHOULD uniquely +identify the broker.
*/ -static constexpr const char *kMessagingOperation = "messaging.operation"; +static constexpr const char *kMessagingDestinationPublishName = + "messaging.destination_publish.name"; /** * The number of messages sent, received, or processed in the scope of the batching operation. @@ -1267,22 +1404,24 @@ static constexpr const char *kMessagingBatchMessageCount = "messaging.batch.mess static constexpr const char *kMessagingClientId = "messaging.client_id"; /** - * RabbitMQ message routing key. + * A string identifying the kind of messaging operation as defined in the Operation names section above. + * + *

Notes: +

  • If a custom value is used, it MUST be of low cardinality.
*/ -static constexpr const char *kMessagingRabbitmqDestinationRoutingKey = - "messaging.rabbitmq.destination.routing_key"; +static constexpr const char *kMessagingOperation = "messaging.operation"; /** - * Message keys in Kafka are used for grouping alike messages to ensure they're processed on the - same partition. They differ from {@code messaging.message.id} in that they're not unique. If the - key is {@code null}, the attribute MUST NOT be set. - * - *

Notes: -

  • If the key type is not string, it's string representation has to be supplied for the - attribute. If the key has no unambiguous, canonical string form, don't include its value.
  • -
+ * A string identifying the messaging system. */ -static constexpr const char *kMessagingKafkaMessageKey = "messaging.kafka.message.key"; +static constexpr const char *kMessagingSystem = "messaging.system"; + +/** + * RabbitMQ message routing key. + */ +static constexpr const char *kMessagingRabbitmqDestinationRoutingKey = + "messaging.rabbitmq.destination.routing_key"; /** * Name of the Kafka Consumer Group that is handling the message. Only applies to consumers, not @@ -1296,6 +1435,18 @@ static constexpr const char *kMessagingKafkaConsumerGroup = "messaging.kafka.con static constexpr const char *kMessagingKafkaDestinationPartition = "messaging.kafka.destination.partition"; +/** + * Message keys in Kafka are used for grouping alike messages to ensure they're processed on the + same partition. They differ from {@code messaging.message.id} in that they're not unique. If the + key is {@code null}, the attribute MUST NOT be set. + * + *

Notes: +

  • If the key type is not string, it's string representation has to be supplied for the + attribute. If the key has no unambiguous, canonical string form, don't include its value.
  • +
+ */ +static constexpr const char *kMessagingKafkaMessageKey = "messaging.kafka.message.key"; + /** * The offset of a record in the corresponding Kafka partition. */ @@ -1306,11 +1457,6 @@ static constexpr const char *kMessagingKafkaMessageOffset = "messaging.kafka.mes */ static constexpr const char *kMessagingKafkaMessageTombstone = "messaging.kafka.message.tombstone"; -/** - * Namespace of RocketMQ resources, resources in different namespaces are individual. - */ -static constexpr const char *kMessagingRocketmqNamespace = "messaging.rocketmq.namespace"; - /** * Name of the RocketMQ producer/consumer group that is handling the message. The client type is * identified by the SpanKind. @@ -1318,10 +1464,10 @@ static constexpr const char *kMessagingRocketmqNamespace = "messaging.rocketmq.n static constexpr const char *kMessagingRocketmqClientGroup = "messaging.rocketmq.client_group"; /** - * The timestamp in milliseconds that the delay message is expected to be delivered to consumer. + * Model of message consumption. This only applies to consumer spans. */ -static constexpr const char *kMessagingRocketmqMessageDeliveryTimestamp = - "messaging.rocketmq.message.delivery_timestamp"; +static constexpr const char *kMessagingRocketmqConsumptionModel = + "messaging.rocketmq.consumption_model"; /** * The delay time level for delay message, which determines the message delay time. @@ -1329,6 +1475,12 @@ static constexpr const char *kMessagingRocketmqMessageDeliveryTimestamp = static constexpr const char *kMessagingRocketmqMessageDelayTimeLevel = "messaging.rocketmq.message.delay_time_level"; +/** + * The timestamp in milliseconds that the delay message is expected to be delivered to consumer. + */ +static constexpr const char *kMessagingRocketmqMessageDeliveryTimestamp = + "messaging.rocketmq.message.delivery_timestamp"; + /** * It is essential for FIFO message. Messages that belong to the same message group are always * processed one by one within the same consumer group. @@ -1336,9 +1488,9 @@ static constexpr const char *kMessagingRocketmqMessageDelayTimeLevel = static constexpr const char *kMessagingRocketmqMessageGroup = "messaging.rocketmq.message.group"; /** - * Type of message. + * Key(s) of message, another way to mark message besides message id. */ -static constexpr const char *kMessagingRocketmqMessageType = "messaging.rocketmq.message.type"; +static constexpr const char *kMessagingRocketmqMessageKeys = "messaging.rocketmq.message.keys"; /** * The secondary classifier of message besides topic. @@ -1346,20 +1498,26 @@ static constexpr const char *kMessagingRocketmqMessageType = "messaging.rocketmq static constexpr const char *kMessagingRocketmqMessageTag = "messaging.rocketmq.message.tag"; /** - * Key(s) of message, another way to mark message besides message id. + * Type of message. */ -static constexpr const char *kMessagingRocketmqMessageKeys = "messaging.rocketmq.message.keys"; +static constexpr const char *kMessagingRocketmqMessageType = "messaging.rocketmq.message.type"; /** - * Model of message consumption. This only applies to consumer spans. + * Namespace of RocketMQ resources, resources in different namespaces are individual. */ -static constexpr const char *kMessagingRocketmqConsumptionModel = - "messaging.rocketmq.consumption_model"; +static constexpr const char *kMessagingRocketmqNamespace = "messaging.rocketmq.namespace"; /** - * A string identifying the remoting system. See below for a list of well-known identifiers. + * The name of the (logical) method being called, must be equal to the $method part in the span + name. + * + *

Notes: +

  • This is the logical name of the method from the RPC interface perspective, which can be + different from the name of any implementing method/function. The {@code code.function} attribute + may be used to store the latter (e.g., method actually executing the call on the server side, RPC + client stub method on the client side).
*/ -static constexpr const char *kRpcSystem = "rpc.system"; +static constexpr const char *kRpcMethod = "rpc.method"; /** * The full (logical) name of the service being called, including its package name, if applicable. @@ -1374,16 +1532,9 @@ static constexpr const char *kRpcSystem = "rpc.system"; static constexpr const char *kRpcService = "rpc.service"; /** - * The name of the (logical) method being called, must be equal to the $method part in the span - name. - * - *

Notes: -

  • This is the logical name of the method from the RPC interface perspective, which can be - different from the name of any implementing method/function. The {@code code.function} attribute - may be used to store the latter (e.g., method actually executing the call on the server side, RPC - client stub method on the client side).
+ * A string identifying the remoting system. See below for a list of well-known identifiers. */ -static constexpr const char *kRpcMethod = "rpc.method"; +static constexpr const char *kRpcSystem = "rpc.system"; /** * The numeric status @@ -1392,10 +1543,14 @@ static constexpr const char *kRpcMethod = "rpc.method"; static constexpr const char *kRpcGrpcStatusCode = "rpc.grpc.status_code"; /** - * Protocol version as in {@code jsonrpc} property of request/response. Since JSON-RPC 1.0 does not - * specify this, the value can be omitted. + * {@code error.code} property of response if it is an error response. */ -static constexpr const char *kRpcJsonrpcVersion = "rpc.jsonrpc.version"; +static constexpr const char *kRpcJsonrpcErrorCode = "rpc.jsonrpc.error_code"; + +/** + * {@code error.message} property of response if it is an error response. + */ +static constexpr const char *kRpcJsonrpcErrorMessage = "rpc.jsonrpc.error_message"; /** * {@code id} property of request or response. Since protocol allows id to be int, string, {@code @@ -1405,19 +1560,15 @@ static constexpr const char *kRpcJsonrpcVersion = "rpc.jsonrpc.version"; static constexpr const char *kRpcJsonrpcRequestId = "rpc.jsonrpc.request_id"; /** - * {@code error.code} property of response if it is an error response. - */ -static constexpr const char *kRpcJsonrpcErrorCode = "rpc.jsonrpc.error_code"; - -/** - * {@code error.message} property of response if it is an error response. + * Protocol version as in {@code jsonrpc} property of request/response. Since JSON-RPC 1.0 does not + * specify this, the value can be omitted. */ -static constexpr const char *kRpcJsonrpcErrorMessage = "rpc.jsonrpc.error_message"; +static constexpr const char *kRpcJsonrpcVersion = "rpc.jsonrpc.version"; /** - * Whether this is a received or sent message. + * Compressed size of the message in bytes. */ -static constexpr const char *kMessageType = "message.type"; +static constexpr const char *kMessageCompressedSize = "message.compressed_size"; /** * MUST be calculated as two different counters starting from {@code 1} one for sent messages and @@ -1430,9 +1581,9 @@ static constexpr const char *kMessageType = "message.type"; static constexpr const char *kMessageId = "message.id"; /** - * Compressed size of the message in bytes. + * Whether this is a received or sent message. */ -static constexpr const char *kMessageCompressedSize = "message.compressed_size"; +static constexpr const char *kMessageType = "message.type"; /** * Uncompressed size of the message in bytes. @@ -1465,10 +1616,9 @@ recorded at a time where it was not clear whether the exception will escape.URI scheme component - * identifying the used protocol. + * The URI fragment component */ -static constexpr const char *kUrlScheme = "url.scheme"; +static constexpr const char *kUrlFragment = "url.fragment"; /** * Absolute URL describing a network resource according to URI fragment component + * The URI scheme component + * identifying the used protocol. */ -static constexpr const char *kUrlFragment = "url.fragment"; +static constexpr const char *kUrlScheme = "url.scheme"; + +/** + * Value of the HTTP + * User-Agent header sent by the client. + */ +static constexpr const char *kUserAgentOriginal = "user_agent.original"; + +// Enum definitions +namespace NetSockFamilyValues +{ +/** IPv4 address. */ +static constexpr const char *kInet = "inet"; +/** IPv6 address. */ +static constexpr const char *kInet6 = "inet6"; +/** Unix domain socket path. */ +static constexpr const char *kUnix = "unix"; +} // namespace NetSockFamilyValues + +namespace NetTransportValues +{ +/** ip_tcp. */ +static constexpr const char *kIpTcp = "ip_tcp"; +/** ip_udp. */ +static constexpr const char *kIpUdp = "ip_udp"; +/** Named or anonymous pipe. */ +static constexpr const char *kPipe = "pipe"; +/** In-process communication. */ +static constexpr const char *kInproc = "inproc"; +/** Something else (non IP-based). */ +static constexpr const char *kOther = "other"; +} // namespace NetTransportValues + +namespace ErrorTypeValues +{ +/** A fallback error value to be used when the instrumentation does not define a custom value for + * it. */ +static constexpr const char *kOther = "_OTHER"; +} // namespace ErrorTypeValues + +namespace FaasInvokedProviderValues +{ +/** Alibaba Cloud. */ +static constexpr const char *kAlibabaCloud = "alibaba_cloud"; +/** Amazon Web Services. */ +static constexpr const char *kAws = "aws"; +/** Microsoft Azure. */ +static constexpr const char *kAzure = "azure"; +/** Google Cloud Platform. */ +static constexpr const char *kGcp = "gcp"; +/** Tencent Cloud. */ +static constexpr const char *kTencentCloud = "tencent_cloud"; +} // namespace FaasInvokedProviderValues + +namespace FaasTriggerValues +{ +/** A response to some data source operation such as a database or filesystem read/write. */ +static constexpr const char *kDatasource = "datasource"; +/** To provide an answer to an inbound HTTP request. */ +static constexpr const char *kHttp = "http"; +/** A function is set to be executed when messages are sent to a messaging system. */ +static constexpr const char *kPubsub = "pubsub"; +/** A function is scheduled to be executed regularly. */ +static constexpr const char *kTimer = "timer"; +/** If none of the others apply. */ +static constexpr const char *kOther = "other"; +} // namespace FaasTriggerValues + +namespace EventDomainValues +{ +/** Events from browser apps. */ +static constexpr const char *kBrowser = "browser"; +/** Events from mobile apps. */ +static constexpr const char *kDevice = "device"; +/** Events from Kubernetes. */ +static constexpr const char *kK8s = "k8s"; +} // namespace EventDomainValues + +namespace LogIostreamValues +{ +/** Logs from stdout stream. */ +static constexpr const char *kStdout = "stdout"; +/** Events from stderr stream. */ +static constexpr const char *kStderr = "stderr"; +} // namespace LogIostreamValues + +namespace StateValues +{ +/** idle. */ +static constexpr const char *kIdle = "idle"; +/** used. */ +static constexpr const char *kUsed = "used"; +} // namespace StateValues + +namespace JvmMemoryTypeValues +{ +/** Heap memory. */ +static constexpr const char *kHeap = "heap"; +/** Non-heap memory. */ +static constexpr const char *kNonHeap = "non_heap"; +} // namespace JvmMemoryTypeValues + +namespace SystemCpuStateValues +{ +/** user. */ +static constexpr const char *kUser = "user"; +/** system. */ +static constexpr const char *kSystem = "system"; +/** nice. */ +static constexpr const char *kNice = "nice"; +/** idle. */ +static constexpr const char *kIdle = "idle"; +/** iowait. */ +static constexpr const char *kIowait = "iowait"; +/** interrupt. */ +static constexpr const char *kInterrupt = "interrupt"; +/** steal. */ +static constexpr const char *kSteal = "steal"; +} // namespace SystemCpuStateValues + +namespace SystemMemoryStateValues +{ +/** total. */ +static constexpr const char *kTotal = "total"; +/** used. */ +static constexpr const char *kUsed = "used"; +/** free. */ +static constexpr const char *kFree = "free"; +/** shared. */ +static constexpr const char *kShared = "shared"; +/** buffers. */ +static constexpr const char *kBuffers = "buffers"; +/** cached. */ +static constexpr const char *kCached = "cached"; +} // namespace SystemMemoryStateValues + +namespace SystemPagingDirectionValues +{ +/** in. */ +static constexpr const char *kIn = "in"; +/** out. */ +static constexpr const char *kOut = "out"; +} // namespace SystemPagingDirectionValues + +namespace SystemPagingStateValues +{ +/** used. */ +static constexpr const char *kUsed = "used"; +/** free. */ +static constexpr const char *kFree = "free"; +} // namespace SystemPagingStateValues + +namespace SystemPagingTypeValues +{ +/** major. */ +static constexpr const char *kMajor = "major"; +/** minor. */ +static constexpr const char *kMinor = "minor"; +} // namespace SystemPagingTypeValues + +namespace SystemDiskDirectionValues +{ +/** read. */ +static constexpr const char *kRead = "read"; +/** write. */ +static constexpr const char *kWrite = "write"; +} // namespace SystemDiskDirectionValues + +namespace SystemFilesystemStateValues +{ +/** used. */ +static constexpr const char *kUsed = "used"; +/** free. */ +static constexpr const char *kFree = "free"; +/** reserved. */ +static constexpr const char *kReserved = "reserved"; +} // namespace SystemFilesystemStateValues + +namespace SystemFilesystemTypeValues +{ +/** fat32. */ +static constexpr const char *kFat32 = "fat32"; +/** exfat. */ +static constexpr const char *kExfat = "exfat"; +/** ntfs. */ +static constexpr const char *kNtfs = "ntfs"; +/** refs. */ +static constexpr const char *kRefs = "refs"; +/** hfsplus. */ +static constexpr const char *kHfsplus = "hfsplus"; +/** ext4. */ +static constexpr const char *kExt4 = "ext4"; +} // namespace SystemFilesystemTypeValues + +namespace SystemNetworkDirectionValues +{ +/** transmit. */ +static constexpr const char *kTransmit = "transmit"; +/** receive. */ +static constexpr const char *kReceive = "receive"; +} // namespace SystemNetworkDirectionValues + +namespace SystemNetworkStateValues +{ +/** close. */ +static constexpr const char *kClose = "close"; +/** close_wait. */ +static constexpr const char *kCloseWait = "close_wait"; +/** closing. */ +static constexpr const char *kClosing = "closing"; +/** delete. */ +static constexpr const char *kDelete = "delete"; +/** established. */ +static constexpr const char *kEstablished = "established"; +/** fin_wait_1. */ +static constexpr const char *kFinWait1 = "fin_wait_1"; +/** fin_wait_2. */ +static constexpr const char *kFinWait2 = "fin_wait_2"; +/** last_ack. */ +static constexpr const char *kLastAck = "last_ack"; +/** listen. */ +static constexpr const char *kListen = "listen"; +/** syn_recv. */ +static constexpr const char *kSynRecv = "syn_recv"; +/** syn_sent. */ +static constexpr const char *kSynSent = "syn_sent"; +/** time_wait. */ +static constexpr const char *kTimeWait = "time_wait"; +} // namespace SystemNetworkStateValues + +namespace SystemProcessesStatusValues +{ +/** running. */ +static constexpr const char *kRunning = "running"; +/** sleeping. */ +static constexpr const char *kSleeping = "sleeping"; +/** stopped. */ +static constexpr const char *kStopped = "stopped"; +/** defunct. */ +static constexpr const char *kDefunct = "defunct"; +} // namespace SystemProcessesStatusValues + +namespace NetworkTransportValues +{ +/** TCP. */ +static constexpr const char *kTcp = "tcp"; +/** UDP. */ +static constexpr const char *kUdp = "udp"; +/** Named or anonymous pipe. See note below. */ +static constexpr const char *kPipe = "pipe"; +/** Unix domain socket. */ +static constexpr const char *kUnix = "unix"; +} // namespace NetworkTransportValues -/** - * Value of the HTTP - * User-Agent header sent by the client. - */ -static constexpr const char *kUserAgentOriginal = "user_agent.original"; +namespace NetworkTypeValues +{ +/** IPv4. */ +static constexpr const char *kIpv4 = "ipv4"; +/** IPv6. */ +static constexpr const char *kIpv6 = "ipv6"; +} // namespace NetworkTypeValues -// Enum definitions -namespace NetTransportValues +namespace NetworkConnectionSubtypeValues { -/** ip_tcp. */ -static constexpr const char *kIpTcp = "ip_tcp"; -/** ip_udp. */ -static constexpr const char *kIpUdp = "ip_udp"; -/** Named or anonymous pipe. */ -static constexpr const char *kPipe = "pipe"; -/** In-process communication. */ -static constexpr const char *kInproc = "inproc"; -/** Something else (non IP-based). */ -static constexpr const char *kOther = "other"; -} // namespace NetTransportValues +/** GPRS. */ +static constexpr const char *kGprs = "gprs"; +/** EDGE. */ +static constexpr const char *kEdge = "edge"; +/** UMTS. */ +static constexpr const char *kUmts = "umts"; +/** CDMA. */ +static constexpr const char *kCdma = "cdma"; +/** EVDO Rel. 0. */ +static constexpr const char *kEvdo0 = "evdo_0"; +/** EVDO Rev. A. */ +static constexpr const char *kEvdoA = "evdo_a"; +/** CDMA2000 1XRTT. */ +static constexpr const char *kCdma20001xrtt = "cdma2000_1xrtt"; +/** HSDPA. */ +static constexpr const char *kHsdpa = "hsdpa"; +/** HSUPA. */ +static constexpr const char *kHsupa = "hsupa"; +/** HSPA. */ +static constexpr const char *kHspa = "hspa"; +/** IDEN. */ +static constexpr const char *kIden = "iden"; +/** EVDO Rev. B. */ +static constexpr const char *kEvdoB = "evdo_b"; +/** LTE. */ +static constexpr const char *kLte = "lte"; +/** EHRPD. */ +static constexpr const char *kEhrpd = "ehrpd"; +/** HSPAP. */ +static constexpr const char *kHspap = "hspap"; +/** GSM. */ +static constexpr const char *kGsm = "gsm"; +/** TD-SCDMA. */ +static constexpr const char *kTdScdma = "td_scdma"; +/** IWLAN. */ +static constexpr const char *kIwlan = "iwlan"; +/** 5G NR (New Radio). */ +static constexpr const char *kNr = "nr"; +/** 5G NRNSA (New Radio Non-Standalone). */ +static constexpr const char *kNrnsa = "nrnsa"; +/** LTE CA. */ +static constexpr const char *kLteCa = "lte_ca"; +} // namespace NetworkConnectionSubtypeValues -namespace NetSockFamilyValues +namespace NetworkConnectionTypeValues { -/** IPv4 address. */ -static constexpr const char *kInet = "inet"; -/** IPv6 address. */ -static constexpr const char *kInet6 = "inet6"; -/** Unix domain socket path. */ -static constexpr const char *kUnix = "unix"; -} // namespace NetSockFamilyValues +/** wifi. */ +static constexpr const char *kWifi = "wifi"; +/** wired. */ +static constexpr const char *kWired = "wired"; +/** cell. */ +static constexpr const char *kCell = "cell"; +/** unavailable. */ +static constexpr const char *kUnavailable = "unavailable"; +/** unknown. */ +static constexpr const char *kUnknown = "unknown"; +} // namespace NetworkConnectionTypeValues namespace HttpRequestMethodValues { @@ -1563,32 +2003,6 @@ static constexpr const char *kTrace = "TRACE"; static constexpr const char *kOther = "_OTHER"; } // namespace HttpRequestMethodValues -namespace EventDomainValues -{ -/** Events from browser apps. */ -static constexpr const char *kBrowser = "browser"; -/** Events from mobile apps. */ -static constexpr const char *kDevice = "device"; -/** Events from Kubernetes. */ -static constexpr const char *kK8s = "k8s"; -} // namespace EventDomainValues - -namespace LogIostreamValues -{ -/** Logs from stdout stream. */ -static constexpr const char *kStdout = "stdout"; -/** Events from stderr stream. */ -static constexpr const char *kStderr = "stderr"; -} // namespace LogIostreamValues - -namespace TypeValues -{ -/** Heap memory. */ -static constexpr const char *kHeap = "heap"; -/** Non-heap memory. */ -static constexpr const char *kNonHeap = "non_heap"; -} // namespace TypeValues - namespace OpentracingRefTypeValues { /** The parent Span depends on the child Span in some capacity. */ @@ -1731,6 +2145,14 @@ static constexpr const char *kSerial = "serial"; static constexpr const char *kLocalSerial = "local_serial"; } // namespace DbCassandraConsistencyLevelValues +namespace DbCosmosdbConnectionModeValues +{ +/** Gateway (HTTP) connections mode. */ +static constexpr const char *kGateway = "gateway"; +/** Direct connection. */ +static constexpr const char *kDirect = "direct"; +} // namespace DbCosmosdbConnectionModeValues + namespace DbCosmosdbOperationTypeValues { /** invalid. */ @@ -1765,14 +2187,6 @@ static constexpr const char *kQueryPlan = "QueryPlan"; static constexpr const char *kExecuteJavascript = "ExecuteJavaScript"; } // namespace DbCosmosdbOperationTypeValues -namespace DbCosmosdbConnectionModeValues -{ -/** Gateway (HTTP) connections mode. */ -static constexpr const char *kGateway = "gateway"; -/** Direct connection. */ -static constexpr const char *kDirect = "direct"; -} // namespace DbCosmosdbConnectionModeValues - namespace OtelStatusCodeValues { /** The operation has been validated by an Application developer or Operator to have completed @@ -1782,20 +2196,6 @@ static constexpr const char *kOk = "OK"; static constexpr const char *kError = "ERROR"; } // namespace OtelStatusCodeValues -namespace FaasTriggerValues -{ -/** A response to some data source operation such as a database or filesystem read/write. */ -static constexpr const char *kDatasource = "datasource"; -/** To provide an answer to an inbound HTTP request. */ -static constexpr const char *kHttp = "http"; -/** A function is set to be executed when messages are sent to a messaging system. */ -static constexpr const char *kPubsub = "pubsub"; -/** A function is scheduled to be executed regularly. */ -static constexpr const char *kTimer = "timer"; -/** If none of the others apply. */ -static constexpr const char *kOther = "other"; -} // namespace FaasTriggerValues - namespace FaasDocumentOperationValues { /** When a new object is created. */ @@ -1806,100 +2206,6 @@ static constexpr const char *kEdit = "edit"; static constexpr const char *kDelete = "delete"; } // namespace FaasDocumentOperationValues -namespace FaasInvokedProviderValues -{ -/** Alibaba Cloud. */ -static constexpr const char *kAlibabaCloud = "alibaba_cloud"; -/** Amazon Web Services. */ -static constexpr const char *kAws = "aws"; -/** Microsoft Azure. */ -static constexpr const char *kAzure = "azure"; -/** Google Cloud Platform. */ -static constexpr const char *kGcp = "gcp"; -/** Tencent Cloud. */ -static constexpr const char *kTencentCloud = "tencent_cloud"; -} // namespace FaasInvokedProviderValues - -namespace NetworkTransportValues -{ -/** TCP. */ -static constexpr const char *kTcp = "tcp"; -/** UDP. */ -static constexpr const char *kUdp = "udp"; -/** Named or anonymous pipe. See note below. */ -static constexpr const char *kPipe = "pipe"; -/** Unix domain socket. */ -static constexpr const char *kUnix = "unix"; -} // namespace NetworkTransportValues - -namespace NetworkTypeValues -{ -/** IPv4. */ -static constexpr const char *kIpv4 = "ipv4"; -/** IPv6. */ -static constexpr const char *kIpv6 = "ipv6"; -} // namespace NetworkTypeValues - -namespace NetworkConnectionTypeValues -{ -/** wifi. */ -static constexpr const char *kWifi = "wifi"; -/** wired. */ -static constexpr const char *kWired = "wired"; -/** cell. */ -static constexpr const char *kCell = "cell"; -/** unavailable. */ -static constexpr const char *kUnavailable = "unavailable"; -/** unknown. */ -static constexpr const char *kUnknown = "unknown"; -} // namespace NetworkConnectionTypeValues - -namespace NetworkConnectionSubtypeValues -{ -/** GPRS. */ -static constexpr const char *kGprs = "gprs"; -/** EDGE. */ -static constexpr const char *kEdge = "edge"; -/** UMTS. */ -static constexpr const char *kUmts = "umts"; -/** CDMA. */ -static constexpr const char *kCdma = "cdma"; -/** EVDO Rel. 0. */ -static constexpr const char *kEvdo0 = "evdo_0"; -/** EVDO Rev. A. */ -static constexpr const char *kEvdoA = "evdo_a"; -/** CDMA2000 1XRTT. */ -static constexpr const char *kCdma20001xrtt = "cdma2000_1xrtt"; -/** HSDPA. */ -static constexpr const char *kHsdpa = "hsdpa"; -/** HSUPA. */ -static constexpr const char *kHsupa = "hsupa"; -/** HSPA. */ -static constexpr const char *kHspa = "hspa"; -/** IDEN. */ -static constexpr const char *kIden = "iden"; -/** EVDO Rev. B. */ -static constexpr const char *kEvdoB = "evdo_b"; -/** LTE. */ -static constexpr const char *kLte = "lte"; -/** EHRPD. */ -static constexpr const char *kEhrpd = "ehrpd"; -/** HSPAP. */ -static constexpr const char *kHspap = "hspap"; -/** GSM. */ -static constexpr const char *kGsm = "gsm"; -/** TD-SCDMA. */ -static constexpr const char *kTdScdma = "td_scdma"; -/** IWLAN. */ -static constexpr const char *kIwlan = "iwlan"; -/** 5G NR (New Radio). */ -static constexpr const char *kNr = "nr"; -/** 5G NRNSA (New Radio Non-Standalone). */ -static constexpr const char *kNrnsa = "nrnsa"; -/** LTE CA. */ -static constexpr const char *kLteCa = "lte_ca"; -} // namespace NetworkConnectionSubtypeValues - namespace GraphqlOperationTypeValues { /** GraphQL query. */ @@ -1920,6 +2226,14 @@ static constexpr const char *kReceive = "receive"; static constexpr const char *kProcess = "process"; } // namespace MessagingOperationValues +namespace MessagingRocketmqConsumptionModelValues +{ +/** Clustering consumption model. */ +static constexpr const char *kClustering = "clustering"; +/** Broadcasting consumption model. */ +static constexpr const char *kBroadcasting = "broadcasting"; +} // namespace MessagingRocketmqConsumptionModelValues + namespace MessagingRocketmqMessageTypeValues { /** Normal message. */ @@ -1932,14 +2246,6 @@ static constexpr const char *kDelay = "delay"; static constexpr const char *kTransaction = "transaction"; } // namespace MessagingRocketmqMessageTypeValues -namespace MessagingRocketmqConsumptionModelValues -{ -/** Clustering consumption model. */ -static constexpr const char *kClustering = "clustering"; -/** Broadcasting consumption model. */ -static constexpr const char *kBroadcasting = "broadcasting"; -} // namespace MessagingRocketmqConsumptionModelValues - namespace RpcSystemValues { /** gRPC. */ diff --git a/buildscripts/semantic-convention/generate.sh b/buildscripts/semantic-convention/generate.sh index 2a6634baa4..daa5131dc5 100755 --- a/buildscripts/semantic-convention/generate.sh +++ b/buildscripts/semantic-convention/generate.sh @@ -18,10 +18,10 @@ ROOT_DIR="${SCRIPT_DIR}/../../" # https://github.com/open-telemetry/opentelemetry-specification # Repository from 1.21.0: # https://github.com/open-telemetry/semantic-conventions -SEMCONV_VERSION=1.21.0 +SEMCONV_VERSION=1.22.0 # repository: https://github.com/open-telemetry/build-tools -GENERATOR_VERSION=0.19.0 +GENERATOR_VERSION=0.22.0 SPEC_VERSION=v$SEMCONV_VERSION SCHEMA_URL=https://opentelemetry.io/schemas/$SEMCONV_VERSION diff --git a/examples/grpc/client.cc b/examples/grpc/client.cc index 92088c12f6..3163b38986 100644 --- a/examples/grpc/client.cc +++ b/examples/grpc/client.cc @@ -53,8 +53,8 @@ class GreeterClient {{SemanticConventions::kRpcSystem, "grpc"}, {SemanticConventions::kRpcService, "grpc-example.GreetService"}, {SemanticConventions::kRpcMethod, "Greet"}, - {SemanticConventions::kServerSocketAddress, ip}, - {SemanticConventions::kServerPort, port}}, + {SemanticConventions::kNetworkPeerAddress, ip}, + {SemanticConventions::kNetworkPeerPort, port}}, options); auto scope = get_tracer("grpc-client")->WithActiveSpan(span); diff --git a/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h b/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h index 9396a6c7f9..1b45f80c36 100644 --- a/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h +++ b/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h @@ -24,7 +24,14 @@ namespace SemanticConventions /** * The URL of the OpenTelemetry schema for these keys and values. */ -static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.21.0"; +static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.22.0"; + +/** + * Uniquely identifies the framework API revision offered by a version ({@code os.version}) of the + * android operating system. More information can be found here. + */ +static constexpr const char *kAndroidOsApiLevel = "android.os.api_level"; /** * Array of brand name and version separated by a space @@ -36,6 +43,25 @@ static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.21 */ static constexpr const char *kBrowserBrands = "browser.brands"; +/** + * Preferred language of the user using the browser + * + *

Notes: +

  • This value is intended to be taken from the Navigator API {@code + navigator.language}.
+ */ +static constexpr const char *kBrowserLanguage = "browser.language"; + +/** + * A boolean that is true if the browser is running on a mobile device + * + *

Notes: +

  • This value is intended to be taken from the UA client hints API ({@code + navigator.userAgentData.mobile}). If unavailable, this attribute SHOULD be left unset.
+ */ +static constexpr const char *kBrowserMobile = "browser.mobile"; + /** * The platform on which the browser is running * @@ -54,34 +80,34 @@ provides. static constexpr const char *kBrowserPlatform = "browser.platform"; /** - * A boolean that is true if the browser is running on a mobile device + * The cloud account ID the resource is assigned to. + */ +static constexpr const char *kCloudAccountId = "cloud.account.id"; + +/** + * Cloud regions often have multiple, isolated locations known as zones to increase availability. + Availability zone represents the zone where the resource is running. * *

Notes: -

  • This value is intended to be taken from the UA client hints API ({@code - navigator.userAgentData.mobile}). If unavailable, this attribute SHOULD be left unset.
+
  • Availability zones are called "zones" on Alibaba Cloud and Google Cloud.
  • +
*/ -static constexpr const char *kBrowserMobile = "browser.mobile"; +static constexpr const char *kCloudAvailabilityZone = "cloud.availability_zone"; /** - * Preferred language of the user using the browser + * The cloud platform in use. * *

Notes: -

  • This value is intended to be taken from the Navigator API {@code - navigator.language}.
+
  • The prefix of the service SHOULD match the one specified in {@code cloud.provider}.
  • +
*/ -static constexpr const char *kBrowserLanguage = "browser.language"; +static constexpr const char *kCloudPlatform = "cloud.platform"; /** * Name of the cloud provider. */ static constexpr const char *kCloudProvider = "cloud.provider"; -/** - * The cloud account ID the resource is assigned to. - */ -static constexpr const char *kCloudAccountId = "cloud.account.id"; - /** * The geographical region the resource is running. * @@ -127,23 +153,10 @@ that would usually share a TracerProvider. static constexpr const char *kCloudResourceId = "cloud.resource_id"; /** - * Cloud regions often have multiple, isolated locations known as zones to increase availability. - Availability zone represents the zone where the resource is running. - * - *

Notes: -

  • Availability zones are called "zones" on Alibaba Cloud and Google Cloud.
  • -
- */ -static constexpr const char *kCloudAvailabilityZone = "cloud.availability_zone"; - -/** - * The cloud platform in use. - * - *

Notes: -

  • The prefix of the service SHOULD match the one specified in {@code cloud.provider}.
  • -
+ * The ARN of an ECS cluster. */ -static constexpr const char *kCloudPlatform = "cloud.platform"; +static constexpr const char *kAwsEcsClusterArn = "aws.ecs.cluster.arn"; /** * The Amazon Resource Name (ARN) of an ECS cluster. - */ -static constexpr const char *kAwsEcsClusterArn = "aws.ecs.cluster.arn"; - /** * The launch @@ -187,15 +194,6 @@ static constexpr const char *kAwsEcsTaskRevision = "aws.ecs.task.revision"; */ static constexpr const char *kAwsEksClusterArn = "aws.eks.cluster.arn"; -/** - * The name(s) of the AWS log group(s) an application is writing to. - * - *

Notes: -

  • Multiple log groups must be supported for cases like multi-container applications, where - a single application has sidecar containers, and each write to their own log group.
- */ -static constexpr const char *kAwsLogGroupNames = "aws.log.group.names"; - /** * The Amazon Resource Name(s) (ARN) of the AWS log group(s). * @@ -207,9 +205,13 @@ static constexpr const char *kAwsLogGroupNames = "aws.log.group.names"; static constexpr const char *kAwsLogGroupArns = "aws.log.group.arns"; /** - * The name(s) of the AWS log stream(s) an application is writing to. + * The name(s) of the AWS log group(s) an application is writing to. + * + *

Notes: +

  • Multiple log groups must be supported for cases like multi-container applications, where + a single application has sidecar containers, and each write to their own log group.
*/ -static constexpr const char *kAwsLogStreamNames = "aws.log.stream.names"; +static constexpr const char *kAwsLogGroupNames = "aws.log.group.names"; /** * The ARN(s) of the AWS log stream(s). @@ -222,6 +224,11 @@ static constexpr const char *kAwsLogStreamNames = "aws.log.stream.names"; */ static constexpr const char *kAwsLogStreamArns = "aws.log.stream.arns"; +/** + * The name(s) of the AWS log stream(s) an application is writing to. + */ +static constexpr const char *kAwsLogStreamNames = "aws.log.stream.names"; + /** * The name of the Cloud Run
execution being run for the @@ -238,6 +245,12 @@ static constexpr const char *kGcpCloudRunJobExecution = "gcp.cloud_run.job.execu */ static constexpr const char *kGcpCloudRunJobTaskIndex = "gcp.cloud_run.job.task_index"; +/** + * The hostname of a GCE instance. This is the full value of the default or custom hostname. + */ +static constexpr const char *kGcpGceInstanceHostname = "gcp.gce.instance.hostname"; + /** * The instance name of a GCE instance. This is the value provided by {@code host.name}, the visible * name of the instance in the Cloud Console UI, and the prefix for the default hostname of the @@ -248,10 +261,14 @@ static constexpr const char *kGcpCloudRunJobTaskIndex = "gcp.cloud_run.job.task_ static constexpr const char *kGcpGceInstanceName = "gcp.gce.instance.name"; /** - * The hostname of a GCE instance. This is the full value of the default or custom hostname. + * Unique identifier for the application */ -static constexpr const char *kGcpGceInstanceHostname = "gcp.gce.instance.hostname"; +static constexpr const char *kHerokuAppId = "heroku.app.id"; + +/** + * Commit hash for the current release + */ +static constexpr const char *kHerokuReleaseCommit = "heroku.release.commit"; /** * Time and date the release was created @@ -259,19 +276,23 @@ static constexpr const char *kGcpGceInstanceHostname = "gcp.gce.instance.hostnam static constexpr const char *kHerokuReleaseCreationTimestamp = "heroku.release.creation_timestamp"; /** - * Commit hash for the current release + * The command used to run the container (i.e. the command name). + * + *

Notes: +

  • If using embedded credentials or sensitive data, it is recommended to remove them to + prevent potential leakage.
*/ -static constexpr const char *kHerokuReleaseCommit = "heroku.release.commit"; +static constexpr const char *kContainerCommand = "container.command"; /** - * Unique identifier for the application + * All the command arguments (including the command/executable itself) run by the container. [2] */ -static constexpr const char *kHerokuAppId = "heroku.app.id"; +static constexpr const char *kContainerCommandArgs = "container.command_args"; /** - * Container name used by container runtime. + * The full command run by the container as a single string representing the full command. [2] */ -static constexpr const char *kContainerName = "container.name"; +static constexpr const char *kContainerCommandLine = "container.command_line"; /** * Container ID. Usually a UUID, as for example used to +The ID is assinged by the container runtime and can vary in different environments. Consider using +{@code oci.manifest.digest} if it is important to identify the same image in different +environments/runtimes. */ static constexpr const char *kContainerImageId = "container.image.id"; /** - * The command used to run the container (i.e. the command name). + * Name of the image the container was built on. + */ +static constexpr const char *kContainerImageName = "container.image.name"; + +/** + * Repo digests of the container image as provided by the container runtime. * *

Notes: -

  • If using embedded credentials or sensitive data, it is recommended to remove them to - prevent potential leakage.
+
  • Docker and CRI + report those under the {@code RepoDigests} field.
*/ -static constexpr const char *kContainerCommand = "container.command"; +static constexpr const char *kContainerImageRepoDigests = "container.image.repo_digests"; /** - * The full command run by the container as a single string representing the full command. [2] + * Container image tags. An example can be found in Docker Image + * Inspect. Should be only the {@code } section of the full name for example from {@code + * registry.example.com/my-org/my-image:}. */ -static constexpr const char *kContainerCommandLine = "container.command_line"; +static constexpr const char *kContainerImageTags = "container.image.tags"; /** - * All the command arguments (including the command/executable itself) run by the container. [2] + * Container name used by container runtime. */ -static constexpr const char *kContainerCommandArgs = "container.command_args"; +static constexpr const char *kContainerName = "container.name"; + +/** + * The container runtime managing this container. + */ +static constexpr const char *kContainerRuntime = "container.runtime"; /** * Name of the deployment @@ -352,6 +375,16 @@ static constexpr const char *kDeploymentEnvironment = "deployment.environment"; */ static constexpr const char *kDeviceId = "device.id"; +/** + * The name of the device manufacturer + * + *

Notes: +

+ */ +static constexpr const char *kDeviceManufacturer = "device.manufacturer"; + /** * The model identifier for the device * @@ -371,14 +404,25 @@ static constexpr const char *kDeviceModelIdentifier = "device.model.identifier"; static constexpr const char *kDeviceModelName = "device.model.name"; /** - * The name of the device manufacturer + * The execution environment ID as a string, that will be potentially reused for other invocations + to the same function/function version. * *

Notes: -

  • The Android OS provides this field via Build. iOS apps - SHOULD hardcode the value {@code Apple}.
+
  • AWS Lambda: Use the (full) log stream name.
  • +
*/ -static constexpr const char *kDeviceManufacturer = "device.manufacturer"; +static constexpr const char *kFaasInstance = "faas.instance"; + +/** + * The amount of memory available to the serverless function converted to Bytes. + * + *

Notes: +

  • It's recommended to set this attribute since e.g. too little memory can easily stop a + Java AWS Lambda function from working correctly. On AWS Lambda, the environment variable {@code + AWS_LAMBDA_FUNCTION_MEMORY_SIZE} provides this information (which must be multiplied by + 1,048,576).
+ */ +static constexpr const char *kFaasMaxMemory = "faas.max_memory"; /** * The name of the single function that this runtime instance executes. @@ -387,7 +431,7 @@ static constexpr const char *kDeviceManufacturer = "device.manufacturer";
  • This is the name of the function as configured/deployed on the FaaS platform and is usually different from the name of the callback function (which may be stored in the -{@code code.namespace}/{@code +{@code code.namespace}/{@code code.function} span attributes).
  • For some cloud providers, the above definition is ambiguous. The following definition of function name MUST be used for this attribute (and consequently the span name) for the listed cloud providers/products:
  • Azure: @@ -418,25 +462,9 @@ not set this attribute.
  • static constexpr const char *kFaasVersion = "faas.version"; /** - * The execution environment ID as a string, that will be potentially reused for other invocations - to the same function/function version. - * - *

    Notes: -

    • AWS Lambda: Use the (full) log stream name.
    • -
    - */ -static constexpr const char *kFaasInstance = "faas.instance"; - -/** - * The amount of memory available to the serverless function converted to Bytes. - * - *

    Notes: -

    • It's recommended to set this attribute since e.g. too little memory can easily stop a - Java AWS Lambda function from working correctly. On AWS Lambda, the environment variable {@code - AWS_LAMBDA_FUNCTION_MEMORY_SIZE} provides this information (which must be multiplied by - 1,048,576).
    + * The CPU architecture the host system is running on. */ -static constexpr const char *kFaasMaxMemory = "faas.max_memory"; +static constexpr const char *kHostArch = "host.arch"; /** * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For @@ -445,6 +473,32 @@ static constexpr const char *kFaasMaxMemory = "faas.max_memory"; */ static constexpr const char *kHostId = "host.id"; +/** + * VM image ID or host OS image ID. For Cloud, this value is from the provider. + */ +static constexpr const char *kHostImageId = "host.image.id"; + +/** + * Name of the VM image or OS install the host was instantiated from. + */ +static constexpr const char *kHostImageName = "host.image.name"; + +/** + * The version string of the VM image or host OS as defined in Version Attributes. + */ +static constexpr const char *kHostImageVersion = "host.image.version"; + +/** + * Available IP addresses of the host, excluding loopback interfaces. + * + *

    Notes: +

    • IPv4 Addresses MUST be specified in dotted-quad notation. IPv6 addresses MUST be + specified in the RFC 5952 format.
    • +
    + */ +static constexpr const char *kHostIp = "host.ip"; + /** * Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully * qualified hostname, or another name specified by the user. @@ -457,25 +511,40 @@ static constexpr const char *kHostName = "host.name"; static constexpr const char *kHostType = "host.type"; /** - * The CPU architecture the host system is running on. + * The amount of level 2 memory cache available to the processor (in Bytes). */ -static constexpr const char *kHostArch = "host.arch"; +static constexpr const char *kHostCpuCacheL2Size = "host.cpu.cache.l2.size"; /** - * Name of the VM image or OS install the host was instantiated from. + * Numeric value specifying the family or generation of the CPU. */ -static constexpr const char *kHostImageName = "host.image.name"; +static constexpr const char *kHostCpuFamily = "host.cpu.family"; /** - * VM image ID or host OS image ID. For Cloud, this value is from the provider. + * Model identifier. It provides more granular information about the CPU, distinguishing it from + * other CPUs within the same family. */ -static constexpr const char *kHostImageId = "host.image.id"; +static constexpr const char *kHostCpuModelId = "host.cpu.model.id"; /** - * The version string of the VM image or host OS as defined in Version Attributes. + * Model designation of the processor. */ -static constexpr const char *kHostImageVersion = "host.image.version"; +static constexpr const char *kHostCpuModelName = "host.cpu.model.name"; + +/** + * Stepping or core revisions. + */ +static constexpr const char *kHostCpuStepping = "host.cpu.stepping"; + +/** + * Processor manufacturer identifier. A maximum 12-character string. + * + *

    Notes: +

    • CPUID command returns the vendor ID string in + EBX, EDX and ECX registers. Writing these to memory in this order results in a 12-character + string.
    + */ +static constexpr const char *kHostCpuVendorId = "host.cpu.vendor.id"; /** * The name of the cluster. @@ -522,14 +591,14 @@ static constexpr const char *kK8sNodeUid = "k8s.node.uid"; static constexpr const char *kK8sNamespaceName = "k8s.namespace.name"; /** - * The UID of the Pod. + * The name of the Pod. */ -static constexpr const char *kK8sPodUid = "k8s.pod.uid"; +static constexpr const char *kK8sPodName = "k8s.pod.name"; /** - * The name of the Pod. + * The UID of the Pod. */ -static constexpr const char *kK8sPodName = "k8s.pod.name"; +static constexpr const char *kK8sPodUid = "k8s.pod.uid"; /** * The name of the Container from Pod specification, must be unique within a Pod. Container runtime @@ -543,15 +612,20 @@ static constexpr const char *kK8sContainerName = "k8s.container.name"; */ static constexpr const char *kK8sContainerRestartCount = "k8s.container.restart_count"; +/** + * The name of the ReplicaSet. + */ +static constexpr const char *kK8sReplicasetName = "k8s.replicaset.name"; + /** * The UID of the ReplicaSet. */ static constexpr const char *kK8sReplicasetUid = "k8s.replicaset.uid"; /** - * The name of the ReplicaSet. + * The name of the Deployment. */ -static constexpr const char *kK8sReplicasetName = "k8s.replicaset.name"; +static constexpr const char *kK8sDeploymentName = "k8s.deployment.name"; /** * The UID of the Deployment. @@ -559,9 +633,9 @@ static constexpr const char *kK8sReplicasetName = "k8s.replicaset.name"; static constexpr const char *kK8sDeploymentUid = "k8s.deployment.uid"; /** - * The name of the Deployment. + * The name of the StatefulSet. */ -static constexpr const char *kK8sDeploymentName = "k8s.deployment.name"; +static constexpr const char *kK8sStatefulsetName = "k8s.statefulset.name"; /** * The UID of the StatefulSet. @@ -569,9 +643,9 @@ static constexpr const char *kK8sDeploymentName = "k8s.deployment.name"; static constexpr const char *kK8sStatefulsetUid = "k8s.statefulset.uid"; /** - * The name of the StatefulSet. + * The name of the DaemonSet. */ -static constexpr const char *kK8sStatefulsetName = "k8s.statefulset.name"; +static constexpr const char *kK8sDaemonsetName = "k8s.daemonset.name"; /** * The UID of the DaemonSet. @@ -579,9 +653,9 @@ static constexpr const char *kK8sStatefulsetName = "k8s.statefulset.name"; static constexpr const char *kK8sDaemonsetUid = "k8s.daemonset.uid"; /** - * The name of the DaemonSet. + * The name of the Job. */ -static constexpr const char *kK8sDaemonsetName = "k8s.daemonset.name"; +static constexpr const char *kK8sJobName = "k8s.job.name"; /** * The UID of the Job. @@ -589,9 +663,9 @@ static constexpr const char *kK8sDaemonsetName = "k8s.daemonset.name"; static constexpr const char *kK8sJobUid = "k8s.job.uid"; /** - * The name of the Job. + * The name of the CronJob. */ -static constexpr const char *kK8sJobName = "k8s.job.name"; +static constexpr const char *kK8sCronjobName = "k8s.cronjob.name"; /** * The UID of the CronJob. @@ -599,14 +673,23 @@ static constexpr const char *kK8sJobName = "k8s.job.name"; static constexpr const char *kK8sCronjobUid = "k8s.cronjob.uid"; /** - * The name of the CronJob. + * The digest of the OCI image manifest. For container images specifically is the digest by which +the container image is known. + * + *

    Notes: +

    */ -static constexpr const char *kK8sCronjobName = "k8s.cronjob.name"; +static constexpr const char *kOciManifestDigest = "oci.manifest.digest"; /** - * The operating system type. + * Unique identifier for a particular build or compilation of the operating system. */ -static constexpr const char *kOsType = "os.type"; +static constexpr const char *kOsBuildId = "os.build_id"; /** * Human readable (not intended to be parsed) OS version information, like e.g. reported by {@code @@ -619,6 +702,11 @@ static constexpr const char *kOsDescription = "os.description"; */ static constexpr const char *kOsName = "os.name"; +/** + * The operating system type. + */ +static constexpr const char *kOsType = "os.type"; + /** * The version string of the operating system as defined in Version Attributes. @@ -626,14 +714,26 @@ static constexpr const char *kOsName = "os.name"; static constexpr const char *kOsVersion = "os.version"; /** - * Process identifier (PID). + * The command used to launch the process (i.e. the command name). On Linux based systems, can be + * set to the zeroth string in {@code proc/[pid]/cmdline}. On Windows, can be set to the first + * parameter extracted from {@code GetCommandLineW}. */ -static constexpr const char *kProcessPid = "process.pid"; +static constexpr const char *kProcessCommand = "process.command"; /** - * Parent Process identifier (PID). + * All the command arguments (including the command/executable itself) as received by the process. + * On Linux-based systems (and some other Unixoid systems supporting procfs), can be set according + * to the list of null-delimited strings extracted from {@code proc/[pid]/cmdline}. For libc-based + * executables, this would be the full argv vector passed to {@code main}. */ -static constexpr const char *kProcessParentPid = "process.parent_pid"; +static constexpr const char *kProcessCommandArgs = "process.command_args"; + +/** + * The full command used to launch the process as a single string representing the full command. On + * Windows, can be set to the result of {@code GetCommandLineW}. Do not set this if you have to + * assemble it just for monitoring; use {@code process.command_args} instead. + */ +static constexpr const char *kProcessCommandLine = "process.command_line"; /** * The name of the process executable. On Linux based systems, can be set to the {@code Name} in @@ -649,31 +749,25 @@ static constexpr const char *kProcessExecutableName = "process.executable.name"; static constexpr const char *kProcessExecutablePath = "process.executable.path"; /** - * The command used to launch the process (i.e. the command name). On Linux based systems, can be - * set to the zeroth string in {@code proc/[pid]/cmdline}. On Windows, can be set to the first - * parameter extracted from {@code GetCommandLineW}. + * The username of the user that owns the process. */ -static constexpr const char *kProcessCommand = "process.command"; +static constexpr const char *kProcessOwner = "process.owner"; /** - * The full command used to launch the process as a single string representing the full command. On - * Windows, can be set to the result of {@code GetCommandLineW}. Do not set this if you have to - * assemble it just for monitoring; use {@code process.command_args} instead. + * Parent Process identifier (PID). */ -static constexpr const char *kProcessCommandLine = "process.command_line"; +static constexpr const char *kProcessParentPid = "process.parent_pid"; /** - * All the command arguments (including the command/executable itself) as received by the process. - * On Linux-based systems (and some other Unixoid systems supporting procfs), can be set according - * to the list of null-delimited strings extracted from {@code proc/[pid]/cmdline}. For libc-based - * executables, this would be the full argv vector passed to {@code main}. + * Process identifier (PID). */ -static constexpr const char *kProcessCommandArgs = "process.command_args"; +static constexpr const char *kProcessPid = "process.pid"; /** - * The username of the user that owns the process. + * An additional description about the runtime of the process, for example a specific vendor + * customization of the runtime environment. */ -static constexpr const char *kProcessOwner = "process.owner"; +static constexpr const char *kProcessRuntimeDescription = "process.runtime.description"; /** * The name of the runtime of this process. For compiled native binaries, this SHOULD be the name of @@ -686,12 +780,6 @@ static constexpr const char *kProcessRuntimeName = "process.runtime.name"; */ static constexpr const char *kProcessRuntimeVersion = "process.runtime.version"; -/** - * An additional description about the runtime of the process, for example a specific vendor - * customization of the runtime environment. - */ -static constexpr const char *kProcessRuntimeDescription = "process.runtime.description"; - /** * Logical name of the service. * @@ -710,19 +798,6 @@ static constexpr const char *kServiceName = "service.name"; */ static constexpr const char *kServiceVersion = "service.version"; -/** - * A namespace for {@code service.name}. - * - *

    Notes: -

    • A string value having a meaning that helps to distinguish a group of services, for - example the team name that owns a group of services. {@code service.name} is expected to be unique - within the same namespace. If {@code service.namespace} is not specified in the Resource then - {@code service.name} is expected to be unique for all services that have no explicit namespace - defined (so the empty/unspecified namespace is simply one more valid namespace). Zero-length - namespace string is assumed equal to unspecified namespace.
    - */ -static constexpr const char *kServiceNamespace = "service.namespace"; - /** * The string ID of the service instance. * @@ -739,6 +814,24 @@ static constexpr const char *kServiceNamespace = "service.namespace"; */ static constexpr const char *kServiceInstanceId = "service.instance.id"; +/** + * A namespace for {@code service.name}. + * + *

    Notes: +

    • A string value having a meaning that helps to distinguish a group of services, for + example the team name that owns a group of services. {@code service.name} is expected to be unique + within the same namespace. If {@code service.namespace} is not specified in the Resource then + {@code service.name} is expected to be unique for all services that have no explicit namespace + defined (so the empty/unspecified namespace is simply one more valid namespace). Zero-length + namespace string is assumed equal to unspecified namespace.
    + */ +static constexpr const char *kServiceNamespace = "service.namespace"; + +/** + * The language of the telemetry SDK. + */ +static constexpr const char *kTelemetrySdkLanguage = "telemetry.sdk.language"; + /** * The name of the telemetry SDK as defined above. * @@ -754,19 +847,29 @@ stable across different versions of an implementation.
static constexpr const char *kTelemetrySdkName = "telemetry.sdk.name"; /** - * The language of the telemetry SDK. + * The version string of the telemetry SDK. */ -static constexpr const char *kTelemetrySdkLanguage = "telemetry.sdk.language"; +static constexpr const char *kTelemetrySdkVersion = "telemetry.sdk.version"; /** - * The version string of the telemetry SDK. + * The name of the auto instrumentation agent or distribution, if used. + * + *

Notes: +

  • Official auto instrumentation agents and distributions SHOULD set the {@code +telemetry.distro.name} attribute to a string starting with {@code opentelemetry-}, e.g. {@code +opentelemetry-java-instrumentation}.
*/ -static constexpr const char *kTelemetrySdkVersion = "telemetry.sdk.version"; +static constexpr const char *kTelemetryDistroName = "telemetry.distro.name"; /** - * The version string of the auto instrumentation agent, if used. + * The version string of the auto instrumentation agent or distribution, if used. */ -static constexpr const char *kTelemetryAutoVersion = "telemetry.auto.version"; +static constexpr const char *kTelemetryDistroVersion = "telemetry.distro.version"; + +/** + * Additional description of the web engine (e.g. detailed version and edition information). + */ +static constexpr const char *kWebengineDescription = "webengine.description"; /** * The name of the web engine. @@ -778,11 +881,6 @@ static constexpr const char *kWebengineName = "webengine.name"; */ static constexpr const char *kWebengineVersion = "webengine.version"; -/** - * Additional description of the web engine (e.g. detailed version and edition information). - */ -static constexpr const char *kWebengineDescription = "webengine.description"; - /** * The name of the instrumentation scope - ({@code InstrumentationScope.Name} in OTLP). */ @@ -810,24 +908,6 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kOtelLibraryVersion = "otel.library.version"; // Enum definitions -namespace CloudProviderValues -{ -/** Alibaba Cloud. */ -static constexpr const char *kAlibabaCloud = "alibaba_cloud"; -/** Amazon Web Services. */ -static constexpr const char *kAws = "aws"; -/** Microsoft Azure. */ -static constexpr const char *kAzure = "azure"; -/** Google Cloud Platform. */ -static constexpr const char *kGcp = "gcp"; -/** Heroku Platform as a Service. */ -static constexpr const char *kHeroku = "heroku"; -/** IBM Cloud. */ -static constexpr const char *kIbmCloud = "ibm_cloud"; -/** Tencent Cloud. */ -static constexpr const char *kTencentCloud = "tencent_cloud"; -} // namespace CloudProviderValues - namespace CloudPlatformValues { /** Alibaba Cloud Elastic Compute Service. */ @@ -886,6 +966,24 @@ static constexpr const char *kTencentCloudEks = "tencent_cloud_eks"; static constexpr const char *kTencentCloudScf = "tencent_cloud_scf"; } // namespace CloudPlatformValues +namespace CloudProviderValues +{ +/** Alibaba Cloud. */ +static constexpr const char *kAlibabaCloud = "alibaba_cloud"; +/** Amazon Web Services. */ +static constexpr const char *kAws = "aws"; +/** Microsoft Azure. */ +static constexpr const char *kAzure = "azure"; +/** Google Cloud Platform. */ +static constexpr const char *kGcp = "gcp"; +/** Heroku Platform as a Service. */ +static constexpr const char *kHeroku = "heroku"; +/** IBM Cloud. */ +static constexpr const char *kIbmCloud = "ibm_cloud"; +/** Tencent Cloud. */ +static constexpr const char *kTencentCloud = "tencent_cloud"; +} // namespace CloudProviderValues + namespace AwsEcsLaunchtypeValues { /** ec2. */ From 46e20a42aef521b9cc1b7207310bfefcd490741a Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 16 Oct 2023 10:38:49 +0200 Subject: [PATCH 10/29] [RELEASE] Prepare release 1.12.0 (#2359) --- CHANGELOG.md | 70 +++++++++++++++++-- api/include/opentelemetry/version.h | 4 +- docs/public/conf.py | 2 +- .../opentelemetry/sdk/version/version.h | 2 +- sdk/src/version/version.cc | 8 +-- 5 files changed, 71 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f889a287f7..678e2d6b4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,23 +15,74 @@ Increment the: ## [Unreleased] +## [1.12.0] 2023-10-16 + +* [BUILD] Support `pkg-config` + [#2269](https://github.com/open-telemetry/opentelemetry-cpp/pull/2269) +* [CI] Do not automatically close stale issues + [#2277](https://github.com/open-telemetry/opentelemetry-cpp/pull/2277) +* [CI] Benchmark workflow fails, C++14 required to build grpc + [#2278](https://github.com/open-telemetry/opentelemetry-cpp/pull/2278) +* [SDK] Increase metric name maximum length from 63 to 255 characters + [#2284](https://github.com/open-telemetry/opentelemetry-cpp/pull/2284) +* [SEMANTIC CONVENTION] Deprecated semconv (in the spec) + not deprecated (in C++) + [#2285](https://github.com/open-telemetry/opentelemetry-cpp/pull/2285) +* [SDK] Remove unused member variables from SyncMetricStorage + [#2294](https://github.com/open-telemetry/opentelemetry-cpp/pull/2294) * [DEPRECATION] Deprecate ZPAGES [#2291](https://github.com/open-telemetry/opentelemetry-cpp/pull/2291) -* [EXPORTER] Prometheus exporter emit resource attributes - [#2301](https://github.com/open-telemetry/opentelemetry-cpp/pull/2301) -* [EXPORTER] Remove explicit timestamps from metric points exported by Prometheus +* [API] Deliver ABI breaking changes + [#2222](https://github.com/open-telemetry/opentelemetry-cpp/pull/2222) +* [SDK] Allow metric instrument names to contain / characters + [#2310](https://github.com/open-telemetry/opentelemetry-cpp/pull/2310) +* [SDK] Fix Observable Counters/UpDownCounters + [#2298](https://github.com/open-telemetry/opentelemetry-cpp/pull/2298) +* [SDK] Add exemplar reservoir to async metric storage + [#2319](https://github.com/open-telemetry/opentelemetry-cpp/pull/2319) +* [TEST] Fix lifetime issues in prometheus test utils + [#2322](https://github.com/open-telemetry/opentelemetry-cpp/pull/2322) +* [EXPORTER] Prometheus: Remove explicit timestamps from metric points [#2324](https://github.com/open-telemetry/opentelemetry-cpp/pull/2324) -* [EXPORTER] Handle attribute key collisions caused by sanitation +* [EXPORTER] Prometheus: Handle attribute key collisions from sanitation [#2326](https://github.com/open-telemetry/opentelemetry-cpp/pull/2326) -* [EXPORTER] Replace colons with underscores when converting to Prometheus label +* [EXPORTER] Prometheus cleanup, test with TranslateToPrometheus + [#2329](https://github.com/open-telemetry/opentelemetry-cpp/pull/2329) +* [SDK] Fix log message in Meter::RegisterSyncMetricStorage + [#2325](https://github.com/open-telemetry/opentelemetry-cpp/pull/2325) +* [DOC] Simplify the project status section + [#2332](https://github.com/open-telemetry/opentelemetry-cpp/pull/2332) +* [EXPORTER] Prometheus: Sanitize labels according to spec [#2330](https://github.com/open-telemetry/opentelemetry-cpp/pull/2330) +* [SDK] Fix deadlock when shuting down http client + [#2337](https://github.com/open-telemetry/opentelemetry-cpp/pull/2337) +* [Exporter] Group spans by resource and instrumentation scope + in OTLP export requests + [#2335](https://github.com/open-telemetry/opentelemetry-cpp/pull/2335) +* [BUILD] Need fine-grained HAVE_CPP_STDLIB + [#2304](https://github.com/open-telemetry/opentelemetry-cpp/pull/2304) * [API] Add InstrumentationScope attributes in MeterProvider::GetMeter() [#2224](https://github.com/open-telemetry/opentelemetry-cpp/pull/2224) * [REMOVAL] Drop C++11 support [#2342](https://github.com/open-telemetry/opentelemetry-cpp/pull/2342) -* [EXPORTER] Add otel_scope_name and otel_scope_version labels to the prometheus - exporter. +* [EXPORTER] prometheus: add otel_scope_name and otel_scope_version labels [#2293](https://github.com/open-telemetry/opentelemetry-cpp/pull/2293) +* [EXPORTER] Export resource for prometheus + [#2301](https://github.com/open-telemetry/opentelemetry-cpp/pull/2301) +* [BUILD] error: read-only reference ‘value’ used as ‘asm’ output + [#2354](https://github.com/open-telemetry/opentelemetry-cpp/pull/2354) +* [BUILD] Build break with external CMake nlohman_json package + [#2353](https://github.com/open-telemetry/opentelemetry-cpp/pull/2353) +* [BUILD] Upgrade libcurl to version 8.4.0 + [#2358](https://github.com/open-telemetry/opentelemetry-cpp/pull/2358) +* [BUILD] Fix opentracing-shim when added in super project + [#2356](https://github.com/open-telemetry/opentelemetry-cpp/pull/2356) +* [BUILD] Fix protoc searching with non-imported protobuf::protoc target + [#2362](https://github.com/open-telemetry/opentelemetry-cpp/pull/2362) +* [BUILD] Support to use different cmake package CONFIG of dependencies + [#2263](https://github.com/open-telemetry/opentelemetry-cpp/pull/2263) +* [SEMANTIC CONVENTION] Upgrade to semconv 1.22.0 + [#2368](https://github.com/open-telemetry/opentelemetry-cpp/pull/2368) Important changes: @@ -70,6 +121,11 @@ Breaking changes: [#2342](https://github.com/open-telemetry/opentelemetry-cpp/pull/2342) * Building with C++11 is no longer supported. +Deprecations: + +* [DEPRECATION] Deprecate ZPAGES + [#2291](https://github.com/open-telemetry/opentelemetry-cpp/pull/2291) + ## [1.11.0] 2023-08-21 * [BUILD] Fix more cases for symbol name for 32-bit win32 DLL build diff --git a/api/include/opentelemetry/version.h b/api/include/opentelemetry/version.h index fd88ffb383..79284c1501 100644 --- a/api/include/opentelemetry/version.h +++ b/api/include/opentelemetry/version.h @@ -10,9 +10,9 @@ # define OPENTELEMETRY_ABI_VERSION_NO 1 #endif -#define OPENTELEMETRY_VERSION "1.11.0" +#define OPENTELEMETRY_VERSION "1.12.0" #define OPENTELEMETRY_VERSION_MAJOR 1 -#define OPENTELEMETRY_VERSION_MINOR 11 +#define OPENTELEMETRY_VERSION_MINOR 12 #define OPENTELEMETRY_VERSION_PATCH 0 #define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO) diff --git a/docs/public/conf.py b/docs/public/conf.py index 1c090b8b35..2375c45924 100644 --- a/docs/public/conf.py +++ b/docs/public/conf.py @@ -24,7 +24,7 @@ author = 'OpenTelemetry authors' # The full version, including alpha/beta/rc tags -release = "1.11.0" +release = "1.12.0" # Run sphinx on subprojects and copy output # ----------------------------------------- diff --git a/sdk/include/opentelemetry/sdk/version/version.h b/sdk/include/opentelemetry/sdk/version/version.h index b790af4574..16bd121b92 100644 --- a/sdk/include/opentelemetry/sdk/version/version.h +++ b/sdk/include/opentelemetry/sdk/version/version.h @@ -5,7 +5,7 @@ #include "opentelemetry/detail/preprocessor.h" -#define OPENTELEMETRY_SDK_VERSION "1.11.0" +#define OPENTELEMETRY_SDK_VERSION "1.12.0" #include "opentelemetry/version.h" diff --git a/sdk/src/version/version.cc b/sdk/src/version/version.cc index 34175bd4e4..fb2db64c30 100644 --- a/sdk/src/version/version.cc +++ b/sdk/src/version/version.cc @@ -12,13 +12,13 @@ namespace sdk namespace version { const int major_version = 1; -const int minor_version = 11; +const int minor_version = 12; const int patch_version = 0; const char *pre_release = "NONE"; const char *build_metadata = "NONE"; -const char *short_version = "1.11.0"; -const char *full_version = "1.11.0-NONE-NONE"; -const char *build_date = "Mon Aug 21 22:31:07 UTC 2023"; +const char *short_version = "1.12.0"; +const char *full_version = "1.12.0-NONE-NONE"; +const char *build_date = "Mon 16 Oct 2023 07:42:23 AM UTC"; } // namespace version } // namespace sdk From e918960e06b45e899cd6e1f361acdb578d968334 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 16 Oct 2023 22:07:47 +0200 Subject: [PATCH 11/29] [BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead (#2370) --- CHANGELOG.md | 10 ++++++++++ api/CMakeLists.txt | 5 ----- api/include/opentelemetry/metrics/meter_provider.h | 14 +++++++++++++- api/include/opentelemetry/metrics/noop.h | 2 +- ci/do_ci.sh | 4 ---- .../opentelemetry/sdk/metrics/meter_provider.h | 2 +- sdk/src/metrics/meter_provider.cc | 2 +- sdk/test/metrics/meter_provider_sdk_test.cc | 4 ++-- 8 files changed, 28 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 678e2d6b4f..48c379b7de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,16 @@ Increment the: ## [Unreleased] +* [BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead + [#2370](https://github.com/open-telemetry/opentelemetry-cpp/pull/2370) + +Breaking changes: + +* [BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead + [#2370](https://github.com/open-telemetry/opentelemetry-cpp/pull/2370) + * The experimental `CMake` option `WITH_REMOVE_METER_PREVIEW` is removed, + use option `WITH_ABI_VERSION_2` instead. + ## [1.12.0] 2023-10-16 * [BUILD] Support `pkg-config` diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index dd1eda3c78..ecbb377725 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -114,11 +114,6 @@ if(WITH_ASYNC_EXPORT_PREVIEW) target_compile_definitions(opentelemetry_api INTERFACE ENABLE_ASYNC_EXPORT) endif() -if(WITH_REMOVE_METER_PREVIEW) - target_compile_definitions(opentelemetry_api - INTERFACE ENABLE_REMOVE_METER_PREVIEW) -endif() - target_compile_definitions( opentelemetry_api INTERFACE OPENTELEMETRY_ABI_VERSION_NO=${OPENTELEMETRY_ABI_VERSION_NO}) diff --git a/api/include/opentelemetry/metrics/meter_provider.h b/api/include/opentelemetry/metrics/meter_provider.h index 152e543d36..fca960bb8e 100644 --- a/api/include/opentelemetry/metrics/meter_provider.h +++ b/api/include/opentelemetry/metrics/meter_provider.h @@ -126,7 +126,19 @@ class MeterProvider nostd::string_view schema_url = "") noexcept = 0; #endif -#ifdef ENABLE_REMOVE_METER_PREVIEW +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + /** + * Remove a named Meter instance (ABI). + * + * This API is experimental, see + * https://github.com/open-telemetry/opentelemetry-specification/issues/2232 + * + * @since ABI_VERSION 2 + * + * @param[in] name Meter instrumentation scope + * @param[in] version Instrumentation scope version, optional + * @param[in] schema_url Instrumentation scope schema URL, optional + */ virtual void RemoveMeter(nostd::string_view name, nostd::string_view version = "", nostd::string_view schema_url = "") noexcept = 0; diff --git a/api/include/opentelemetry/metrics/noop.h b/api/include/opentelemetry/metrics/noop.h index edbbe2c100..f20e855cb7 100644 --- a/api/include/opentelemetry/metrics/noop.h +++ b/api/include/opentelemetry/metrics/noop.h @@ -214,7 +214,7 @@ class NoopMeterProvider final : public MeterProvider } #endif -#ifdef ENABLE_REMOVE_METER_PREVIEW +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 void RemoveMeter(nostd::string_view /* name */, nostd::string_view /* version */, nostd::string_view /* schema_url */) noexcept override diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 948a62b9dd..d9dc0c178f 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -112,7 +112,6 @@ elif [[ "$1" == "cmake.maintainer.sync.test" ]]; then -DWITH_OTLP_HTTP=ON \ -DWITH_OTLP_HTTP_SSL_PREVIEW=ON \ -DWITH_OTLP_HTTP_SSL_TLS_PREVIEW=ON \ - -DWITH_REMOVE_METER_PREVIEW=ON \ -DWITH_PROMETHEUS=ON \ -DWITH_EXAMPLES=ON \ -DWITH_EXAMPLES_HTTP=ON \ @@ -135,7 +134,6 @@ elif [[ "$1" == "cmake.maintainer.async.test" ]]; then -DWITH_OTLP_HTTP=ON \ -DWITH_OTLP_HTTP_SSL_PREVIEW=ON \ -DWITH_OTLP_HTTP_SSL_TLS_PREVIEW=ON \ - -DWITH_REMOVE_METER_PREVIEW=ON \ -DWITH_PROMETHEUS=ON \ -DWITH_EXAMPLES=ON \ -DWITH_EXAMPLES_HTTP=ON \ @@ -159,7 +157,6 @@ elif [[ "$1" == "cmake.maintainer.cpp11.async.test" ]]; then -DWITH_OTLP_HTTP=ON \ -DWITH_OTLP_HTTP_SSL_PREVIEW=ON \ -DWITH_OTLP_HTTP_SSL_TLS_PREVIEW=ON \ - -DWITH_REMOVE_METER_PREVIEW=ON \ -DWITH_PROMETHEUS=ON \ -DWITH_EXAMPLES=ON \ -DWITH_EXAMPLES_HTTP=ON \ @@ -181,7 +178,6 @@ elif [[ "$1" == "cmake.maintainer.abiv2.test" ]]; then -DWITH_OTLP_HTTP=ON \ -DWITH_OTLP_HTTP_SSL_PREVIEW=ON \ -DWITH_OTLP_HTTP_SSL_TLS_PREVIEW=ON \ - -DWITH_REMOVE_METER_PREVIEW=ON \ -DWITH_PROMETHEUS=ON \ -DWITH_EXAMPLES=ON \ -DWITH_EXAMPLES_HTTP=ON \ diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h index 00f9a35ac2..c7089844a5 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h @@ -66,7 +66,7 @@ class MeterProvider final : public opentelemetry::metrics::MeterProvider nostd::string_view schema_url = "") noexcept override; #endif -#ifdef ENABLE_REMOVE_METER_PREVIEW +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 void RemoveMeter(nostd::string_view name, nostd::string_view version, nostd::string_view schema_url) noexcept override; diff --git a/sdk/src/metrics/meter_provider.cc b/sdk/src/metrics/meter_provider.cc index 23ddbc75cf..63bea5ae28 100644 --- a/sdk/src/metrics/meter_provider.cc +++ b/sdk/src/metrics/meter_provider.cc @@ -75,7 +75,7 @@ nostd::shared_ptr MeterProvider::GetMeter( return nostd::shared_ptr{meter}; } -#ifdef ENABLE_REMOVE_METER_PREVIEW +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 void MeterProvider::RemoveMeter(nostd::string_view name, nostd::string_view version, nostd::string_view schema_url) noexcept diff --git a/sdk/test/metrics/meter_provider_sdk_test.cc b/sdk/test/metrics/meter_provider_sdk_test.cc index 1844f113d2..ce79b563c1 100644 --- a/sdk/test/metrics/meter_provider_sdk_test.cc +++ b/sdk/test/metrics/meter_provider_sdk_test.cc @@ -191,7 +191,7 @@ TEST(MeterProvider, GetMeterAbiv2) } #endif /* OPENTELEMETRY_ABI_VERSION_NO >= 2 */ -#ifdef ENABLE_REMOVE_METER_PREVIEW +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 TEST(MeterProvider, RemoveMeter) { MeterProvider mp; @@ -225,4 +225,4 @@ TEST(MeterProvider, RemoveMeter) mp.ForceFlush(); mp.Shutdown(); } -#endif +#endif /* OPENTELEMETRY_ABI_VERSION_NO >= 2 */ From 231ca4ade18c8cf691c9520d174b518feae78f35 Mon Sep 17 00:00:00 2001 From: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> Date: Thu, 19 Oct 2023 00:20:54 +0530 Subject: [PATCH 12/29] [SDK] Metrics ObservableRegistry Cleanup (#2376) --- .../opentelemetry/sdk/metrics/async_instruments.h | 1 + .../sdk/metrics/state/observable_registry.h | 2 ++ sdk/src/metrics/async_instruments.cc | 5 +++++ sdk/src/metrics/state/observable_registry.cc | 10 ++++++++++ 4 files changed, 18 insertions(+) diff --git a/sdk/include/opentelemetry/sdk/metrics/async_instruments.h b/sdk/include/opentelemetry/sdk/metrics/async_instruments.h index a22ce1f0f8..48c7d14ec5 100644 --- a/sdk/include/opentelemetry/sdk/metrics/async_instruments.h +++ b/sdk/include/opentelemetry/sdk/metrics/async_instruments.h @@ -25,6 +25,7 @@ class ObservableInstrument : public opentelemetry::metrics::ObservableInstrument ObservableInstrument(InstrumentDescriptor instrument_descriptor, std::unique_ptr storage, std::shared_ptr observable_registry); + ~ObservableInstrument() override; void AddCallback(opentelemetry::metrics::ObservableCallbackPtr callback, void *state) noexcept override; diff --git a/sdk/include/opentelemetry/sdk/metrics/state/observable_registry.h b/sdk/include/opentelemetry/sdk/metrics/state/observable_registry.h index 5eb5b6d6ff..b584cc055f 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/observable_registry.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/observable_registry.h @@ -35,6 +35,8 @@ class ObservableRegistry void *state, opentelemetry::metrics::ObservableInstrument *instrument); + void CleanupCallback(opentelemetry::metrics::ObservableInstrument *instrument); + void Observe(opentelemetry::common::SystemTimestamp collection_ts); private: diff --git a/sdk/src/metrics/async_instruments.cc b/sdk/src/metrics/async_instruments.cc index 082d6713b4..5ca56b3969 100644 --- a/sdk/src/metrics/async_instruments.cc +++ b/sdk/src/metrics/async_instruments.cc @@ -21,6 +21,11 @@ ObservableInstrument::ObservableInstrument(InstrumentDescriptor instrument_descr {} +ObservableInstrument::~ObservableInstrument() +{ + observable_registry_->CleanupCallback(this); +} + void ObservableInstrument::AddCallback(opentelemetry::metrics::ObservableCallbackPtr callback, void *state) noexcept { diff --git a/sdk/src/metrics/state/observable_registry.cc b/sdk/src/metrics/state/observable_registry.cc index 0296167b05..41b8e86067 100644 --- a/sdk/src/metrics/state/observable_registry.cc +++ b/sdk/src/metrics/state/observable_registry.cc @@ -38,6 +38,16 @@ void ObservableRegistry::RemoveCallback(opentelemetry::metrics::ObservableCallba callbacks_.erase(new_end, callbacks_.end()); } +void ObservableRegistry::CleanupCallback(opentelemetry::metrics::ObservableInstrument *instrument) +{ + std::lock_guard lock_guard{callbacks_m_}; + auto iter = std::remove_if(callbacks_.begin(), callbacks_.end(), + [instrument](const std::unique_ptr &record) { + return record->instrument == instrument; + }); + callbacks_.erase(iter, callbacks_.end()); +} + void ObservableRegistry::Observe(opentelemetry::common::SystemTimestamp collection_ts) { std::lock_guard lock_guard{callbacks_m_}; From 0e6eae04668f67fb4720bedeb16d219ef837c8f5 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 19 Oct 2023 09:42:40 +0200 Subject: [PATCH 13/29] [BUILD] Make WITH_OTLP_HTTP_SSL_PREVIEW mainstream (#2378) --- CHANGELOG.md | 13 +++++++++++++ CMakeLists.txt | 8 ++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48c379b7de..0e30d1784e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,19 @@ Increment the: * [BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead [#2370](https://github.com/open-telemetry/opentelemetry-cpp/pull/2370) +* [BUILD] Make WITH_OTLP_HTTP_SSL_PREVIEW mainstream + [#2378](https://github.com/open-telemetry/opentelemetry-cpp/pull/2378) + +Important changes: + +* [BUILD] Make WITH_OTLP_HTTP_SSL_PREVIEW mainstream + [#2378](https://github.com/open-telemetry/opentelemetry-cpp/pull/2378) + * The experimental `CMake` option `WITH_OTLP_HTTP_SSL_PREVIEW` + is now promoted to stable. The default is changed to `ON`. + * The experimental `CMake` option `WITH_OTLP_HTTP_SSL_TLS_PREVIEW` + is now promoted to stable. The default is changed to `ON`. + * These build options are scheduled to be removed by the next release, + building without SSL/TLS will no longer be possible. Breaking changes: diff --git a/CMakeLists.txt b/CMakeLists.txt index 4af81bf0e9..b72e58a963 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,12 +275,12 @@ endif() option(WITH_ASYNC_EXPORT_PREVIEW "Whether to enable async export" OFF) -# EXPERIMENTAL -option(WITH_OTLP_HTTP_SSL_PREVIEW "Whether to enable otlp http ssl export" OFF) +# STABLE +option(WITH_OTLP_HTTP_SSL_PREVIEW "Whether to enable otlp http ssl export" ON) -# EXPERIMENTAL +# STABLE option(WITH_OTLP_HTTP_SSL_TLS_PREVIEW - "Whether to enable otlp http ssl tls min/max/cipher options" OFF) + "Whether to enable otlp http ssl tls min/max/cipher options" ON) # Exemplar specs status is experimental, so behind feature flag by default option(WITH_METRICS_EXEMPLAR_PREVIEW From d9ad76f6be2b85d8685c31bbdc470a0fb555baba Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Thu, 19 Oct 2023 02:28:12 -0700 Subject: [PATCH 14/29] [SDK] Creating DoubleUpDownCounter with no matching view (#2379) --- .../metrics/aggregation/default_aggregation.h | 3 ++- sdk/test/metrics/sum_aggregation_test.cc | 26 +++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h b/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h index 6ae111fd85..4f3346707f 100644 --- a/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h +++ b/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h @@ -35,7 +35,8 @@ class DefaultAggregation case AggregationType::kSum: return (instrument_descriptor.value_type_ == InstrumentValueType::kLong) ? std::move(std::unique_ptr(new LongSumAggregation(is_monotonic))) - : std::move(std::unique_ptr(new DoubleSumAggregation(true))); + : std::move( + std::unique_ptr(new DoubleSumAggregation(is_monotonic))); break; case AggregationType::kHistogram: { if (instrument_descriptor.value_type_ == InstrumentValueType::kLong) diff --git a/sdk/test/metrics/sum_aggregation_test.cc b/sdk/test/metrics/sum_aggregation_test.cc index b355f134ed..403bf34b22 100644 --- a/sdk/test/metrics/sum_aggregation_test.cc +++ b/sdk/test/metrics/sum_aggregation_test.cc @@ -121,8 +121,12 @@ TEST(CounterToSum, Double) ASSERT_EQ(1000275.0, opentelemetry::nostd::get(actual.value_)); } -TEST(UpDownCounterToSum, Double) +class UpDownCounterToSumFixture : public ::testing::TestWithParam +{}; + +TEST_P(UpDownCounterToSumFixture, Double) { + bool is_matching_view = GetParam(); MeterProvider mp; auto m = mp.GetMeter("meter1", "version1", "schema1"); std::string instrument_name = "updowncounter1"; @@ -133,13 +137,16 @@ TEST(UpDownCounterToSum, Double) std::shared_ptr reader{new MockMetricReader(std::move(exporter))}; mp.AddMetricReader(reader); - std::unique_ptr view{ - new View("view1", "view1_description", instrument_unit, AggregationType::kSum)}; - std::unique_ptr instrument_selector{ - new InstrumentSelector(InstrumentType::kUpDownCounter, instrument_name, instrument_unit)}; - std::unique_ptr meter_selector{new MeterSelector("meter1", "version1", "schema1")}; - mp.AddView(std::move(instrument_selector), std::move(meter_selector), std::move(view)); - + if (is_matching_view) + { + std::unique_ptr view{ + new View("view1", "view1_description", instrument_unit, AggregationType::kSum)}; + std::unique_ptr instrument_selector{ + new InstrumentSelector(InstrumentType::kUpDownCounter, instrument_name, instrument_unit)}; + std::unique_ptr meter_selector{ + new MeterSelector("meter1", "version1", "schema1")}; + mp.AddView(std::move(instrument_selector), std::move(meter_selector), std::move(view)); + } auto h = m->CreateDoubleUpDownCounter(instrument_name, instrument_desc, instrument_unit); h->Add(5, {}); @@ -168,4 +175,7 @@ TEST(UpDownCounterToSum, Double) const auto &actual = actuals.at(0); ASSERT_EQ(15.0, opentelemetry::nostd::get(actual.value_)); } +INSTANTIATE_TEST_SUITE_P(UpDownCounterToSum, + UpDownCounterToSumFixture, + ::testing::Values(true, false)); #endif From 91dd15fbdfd23b33e66e4750a8009d2f91525cb1 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 19 Oct 2023 23:34:58 +0200 Subject: [PATCH 15/29] [API] Add InstrumentationScope attributes in TracerProvider::GetTracer() (#2371) --- CHANGELOG.md | 10 ++ api/include/opentelemetry/trace/noop.h | 15 +- .../opentelemetry/trace/tracer_provider.h | 99 ++++++++++++- api/test/singleton/singleton_test.cc | 16 +- api/test/trace/provider_test.cc | 17 ++- .../opentelemetry/sdk/trace/tracer_provider.h | 19 ++- sdk/src/trace/tracer_provider.cc | 37 +++-- sdk/test/trace/tracer_provider_test.cc | 137 ++++++++++++++++++ 8 files changed, 327 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e30d1784e..01f54cf339 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,9 +19,19 @@ Increment the: [#2370](https://github.com/open-telemetry/opentelemetry-cpp/pull/2370) * [BUILD] Make WITH_OTLP_HTTP_SSL_PREVIEW mainstream [#2378](https://github.com/open-telemetry/opentelemetry-cpp/pull/2378) +* [API] Add InstrumentationScope attributes in TracerProvider::GetTracer() + [#2371](https://github.com/open-telemetry/opentelemetry-cpp/pull/2371) Important changes: +* [API] Add InstrumentationScope attributes in TracerProvider::GetTracer() + [#2371](https://github.com/open-telemetry/opentelemetry-cpp/pull/2371) + * TracerProvider::GetTracer() now accepts InstrumentationScope attributes. + * Because this is an `ABI` breaking change, the fix is only available + with the `CMake` option `WITH_ABI_VERSION_2=ON`. + * When building with `CMake` option `WITH_ABI_VERSION_1=ON` (by default) + the `ABI` is unchanged, and the fix is not available. + * [BUILD] Make WITH_OTLP_HTTP_SSL_PREVIEW mainstream [#2378](https://github.com/open-telemetry/opentelemetry-cpp/pull/2378) * The experimental `CMake` option `WITH_OTLP_HTTP_SSL_PREVIEW` diff --git a/api/include/opentelemetry/trace/noop.h b/api/include/opentelemetry/trace/noop.h index 2a2b7312ba..c6a5838867 100644 --- a/api/include/opentelemetry/trace/noop.h +++ b/api/include/opentelemetry/trace/noop.h @@ -108,12 +108,23 @@ class OPENTELEMETRY_EXPORT NoopTracerProvider final : public trace::TracerProvid : tracer_{nostd::shared_ptr(new trace::NoopTracer)} {} - nostd::shared_ptr GetTracer(nostd::string_view /* library_name */, - nostd::string_view /* library_version */, +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + nostd::shared_ptr GetTracer( + nostd::string_view /* name */, + nostd::string_view /* version */, + nostd::string_view /* schema_url */, + const common::KeyValueIterable * /* attributes */) noexcept override + { + return tracer_; + } +#else + nostd::shared_ptr GetTracer(nostd::string_view /* name */, + nostd::string_view /* version */, nostd::string_view /* schema_url */) noexcept override { return tracer_; } +#endif private: nostd::shared_ptr tracer_; diff --git a/api/include/opentelemetry/trace/tracer_provider.h b/api/include/opentelemetry/trace/tracer_provider.h index bc8ff8da89..059298d395 100644 --- a/api/include/opentelemetry/trace/tracer_provider.h +++ b/api/include/opentelemetry/trace/tracer_provider.h @@ -3,6 +3,8 @@ #pragma once +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" @@ -20,15 +22,106 @@ class OPENTELEMETRY_EXPORT TracerProvider { public: virtual ~TracerProvider() = default; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + + /** + * Gets or creates a named Tracer instance (ABI). + * + * @since ABI_VERSION 2 + * + * @param[in] name Tracer instrumentation scope + * @param[in] version Instrumentation scope version + * @param[in] schema_url Instrumentation scope schema URL + * @param[in] attributes Instrumentation scope attributes (optional, may be nullptr) + */ + virtual nostd::shared_ptr GetTracer( + nostd::string_view name, + nostd::string_view version, + nostd::string_view schema_url, + const common::KeyValueIterable *attributes) noexcept = 0; + + /** + * Gets or creates a named Tracer instance (API helper). + * + * @since ABI_VERSION 2 + * + * @param[in] name Tracer instrumentation scope + * @param[in] version Instrumentation scope version, optional + * @param[in] schema_url Instrumentation scope schema URL, optional + */ + nostd::shared_ptr GetTracer(nostd::string_view name, + nostd::string_view version = "", + nostd::string_view schema_url = "") + { + return GetTracer(name, version, schema_url, nullptr); + } + + /** + * Gets or creates a named Tracer instance (API helper). + * + * @since ABI_VERSION 2 + * + * @param[in] name Tracer instrumentation scope + * @param[in] version Instrumentation scope version + * @param[in] schema_url Instrumentation scope schema URL + * @param[in] attributes Instrumentation scope attributes + */ + nostd::shared_ptr GetTracer( + nostd::string_view name, + nostd::string_view version, + nostd::string_view schema_url, + std::initializer_list> attributes) + { + /* Build a container from std::initializer_list. */ + nostd::span> attributes_span{ + attributes.begin(), attributes.end()}; + + /* Build a view on the container. */ + common::KeyValueIterableView< + nostd::span>> + iterable_attributes{attributes_span}; + + /* Add attributes using the view. */ + return GetTracer(name, version, schema_url, &iterable_attributes); + } + + /** + * Gets or creates a named Tracer instance (API helper). + * + * @since ABI_VERSION 2 + * + * @param[in] name Tracer instrumentation scope + * @param[in] version Instrumentation scope version + * @param[in] schema_url Instrumentation scope schema URL + * @param[in] attributes Instrumentation scope attributes container + */ + template ::value> * = nullptr> + nostd::shared_ptr GetTracer(nostd::string_view name, + nostd::string_view version, + nostd::string_view schema_url, + const T &attributes) + { + /* Build a view on the container. */ + common::KeyValueIterableView iterable_attributes(attributes); + + /* Add attributes using the view. */ + return GetTracer(name, version, schema_url, &iterable_attributes); + } + +#else + /** * Gets or creates a named tracer instance. * * Optionally a version can be passed to create a named and versioned tracer * instance. */ - virtual nostd::shared_ptr GetTracer(nostd::string_view library_name, - nostd::string_view library_version = "", - nostd::string_view schema_url = "") noexcept = 0; + virtual nostd::shared_ptr GetTracer(nostd::string_view name, + nostd::string_view version = "", + nostd::string_view schema_url = "") noexcept = 0; +#endif }; } // namespace trace OPENTELEMETRY_END_NAMESPACE diff --git a/api/test/singleton/singleton_test.cc b/api/test/singleton/singleton_test.cc index 44a445e5bd..187e26f2b4 100644 --- a/api/test/singleton/singleton_test.cc +++ b/api/test/singleton/singleton_test.cc @@ -264,13 +264,25 @@ class MyTracerProvider : public trace::TracerProvider return result; } - nostd::shared_ptr GetTracer(nostd::string_view /* library_name */, - nostd::string_view /* library_version */, +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + nostd::shared_ptr GetTracer( + nostd::string_view /* name */, + nostd::string_view /* version */, + nostd::string_view /* schema_url */, + const common::KeyValueIterable * /* attributes */) noexcept override + { + nostd::shared_ptr result(new MyTracer()); + return result; + } +#else + nostd::shared_ptr GetTracer(nostd::string_view /* name */, + nostd::string_view /* version */, nostd::string_view /* schema_url */) noexcept override { nostd::shared_ptr result(new MyTracer()); return result; } +#endif }; void setup_otel() diff --git a/api/test/trace/provider_test.cc b/api/test/trace/provider_test.cc index 21e3619334..be2ca2842c 100644 --- a/api/test/trace/provider_test.cc +++ b/api/test/trace/provider_test.cc @@ -3,6 +3,7 @@ #include "opentelemetry/trace/provider.h" #include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/trace/tracer_provider.h" #include @@ -14,12 +15,24 @@ namespace nostd = opentelemetry::nostd; class TestProvider : public TracerProvider { - nostd::shared_ptr GetTracer(nostd::string_view /* library_name */, - nostd::string_view /* library_version */, + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + nostd::shared_ptr GetTracer( + nostd::string_view /* name */, + nostd::string_view /* version */, + nostd::string_view /* schema_url */, + const opentelemetry::common::KeyValueIterable * /* attributes */) noexcept override + { + return nostd::shared_ptr(nullptr); + } +#else + nostd::shared_ptr GetTracer(nostd::string_view /* name */, + nostd::string_view /* version */, nostd::string_view /* schema_url */) noexcept override { return nostd::shared_ptr(nullptr); } +#endif }; TEST(Provider, GetTracerProviderDefault) diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h index 092db1eaf8..ce2a6d4401 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h @@ -63,10 +63,23 @@ class TracerProvider final : public opentelemetry::trace::TracerProvider ~TracerProvider() override; + /* + Make sure GetTracer() helpers from the API are seen in overload resolution. + */ + using opentelemetry::trace::TracerProvider::GetTracer; + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + opentelemetry::nostd::shared_ptr GetTracer( + nostd::string_view name, + nostd::string_view version, + nostd::string_view schema_url, + const opentelemetry::common::KeyValueIterable *attributes) noexcept override; +#else opentelemetry::nostd::shared_ptr GetTracer( - nostd::string_view library_name, - nostd::string_view library_version = "", - nostd::string_view schema_url = "") noexcept override; + nostd::string_view name, + nostd::string_view version = "", + nostd::string_view schema_url = "") noexcept override; +#endif /** * Attaches a span processor to list of configured processors for this tracer provider. diff --git a/sdk/src/trace/tracer_provider.cc b/sdk/src/trace/tracer_provider.cc index 13d56f9966..8569b63f23 100644 --- a/sdk/src/trace/tracer_provider.cc +++ b/sdk/src/trace/tracer_provider.cc @@ -53,17 +53,29 @@ TracerProvider::~TracerProvider() } } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 nostd::shared_ptr TracerProvider::GetTracer( - nostd::string_view library_name, - nostd::string_view library_version, + nostd::string_view name, + nostd::string_view version, + nostd::string_view schema_url, + const opentelemetry::common::KeyValueIterable *attributes) noexcept +#else +nostd::shared_ptr TracerProvider::GetTracer( + nostd::string_view name, + nostd::string_view version, nostd::string_view schema_url) noexcept +#endif { - if (library_name.data() == nullptr) +#if OPENTELEMETRY_ABI_VERSION_NO < 2 + const opentelemetry::common::KeyValueIterable *attributes = nullptr; +#endif + + if (name.data() == nullptr) { OTEL_INTERNAL_LOG_ERROR("[TracerProvider::GetTracer] Library name is null."); - library_name = ""; + name = ""; } - else if (library_name == "") + else if (name == "") { OTEL_INTERNAL_LOG_ERROR("[TracerProvider::GetTracer] Library name is empty."); } @@ -72,17 +84,20 @@ nostd::shared_ptr TracerProvider::GetTracer( for (auto &tracer : tracers_) { - auto &tracer_lib = tracer->GetInstrumentationScope(); - if (tracer_lib.equal(library_name, library_version, schema_url)) + auto &tracer_scope = tracer->GetInstrumentationScope(); + if (tracer_scope.equal(name, version, schema_url)) { return nostd::shared_ptr{tracer}; } } - auto lib = InstrumentationScope::Create(library_name, library_version, schema_url); - tracers_.push_back(std::shared_ptr( - new sdk::trace::Tracer(context_, std::move(lib)))); - return nostd::shared_ptr{tracers_.back()}; + instrumentationscope::InstrumentationScopeAttributes attrs_map(attributes); + auto scope = + instrumentationscope::InstrumentationScope::Create(name, version, schema_url, attrs_map); + + auto tracer = std::shared_ptr(new Tracer(context_, std::move(scope))); + tracers_.push_back(tracer); + return nostd::shared_ptr{tracer}; } void TracerProvider::AddProcessor(std::unique_ptr processor) noexcept diff --git a/sdk/test/trace/tracer_provider_test.cc b/sdk/test/trace/tracer_provider_test.cc index 364efc0208..8e1b22fb62 100644 --- a/sdk/test/trace/tracer_provider_test.cc +++ b/sdk/test/trace/tracer_provider_test.cc @@ -78,6 +78,143 @@ TEST(TracerProvider, GetTracer) ASSERT_EQ(instrumentation_scope3.GetVersion(), "1.0.0"); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +TEST(TracerProvider, GetTracerAbiv2) +{ + std::unique_ptr processor(new SimpleSpanProcessor(nullptr)); + std::vector> processors; + processors.push_back(std::move(processor)); + std::unique_ptr context1( + new TracerContext(std::move(processors), Resource::Create({}))); + TracerProvider tp(std::move(context1)); + + auto t1 = tp.GetTracer("name1", "version1", "url1"); + ASSERT_NE(nullptr, t1); + + auto t2 = tp.GetTracer("name2", "version2", "url2", nullptr); + ASSERT_NE(nullptr, t2); + + auto t3 = tp.GetTracer("name3", "version3", "url3", {{"accept_single_attr", true}}); + ASSERT_NE(nullptr, t3); + { + auto tracer = static_cast(t3.get()); + auto scope = tracer->GetInstrumentationScope(); + auto attrs = scope.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + auto attr = attrs.find("accept_single_attr"); + ASSERT_FALSE(attr == attrs.end()); + ASSERT_TRUE(opentelemetry::nostd::holds_alternative(attr->second)); + EXPECT_EQ(opentelemetry::nostd::get(attr->second), true); + } + + std::pair attr4 = { + "accept_single_attr", true}; + auto t4 = tp.GetTracer("name4", "version4", "url4", {attr4}); + ASSERT_NE(nullptr, t4); + { + auto tracer = static_cast(t4.get()); + auto scope = tracer->GetInstrumentationScope(); + auto attrs = scope.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + auto attr = attrs.find("accept_single_attr"); + ASSERT_FALSE(attr == attrs.end()); + ASSERT_TRUE(opentelemetry::nostd::holds_alternative(attr->second)); + EXPECT_EQ(opentelemetry::nostd::get(attr->second), true); + } + + auto t5 = tp.GetTracer("name5", "version5", "url5", {{"foo", "1"}, {"bar", "2"}}); + ASSERT_NE(nullptr, t5); + { + auto tracer = static_cast(t5.get()); + auto scope = tracer->GetInstrumentationScope(); + auto attrs = scope.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + auto attr = attrs.find("bar"); + ASSERT_FALSE(attr == attrs.end()); + ASSERT_TRUE(opentelemetry::nostd::holds_alternative(attr->second)); + EXPECT_EQ(opentelemetry::nostd::get(attr->second), "2"); + } + + std::initializer_list< + std::pair> + attrs6 = {{"foo", "1"}, {"bar", 42}}; + + auto t6 = tp.GetTracer("name6", "version6", "url6", attrs6); + ASSERT_NE(nullptr, t6); + { + auto tracer = static_cast(t6.get()); + auto scope = tracer->GetInstrumentationScope(); + auto attrs = scope.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + auto attr = attrs.find("bar"); + ASSERT_FALSE(attr == attrs.end()); + ASSERT_TRUE(opentelemetry::nostd::holds_alternative(attr->second)); + EXPECT_EQ(opentelemetry::nostd::get(attr->second), 42); + } + + typedef std::pair KV; + + std::initializer_list attrs7 = {{"foo", 3.14}, {"bar", "2"}}; + auto t7 = tp.GetTracer("name7", "version7", "url7", attrs7); + ASSERT_NE(nullptr, t7); + { + auto tracer = static_cast(t7.get()); + auto scope = tracer->GetInstrumentationScope(); + auto attrs = scope.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + auto attr = attrs.find("foo"); + ASSERT_FALSE(attr == attrs.end()); + ASSERT_TRUE(opentelemetry::nostd::holds_alternative(attr->second)); + EXPECT_EQ(opentelemetry::nostd::get(attr->second), 3.14); + } + + auto t8 = tp.GetTracer("name8", "version8", "url8", + {{"a", "string"}, + {"b", false}, + {"c", 314159}, + {"d", (unsigned int)314159}, + {"e", (int32_t)-20}, + {"f", (uint32_t)20}, + {"g", (int64_t)-20}, + {"h", (uint64_t)20}, + {"i", 3.1}, + {"j", "string"}}); + ASSERT_NE(nullptr, t8); + { + auto tracer = static_cast(t8.get()); + auto scope = tracer->GetInstrumentationScope(); + auto attrs = scope.GetAttributes(); + ASSERT_EQ(attrs.size(), 10); + auto attr = attrs.find("e"); + ASSERT_FALSE(attr == attrs.end()); + ASSERT_TRUE(opentelemetry::nostd::holds_alternative(attr->second)); + EXPECT_EQ(opentelemetry::nostd::get(attr->second), -20); + } + + std::map attr9{ + {"a", "string"}, {"b", false}, {"c", 314159}, {"d", (unsigned int)314159}, + {"e", (int32_t)-20}, {"f", (uint32_t)20}, {"g", (int64_t)-20}, {"h", (uint64_t)20}, + {"i", 3.1}, {"j", "string"}}; + + auto t9 = tp.GetTracer("name9", "version9", "url9", attr9); + ASSERT_NE(nullptr, t9); + { + auto tracer = static_cast(t9.get()); + auto scope = tracer->GetInstrumentationScope(); + auto attrs = scope.GetAttributes(); + ASSERT_EQ(attrs.size(), 10); + auto attr = attrs.find("h"); + ASSERT_FALSE(attr == attrs.end()); + ASSERT_TRUE(opentelemetry::nostd::holds_alternative(attr->second)); + EXPECT_EQ(opentelemetry::nostd::get(attr->second), 20); + } + + // cleanup properly without crash + tp.ForceFlush(); + tp.Shutdown(); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO >= 2 */ + TEST(TracerProvider, Shutdown) { std::unique_ptr processor(new SimpleSpanProcessor(nullptr)); From f16deb0740dbbbdde2e434c3d142247b43f55460 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Oct 2023 23:01:38 -0700 Subject: [PATCH 16/29] Bump peter-evans/create-or-update-comment from 3.0.2 to 3.1.0 (#2381) --- .github/workflows/project_management_comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/project_management_comment.yml b/.github/workflows/project_management_comment.yml index c3ddd0034f..feba7112af 100644 --- a/.github/workflows/project_management_comment.yml +++ b/.github/workflows/project_management_comment.yml @@ -12,7 +12,7 @@ jobs: issues: write steps: - name: Add comment - uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa + uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 with: issue-number: ${{ github.event.issue.number }} body: | From 045be9c02b555545e64eff91a792cc3869a0892c Mon Sep 17 00:00:00 2001 From: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> Date: Tue, 24 Oct 2023 03:12:28 +0530 Subject: [PATCH 17/29] [BUILD] DLL export interface for Metrics (#2344) --- ci/do_ci.ps1 | 12 +++++- .../common/metrics_foo_library/CMakeLists.txt | 8 +++- examples/metrics_simple/CMakeLists.txt | 19 ++++++++-- examples/otlp/CMakeLists.txt | 28 ++++++++++---- .../otlp/otlp_grpc_metric_exporter_factory.h | 2 +- .../otlp/otlp_http_metric_exporter_factory.h | 2 +- ext/src/dll/CMakeLists.txt | 14 +++++++ ext/src/dll/opentelemetry_cpp.src | 37 +++++++++++++++++++ ...periodic_exporting_metric_reader_factory.h | 2 +- .../sdk/metrics/meter_context_factory.h | 2 +- .../sdk/metrics/meter_provider.h | 2 +- .../sdk/metrics/meter_provider_factory.h | 2 +- .../view/instrument_selector_factory.h | 2 +- .../sdk/metrics/view/meter_selector_factory.h | 2 +- 14 files changed, 112 insertions(+), 22 deletions(-) diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index e55cf8e536..b97617e96f 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -58,7 +58,7 @@ switch ($action) { cmake $SRC_DIR ` -DVCPKG_TARGET_TRIPLET=x64-windows ` -DOPENTELEMETRY_BUILD_DLL=1 ` - "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" + "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" $exit = $LASTEXITCODE if ($exit -ne 0) { exit $exit @@ -79,6 +79,16 @@ switch ($action) { if ($exit -ne 0) { exit $exit } + examples\metrics_simple\Debug\metrics_ostream_example.exe + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } + examples\logs_simple\Debug\example_logs_simple.exe + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } } "cmake.maintainer.test" { cd "$BUILD_DIR" diff --git a/examples/common/metrics_foo_library/CMakeLists.txt b/examples/common/metrics_foo_library/CMakeLists.txt index a91b2595b8..abda93c3e6 100644 --- a/examples/common/metrics_foo_library/CMakeLists.txt +++ b/examples/common/metrics_foo_library/CMakeLists.txt @@ -1,6 +1,12 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 +if(DEFINED OPENTELEMETRY_BUILD_DLL) + add_definitions(-DOPENTELEMETRY_BUILD_IMPORT_DLL) +endif() + add_library(common_metrics_foo_library foo_library.h foo_library.cc) set_target_version(common_metrics_foo_library) -target_link_libraries(common_metrics_foo_library PUBLIC opentelemetry_api) + +target_link_libraries(common_metrics_foo_library + PUBLIC ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) diff --git a/examples/metrics_simple/CMakeLists.txt b/examples/metrics_simple/CMakeLists.txt index 2018ed808c..0fc8c24621 100644 --- a/examples/metrics_simple/CMakeLists.txt +++ b/examples/metrics_simple/CMakeLists.txt @@ -1,9 +1,20 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 +if(DEFINED OPENTELEMETRY_BUILD_DLL) + add_definitions(-DOPENTELEMETRY_BUILD_IMPORT_DLL) +endif() + include_directories(${CMAKE_SOURCE_DIR}/exporters/ostream/include) + add_executable(metrics_ostream_example metrics_ostream.cc) -target_link_libraries( - metrics_ostream_example ${CMAKE_THREAD_LIBS_INIT} opentelemetry_metrics - opentelemetry_exporter_ostream_metrics opentelemetry_resources - common_metrics_foo_library) +target_link_libraries(metrics_ostream_example ${CMAKE_THREAD_LIBS_INIT} + common_metrics_foo_library) + +if(DEFINED OPENTELEMETRY_BUILD_DLL) + target_link_libraries(metrics_ostream_example opentelemetry_cpp) +else() + target_link_libraries( + metrics_ostream_example opentelemetry_metrics + opentelemetry_exporter_ostream_metrics opentelemetry_resources) +endif() diff --git a/examples/otlp/CMakeLists.txt b/examples/otlp/CMakeLists.txt index 398300ab36..5d051a52cc 100644 --- a/examples/otlp/CMakeLists.txt +++ b/examples/otlp/CMakeLists.txt @@ -28,10 +28,15 @@ if(WITH_OTLP_GRPC) add_executable(example_otlp_grpc_metric grpc_metric_main.cc) - target_link_libraries( - example_otlp_grpc_metric ${CMAKE_THREAD_LIBS_INIT} - common_metrics_foo_library opentelemetry_metrics - opentelemetry_exporter_otlp_grpc_metrics) + target_link_libraries(example_otlp_grpc_metric ${CMAKE_THREAD_LIBS_INIT} + common_metrics_foo_library) + + if(DEFINED OPENTELEMETRY_BUILD_DLL) + target_link_libraries(example_otlp_grpc_metric opentelemetry_cpp) + else() + target_link_libraries(example_otlp_grpc_metric opentelemetry_metrics + opentelemetry_exporter_otlp_grpc_metrics) + endif() # LOG @@ -66,10 +71,17 @@ if(WITH_OTLP_HTTP) # METRIC add_executable(example_otlp_http_metric http_metric_main.cc) - target_link_libraries( - example_otlp_http_metric ${CMAKE_THREAD_LIBS_INIT} - common_metrics_foo_library opentelemetry_metrics - opentelemetry_exporter_otlp_http_metric) + target_link_libraries(example_otlp_http_metric ${CMAKE_THREAD_LIBS_INIT} + common_metrics_foo_library) + + if(DEFINED OPENTELEMETRY_BUILD_DLL) + target_link_libraries(example_otlp_http_metric opentelemetry_cpp + opentelemetry_common) + else() + target_link_libraries( + example_otlp_http_metric common_metrics_foo_library opentelemetry_metrics + opentelemetry_exporter_otlp_http_metric) + endif() # LOG diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h index d605100ae6..f8b3ee1fc3 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h @@ -15,7 +15,7 @@ namespace otlp /** * Factory class for OtlpGrpcMetricExporter. */ -class OtlpGrpcMetricExporterFactory +class OPENTELEMETRY_EXPORT OtlpGrpcMetricExporterFactory { public: /** diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h index 2fe0476575..7fa7980470 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h @@ -17,7 +17,7 @@ namespace otlp /** * Factory class for OtlpHttpMetricExporter. */ -class OtlpHttpMetricExporterFactory +class OPENTELEMETRY_EXPORT OtlpHttpMetricExporterFactory { public: /** diff --git a/ext/src/dll/CMakeLists.txt b/ext/src/dll/CMakeLists.txt index c0b6b91745..687d55e01f 100644 --- a/ext/src/dll/CMakeLists.txt +++ b/ext/src/dll/CMakeLists.txt @@ -22,6 +22,20 @@ if(WITH_OTLP_HTTP) PRIVATE opentelemetry_exporter_otlp_http) endif() +target_link_libraries( + opentelemetry_cpp PRIVATE opentelemetry_metrics + opentelemetry_exporter_ostream_metrics) + +if(WITH_OTLP_GRPC) + target_link_libraries(opentelemetry_cpp + PRIVATE opentelemetry_exporter_otlp_grpc_metrics) +endif() + +if(WITH_OTLP_HTTP) + target_link_libraries(opentelemetry_cpp + PRIVATE opentelemetry_exporter_otlp_http_metric) +endif() + target_link_libraries( opentelemetry_cpp PRIVATE opentelemetry_logs opentelemetry_exporter_ostream_logs) diff --git a/ext/src/dll/opentelemetry_cpp.src b/ext/src/dll/opentelemetry_cpp.src index 5d6d5e0092..49226ec543 100644 --- a/ext/src/dll/opentelemetry_cpp.src +++ b/ext/src/dll/opentelemetry_cpp.src @@ -57,15 +57,48 @@ EXPORTS ?ForceFlush@TracerProvider@trace@sdk@v1@opentelemetry@@QEAA_NV?$duration@_JU?$ratio@$00$0PECEA@@std@@@chrono@std@@@Z ?ForceFlush@LoggerProvider@logs@sdk@v1@opentelemetry@@QEAA_NV?$duration@_JU?$ratio@$00$0PECEA@@std@@@chrono@std@@@Z ??0OStreamLogRecordExporter@logs@exporter@v1@opentelemetry@@QEAA@AEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z + + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::metrics::OStreamMetricExporterFactory::Create(void) + ?Create@OStreamMetricExporterFactory@metrics@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@std@@XZ + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::PeriodicExportingMetricReaderFactory::Create(class std::unique_ptr >,struct opentelemetry::v1::sdk::metrics::PeriodicExportingMetricReaderOptions const & __ptr64) + ?Create@PeriodicExportingMetricReaderFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMetricReader@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMetricReader@metrics@sdk@v1@opentelemetry@@@std@@@std@@V?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@7@AEBUPeriodicExportingMetricReaderOptions@2345@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::MeterProviderFactory::Create(void) + ?Create@MeterProviderFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterProvider@metrics@v1@opentelemetry@@U?$default_delete@VMeterProvider@metrics@v1@opentelemetry@@@std@@@std@@XZ + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::MeterContextFactory::Create(void) + ?Create@MeterContextFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterContext@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterContext@metrics@sdk@v1@opentelemetry@@@std@@@std@@XZ + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::MeterProviderFactory::Create(class std::unique_ptr >) + ?Create@MeterProviderFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterProvider@metrics@v1@opentelemetry@@U?$default_delete@VMeterProvider@metrics@v1@opentelemetry@@@std@@@std@@V?$unique_ptr@VMeterContext@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterContext@metrics@sdk@v1@opentelemetry@@@std@@@7@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::ViewFactory::Create(class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,enum opentelemetry::v1::sdk::metrics::AggregationType,class std::shared_ptr) + ?Create@ViewFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@00W4AggregationType@2345@V?$shared_ptr@VAggregationConfig@metrics@sdk@v1@opentelemetry@@@7@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::ViewFactory::Create(class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,enum opentelemetry::v1::sdk::metrics::AggregationType) + ?Create@ViewFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@00W4AggregationType@2345@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::MeterSelectorFactory::Create(class opentelemetry::v1::nostd::string_view,class opentelemetry::v1::nostd::string_view,class opentelemetry::v1::nostd::string_view) + ?Create@MeterSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@Vstring_view@nostd@45@00@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::InstrumentSelectorFactory::Create(enum opentelemetry::v1::sdk::metrics::InstrumentType,class opentelemetry::v1::nostd::string_view,class opentelemetry::v1::nostd::string_view) + ?Create@InstrumentSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@W4InstrumentType@2345@Vstring_view@nostd@45@1@Z + + // public: void __cdecl opentelemetry::v1::sdk::metrics::MeterContext::AddMetricReader(class std::shared_ptr) + ?AddMetricReader@MeterContext@metrics@sdk@v1@opentelemetry@@QEAAXV?$shared_ptr@VMetricReader@metrics@sdk@v1@opentelemetry@@@std@@@Z + // public: void __cdecl opentelemetry::v1::sdk::metrics::MeterProvider::AddMetricReader(class std::shared_ptr) + ?AddMetricReader@MeterProvider@metrics@sdk@v1@opentelemetry@@QEAAXV?$shared_ptr@VMetricReader@metrics@sdk@v1@opentelemetry@@@std@@@Z + // public: void __cdecl opentelemetry::v1::sdk::metrics::MeterProvider::AddView(class std::unique_ptr >,class std::unique_ptr >,class std::unique_ptr >) + ?AddView@MeterProvider@metrics@sdk@v1@opentelemetry@@QEAAXV?$unique_ptr@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@V?$unique_ptr@VMeterSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterSelector@metrics@sdk@v1@opentelemetry@@@std@@@7@V?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@7@@Z + + #if defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP) ?GetOtlpDefaultTracesTimeout@otlp@exporter@v1@opentelemetry@@YA?AV?$duration@_JU?$ratio@$00$0JIJGIA@@std@@@chrono@std@@XZ ?GetOtlpDefaultTracesHeaders@otlp@exporter@v1@opentelemetry@@YA?AV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@Ucmp_ic@otlp@exporter@v1@opentelemetry@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ ?GetOtlpDefaultLogsTimeout@otlp@exporter@v1@opentelemetry@@YA?AV?$duration@_JU?$ratio@$00$0JIJGIA@@std@@@chrono@std@@XZ ?GetOtlpDefaultLogsHeaders@otlp@exporter@v1@opentelemetry@@YA?AV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@Ucmp_ic@otlp@exporter@v1@opentelemetry@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ + ?GetOtlpDefaultMetricsTimeout@otlp@exporter@v1@opentelemetry@@YA?AV?$duration@_JU?$ratio@$00$0JIJGIA@@std@@@chrono@std@@XZ + ?GetOtlpDefaultMetricsHeaders@otlp@exporter@v1@opentelemetry@@YA?AV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@Ucmp_ic@otlp@exporter@v1@opentelemetry@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ #endif // defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP) #if defined(WITH_OTLP_GRPC) // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcLogRecordExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpGrpcExporterOptions const & __ptr64) ?Create@OtlpGrpcLogRecordExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VLogRecordExporter@logs@sdk@v1@opentelemetry@@U?$default_delete@VLogRecordExporter@logs@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpGrpcExporterOptions@2345@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporterOptions const & __ptr64) + ?Create@OtlpGrpcMetricExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpGrpcMetricExporterOptions@2345@@Z + ?GetOtlpDefaultGrpcTracesEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ ?GetOtlpDefaultGrpcTracesIsInsecure@otlp@exporter@v1@opentelemetry@@YA_NXZ ?GetOtlpDefaultTracesSslCertificatePath@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @@ -76,5 +109,9 @@ EXPORTS ?Create@OtlpHttpLogRecordExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VLogRecordExporter@logs@sdk@v1@opentelemetry@@U?$default_delete@VLogRecordExporter@logs@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpHttpLogRecordExporterOptions@2345@@Z ?GetOtlpDefaultHttpTracesEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ ?GetOtlpDefaultHttpLogsEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ + + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpHttpMetricExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpHttpMetricExporterOptions const &) + ?Create@OtlpHttpMetricExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpHttpMetricExporterOptions@2345@@Z + ?GetOtlpDefaultHttpMetricsEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ #endif // defined(WITH_OTLP_HTTP) // clang-format on diff --git a/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h b/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h index c4254793f3..1c5c1a0d7b 100644 --- a/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h @@ -16,7 +16,7 @@ namespace metrics class MetricReader; class PushMetricExporter; -class PeriodicExportingMetricReaderFactory +class OPENTELEMETRY_EXPORT PeriodicExportingMetricReaderFactory { public: static std::unique_ptr Create(std::unique_ptr exporter, diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h b/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h index d5ca16cc27..13e3a9f290 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h @@ -21,7 +21,7 @@ class ViewRegistry; /** * Factory class for MeterContext. */ -class MeterContextFactory +class OPENTELEMETRY_EXPORT MeterContextFactory { public: /** diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h index c7089844a5..8a8c04c636 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h @@ -30,7 +30,7 @@ class MeterContext; class MetricCollector; class MetricReader; -class MeterProvider final : public opentelemetry::metrics::MeterProvider +class OPENTELEMETRY_EXPORT MeterProvider final : public opentelemetry::metrics::MeterProvider { public: /** diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h index 6c0375ad9d..69e77ebf5e 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h @@ -56,7 +56,7 @@ namespace metrics even if this forces, temporarily, existing applications to use a downcast. */ -class MeterProviderFactory +class OPENTELEMETRY_EXPORT MeterProviderFactory { public: static std::unique_ptr Create(); diff --git a/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h b/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h index f30b1e27c1..0af1efe04b 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h @@ -14,7 +14,7 @@ namespace metrics class InstrumentSelector; -class InstrumentSelectorFactory +class OPENTELEMETRY_EXPORT InstrumentSelectorFactory { public: static std::unique_ptr Create( diff --git a/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h b/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h index f335f725f7..bd599d9c4b 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h @@ -16,7 +16,7 @@ namespace metrics class MeterSelector; -class MeterSelectorFactory +class OPENTELEMETRY_EXPORT MeterSelectorFactory { public: static std::unique_ptr Create(opentelemetry::nostd::string_view name, From 0baf5015ea3b4efc1e86db6fa179ec2e3918eb80 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Tue, 24 Oct 2023 10:11:32 +0200 Subject: [PATCH 18/29] [BUILD] enum CanonicalCode names too generic... conflict with old C defines (#2385) --- CHANGELOG.md | 9 ++ .../opentelemetry/trace/canonical_code.h | 141 ------------------ api/include/opentelemetry/trace/span.h | 1 - .../exporters/ostream/span_exporter.h | 2 +- .../ext/zpages/threadsafe_span_data.h | 1 - .../opentelemetry/ext/zpages/tracez_data.h | 2 - .../ext/zpages/tracez_data_aggregator.h | 3 - 7 files changed, 10 insertions(+), 149 deletions(-) delete mode 100644 api/include/opentelemetry/trace/canonical_code.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 01f54cf339..536a90487a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ Increment the: [#2378](https://github.com/open-telemetry/opentelemetry-cpp/pull/2378) * [API] Add InstrumentationScope attributes in TracerProvider::GetTracer() [#2371](https://github.com/open-telemetry/opentelemetry-cpp/pull/2371) +* [BUILD] enum CanonicalCode names too generic... conflict with old C defines + [#2385](https://github.com/open-telemetry/opentelemetry-cpp/pull/2385) Important changes: @@ -48,6 +50,13 @@ Breaking changes: * The experimental `CMake` option `WITH_REMOVE_METER_PREVIEW` is removed, use option `WITH_ABI_VERSION_2` instead. +* [BUILD] enum CanonicalCode names too generic... conflict with old C defines + [#2385](https://github.com/open-telemetry/opentelemetry-cpp/pull/2385) + * Header file `opentelemetry/trace/canonical_code.h` is unused, + and is now removed. + * This header should not be included directly in an application. + If this is the case, please remove any remaining include directives. + ## [1.12.0] 2023-10-16 * [BUILD] Support `pkg-config` diff --git a/api/include/opentelemetry/trace/canonical_code.h b/api/include/opentelemetry/trace/canonical_code.h deleted file mode 100644 index fd722891d6..0000000000 --- a/api/include/opentelemetry/trace/canonical_code.h +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace trace -{ -enum class CanonicalCode : uint8_t -{ - /** - * The operation completed successfully. - */ - OK = 0, - - /** - * The operation was cancelled (typically by the caller). - */ - CANCELLED = 1, - - /** - * Unknown error. An example of where this error may be returned is if a Status value received - * from another address space belongs to an error-space that is not known in this address space. - * Also errors raised by APIs that do not return enough error information may be converted to - * this error. - */ - UNKNOWN = 2, - - /** - * Client specified an invalid argument. Note that this differs from FAILED_PRECONDITION. - * INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of the - * system (e.g., a malformed file name). - */ - INVALID_ARGUMENT = 3, - - /** - * Deadline expired before operation could complete. For operations that change the state of the - * system, this error may be returned even if the operation has completed successfully. For - * example, a successful response from a server could have been delayed long enough for the - * deadline to expire. - */ - DEADLINE_EXCEEDED = 4, - - /** - * Some requested entity (e.g., file or directory) was not found. - */ - NOT_FOUND = 5, - - /** - * Some entity that we attempted to create (e.g., file or directory) already exists. - */ - ALREADY_EXISTS = 6, - - /** - * The caller does not have permission to execute the specified operation. PERMISSION_DENIED - * must not be used for rejections caused by exhausting some resource (use RESOURCE_EXHAUSTED - * instead for those errors). PERMISSION_DENIED must not be used if the caller cannot be - * identified (use UNAUTHENTICATED instead for those errors). - */ - PERMISSION_DENIED = 7, - - /** - * Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system - * is out of space. - */ - RESOURCE_EXHAUSTED = 8, - - /** - * Operation was rejected because the system is not in a state required for the operation's - * execution. For example, directory to be deleted may be non-empty, an rmdir operation is - * applied to a non-directory, etc. - * - * A litmus test that may help a service implementor in deciding between FAILED_PRECONDITION, - * ABORTED, and UNAVAILABLE: (a) Use UNAVAILABLE if the client can retry just the failing call. - * (b) Use ABORTED if the client should retry at a higher-level (e.g., restarting a - * read-modify-write sequence). (c) Use FAILED_PRECONDITION if the client should not retry until - * the system state has been explicitly fixed. E.g., if an "rmdir" fails because the directory - * is non-empty, FAILED_PRECONDITION should be returned since the client should not retry unless - * they have first fixed up the directory by deleting files from it. - */ - FAILED_PRECONDITION = 9, - - /** - * The operation was aborted, typically due to a concurrency issue like sequencer check - * failures, transaction aborts, etc. - * - * See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE. - */ - ABORTED = 10, - - /** - * Operation was attempted past the valid range. E.g., seeking or reading past end of file. - * - * Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed if the system - * state changes. For example, a 32-bit file system will generate INVALID_ARGUMENT if asked to - * read at an offset that is not in the range [0,2^32-1], but it will generate OUT_OF_RANGE if - * asked to read from an offset past the current file size. - * - * There is a fair bit of overlap between FAILED_PRECONDITION and OUT_OF_RANGE. We recommend - * using OUT_OF_RANGE (the more specific error) when it applies so that callers who are - * iterating through a space can easily look for an OUT_OF_RANGE error to detect when they are - * done. - */ - OUT_OF_RANGE = 11, - - /** - * Operation is not implemented or not supported/enabled in this service. - */ - UNIMPLEMENTED = 12, - - /** - * Internal errors. Means some invariants expected by underlying system has been broken. If you - * see one of these errors, something is very broken. - */ - INTERNAL = 13, - - /** - * The service is currently unavailable. This is a most likely a transient condition and may be - * corrected by retrying with a backoff. - * - * See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE. - */ - UNAVAILABLE = 14, - - /** - * Unrecoverable data loss or corruption. - */ - DATA_LOSS = 15, - - /** - * The request does not have valid authentication credentials for the operation. - */ - UNAUTHENTICATED = 16, -}; - -} // namespace trace -OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/trace/span.h b/api/include/opentelemetry/trace/span.h index ffd145a30d..8fb371d48c 100644 --- a/api/include/opentelemetry/trace/span.h +++ b/api/include/opentelemetry/trace/span.h @@ -10,7 +10,6 @@ #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/type_traits.h" -#include "opentelemetry/trace/canonical_code.h" #include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_metadata.h" diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h index baa4e860b1..05c8a89982 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h @@ -55,7 +55,7 @@ class OStreamSpanExporter final : public opentelemetry::sdk::trace::SpanExporter mutable opentelemetry::common::SpinLockMutex lock_; bool isShutdown() const noexcept; - // Mapping status number to the string from api/include/opentelemetry/trace/canonical_code.h + // Mapping status number to the string from api/include/opentelemetry/trace/span_metadata.h std::map statusMap{{0, "Unset"}, {1, "Ok"}, {2, "Error"}}; // various print helpers diff --git a/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h b/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h index fdc244255b..bd1f716ad8 100644 --- a/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h +++ b/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h @@ -12,7 +12,6 @@ #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/span_data.h" -#include "opentelemetry/trace/canonical_code.h" #include "opentelemetry/trace/span.h" #include "opentelemetry/trace/span_id.h" #include "opentelemetry/trace/trace_id.h" diff --git a/ext/include/opentelemetry/ext/zpages/tracez_data.h b/ext/include/opentelemetry/ext/zpages/tracez_data.h index 4594fbe057..5f36a6b047 100644 --- a/ext/include/opentelemetry/ext/zpages/tracez_data.h +++ b/ext/include/opentelemetry/ext/zpages/tracez_data.h @@ -12,13 +12,11 @@ #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/trace/span_data.h" -#include "opentelemetry/trace/canonical_code.h" #include "opentelemetry/trace/span_id.h" #include "opentelemetry/trace/trace_id.h" #include "opentelemetry/version.h" using opentelemetry::ext::zpages::ThreadsafeSpanData; -using opentelemetry::trace::CanonicalCode; using opentelemetry::trace::SpanId; using opentelemetry::trace::TraceId; diff --git a/ext/include/opentelemetry/ext/zpages/tracez_data_aggregator.h b/ext/include/opentelemetry/ext/zpages/tracez_data_aggregator.h index 62c944b704..5bc7e847db 100644 --- a/ext/include/opentelemetry/ext/zpages/tracez_data_aggregator.h +++ b/ext/include/opentelemetry/ext/zpages/tracez_data_aggregator.h @@ -19,9 +19,6 @@ #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/trace/span_data.h" -#include "opentelemetry/trace/canonical_code.h" - -using opentelemetry::trace::CanonicalCode; OPENTELEMETRY_BEGIN_NAMESPACE namespace ext From d3a873a673809875595aaf98615b8a1a1fc501db Mon Sep 17 00:00:00 2001 From: jafonso Date: Wed, 25 Oct 2023 20:33:21 +0200 Subject: [PATCH 19/29] [BUILD] Fix cpack broken package version (#2386) --- cmake/package.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/package.cmake b/cmake/package.cmake index ef0a879e0f..c14b38fde0 100644 --- a/cmake/package.cmake +++ b/cmake/package.cmake @@ -1,6 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 +set(CPACK_PACKAGE_VERSION "${OPENTELEMETRY_VERSION}") set(CPACK_PACKAGE_DESCRIPTION "OpenTelemetry C++ for Linux") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenTelemetry C++ for Linux - C++ Implementation of OpenTelemetry Specification") set(CPACK_PACKAGE_VENDOR "OpenTelemetry") From 17da6d87c1fbd5e63260b3eb414e426e255dfebd Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Fri, 27 Oct 2023 18:27:57 +0200 Subject: [PATCH 20/29] [API] Add a new AddLink() operation to Span (#2380) --- CHANGELOG.md | 11 + api/include/opentelemetry/plugin/tracer.h | 14 + .../opentelemetry/trace/default_span.h | 8 + api/include/opentelemetry/trace/noop.h | 9 + api/include/opentelemetry/trace/span.h | 138 ++++++- .../trace/span_context_kv_iterable.h | 1 + api/test/trace/noop_test.cc | 15 + examples/plugin/plugin/tracer.cc | 8 + sdk/src/trace/span.cc | 29 ++ sdk/src/trace/span.h | 7 + sdk/test/trace/tracer_test.cc | 386 ++++++++++++++++++ 11 files changed, 623 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 536a90487a..a76b91692b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ Increment the: [#2371](https://github.com/open-telemetry/opentelemetry-cpp/pull/2371) * [BUILD] enum CanonicalCode names too generic... conflict with old C defines [#2385](https://github.com/open-telemetry/opentelemetry-cpp/pull/2385) +* [API] Add a new AddLink() operation to Span + [#2380](https://github.com/open-telemetry/opentelemetry-cpp/pull/2380) Important changes: @@ -34,6 +36,15 @@ Important changes: * When building with `CMake` option `WITH_ABI_VERSION_1=ON` (by default) the `ABI` is unchanged, and the fix is not available. +* [API] Add a new AddLink() operation to Span + [#2380](https://github.com/open-telemetry/opentelemetry-cpp/pull/2380) + * New `API` Span::AddLink() adds a single link to a span. + * New `API` Span::AddLinks() adds multiple links to a span. + * Because this is an `ABI` breaking change, the fix is only available + with the `CMake` option `WITH_ABI_VERSION_2=ON`. + * When building with `CMake` option `WITH_ABI_VERSION_1=ON` (by default) + the `ABI` is unchanged, and the fix is not available. + * [BUILD] Make WITH_OTLP_HTTP_SSL_PREVIEW mainstream [#2378](https://github.com/open-telemetry/opentelemetry-cpp/pull/2378) * The experimental `CMake` option `WITH_OTLP_HTTP_SSL_PREVIEW` diff --git a/api/include/opentelemetry/plugin/tracer.h b/api/include/opentelemetry/plugin/tracer.h index b87f9e889f..068b08071d 100644 --- a/api/include/opentelemetry/plugin/tracer.h +++ b/api/include/opentelemetry/plugin/tracer.h @@ -7,6 +7,7 @@ #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/plugin/detail/tracer_handle.h" +#include "opentelemetry/trace/span_context_kv_iterable.h" #include "opentelemetry/trace/tracer.h" #include "opentelemetry/version.h" @@ -49,6 +50,19 @@ class Span final : public trace::Span span_->AddEvent(name, timestamp, attributes); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + void AddLink(const trace::SpanContext &target, + const common::KeyValueIterable &attrs) noexcept override + { + span_->AddLink(target, attrs); + } + + void AddLinks(const trace::SpanContextKeyValueIterable &links) noexcept override + { + span_->AddLinks(links); + } +#endif + void SetStatus(trace::StatusCode code, nostd::string_view description) noexcept override { span_->SetStatus(code, description); diff --git a/api/include/opentelemetry/trace/default_span.h b/api/include/opentelemetry/trace/default_span.h index cccc7951ad..7e3979501e 100644 --- a/api/include/opentelemetry/trace/default_span.h +++ b/api/include/opentelemetry/trace/default_span.h @@ -47,6 +47,14 @@ class DefaultSpan : public Span const common::KeyValueIterable & /* attributes */) noexcept override {} +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + void AddLink(const SpanContext & /* target */, + const common::KeyValueIterable & /* attrs */) noexcept override + {} + + void AddLinks(const SpanContextKeyValueIterable & /* links */) noexcept override {} +#endif + void SetStatus(StatusCode /* status */, nostd::string_view /* description */) noexcept override {} void UpdateName(nostd::string_view /* name */) noexcept override {} diff --git a/api/include/opentelemetry/trace/noop.h b/api/include/opentelemetry/trace/noop.h index c6a5838867..407f3c1ac9 100644 --- a/api/include/opentelemetry/trace/noop.h +++ b/api/include/opentelemetry/trace/noop.h @@ -15,6 +15,7 @@ #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/trace/span.h" #include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_context_kv_iterable.h" #include "opentelemetry/trace/tracer.h" #include "opentelemetry/trace/tracer_provider.h" #include "opentelemetry/version.h" @@ -58,6 +59,14 @@ class OPENTELEMETRY_EXPORT NoopSpan final : public Span const common::KeyValueIterable & /*attributes*/) noexcept override {} +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + void AddLink(const SpanContext & /* target */, + const common::KeyValueIterable & /* attrs */) noexcept override + {} + + void AddLinks(const SpanContextKeyValueIterable & /* links */) noexcept override {} +#endif + void SetStatus(StatusCode /*code*/, nostd::string_view /*description*/) noexcept override {} void UpdateName(nostd::string_view /*name*/) noexcept override {} diff --git a/api/include/opentelemetry/trace/span.h b/api/include/opentelemetry/trace/span.h index 8fb371d48c..27e91ceec4 100644 --- a/api/include/opentelemetry/trace/span.h +++ b/api/include/opentelemetry/trace/span.h @@ -11,6 +11,8 @@ #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/type_traits.h" #include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_context_kv_iterable.h" +#include "opentelemetry/trace/span_context_kv_iterable_view.h" #include "opentelemetry/trace/span_metadata.h" #include "opentelemetry/version.h" @@ -23,6 +25,31 @@ class Tracer; /** * A Span represents a single operation within a Trace. + * + * Span attributes can be provided: + * - at span creation time, using Tracer::StartSpan(), + * - during the span lifetime, using Span::SetAttribute() + * + * Please note that head samplers, + * in the SDK (@ref opentelemetry::sdk::trace::Sampler), + * can only make sampling decisions based on data known + * at span creation time. + * + * When attributes are known early, adding attributes + * with @ref opentelemetry::trace::Tracer::StartSpan() is preferable. + * + * Attributes added or changed with Span::SetAttribute() + * can not change a sampler decision. + * + * Likewise, links can be provided: + * - at span creation time, using Tracer::StartSpan(), + * - during the span lifetime, using Span::AddLink() or Span::AddLinks(). + * + * When links are known early, adding links + * with @ref opentelemetry::trace::Tracer::StartSpan() is preferable. + * + * Links added with Span::AddLink() or Span::AddLinks() + * can not change a sampler decision. */ class Span { @@ -40,9 +67,14 @@ class Span Span &operator=(const Span &) = delete; Span &operator=(Span &&) = delete; - // Sets an attribute on the Span. If the Span previously contained a mapping - // for - // the key, the old value is replaced. + /** + * Sets an attribute on the Span (ABI). + * + * If the Span previously contained a mapping for the key, + * the old value is replaced. + * + * See comments about sampling in @ref opentelemetry::trace::Span + */ virtual void SetAttribute(nostd::string_view key, const common::AttributeValue &value) noexcept = 0; @@ -98,6 +130,106 @@ class Span attributes.begin(), attributes.end()}); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + + /** + * Add link (ABI). + * + * See comments about sampling in @ref opentelemetry::trace::Span + * + * @since ABI_VERSION 2 + */ + virtual void AddLink(const SpanContext &target, + const common::KeyValueIterable &attrs) noexcept = 0; + + /** + * Add links (ABI). + * + * See comments about sampling in @ref opentelemetry::trace::Span + * + * @since ABI_VERSION 2 + */ + virtual void AddLinks(const SpanContextKeyValueIterable &links) noexcept = 0; + + /** + * Add link (API helper). + * + * See comments about sampling in @ref opentelemetry::trace::Span + * + * @since ABI_VERSION 2 + */ + template ::value> * = nullptr> + void AddLink(const SpanContext &target, const U &attrs) + { + common::KeyValueIterableView view(attrs); + this->AddLink(target, view); + } + + /** + * Add link (API helper). + * + * See comments about sampling in @ref opentelemetry::trace::Span + * + * @since ABI_VERSION 2 + */ + void AddLink(const SpanContext &target, + std::initializer_list> attrs) + { + /* Build a container from std::initializer_list. */ + nostd::span> container{ + attrs.begin(), attrs.end()}; + + /* Build a view on the container. */ + common::KeyValueIterableView< + nostd::span>> + view(container); + + return this->AddLink(target, view); + } + + /** + * Add links (API helper). + * + * See comments about sampling in @ref opentelemetry::trace::Span + * + * @since ABI_VERSION 2 + */ + template ::value> * = nullptr> + void AddLinks(const U &links) + { + SpanContextKeyValueIterableView view(links); + this->AddLinks(view); + } + + /** + * Add links (API helper). + * + * See comments about sampling in @ref opentelemetry::trace::Span + * + * @since ABI_VERSION 2 + */ + void AddLinks( + std::initializer_list< + std::pair>>> + links) + { + /* Build a container from std::initializer_list. */ + nostd::span>>> + container{links.begin(), links.end()}; + + /* Build a view on the container. */ + SpanContextKeyValueIterableView>>>> + view(container); + + return this->AddLinks(view); + } + +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + // Sets the status of the span. The default status is Unset. Only the value of // the last call will be // recorded, and implementations are free to ignore previous calls. diff --git a/api/include/opentelemetry/trace/span_context_kv_iterable.h b/api/include/opentelemetry/trace/span_context_kv_iterable.h index 8f3010ce9d..aed3474272 100644 --- a/api/include/opentelemetry/trace/span_context_kv_iterable.h +++ b/api/include/opentelemetry/trace/span_context_kv_iterable.h @@ -6,6 +6,7 @@ #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/api/test/trace/noop_test.cc b/api/test/trace/noop_test.cc index 130496faf0..b47700d442 100644 --- a/api/test/trace/noop_test.cc +++ b/api/test/trace/noop_test.cc @@ -46,6 +46,21 @@ TEST(NoopTest, UseNoopTracers) s1->GetContext(); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +TEST(NoopTest, UseNoopTracersAbiv2) +{ + std::shared_ptr tracer{new trace_api::NoopTracer{}}; + auto s1 = tracer->StartSpan("abc"); + + EXPECT_EQ(s1->IsRecording(), false); + + trace_api::SpanContext target(false, false); + s1->AddLink(target, {{"noop1", 1}}); + + s1->AddLinks({{trace_api::SpanContext(false, false), {{"noop2", 2}}}}); +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO >= 2 */ + TEST(NoopTest, StartSpan) { std::shared_ptr tracer{new trace_api::NoopTracer{}}; diff --git a/examples/plugin/plugin/tracer.cc b/examples/plugin/plugin/tracer.cc index 55de64438d..14d1a746df 100644 --- a/examples/plugin/plugin/tracer.cc +++ b/examples/plugin/plugin/tracer.cc @@ -49,6 +49,14 @@ class Span final : public trace::Span const common::KeyValueIterable & /*attributes*/) noexcept override {} +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + void AddLink(const trace::SpanContext & /* target */, + const common::KeyValueIterable & /* attrs */) noexcept override + {} + + void AddLinks(const trace::SpanContextKeyValueIterable & /* links */) noexcept override {} +#endif + void SetStatus(trace::StatusCode /*code*/, nostd::string_view /*description*/) noexcept override {} diff --git a/sdk/src/trace/span.cc b/sdk/src/trace/span.cc index c7524d43aa..25708cddd9 100644 --- a/sdk/src/trace/span.cc +++ b/sdk/src/trace/span.cc @@ -146,6 +146,35 @@ void Span::AddEvent(nostd::string_view name, recordable_->AddEvent(name, timestamp, attributes); } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +void Span::AddLink(const opentelemetry::trace::SpanContext &target, + const opentelemetry::common::KeyValueIterable &attrs) noexcept +{ + std::lock_guard lock_guard{mu_}; + if (recordable_ == nullptr) + { + return; + } + + recordable_->AddLink(target, attrs); +} + +void Span::AddLinks(const opentelemetry::trace::SpanContextKeyValueIterable &links) noexcept +{ + std::lock_guard lock_guard{mu_}; + if (recordable_ == nullptr) + { + return; + } + + links.ForEachKeyValue([&](opentelemetry::trace::SpanContext span_context, + const common::KeyValueIterable &attributes) { + recordable_->AddLink(span_context, attributes); + return true; + }); +} +#endif + void Span::SetStatus(opentelemetry::trace::StatusCode code, nostd::string_view description) noexcept { std::lock_guard lock_guard{mu_}; diff --git a/sdk/src/trace/span.h b/sdk/src/trace/span.h index 75e31e9500..eb603b9025 100644 --- a/sdk/src/trace/span.h +++ b/sdk/src/trace/span.h @@ -42,6 +42,13 @@ class Span final : public opentelemetry::trace::Span opentelemetry::common::SystemTimestamp timestamp, const opentelemetry::common::KeyValueIterable &attributes) noexcept override; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + void AddLink(const opentelemetry::trace::SpanContext &target, + const opentelemetry::common::KeyValueIterable &attrs) noexcept override; + + void AddLinks(const opentelemetry::trace::SpanContextKeyValueIterable &links) noexcept override; +#endif + void SetStatus(opentelemetry::trace::StatusCode code, nostd::string_view description) noexcept override; diff --git a/sdk/test/trace/tracer_test.cc b/sdk/test/trace/tracer_test.cc index 45b5fc010f..36cc135a1d 100644 --- a/sdk/test/trace/tracer_test.cc +++ b/sdk/test/trace/tracer_test.cc @@ -519,6 +519,392 @@ TEST(Tracer, SpanSetLinks) } } +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 +TEST(Tracer, SpanAddLinkAbiv2) +{ + InMemorySpanExporter *exporter = new InMemorySpanExporter(); + std::shared_ptr span_data = exporter->GetData(); + auto tracer = initTracer(std::unique_ptr{exporter}); + + { + auto span = tracer->StartSpan("span"); + SpanContext target(false, false); + // Single link attribute passed through Initialization list + span->AddLink(target, {{"attr2", 2}}); + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(1, span_data_links.size()); + auto link = span_data_links.at(0); + auto attrs = link.GetAttributes(); + ASSERT_EQ(nostd::get(attrs.at("attr2")), 2); + } + + { + auto span = tracer->StartSpan("span"); + SpanContext target(false, false); + // Multiple link attributes passed through Initialization list + span->AddLink(target, {{"attr2", 2}, {"attr3", 3}}); + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(1, span_data_links.size()); + auto link = span_data_links.at(0); + auto attrs = link.GetAttributes(); + ASSERT_EQ(nostd::get(attrs.at("attr2")), 2); + ASSERT_EQ(nostd::get(attrs.at("attr3")), 3); + } + + { + std::map attrs_map = {{"attr1", "1"}, {"attr2", "2"}}; + + auto span = tracer->StartSpan("span"); + SpanContext target(false, false); + span->AddLink(target, attrs_map); + span->End(); + + auto spans = span_data->GetSpans(); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(1, span_data_links.size()); + auto link = span_data_links.at(0); + auto attrs = link.GetAttributes(); + ASSERT_EQ(nostd::get(attrs.at("attr1")), "1"); + ASSERT_EQ(nostd::get(attrs.at("attr2")), "2"); + } + + { + auto span = tracer->StartSpan("span"); + SpanContext target(false, false); + + // Single link attribute passed through Initialization list + span->AddLink(target, {{"attr1", 1}}); + + // Multiple link attributes passed through Initialization list + span->AddLink(target, {{"attr2", 2}, {"attr3", 3}}); + + std::map attrs_map = {{"attr4", "4"}, {"attr5", "5"}}; + span->AddLink(target, attrs_map); + + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(3, span_data_links.size()); + + { + auto link = span_data_links.at(0); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr1")), 1); + } + + { + auto link = span_data_links.at(1); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attr2")), 2); + ASSERT_EQ(nostd::get(attrs.at("attr3")), 3); + } + + { + auto link = span_data_links.at(2); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attr4")), "4"); + ASSERT_EQ(nostd::get(attrs.at("attr5")), "5"); + } + } +} + +TEST(Tracer, SpanAddLinksAbiv2) +{ + InMemorySpanExporter *exporter = new InMemorySpanExporter(); + std::shared_ptr span_data = exporter->GetData(); + auto tracer = initTracer(std::unique_ptr{exporter}); + + { + auto span = tracer->StartSpan("span"); + // Single span link passed through Initialization list + span->AddLinks({{SpanContext(false, false), {{"attr2", 2}}}}); + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(1, span_data_links.size()); + auto link = span_data_links.at(0); + ASSERT_EQ(nostd::get(link.GetAttributes().at("attr2")), 2); + } + + { + auto span = tracer->StartSpan("span"); + // Multiple span links passed through Initialization list + span->AddLinks( + {{SpanContext(false, false), {{"attr2", 2}}}, {SpanContext(false, false), {{"attr3", 3}}}}); + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(2, span_data_links.size()); + auto link1 = span_data_links.at(0); + ASSERT_EQ(nostd::get(link1.GetAttributes().at("attr2")), 2); + auto link2 = span_data_links.at(1); + ASSERT_EQ(nostd::get(link2.GetAttributes().at("attr3")), 3); + } + + { + auto span = tracer->StartSpan("span"); + // Multiple links, each with multiple attributes passed through Initialization list + span->AddLinks({{SpanContext(false, false), {{"attr2", 2}, {"attr3", 3}}}, + {SpanContext(false, false), {{"attr4", 4}}}}); + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(2, span_data_links.size()); + auto link1 = span_data_links.at(0); + ASSERT_EQ(nostd::get(link1.GetAttributes().at("attr2")), 2); + ASSERT_EQ(nostd::get(link1.GetAttributes().at("attr3")), 3); + auto link2 = span_data_links.at(1); + ASSERT_EQ(nostd::get(link2.GetAttributes().at("attr4")), 4); + } + + { + std::map attrs1 = {{"attr1", "1"}, {"attr2", "2"}}; + std::map attrs2 = {{"attr3", "3"}, {"attr4", "4"}}; + + std::vector>> links = { + {SpanContext(false, false), attrs1}, {SpanContext(false, false), attrs2}}; + + auto span = tracer->StartSpan("span"); + span->AddLinks(links); + span->End(); + + auto spans = span_data->GetSpans(); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(2, span_data_links.size()); + auto link1 = span_data_links.at(0); + ASSERT_EQ(nostd::get(link1.GetAttributes().at("attr1")), "1"); + ASSERT_EQ(nostd::get(link1.GetAttributes().at("attr2")), "2"); + auto link2 = span_data_links.at(1); + ASSERT_EQ(nostd::get(link2.GetAttributes().at("attr3")), "3"); + ASSERT_EQ(nostd::get(link2.GetAttributes().at("attr4")), "4"); + } + + { + auto span = tracer->StartSpan("span"); + + // Single span link passed through Initialization list + span->AddLinks({{SpanContext(false, false), {{"attr10", 10}}}}); + span->AddLinks({{SpanContext(false, false), {{"attr11", 11}}}}); + + // Multiple span links passed through Initialization list + span->AddLinks({{SpanContext(false, false), {{"attr12", 12}}}, + {SpanContext(false, false), {{"attr13", 13}}}}); + span->AddLinks({{SpanContext(false, false), {{"attr14", 14}}}, + {SpanContext(false, false), {{"attr15", 15}}}}); + + // Multiple links, each with multiple attributes passed through Initialization list + span->AddLinks({{SpanContext(false, false), {{"attr16", 16}, {"attr17", 17}}}, + {SpanContext(false, false), {{"attr18", 18}}}}); + span->AddLinks({{SpanContext(false, false), {{"attr19", 19}, {"attr20", 20}}}, + {SpanContext(false, false), {{"attr21", 21}}}}); + + std::map attrsa1 = {{"attra1", "1"}, {"attra2", "2"}}; + std::map attrsa2 = {{"attra3", "3"}, {"attra4", "4"}}; + + std::vector>> linksa = { + {SpanContext(false, false), attrsa1}, {SpanContext(false, false), attrsa2}}; + + span->AddLinks(linksa); + + std::map attrsb1 = {{"attrb1", "1"}, {"attrb2", "2"}}; + std::map attrsb2 = {{"attrb3", "3"}, {"attrb4", "4"}}; + + std::vector>> linksb = { + {SpanContext(false, false), attrsb1}, {SpanContext(false, false), attrsb2}}; + + span->AddLinks(linksb); + + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(14, span_data_links.size()); + + { + auto link = span_data_links.at(0); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr10")), 10); + } + + { + auto link = span_data_links.at(1); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr11")), 11); + } + + { + auto link = span_data_links.at(2); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr12")), 12); + } + + { + auto link = span_data_links.at(3); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr13")), 13); + } + + { + auto link = span_data_links.at(4); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr14")), 14); + } + + { + auto link = span_data_links.at(5); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr15")), 15); + } + + { + auto link = span_data_links.at(6); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attr16")), 16); + ASSERT_EQ(nostd::get(attrs.at("attr17")), 17); + } + + { + auto link = span_data_links.at(7); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr18")), 18); + } + + { + auto link = span_data_links.at(8); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attr19")), 19); + ASSERT_EQ(nostd::get(attrs.at("attr20")), 20); + } + + { + auto link = span_data_links.at(9); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr21")), 21); + } + + { + auto link = span_data_links.at(10); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attra1")), "1"); + ASSERT_EQ(nostd::get(attrs.at("attra2")), "2"); + } + + { + auto link = span_data_links.at(11); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attra3")), "3"); + ASSERT_EQ(nostd::get(attrs.at("attra4")), "4"); + } + + { + auto link = span_data_links.at(12); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attrb1")), "1"); + ASSERT_EQ(nostd::get(attrs.at("attrb2")), "2"); + } + + { + auto link = span_data_links.at(13); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 2); + ASSERT_EQ(nostd::get(attrs.at("attrb3")), "3"); + ASSERT_EQ(nostd::get(attrs.at("attrb4")), "4"); + } + } +} + +TEST(Tracer, SpanMixLinksAbiv2) +{ + InMemorySpanExporter *exporter = new InMemorySpanExporter(); + std::shared_ptr span_data = exporter->GetData(); + auto tracer = initTracer(std::unique_ptr{exporter}); + + { + // Link 1 added at StartSpan + auto span = + tracer->StartSpan("span", {{"attr1", 1}}, {{SpanContext(false, false), {{"attr2", 2}}}}); + + SpanContext target(false, false); + // Link 2 added with AddLink + span->AddLink(target, {{"attr3", 3}}); + + // Link 3 added with AddLinks + span->AddLinks({{SpanContext(false, false), {{"attr4", 4}}}}); + + span->End(); + + auto spans = span_data->GetSpans(); + ASSERT_EQ(1, spans.size()); + + auto &span_data_links = spans.at(0)->GetLinks(); + ASSERT_EQ(3, span_data_links.size()); + + { + auto link = span_data_links.at(0); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr2")), 2); + } + + { + auto link = span_data_links.at(1); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr3")), 3); + } + + { + auto link = span_data_links.at(2); + auto attrs = link.GetAttributes(); + ASSERT_EQ(attrs.size(), 1); + ASSERT_EQ(nostd::get(attrs.at("attr4")), 4); + } + } +} +#endif /* OPENTELEMETRY_ABI_VERSION_NO >= 2 */ + TEST(Tracer, TestAlwaysOnSampler) { InMemorySpanExporter *exporter = new InMemorySpanExporter(); From 758687cde41c5a4a854818585520b47305011267 Mon Sep 17 00:00:00 2001 From: Alex E <36134278+chusitoo@users.noreply.github.com> Date: Mon, 30 Oct 2023 12:55:32 -0400 Subject: [PATCH 21/29] [opentracing-shim] Add check for sampled context (#2390) --- opentracing-shim/src/tracer_shim.cc | 21 ++++++++++++++------- opentracing-shim/test/tracer_shim_test.cc | 1 + 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/opentracing-shim/src/tracer_shim.cc b/opentracing-shim/src/tracer_shim.cc index c8805d15ef..41c6404624 100644 --- a/opentracing-shim/src/tracer_shim.cc +++ b/opentracing-shim/src/tracer_shim.cc @@ -148,13 +148,20 @@ opentracing::expected> TracerShim::ext auto span_context = opentelemetry::trace::GetSpan(context)->GetContext(); auto baggage = opentelemetry::baggage::GetBaggage(context); - // If the extracted SpanContext is invalid AND the extracted Baggage is empty, - // this operation MUST return a null value, and otherwise it MUST return a - // SpanContext Shim instance with the extracted values. - SpanContextShim *context_shim = (!span_context.IsValid() && utils::isBaggageEmpty(baggage)) - ? nullptr - : new (std::nothrow) SpanContextShim(span_context, baggage); - + // The operation MUST return a `SpanContext` Shim instance with the extracted values if any of + // these conditions are met: + // * `SpanContext` is valid. + // * `SpanContext` is sampled. + // * `SpanContext` contains non-empty extracted `Baggage`. + // Otherwise, the operation MUST return null or empty value. + SpanContextShim *context_shim = + (!span_context.IsValid() && !span_context.IsSampled() && utils::isBaggageEmpty(baggage)) + ? nullptr + : new (std::nothrow) SpanContextShim(span_context, baggage); + + // Note: Invalid but sampled `SpanContext` instances are returned as a way to support + // jaeger-debug-id headers (https://github.com/jaegertracing/jaeger-client-java#via-http-headers) + // which are used to force propagation of debug information. return opentracing::make_expected(std::unique_ptr(context_shim)); } diff --git a/opentracing-shim/test/tracer_shim_test.cc b/opentracing-shim/test/tracer_shim_test.cc index 7a06175323..9d57bbcae4 100644 --- a/opentracing-shim/test/tracer_shim_test.cc +++ b/opentracing-shim/test/tracer_shim_test.cc @@ -211,6 +211,7 @@ TEST_F(TracerShimTest, ExtractOnlyBaggage) auto span_context_shim = static_cast(span_context.value().get()); ASSERT_TRUE(span_context_shim != nullptr); ASSERT_FALSE(span_context_shim->context().IsValid()); + ASSERT_FALSE(span_context_shim->context().IsSampled()); ASSERT_FALSE(shim::utils::isBaggageEmpty(span_context_shim->baggage())); std::string value; From ca08c5a34ad4af1b6b392c8bf5fc26a5210a2f2c Mon Sep 17 00:00:00 2001 From: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> Date: Wed, 1 Nov 2023 11:12:53 +0530 Subject: [PATCH 22/29] [BUILD] Fix exported definitions when building DLL with STL (#2387) --- CHANGELOG.md | 7 +++++++ ext/src/dll/opentelemetry_cpp.src | 10 ++++------ .../sdk/metrics/view/instrument_selector.h | 6 +++--- .../sdk/metrics/view/instrument_selector_factory.h | 7 ++++--- .../opentelemetry/sdk/metrics/view/meter_selector.h | 6 ++---- .../sdk/metrics/view/meter_selector_factory.h | 8 ++++---- sdk/src/metrics/view/instrument_selector_factory.cc | 4 ++-- sdk/src/metrics/view/meter_selector_factory.cc | 7 +++---- 8 files changed, 29 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a76b91692b..9acee42235 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,13 @@ Breaking changes: * This header should not be included directly in an application. If this is the case, please remove any remaining include directives. +* [BUILD] Fix exported definitions when building DLL with STL + [#2387](https://github.com/open-telemetry/opentelemetry-cpp/pull/2387) + * The MeterSelector, MeterSelectorFactory, InstrumentSelector, + and InstrumentSelectorFactory APIs now use const std::string& + instead of nostd::string_view for name, version and schema to + maintain a single export definition for DLL. + ## [1.12.0] 2023-10-16 * [BUILD] Support `pkg-config` diff --git a/ext/src/dll/opentelemetry_cpp.src b/ext/src/dll/opentelemetry_cpp.src index 49226ec543..10172dbb3f 100644 --- a/ext/src/dll/opentelemetry_cpp.src +++ b/ext/src/dll/opentelemetry_cpp.src @@ -72,11 +72,10 @@ EXPORTS ?Create@ViewFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@00W4AggregationType@2345@V?$shared_ptr@VAggregationConfig@metrics@sdk@v1@opentelemetry@@@7@@Z // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::ViewFactory::Create(class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,enum opentelemetry::v1::sdk::metrics::AggregationType) ?Create@ViewFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@00W4AggregationType@2345@@Z - // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::MeterSelectorFactory::Create(class opentelemetry::v1::nostd::string_view,class opentelemetry::v1::nostd::string_view,class opentelemetry::v1::nostd::string_view) - ?Create@MeterSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@Vstring_view@nostd@45@00@Z - // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::InstrumentSelectorFactory::Create(enum opentelemetry::v1::sdk::metrics::InstrumentType,class opentelemetry::v1::nostd::string_view,class opentelemetry::v1::nostd::string_view) - ?Create@InstrumentSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@W4InstrumentType@2345@Vstring_view@nostd@45@1@Z - + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::MeterSelectorFactory::Create(class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &) + ?Create@MeterSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@00@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::InstrumentSelectorFactory::Create(enum opentelemetry::v1::sdk::metrics::InstrumentType,class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &) + ?Create@InstrumentSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@W4InstrumentType@2345@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@1@Z // public: void __cdecl opentelemetry::v1::sdk::metrics::MeterContext::AddMetricReader(class std::shared_ptr) ?AddMetricReader@MeterContext@metrics@sdk@v1@opentelemetry@@QEAAXV?$shared_ptr@VMetricReader@metrics@sdk@v1@opentelemetry@@@std@@@Z // public: void __cdecl opentelemetry::v1::sdk::metrics::MeterProvider::AddMetricReader(class std::shared_ptr) @@ -84,7 +83,6 @@ EXPORTS // public: void __cdecl opentelemetry::v1::sdk::metrics::MeterProvider::AddView(class std::unique_ptr >,class std::unique_ptr >,class std::unique_ptr >) ?AddView@MeterProvider@metrics@sdk@v1@opentelemetry@@QEAAXV?$unique_ptr@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@V?$unique_ptr@VMeterSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterSelector@metrics@sdk@v1@opentelemetry@@@std@@@7@V?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@7@@Z - #if defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP) ?GetOtlpDefaultTracesTimeout@otlp@exporter@v1@opentelemetry@@YA?AV?$duration@_JU?$ratio@$00$0JIJGIA@@std@@@chrono@std@@XZ ?GetOtlpDefaultTracesHeaders@otlp@exporter@v1@opentelemetry@@YA?AV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@Ucmp_ic@otlp@exporter@v1@opentelemetry@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ diff --git a/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector.h b/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector.h index 67c8592bb6..690a9168d0 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector.h @@ -4,8 +4,8 @@ #pragma once #include +#include -#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/view/predicate_factory.h" #include "opentelemetry/version.h" @@ -19,8 +19,8 @@ class InstrumentSelector { public: InstrumentSelector(opentelemetry::sdk::metrics::InstrumentType instrument_type, - opentelemetry::nostd::string_view name, - opentelemetry::nostd::string_view units) + const std::string &name, + const std::string &units) : name_filter_{PredicateFactory::GetPredicate(name, PredicateType::kPattern)}, unit_filter_{PredicateFactory::GetPredicate(units, PredicateType::kExact)}, instrument_type_{instrument_type} diff --git a/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h b/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h index 0af1efe04b..3c221f123b 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h @@ -3,7 +3,8 @@ #pragma once -#include "opentelemetry/nostd/string_view.h" +#include + #include "opentelemetry/sdk/metrics/instruments.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -19,8 +20,8 @@ class OPENTELEMETRY_EXPORT InstrumentSelectorFactory public: static std::unique_ptr Create( opentelemetry::sdk::metrics::InstrumentType instrument_type, - opentelemetry::nostd::string_view name, - opentelemetry::nostd::string_view unit); + const std::string &name, + const std::string &unit); }; } // namespace metrics diff --git a/sdk/include/opentelemetry/sdk/metrics/view/meter_selector.h b/sdk/include/opentelemetry/sdk/metrics/view/meter_selector.h index 16d777b71f..65dba7d7b9 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/meter_selector.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/meter_selector.h @@ -4,8 +4,8 @@ #pragma once #include +#include -#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/metrics/view/predicate_factory.h" #include "opentelemetry/version.h" @@ -17,9 +17,7 @@ namespace metrics class MeterSelector { public: - MeterSelector(opentelemetry::nostd::string_view name, - opentelemetry::nostd::string_view version, - opentelemetry::nostd::string_view schema) + MeterSelector(const std::string &name, const std::string &version, const std::string &schema) : name_filter_{PredicateFactory::GetPredicate(name, PredicateType::kExact)}, version_filter_{PredicateFactory::GetPredicate(version, PredicateType::kExact)}, schema_filter_{PredicateFactory::GetPredicate(schema, PredicateType::kExact)} diff --git a/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h b/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h index bd599d9c4b..47aa77b772 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h @@ -4,8 +4,8 @@ #pragma once #include +#include -#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -19,9 +19,9 @@ class MeterSelector; class OPENTELEMETRY_EXPORT MeterSelectorFactory { public: - static std::unique_ptr Create(opentelemetry::nostd::string_view name, - opentelemetry::nostd::string_view version, - opentelemetry::nostd::string_view schema); + static std::unique_ptr Create(const std::string &name, + const std::string &version, + const std::string &schema); }; } // namespace metrics diff --git a/sdk/src/metrics/view/instrument_selector_factory.cc b/sdk/src/metrics/view/instrument_selector_factory.cc index 98a587ea62..5cf4a5b968 100644 --- a/sdk/src/metrics/view/instrument_selector_factory.cc +++ b/sdk/src/metrics/view/instrument_selector_factory.cc @@ -13,8 +13,8 @@ namespace metrics std::unique_ptr InstrumentSelectorFactory::Create( opentelemetry::sdk::metrics::InstrumentType instrument_type, - opentelemetry::nostd::string_view name, - opentelemetry::nostd::string_view unit) + const std::string &name, + const std::string &unit) { std::unique_ptr instrument_selector( new InstrumentSelector(instrument_type, name, unit)); diff --git a/sdk/src/metrics/view/meter_selector_factory.cc b/sdk/src/metrics/view/meter_selector_factory.cc index f8f906d9ad..088dcd864e 100644 --- a/sdk/src/metrics/view/meter_selector_factory.cc +++ b/sdk/src/metrics/view/meter_selector_factory.cc @@ -11,10 +11,9 @@ namespace sdk namespace metrics { -std::unique_ptr MeterSelectorFactory::Create( - opentelemetry::nostd::string_view name, - opentelemetry::nostd::string_view version, - opentelemetry::nostd::string_view schema) +std::unique_ptr MeterSelectorFactory::Create(const std::string &name, + const std::string &version, + const std::string &schema) { std::unique_ptr meter_selector(new MeterSelector(name, version, schema)); return meter_selector; From 5bf2f8007f31cf0c0414c1c552edd1123c4cf018 Mon Sep 17 00:00:00 2001 From: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> Date: Tue, 7 Nov 2023 01:12:59 +0530 Subject: [PATCH 23/29] [BUILD] Add missing includes to runtime_context_test (#2395) --- api/test/context/runtime_context_test.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/test/context/runtime_context_test.cc b/api/test/context/runtime_context_test.cc index e85fc6350d..40b11dde95 100644 --- a/api/test/context/runtime_context_test.cc +++ b/api/test/context/runtime_context_test.cc @@ -4,6 +4,9 @@ #include "opentelemetry/context/runtime_context.h" #include "opentelemetry/context/context.h" +#include +#include + #include using namespace opentelemetry; From 35a9362732216c00a24bdd4c98ebb5f9bbaab2c5 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 6 Nov 2023 23:27:16 +0100 Subject: [PATCH 24/29] [ADMIN] Add file .github/repository-settings.md (#2392) --- .github/repository-settings.md | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/repository-settings.md diff --git a/.github/repository-settings.md b/.github/repository-settings.md new file mode 100644 index 0000000000..fa86d02cfc --- /dev/null +++ b/.github/repository-settings.md @@ -0,0 +1,38 @@ +# Process + +This file documents local admin changes for opentelemetry-cpp, +per the community process: https://github.com/open-telemetry/community/blob/main/docs/how-to-configure-new-repository.md + +Please note that the EasyCLA check **MUST** stay **REQUIRED**, +it should never be disabled or bypassed, at the risk of tainting the repository. + +# Guidelines + +The best is to open a PR first that describes the change, +so it can be discussed during review (maybe it is not needed, +maybe there is an alternate solution, ...). + +The PR must add a log entry in this file, detailing: + +* the date the change is implemented +* what is changed exactly (which setting) +* a short rationale + +Admin changes are then applied only when the PR is merged. + +If for some reason a change is implemented in emergency, +before a PR can be discussed and merged, +a PR should still be prepared and pushed after the fact to +describe the settings changed. + +# Log of local changes + +## 2023-11-03 + +Created log file `.github/repository-settings.md`, since admin permissions are now granted to maintainers. + +See https://github.com/open-telemetry/community/issues/1727 + +No setting changed. + + From 86ee88615b813ea08901db029343847e77d0f38b Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Fri, 10 Nov 2023 01:53:12 -0800 Subject: [PATCH 25/29] [SDK] Fix GetLogger with empty library name (#2398) --- CHANGELOG.md | 2 ++ sdk/src/logs/logger_provider.cc | 21 +++++++++------------ sdk/test/logs/logger_provider_sdk_test.cc | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9acee42235..7317b2b5f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ Increment the: [#2385](https://github.com/open-telemetry/opentelemetry-cpp/pull/2385) * [API] Add a new AddLink() operation to Span [#2380](https://github.com/open-telemetry/opentelemetry-cpp/pull/2380) +* [SDK] Fix GetLogger with empty library + name[#2398](https://github.com/open-telemetry/opentelemetry-cpp/pull/2398) Important changes: diff --git a/sdk/src/logs/logger_provider.cc b/sdk/src/logs/logger_provider.cc index d64863ed73..46eaa01054 100644 --- a/sdk/src/logs/logger_provider.cc +++ b/sdk/src/logs/logger_provider.cc @@ -57,6 +57,12 @@ nostd::shared_ptr LoggerProvider::GetLogger( nostd::string_view schema_url, const opentelemetry::common::KeyValueIterable &attributes) noexcept { + // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-instrumentationscope + if (library_name.empty()) + { + library_name = logger_name; + } + // Ensure only one thread can read/write from the map of loggers std::lock_guard lock_guard{lock_}; @@ -84,18 +90,9 @@ nostd::shared_ptr LoggerProvider::GetLogger( } */ - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-instrumentationscope - std::unique_ptr lib; - if (library_name.empty()) - { - lib = instrumentationscope::InstrumentationScope::Create(logger_name, library_version, - schema_url, attributes); - } - else - { - lib = instrumentationscope::InstrumentationScope::Create(library_name, library_version, - schema_url, attributes); - } + std::unique_ptr lib = + instrumentationscope::InstrumentationScope::Create(library_name, library_version, schema_url, + attributes); loggers_.push_back(std::shared_ptr( new Logger(logger_name, context_, std::move(lib)))); diff --git a/sdk/test/logs/logger_provider_sdk_test.cc b/sdk/test/logs/logger_provider_sdk_test.cc index 51f40178ba..ecb9ea6f9c 100644 --- a/sdk/test/logs/logger_provider_sdk_test.cc +++ b/sdk/test/logs/logger_provider_sdk_test.cc @@ -111,6 +111,20 @@ TEST(LoggerProviderSDK, EventLoggerProviderFactory) auto event_logger = elp->CreateEventLogger(logger1, "otel-cpp.test"); } +TEST(LoggerPviderSDK, LoggerEquityCheck) +{ + auto lp = std::shared_ptr(new LoggerProvider()); + nostd::string_view schema_url{"https://opentelemetry.io/schemas/1.11.0"}; + + auto logger1 = lp->GetLogger("logger1", "opentelelemtry_library", "", schema_url); + auto logger2 = lp->GetLogger("logger1", "opentelelemtry_library", "", schema_url); + EXPECT_EQ(logger1, logger2); + + auto logger3 = lp->GetLogger("logger3"); + auto another_logger3 = lp->GetLogger("logger3"); + EXPECT_EQ(logger3, another_logger3); +} + class DummyLogRecordable final : public opentelemetry::sdk::logs::Recordable { public: From 63226075207c2807f61ae670355c1e705a4ce1d1 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Sat, 11 Nov 2023 18:20:51 +0800 Subject: [PATCH 26/29] [TEST] Fix compiling problem and removed -DENABLE_TEST (#2401) --- CMakeLists.txt | 1 - ci/do_ci.ps1 | 2 +- ci/do_ci.sh | 2 +- .../otlp/test/otlp_http_exporter_test.cc | 3 ++- .../otlp_http_log_record_exporter_test.cc | 3 ++- .../test/otlp_http_metric_exporter_test.cc | 3 ++- .../ext/http/client/curl/http_client_curl.h | 5 +--- .../ext/http/client/http_client_factory.h | 4 --- .../http/client/http_client_test_factory.h | 22 ++++++++++++++++ .../http/client/nosend/http_client_nosend.h | 26 +++++++++---------- test_common/src/http/client/nosend/BUILD | 2 +- .../src/http/client/nosend/CMakeLists.txt | 2 +- .../http/client/nosend/http_client_nosend.cc | 4 +-- ..._nosend.cc => http_client_test_factory.cc} | 10 +++---- 14 files changed, 50 insertions(+), 39 deletions(-) create mode 100644 test_common/include/opentelemetry/test_common/ext/http/client/http_client_test_factory.h rename test_common/src/http/client/nosend/{http_client_factory_nosend.cc => http_client_test_factory.cc} (51%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b72e58a963..de5e714916 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -579,7 +579,6 @@ list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}") include(CTest) if(BUILD_TESTING) - add_definitions(-DENABLE_TEST) if(EXISTS ${CMAKE_BINARY_DIR}/lib/libgtest.a) # Prefer GTest from build tree. GTest is not always working with # CMAKE_PREFIX_PATH diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index b97617e96f..0b6cd9513e 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -27,7 +27,7 @@ $VCPKG_DIR = Join-Path "$SRC_DIR" "tools" "vcpkg" switch ($action) { "bazel.build" { - bazel build --copt=-DENABLE_TEST $BAZEL_OPTIONS --action_env=VCPKG_DIR=$VCPKG_DIR --deleted_packages=opentracing-shim -- //... + bazel build $BAZEL_OPTIONS --action_env=VCPKG_DIR=$VCPKG_DIR --deleted_packages=opentracing-shim -- //... $exit = $LASTEXITCODE if ($exit -ne 0) { exit $exit diff --git a/ci/do_ci.sh b/ci/do_ci.sh index d9dc0c178f..f679c6af04 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -69,7 +69,7 @@ fi echo "make command: ${MAKE_COMMAND}" echo "IWYU option: ${IWYU}" -BAZEL_OPTIONS_DEFAULT="--copt=-DENABLE_TEST --copt=-DENABLE_METRICS_EXEMPLAR_PREVIEW" +BAZEL_OPTIONS_DEFAULT="--copt=-DENABLE_METRICS_EXEMPLAR_PREVIEW" BAZEL_OPTIONS="--cxxopt=-std=c++14 $BAZEL_OPTIONS_DEFAULT" BAZEL_TEST_OPTIONS="$BAZEL_OPTIONS --test_output=errors" diff --git a/exporters/otlp/test/otlp_http_exporter_test.cc b/exporters/otlp/test/otlp_http_exporter_test.cc index 42258d2b45..1c76ad0d02 100644 --- a/exporters/otlp/test/otlp_http_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_exporter_test.cc @@ -19,6 +19,7 @@ # include "opentelemetry/sdk/trace/batch_span_processor.h" # include "opentelemetry/sdk/trace/batch_span_processor_options.h" # include "opentelemetry/sdk/trace/tracer_provider.h" +# include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" # include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" # include "opentelemetry/trace/provider.h" @@ -102,7 +103,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test static std::pair> GetMockOtlpHttpClient(HttpRequestContentType content_type, bool async_mode = false) { - auto http_client = http_client::HttpClientFactory::CreateNoSend(); + auto http_client = http_client::HttpClientTestFactory::Create(); return {new OtlpHttpClient(MakeOtlpHttpClientOptions(content_type, async_mode), http_client), http_client}; } diff --git a/exporters/otlp/test/otlp_http_log_record_exporter_test.cc b/exporters/otlp/test/otlp_http_log_record_exporter_test.cc index df89ca17fa..44fa812a35 100644 --- a/exporters/otlp/test/otlp_http_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_log_record_exporter_test.cc @@ -22,6 +22,7 @@ # include "opentelemetry/sdk/logs/exporter.h" # include "opentelemetry/sdk/logs/logger_provider.h" # include "opentelemetry/sdk/resource/resource.h" +# include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" # include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" # include @@ -103,7 +104,7 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test static std::pair> GetMockOtlpHttpClient(HttpRequestContentType content_type, bool async_mode = false) { - auto http_client = http_client::HttpClientFactory::CreateNoSend(); + auto http_client = http_client::HttpClientTestFactory::Create(); return {new OtlpHttpClient(MakeOtlpHttpClientOptions(content_type, async_mode), http_client), http_client}; } diff --git a/exporters/otlp/test/otlp_http_metric_exporter_test.cc b/exporters/otlp/test/otlp_http_metric_exporter_test.cc index ed7c4dba30..8b7688adc0 100644 --- a/exporters/otlp/test/otlp_http_metric_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_metric_exporter_test.cc @@ -24,6 +24,7 @@ #include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" #include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" #include @@ -109,7 +110,7 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test static std::pair> GetMockOtlpHttpClient(HttpRequestContentType content_type, bool async_mode = false) { - auto http_client = http_client::HttpClientFactory::CreateNoSend(); + auto http_client = http_client::HttpClientTestFactory::Create(); return {new OtlpHttpClient(MakeOtlpHttpClientOptions(content_type, async_mode), http_client), http_client}; } diff --git a/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h b/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h index 876d9fab4f..45ee13d55c 100644 --- a/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h +++ b/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h @@ -37,6 +37,7 @@ class HttpCurlGlobalInitializer HttpCurlGlobalInitializer(HttpCurlGlobalInitializer &&) = delete; HttpCurlGlobalInitializer &operator=(const HttpCurlGlobalInitializer &) = delete; + HttpCurlGlobalInitializer &operator=(HttpCurlGlobalInitializer &&) = delete; HttpCurlGlobalInitializer(); @@ -190,9 +191,7 @@ class Session : public opentelemetry::ext::http::client::Session, */ const std::string &GetBaseUri() const { return host_; } -#ifdef ENABLE_TEST std::shared_ptr GetRequest() { return http_request_; } -#endif inline HttpClient &GetHttpClient() noexcept { return http_client_; } inline const HttpClient &GetHttpClient() const noexcept { return http_client_; } @@ -327,7 +326,6 @@ class HttpClient : public opentelemetry::ext::http::client::HttpClient void ScheduleAbortSession(uint64_t session_id); void ScheduleRemoveSession(uint64_t session_id, HttpCurlEasyResource &&resource); -#ifdef ENABLE_TEST void WaitBackgroundThreadExit() { std::unique_ptr background_thread; @@ -341,7 +339,6 @@ class HttpClient : public opentelemetry::ext::http::client::HttpClient background_thread->join(); } } -#endif private: void wakeupBackgroundThread(); diff --git a/ext/include/opentelemetry/ext/http/client/http_client_factory.h b/ext/include/opentelemetry/ext/http/client/http_client_factory.h index 8df1e578d2..43e15cf255 100644 --- a/ext/include/opentelemetry/ext/http/client/http_client_factory.h +++ b/ext/include/opentelemetry/ext/http/client/http_client_factory.h @@ -17,10 +17,6 @@ class HttpClientFactory static std::shared_ptr CreateSync(); static std::shared_ptr Create(); - -#ifdef ENABLE_TEST - static std::shared_ptr CreateNoSend(); -#endif }; } // namespace client } // namespace http diff --git a/test_common/include/opentelemetry/test_common/ext/http/client/http_client_test_factory.h b/test_common/include/opentelemetry/test_common/ext/http/client/http_client_test_factory.h new file mode 100644 index 0000000000..51f9502bb8 --- /dev/null +++ b/test_common/include/opentelemetry/test_common/ext/http/client/http_client_test_factory.h @@ -0,0 +1,22 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once +#include "opentelemetry/ext/http/client/http_client.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace ext +{ +namespace http +{ +namespace client +{ +class HttpClientTestFactory +{ +public: + static std::shared_ptr Create(); +}; +} // namespace client +} // namespace http +} // namespace ext +OPENTELEMETRY_END_NAMESPACE diff --git a/test_common/include/opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h b/test_common/include/opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h index 7a6fadbd11..7dddde13d4 100644 --- a/test_common/include/opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h +++ b/test_common/include/opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h @@ -3,17 +3,16 @@ #pragma once -#ifdef ENABLE_TEST -# include "opentelemetry/ext/http/client/http_client.h" -# include "opentelemetry/ext/http/common/url_parser.h" -# include "opentelemetry/version.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/ext/http/common/url_parser.h" +#include "opentelemetry/version.h" -# include -# include -# include +#include +#include +#include -# include -# include "gmock/gmock.h" +#include +#include "gmock/gmock.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace ext @@ -37,12 +36,12 @@ class Request : public opentelemetry::ext::http::client::Request method_ = method; } -# ifdef ENABLE_HTTP_SSL_PREVIEW +#ifdef ENABLE_HTTP_SSL_PREVIEW void SetSslOptions(const HttpSslOptions &ssl_options) noexcept override { ssl_options_ = ssl_options; } -# endif /* ENABLE_HTTP_SSL_PREVIEW */ +#endif /* ENABLE_HTTP_SSL_PREVIEW */ void SetBody(opentelemetry::ext::http::client::Body &body) noexcept override { @@ -66,9 +65,9 @@ class Request : public opentelemetry::ext::http::client::Request public: opentelemetry::ext::http::client::Method method_; -# ifdef ENABLE_HTTP_SSL_PREVIEW +#ifdef ENABLE_HTTP_SSL_PREVIEW opentelemetry::ext::http::client::HttpSslOptions ssl_options_; -# endif /* ENABLE_HTTP_SSL_PREVIEW */ +#endif /* ENABLE_HTTP_SSL_PREVIEW */ opentelemetry::ext::http::client::Body body_; opentelemetry::ext::http::client::Headers headers_; std::string uri_; @@ -186,4 +185,3 @@ class HttpClient : public opentelemetry::ext::http::client::HttpClient } // namespace http } // namespace ext OPENTELEMETRY_END_NAMESPACE -#endif diff --git a/test_common/src/http/client/nosend/BUILD b/test_common/src/http/client/nosend/BUILD index 7aaf2a61b5..fa7ba623ab 100644 --- a/test_common/src/http/client/nosend/BUILD +++ b/test_common/src/http/client/nosend/BUILD @@ -6,8 +6,8 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "http_client_nosend", srcs = [ - "http_client_factory_nosend.cc", "http_client_nosend.cc", + "http_client_test_factory.cc", ], include_prefix = "src/http/client/nosend", tags = [ diff --git a/test_common/src/http/client/nosend/CMakeLists.txt b/test_common/src/http/client/nosend/CMakeLists.txt index 1f32861b41..92a2c1f98c 100644 --- a/test_common/src/http/client/nosend/CMakeLists.txt +++ b/test_common/src/http/client/nosend/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 if(${BUILD_TESTING}) - add_library(opentelemetry_http_client_nosend http_client_factory_nosend.cc + add_library(opentelemetry_http_client_nosend http_client_test_factory.cc http_client_nosend.cc) set_target_properties(opentelemetry_http_client_nosend diff --git a/test_common/src/http/client/nosend/http_client_nosend.cc b/test_common/src/http/client/nosend/http_client_nosend.cc index dd14e4404a..98cae0476a 100644 --- a/test_common/src/http/client/nosend/http_client_nosend.cc +++ b/test_common/src/http/client/nosend/http_client_nosend.cc @@ -1,8 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#ifdef ENABLE_TEST -# include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" +#include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace ext @@ -96,4 +95,3 @@ void HttpClient::CleanupSession(uint64_t /* session_id */) {} } // namespace http } // namespace ext OPENTELEMETRY_END_NAMESPACE -#endif diff --git a/test_common/src/http/client/nosend/http_client_factory_nosend.cc b/test_common/src/http/client/nosend/http_client_test_factory.cc similarity index 51% rename from test_common/src/http/client/nosend/http_client_factory_nosend.cc rename to test_common/src/http/client/nosend/http_client_test_factory.cc index c70d1b9578..215c173549 100644 --- a/test_common/src/http/client/nosend/http_client_factory_nosend.cc +++ b/test_common/src/http/client/nosend/http_client_test_factory.cc @@ -1,15 +1,13 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#ifdef ENABLE_TEST -# include "opentelemetry/ext/http/client/http_client.h" -# include "opentelemetry/ext/http/client/http_client_factory.h" -# include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" +#include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" namespace http_client = opentelemetry::ext::http::client; -std::shared_ptr http_client::HttpClientFactory::CreateNoSend() +std::shared_ptr http_client::HttpClientTestFactory::Create() { return std::make_shared(); } -#endif From 5bd9c65c64e402bf17f73528693a9b4afe5aed2f Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Sun, 12 Nov 2023 12:07:11 -0800 Subject: [PATCH 27/29] [BUILD] Check windows options are not passed to non-Windows build (#2399) --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index de5e714916..f795eadbb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -248,6 +248,10 @@ set(OTELCPP_PROTO_PATH if(WIN32) option(WITH_ETW "Whether to include the ETW Exporter in the SDK" ON) +else() + if(DEFINED (WITH_ETW)) + message(FATAL_ERROR "WITH_ETW is only supported on Windows") + endif() endif(WIN32) # Do not convert deprecated message to error @@ -628,6 +632,9 @@ endif() include(CMakePackageConfigHelpers) if(DEFINED OPENTELEMETRY_BUILD_DLL) + if(NOT WIN32) + message(FATAL_ERROR "Build DLL is only supported on Windows!") + endif() if(NOT MSVC) message(WARNING "Build DLL is supposed to work with MSVC!") endif() From 3dfcf93c41bb1d487b3d4d1291791ea21a2a38ce Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 13 Nov 2023 23:27:29 +0100 Subject: [PATCH 28/29] [EXPORTER] Rework OTLP/HTTP and OTLP/GRPC exporter options (#2388) --- CHANGELOG.md | 28 ++- examples/otlp/grpc_log_main.cc | 14 +- exporters/otlp/BUILD | 30 ++- exporters/otlp/CMakeLists.txt | 35 ++- .../exporters/otlp/otlp_grpc_client.h | 14 +- .../exporters/otlp/otlp_grpc_client_options.h | 58 +++++ .../otlp/otlp_grpc_exporter_options.h | 44 +--- .../otlp/otlp_grpc_log_record_exporter.h | 6 +- .../otlp_grpc_log_record_exporter_factory.h | 4 +- .../otlp_grpc_log_record_exporter_options.h | 31 +++ .../otlp/otlp_grpc_metric_exporter.h | 2 +- .../otlp/otlp_grpc_metric_exporter_options.h | 21 +- .../otlp/otlp_http_exporter_options.h | 98 ++++---- .../otlp_http_log_record_exporter_options.h | 98 ++++---- .../otlp/otlp_http_metric_exporter_options.h | 100 +++++---- exporters/otlp/src/otlp_grpc_client.cc | 10 +- .../otlp/src/otlp_grpc_exporter_options.cc | 38 ++++ .../otlp/src/otlp_grpc_log_record_exporter.cc | 7 +- .../otlp_grpc_log_record_exporter_factory.cc | 6 +- .../otlp_grpc_log_record_exporter_options.cc | 36 +++ .../src/otlp_grpc_metric_exporter_options.cc | 38 ++++ .../otlp/src/otlp_http_exporter_options.cc | 54 +++++ .../otlp_http_log_record_exporter_options.cc | 54 +++++ .../src/otlp_http_metric_exporter_options.cc | 55 +++++ ...p_grpc_log_record_exporter_factory_test.cc | 4 +- .../otlp_grpc_log_record_exporter_test.cc | 3 +- .../test/otlp_grpc_metric_exporter_test.cc | 209 ++++++++++++++++++ ext/src/dll/opentelemetry_cpp.src | 70 +++--- 28 files changed, 945 insertions(+), 222 deletions(-) create mode 100644 exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h create mode 100644 exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h create mode 100644 exporters/otlp/src/otlp_grpc_exporter_options.cc create mode 100644 exporters/otlp/src/otlp_grpc_log_record_exporter_options.cc create mode 100644 exporters/otlp/src/otlp_grpc_metric_exporter_options.cc create mode 100644 exporters/otlp/src/otlp_http_exporter_options.cc create mode 100644 exporters/otlp/src/otlp_http_log_record_exporter_options.cc create mode 100644 exporters/otlp/src/otlp_http_metric_exporter_options.cc create mode 100644 exporters/otlp/test/otlp_grpc_metric_exporter_test.cc diff --git a/CHANGELOG.md b/CHANGELOG.md index 7317b2b5f1..2f89ef1505 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,8 +25,10 @@ Increment the: [#2385](https://github.com/open-telemetry/opentelemetry-cpp/pull/2385) * [API] Add a new AddLink() operation to Span [#2380](https://github.com/open-telemetry/opentelemetry-cpp/pull/2380) -* [SDK] Fix GetLogger with empty library - name[#2398](https://github.com/open-telemetry/opentelemetry-cpp/pull/2398) +* [SDK] Fix GetLogger with empty library name + [#2398](https://github.com/open-telemetry/opentelemetry-cpp/pull/2398) +* [EXPORTER] Rework OTLP/HTTP and OTLP/GRPC exporter options + [#2388](https://github.com/open-telemetry/opentelemetry-cpp/pull/2388) Important changes: @@ -56,6 +58,14 @@ Important changes: * These build options are scheduled to be removed by the next release, building without SSL/TLS will no longer be possible. +* [EXPORTER] Rework OTLP/HTTP and OTLP/GRPC exporter options + [#2388](https://github.com/open-telemetry/opentelemetry-cpp/pull/2388) + * `OtlpGrpcMetricExporterOptions` used to honor `_TRACES_` + environment variables, instead of `_METRICS_` environment variables. + * The implementation of `OtlpGrpcMetricExporterOptions` is now fixed. + * Please check configuration variables, + to make sure `_METRICS_` variables are set as expected. + Breaking changes: * [BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead @@ -77,6 +87,20 @@ Breaking changes: instead of nostd::string_view for name, version and schema to maintain a single export definition for DLL. +* [EXPORTER] Rework OTLP/HTTP and OTLP/GRPC exporter options + [#2388](https://github.com/open-telemetry/opentelemetry-cpp/pull/2388) + * `OtlpGrpcLogRecordExporter` incorrectly used `OtlpGrpcExporterOptions`, + which are options for traces and not logs. + * This created a bug: the `OtlpGrpcLogRecordExporter` honors `_TRACES_` + environment variables, instead of `_LOGS_` environment variables. + * `OtlpGrpcLogRecordExporter` is changed to use + `OtlpGrpcLogRecordExporterOptions` instead, fixing the bug. + * User code that initializes the SDK with a GRPC Log exporter, + and uses exporter options, should adjust to replace + `OtlpGrpcExporterOptions` with `OtlpGrpcLogRecordExporterOptions`. + * Please check configuration variables, + to make sure `_LOGS_` variables are set as expected. + ## [1.12.0] 2023-10-16 * [BUILD] Support `pkg-config` diff --git a/examples/otlp/grpc_log_main.cc b/examples/otlp/grpc_log_main.cc index b1726de358..9d7399dbaf 100644 --- a/examples/otlp/grpc_log_main.cc +++ b/examples/otlp/grpc_log_main.cc @@ -2,7 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h" #include "opentelemetry/logs/provider.h" #include "opentelemetry/sdk/logs/exporter.h" #include "opentelemetry/sdk/logs/logger_provider_factory.h" @@ -37,6 +39,7 @@ namespace trace_sdk = opentelemetry::sdk::trace; namespace { opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts; +opentelemetry::exporter::otlp::OtlpGrpcLogRecordExporterOptions log_opts; void InitTracer() { // Create OTLP exporter instance @@ -65,7 +68,7 @@ void CleanupTracer() void InitLogger() { // Create OTLP exporter instance - auto exporter = otlp::OtlpGrpcLogRecordExporterFactory::Create(opts); + auto exporter = otlp::OtlpGrpcLogRecordExporterFactory::Create(log_opts); auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); nostd::shared_ptr provider( logs_sdk::LoggerProviderFactory::Create(std::move(processor))); @@ -92,11 +95,14 @@ int main(int argc, char *argv[]) { if (argc > 1) { - opts.endpoint = argv[1]; + opts.endpoint = argv[1]; + log_opts.endpoint = argv[1]; if (argc > 2) { - opts.use_ssl_credentials = true; - opts.ssl_credentials_cacert_path = argv[2]; + opts.use_ssl_credentials = true; + log_opts.use_ssl_credentials = true; + opts.ssl_credentials_cacert_path = argv[2]; + log_opts.ssl_credentials_cacert_path = argv[2]; } } InitLogger(); diff --git a/exporters/otlp/BUILD b/exporters/otlp/BUILD index 5099b43510..a70153edd8 100644 --- a/exporters/otlp/BUILD +++ b/exporters/otlp/BUILD @@ -47,7 +47,7 @@ cc_library( hdrs = [ "include/opentelemetry/exporters/otlp/otlp_environment.h", "include/opentelemetry/exporters/otlp/otlp_grpc_client.h", - "include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h", + "include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h", "include/opentelemetry/exporters/otlp/otlp_grpc_utils.h", "include/opentelemetry/exporters/otlp/protobuf_include_prefix.h", "include/opentelemetry/exporters/otlp/protobuf_include_suffix.h", @@ -73,9 +73,11 @@ cc_library( srcs = [ "src/otlp_grpc_exporter.cc", "src/otlp_grpc_exporter_factory.cc", + "src/otlp_grpc_exporter_options.cc", ], hdrs = [ "include/opentelemetry/exporters/otlp/otlp_environment.h", + "include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h", "include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h", "include/opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h", "include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h", @@ -143,6 +145,7 @@ cc_library( srcs = [ "src/otlp_http_exporter.cc", "src/otlp_http_exporter_factory.cc", + "src/otlp_http_exporter_options.cc", ], hdrs = [ "include/opentelemetry/exporters/otlp/otlp_environment.h", @@ -170,10 +173,11 @@ cc_library( srcs = [ "src/otlp_grpc_metric_exporter.cc", "src/otlp_grpc_metric_exporter_factory.cc", + "src/otlp_grpc_metric_exporter_options.cc", ], hdrs = [ "include/opentelemetry/exporters/otlp/otlp_environment.h", - "include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h", + "include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h", "include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h", "include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h", "include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h", @@ -201,6 +205,7 @@ cc_library( srcs = [ "src/otlp_http_metric_exporter.cc", "src/otlp_http_metric_exporter_factory.cc", + "src/otlp_http_metric_exporter_options.cc", ], hdrs = [ "include/opentelemetry/exporters/otlp/otlp_environment.h", @@ -228,6 +233,7 @@ cc_library( srcs = [ "src/otlp_http_log_record_exporter.cc", "src/otlp_http_log_record_exporter_factory.cc", + "src/otlp_http_log_record_exporter_options.cc", ], hdrs = [ "include/opentelemetry/exporters/otlp/otlp_environment.h", @@ -255,12 +261,14 @@ cc_library( srcs = [ "src/otlp_grpc_log_record_exporter.cc", "src/otlp_grpc_log_record_exporter_factory.cc", + "src/otlp_grpc_log_record_exporter_options.cc", ], hdrs = [ "include/opentelemetry/exporters/otlp/otlp_environment.h", - "include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h", + "include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h", "include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h", "include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h", + "include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h", "include/opentelemetry/exporters/otlp/protobuf_include_prefix.h", "include/opentelemetry/exporters/otlp/protobuf_include_suffix.h", ], @@ -436,6 +444,22 @@ cc_test( ], ) +cc_test( + name = "otlp_grpc_metric_exporter_test", + srcs = ["test/otlp_grpc_metric_exporter_test.cc"], + tags = [ + "otlp", + "otlp_grpc_metric", + "test", + ], + deps = [ + ":otlp_grpc_metric_exporter", + "//api", + "//sdk/src/metrics", + "@com_google_googletest//:gtest_main", + ], +) + cc_test( name = "otlp_grpc_metric_exporter_factory_test", srcs = ["test/otlp_grpc_metric_exporter_factory_test.cc"], diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index adab87ff02..ec55211a6d 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -56,8 +56,10 @@ if(WITH_OTLP_GRPC) list(APPEND OPENTELEMETRY_OTLP_TARGETS opentelemetry_exporter_otlp_grpc_client) - add_library(opentelemetry_exporter_otlp_grpc - src/otlp_grpc_exporter.cc src/otlp_grpc_exporter_factory.cc) + add_library( + opentelemetry_exporter_otlp_grpc + src/otlp_grpc_exporter.cc src/otlp_grpc_exporter_factory.cc + src/otlp_grpc_exporter_options.cc) set_target_properties(opentelemetry_exporter_otlp_grpc PROPERTIES EXPORT_NAME otlp_grpc_exporter) @@ -73,7 +75,8 @@ if(WITH_OTLP_GRPC) add_library( opentelemetry_exporter_otlp_grpc_log src/otlp_grpc_log_record_exporter.cc - src/otlp_grpc_log_record_exporter_factory.cc) + src/otlp_grpc_log_record_exporter_factory.cc + src/otlp_grpc_log_record_exporter_options.cc) set_target_properties(opentelemetry_exporter_otlp_grpc_log PROPERTIES EXPORT_NAME otlp_grpc_log_record_exporter) @@ -88,7 +91,8 @@ if(WITH_OTLP_GRPC) add_library( opentelemetry_exporter_otlp_grpc_metrics - src/otlp_grpc_metric_exporter.cc src/otlp_grpc_metric_exporter_factory.cc) + src/otlp_grpc_metric_exporter.cc src/otlp_grpc_metric_exporter_factory.cc + src/otlp_grpc_metric_exporter_options.cc) set_target_properties(opentelemetry_exporter_otlp_grpc_metrics PROPERTIES EXPORT_NAME otlp_grpc_metrics_exporter) @@ -130,8 +134,10 @@ if(WITH_OTLP_HTTP) list(APPEND OPENTELEMETRY_OTLP_TARGETS opentelemetry_exporter_otlp_http_client) - add_library(opentelemetry_exporter_otlp_http - src/otlp_http_exporter.cc src/otlp_http_exporter_factory.cc) + add_library( + opentelemetry_exporter_otlp_http + src/otlp_http_exporter.cc src/otlp_http_exporter_factory.cc + src/otlp_http_exporter_options.cc) set_target_properties(opentelemetry_exporter_otlp_http PROPERTIES EXPORT_NAME otlp_http_exporter) @@ -147,7 +153,8 @@ if(WITH_OTLP_HTTP) add_library( opentelemetry_exporter_otlp_http_log src/otlp_http_log_record_exporter.cc - src/otlp_http_log_record_exporter_factory.cc) + src/otlp_http_log_record_exporter_factory.cc + src/otlp_http_log_record_exporter_options.cc) set_target_properties(opentelemetry_exporter_otlp_http_log PROPERTIES EXPORT_NAME otlp_http_log_record_exporter) @@ -162,7 +169,8 @@ if(WITH_OTLP_HTTP) add_library( opentelemetry_exporter_otlp_http_metric - src/otlp_http_metric_exporter.cc src/otlp_http_metric_exporter_factory.cc) + src/otlp_http_metric_exporter.cc src/otlp_http_metric_exporter_factory.cc + src/otlp_http_metric_exporter_options.cc) set_target_properties(opentelemetry_exporter_otlp_http_metric PROPERTIES EXPORT_NAME otlp_http_metric_exporter) @@ -295,6 +303,17 @@ if(BUILD_TESTING) TEST_PREFIX exporter.otlp. TEST_LIST otlp_grpc_log_record_exporter_factory_test) + add_executable(otlp_grpc_metric_exporter_test + test/otlp_grpc_metric_exporter_test.cc) + target_link_libraries( + otlp_grpc_metric_exporter_test ${GTEST_BOTH_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} ${GMOCK_LIB} opentelemetry_exporter_otlp_grpc + opentelemetry_exporter_otlp_grpc_metrics) + gtest_add_tests( + TARGET otlp_grpc_metric_exporter_test + TEST_PREFIX exporter.otlp. + TEST_LIST otlp_grpc_metric_exporter_test) + add_executable(otlp_grpc_metric_exporter_factory_test test/otlp_grpc_metric_exporter_factory_test.cc) target_link_libraries( diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h index 7998bd2646..fa1a69d619 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h @@ -7,7 +7,7 @@ #include -#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_client_options.h" #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" @@ -23,6 +23,8 @@ namespace exporter namespace otlp { +struct OtlpGrpcClientOptions; + /** * The OTLP gRPC client contains utility functions of gRPC. */ @@ -32,13 +34,13 @@ class OtlpGrpcClient /** * Create gRPC channel from the exporter options. */ - static std::shared_ptr MakeChannel(const OtlpGrpcExporterOptions &options); + static std::shared_ptr MakeChannel(const OtlpGrpcClientOptions &options); /** * Create gRPC client context to call RPC. */ static std::unique_ptr MakeClientContext( - const OtlpGrpcExporterOptions &options); + const OtlpGrpcClientOptions &options); /** * Create gRPC CompletionQueue to async call RPC. @@ -49,19 +51,19 @@ class OtlpGrpcClient * Create trace service stub to communicate with the OpenTelemetry Collector. */ static std::unique_ptr - MakeTraceServiceStub(const OtlpGrpcExporterOptions &options); + MakeTraceServiceStub(const OtlpGrpcClientOptions &options); /** * Create metrics service stub to communicate with the OpenTelemetry Collector. */ static std::unique_ptr - MakeMetricsServiceStub(const OtlpGrpcExporterOptions &options); + MakeMetricsServiceStub(const OtlpGrpcClientOptions &options); /** * Create logs service stub to communicate with the OpenTelemetry Collector. */ static std::unique_ptr - MakeLogsServiceStub(const OtlpGrpcExporterOptions &options); + MakeLogsServiceStub(const OtlpGrpcClientOptions &options); static grpc::Status DelegateExport( proto::collector::trace::v1::TraceService::StubInterface *stub, diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h new file mode 100644 index 0000000000..310fc94d4d --- /dev/null +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h @@ -0,0 +1,58 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/version.h" + +#include +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +struct OtlpGrpcClientOptions +{ + /** The endpoint to export to. */ + std::string endpoint; + + /** Use SSL. */ + bool use_ssl_credentials; + + /** CA CERT, path to a file. */ + std::string ssl_credentials_cacert_path; + + /** CA CERT, as a string. */ + std::string ssl_credentials_cacert_as_string; + +#ifdef ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW + /** CLIENT KEY, path to a file. */ + std::string ssl_client_key_path; + + /** CLIENT KEY, as a string. */ + std::string ssl_client_key_string; + + /** CLIENT CERT, path to a file. */ + std::string ssl_client_cert_path; + + /** CLIENT CERT, as a string. */ + std::string ssl_client_cert_string; +#endif + + /** Export timeout. */ + std::chrono::system_clock::duration timeout; + + /** Additional HTTP headers. */ + OtlpHeaders metadata; + + /** User agent. */ + std::string user_agent; +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h index 01ac5b43f2..b2556f1f76 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h @@ -3,9 +3,8 @@ #pragma once -#include "opentelemetry/exporters/otlp/otlp_environment.h" - -#include +#include "opentelemetry/exporters/otlp/otlp_grpc_client_options.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter @@ -15,38 +14,17 @@ namespace otlp /** * Struct to hold OTLP GRPC traces exporter options. + * + * See + * https://github.com/open-telemetry/opentelemetry-proto/blob/main/docs/specification.md#otlpgrpc + * + * See + * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md */ -struct OtlpGrpcExporterOptions +struct OPENTELEMETRY_EXPORT OtlpGrpcExporterOptions : public OtlpGrpcClientOptions { - // The endpoint to export to. By default the OpenTelemetry Collector's default endpoint. - std::string endpoint = GetOtlpDefaultGrpcEndpoint(); - // By default when false, uses grpc::InsecureChannelCredentials(); If true, - // uses ssl_credentials_cacert_path if non-empty, else uses ssl_credentials_cacert_as_string - bool use_ssl_credentials = GetOtlpDefaultIsSslEnable(); - // ssl_credentials_cacert_path specifies path to .pem file to be used for SSL encryption. - std::string ssl_credentials_cacert_path = GetOtlpDefaultSslCertificatePath(); - // ssl_credentials_cacert_as_string in-memory string representation of .pem file to be used for - // SSL encryption. - std::string ssl_credentials_cacert_as_string = GetOtlpDefaultSslCertificateString(); - -#ifdef ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW - // At most one of ssl_client_key_* should be non-empty. If use_ssl_credentials, they will - // be read to allow for mTLS. - std::string ssl_client_key_path = GetOtlpDefaultTracesSslClientKeyPath(); - std::string ssl_client_key_string = GetOtlpDefaultTracesSslClientKeyString(); - - // At most one of ssl_client_cert_* should be non-empty. If use_ssl_credentials, they will - // be read to allow for mTLS. - std::string ssl_client_cert_path = GetOtlpDefaultTracesSslClientCertificatePath(); - std::string ssl_client_cert_string = GetOtlpDefaultTracesSslClientCertificateString(); -#endif - - // Timeout for grpc deadline - std::chrono::system_clock::duration timeout = GetOtlpDefaultTimeout(); - // Additional HTTP headers - OtlpHeaders metadata = GetOtlpDefaultHeaders(); - // User agent - std::string user_agent = GetOtlpDefaultUserAgent(); + OtlpGrpcExporterOptions(); + ~OtlpGrpcExporterOptions(); }; } // namespace otlp diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h index 33476297cb..29333703b1 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h @@ -13,7 +13,7 @@ // clang-format on #include "opentelemetry/exporters/otlp/otlp_environment.h" -#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h" #include "opentelemetry/sdk/logs/exporter.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -37,7 +37,7 @@ class OtlpGrpcLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExpo * Create an OtlpGrpcLogRecordExporter with user specified options. * @param options An object containing the user's configuration options. */ - OtlpGrpcLogRecordExporter(const OtlpGrpcExporterOptions &options); + OtlpGrpcLogRecordExporter(const OtlpGrpcLogRecordExporterOptions &options); /** * Creates a recordable that stores the data in protobuf. @@ -71,7 +71,7 @@ class OtlpGrpcLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExpo private: // Configuration options for the exporter - const OtlpGrpcExporterOptions options_; + const OtlpGrpcLogRecordExporterOptions options_; // For testing friend class OtlpGrpcLogRecordExporterTestPeer; diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h index 5f81e60f2e..7a88615959 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h @@ -3,7 +3,7 @@ #pragma once -#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h" #include "opentelemetry/sdk/logs/exporter.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -27,7 +27,7 @@ class OPENTELEMETRY_EXPORT OtlpGrpcLogRecordExporterFactory * Create a OtlpGrpcLogRecordExporter. */ static std::unique_ptr Create( - const OtlpGrpcExporterOptions &options); + const OtlpGrpcLogRecordExporterOptions &options); }; } // namespace otlp diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h new file mode 100644 index 0000000000..cc1a199c4b --- /dev/null +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h @@ -0,0 +1,31 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "opentelemetry/exporters/otlp/otlp_grpc_client_options.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +/** + * Struct to hold OTLP GRPC log record exporter options. + * + * See + * https://github.com/open-telemetry/opentelemetry-proto/blob/main/docs/specification.md#otlpgrpc + * + * See + * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md + */ +struct OPENTELEMETRY_EXPORT OtlpGrpcLogRecordExporterOptions : public OtlpGrpcClientOptions +{ + OtlpGrpcLogRecordExporterOptions(); + ~OtlpGrpcLogRecordExporterOptions(); +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h index 11bb64c24f..5f975c8ce3 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h @@ -63,7 +63,7 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp const sdk::metrics::AggregationTemporalitySelector aggregation_temporality_selector_; // For testing - friend class OtlpGrpcExporterTestPeer; + friend class OtlpGrpcMetricExporterTestPeer; // Store service stub internally. Useful for testing. std::unique_ptr diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h index a56cf8cb55..22be580972 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h @@ -3,11 +3,9 @@ #pragma once -#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_client_options.h" #include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h" -#include "opentelemetry/sdk/metrics/instruments.h" - -#include +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter @@ -17,13 +15,20 @@ namespace otlp /** * Struct to hold OTLP GRPC metrics exporter options. + * + * See + * https://github.com/open-telemetry/opentelemetry-proto/blob/main/docs/specification.md#otlpgrpc + * + * See + * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md */ -struct OtlpGrpcMetricExporterOptions : public OtlpGrpcExporterOptions +struct OPENTELEMETRY_EXPORT OtlpGrpcMetricExporterOptions : public OtlpGrpcClientOptions { + OtlpGrpcMetricExporterOptions(); + ~OtlpGrpcMetricExporterOptions(); - // Preferred Aggregation Temporality - PreferredAggregationTemporality aggregation_temporality = - PreferredAggregationTemporality::kCumulative; + /** Preferred Aggregation Temporality. */ + PreferredAggregationTemporality aggregation_temporality; }; } // namespace otlp diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h index 29b4b76ec0..9200a506b8 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h @@ -3,9 +3,9 @@ #pragma once -#include "opentelemetry/exporters/otlp/otlp_http.h" - #include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/version.h" #include #include @@ -20,65 +20,89 @@ namespace otlp /** * Struct to hold OTLP HTTP traces exporter options. + * + * See + * https://github.com/open-telemetry/opentelemetry-proto/blob/main/docs/specification.md#otlphttp + * + * See + * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md */ -struct OtlpHttpExporterOptions +struct OPENTELEMETRY_EXPORT OtlpHttpExporterOptions { - // The endpoint to export to. By default - // @see - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md - // @see https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver - std::string url = GetOtlpDefaultHttpEndpoint(); + OtlpHttpExporterOptions(); + ~OtlpHttpExporterOptions(); - // By default, post json data - HttpRequestContentType content_type = HttpRequestContentType::kJson; + /** The endpoint to export to. */ + std::string url; - // If convert bytes into hex. By default, we will convert all bytes but id into base64 - // This option is ignored if content_type is not kJson - JsonBytesMappingKind json_bytes_mapping = JsonBytesMappingKind::kHexId; + /** HTTP content type. */ + HttpRequestContentType content_type; - // If using the json name of protobuf field to set the key of json. By default, we will use the - // field name just like proto files. - bool use_json_name = false; + /** + Json byte mapping. - // Whether to print the status of the exporter in the console - bool console_debug = false; + Used only for HttpRequestContentType::kJson. + Convert bytes to hex / base64. + */ + JsonBytesMappingKind json_bytes_mapping; - std::chrono::system_clock::duration timeout = GetOtlpDefaultTimeout(); + /** + Use json names (true) or protobuf field names (false) to set the json key. + */ + bool use_json_name; - // Additional HTTP headers - OtlpHeaders http_headers = GetOtlpDefaultHeaders(); + /** Print debug messages. */ + bool console_debug; + + /** Export timeout. */ + std::chrono::system_clock::duration timeout; + + /** Additional HTTP headers. */ + OtlpHeaders http_headers; #ifdef ENABLE_ASYNC_EXPORT - // Concurrent requests - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md#otlpgrpc-concurrent-requests - std::size_t max_concurrent_requests = 64; + /** Max number of concurrent requests. */ + std::size_t max_concurrent_requests; - // Requests per connections - std::size_t max_requests_per_connection = 8; + /** Max number of requests per connection. */ + std::size_t max_requests_per_connection; #endif #ifdef ENABLE_OTLP_HTTP_SSL_PREVIEW - bool ssl_insecure_skip_verify{false}; + /** True do disable SSL. */ + bool ssl_insecure_skip_verify; + + /** CA CERT, path to a file. */ + std::string ssl_ca_cert_path; - std::string ssl_ca_cert_path = GetOtlpDefaultTracesSslCertificatePath(); - std::string ssl_ca_cert_string = GetOtlpDefaultTracesSslCertificateString(); + /** CA CERT, as a string. */ + std::string ssl_ca_cert_string; - std::string ssl_client_key_path = GetOtlpDefaultTracesSslClientKeyPath(); - std::string ssl_client_key_string = GetOtlpDefaultTracesSslClientKeyString(); + /** CLIENT KEY, path to a file. */ + std::string ssl_client_key_path; - std::string ssl_client_cert_path = GetOtlpDefaultTracesSslClientCertificatePath(); - std::string ssl_client_cert_string = GetOtlpDefaultTracesSslClientCertificateString(); + /** CLIENT KEY, as a string. */ + std::string ssl_client_key_string; + + /** CLIENT CERT, path to a file. */ + std::string ssl_client_cert_path; + + /** CLIENT CERT, as a string. */ + std::string ssl_client_cert_string; #endif /* ENABLE_OTLP_HTTP_SSL_PREVIEW */ #ifdef ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW /** Minimum TLS version. */ - std::string ssl_min_tls = GetOtlpDefaultTracesSslTlsMinVersion(); + std::string ssl_min_tls; + /** Maximum TLS version. */ - std::string ssl_max_tls = GetOtlpDefaultTracesSslTlsMaxVersion(); + std::string ssl_max_tls; + /** TLS cipher. */ - std::string ssl_cipher = GetOtlpDefaultTracesSslTlsCipher(); + std::string ssl_cipher; + /** TLS cipher suite. */ - std::string ssl_cipher_suite = GetOtlpDefaultTracesSslTlsCipherSuite(); + std::string ssl_cipher_suite; #endif /* ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW */ }; diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h index 65fd2b9b63..e2a6264675 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h @@ -5,7 +5,7 @@ #include "opentelemetry/exporters/otlp/otlp_environment.h" #include "opentelemetry/exporters/otlp/otlp_http.h" -#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" #include #include @@ -19,66 +19,90 @@ namespace otlp { /** - * Struct to hold OTLP HTTP logs exporter options. + * Struct to hold OTLP HTTP log record exporter options. + * + * See + * https://github.com/open-telemetry/opentelemetry-proto/blob/main/docs/specification.md#otlphttp + * + * See + * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md */ -struct OtlpHttpLogRecordExporterOptions +struct OPENTELEMETRY_EXPORT OtlpHttpLogRecordExporterOptions { - // The endpoint to export to. By default - // @see - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md - // @see https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver - std::string url = GetOtlpDefaultHttpLogsEndpoint(); + OtlpHttpLogRecordExporterOptions(); + ~OtlpHttpLogRecordExporterOptions(); - // By default, post json data - HttpRequestContentType content_type = HttpRequestContentType::kJson; + /** The endpoint to export to. */ + std::string url; - // If convert bytes into hex. By default, we will convert all bytes but id into base64 - // This option is ignored if content_type is not kJson - JsonBytesMappingKind json_bytes_mapping = JsonBytesMappingKind::kHexId; + /** HTTP content type. */ + HttpRequestContentType content_type; - // If using the json name of protobuf field to set the key of json. By default, we will use the - // field name just like proto files. - bool use_json_name = false; + /** + Json byte mapping. - // Whether to print the status of the exporter in the console - bool console_debug = false; + Used only for HttpRequestContentType::kJson. + Convert bytes to hex / base64. + */ + JsonBytesMappingKind json_bytes_mapping; - std::chrono::system_clock::duration timeout = GetOtlpDefaultLogsTimeout(); + /** + Use json names (true) or protobuf field names (false) to set the json key. + */ + bool use_json_name; - // Additional HTTP headers - OtlpHeaders http_headers = GetOtlpDefaultLogsHeaders(); + /** Print debug messages. */ + bool console_debug; + + /** Export timeout. */ + std::chrono::system_clock::duration timeout; + + /** Additional HTTP headers. */ + OtlpHeaders http_headers; #ifdef ENABLE_ASYNC_EXPORT - // Concurrent requests - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md#otlpgrpc-concurrent-requests - std::size_t max_concurrent_requests = 64; + /** Max number of concurrent requests. */ + std::size_t max_concurrent_requests; - // Requests per connections - std::size_t max_requests_per_connection = 8; + /** Max number of requests per connection. */ + std::size_t max_requests_per_connection; #endif #ifdef ENABLE_OTLP_HTTP_SSL_PREVIEW - bool ssl_insecure_skip_verify{false}; + /** True do disable SSL. */ + bool ssl_insecure_skip_verify; + + /** CA CERT, path to a file. */ + std::string ssl_ca_cert_path; + + /** CA CERT, as a string. */ + std::string ssl_ca_cert_string; - std::string ssl_ca_cert_path = GetOtlpDefaultLogsSslCertificatePath(); - std::string ssl_ca_cert_string = GetOtlpDefaultLogsSslCertificateString(); + /** CLIENT KEY, path to a file. */ + std::string ssl_client_key_path; - std::string ssl_client_key_path = GetOtlpDefaultLogsSslClientKeyPath(); - std::string ssl_client_key_string = GetOtlpDefaultLogsSslClientKeyString(); + /** CLIENT KEY, as a string. */ + std::string ssl_client_key_string; - std::string ssl_client_cert_path = GetOtlpDefaultLogsSslClientCertificatePath(); - std::string ssl_client_cert_string = GetOtlpDefaultLogsSslClientCertificateString(); + /** CLIENT CERT, path to a file. */ + std::string ssl_client_cert_path; + + /** CLIENT CERT, as a string. */ + std::string ssl_client_cert_string; #endif /* ENABLE_OTLP_HTTP_SSL_PREVIEW */ #ifdef ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW /** Minimum TLS version. */ - std::string ssl_min_tls = GetOtlpDefaultLogsSslTlsMinVersion(); + std::string ssl_min_tls; + /** Maximum TLS version. */ - std::string ssl_max_tls = GetOtlpDefaultLogsSslTlsMaxVersion(); + std::string ssl_max_tls; + /** TLS cipher. */ - std::string ssl_cipher = GetOtlpDefaultLogsSslTlsCipher(); + std::string ssl_cipher; + /** TLS cipher suite. */ - std::string ssl_cipher_suite = GetOtlpDefaultLogsSslTlsCipherSuite(); + std::string ssl_cipher_suite; #endif /* ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW */ }; diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h index 8aa0ccad21..38446be73b 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h @@ -6,6 +6,7 @@ #include "opentelemetry/exporters/otlp/otlp_environment.h" #include "opentelemetry/exporters/otlp/otlp_http.h" #include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h" +#include "opentelemetry/version.h" #include #include @@ -20,70 +21,91 @@ namespace otlp /** * Struct to hold OTLP HTTP metrics exporter options. + * + * See + * https://github.com/open-telemetry/opentelemetry-proto/blob/main/docs/specification.md#otlphttp + * + * See + * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md */ -struct OtlpHttpMetricExporterOptions +struct OPENTELEMETRY_EXPORT OtlpHttpMetricExporterOptions { - // The endpoint to export to. By default - // @see - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md - // @see https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver - std::string url = GetOtlpDefaultMetricsEndpoint(); + OtlpHttpMetricExporterOptions(); + ~OtlpHttpMetricExporterOptions(); - // By default, post json data - HttpRequestContentType content_type = HttpRequestContentType::kJson; + /** The endpoint to export to. */ + std::string url; - // If convert bytes into hex. By default, we will convert all bytes but id into base64 - // This option is ignored if content_type is not kJson - JsonBytesMappingKind json_bytes_mapping = JsonBytesMappingKind::kHexId; + /** HTTP content type. */ + HttpRequestContentType content_type; - // If using the json name of protobuf field to set the key of json. By default, we will use the - // field name just like proto files. - bool use_json_name = false; + /** + Json byte mapping. - // Whether to print the status of the exporter in the console - bool console_debug = false; + Used only for HttpRequestContentType::kJson. + Convert bytes to hex / base64. + */ + JsonBytesMappingKind json_bytes_mapping; - // TODO: Enable/disable to verify SSL certificate - std::chrono::system_clock::duration timeout = GetOtlpDefaultMetricsTimeout(); + /** + Use json names (true) or protobuf field names (false) to set the json key. + */ + bool use_json_name; - // Additional HTTP headers - OtlpHeaders http_headers = GetOtlpDefaultMetricsHeaders(); + /** Print debug messages. */ + bool console_debug; - // Preferred Aggregation Temporality - PreferredAggregationTemporality aggregation_temporality = - PreferredAggregationTemporality::kCumulative; + /** Export timeout. */ + std::chrono::system_clock::duration timeout; + + /** Additional HTTP headers. */ + OtlpHeaders http_headers; + + PreferredAggregationTemporality aggregation_temporality; #ifdef ENABLE_ASYNC_EXPORT - // Concurrent requests - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md#otlpgrpc-concurrent-requests - std::size_t max_concurrent_requests = 64; + /** Max number of concurrent requests. */ + std::size_t max_concurrent_requests; - // Requests per connections - std::size_t max_requests_per_connection = 8; + /** Max number of requests per connection. */ + std::size_t max_requests_per_connection; #endif #ifdef ENABLE_OTLP_HTTP_SSL_PREVIEW - bool ssl_insecure_skip_verify{false}; + /** True do disable SSL. */ + bool ssl_insecure_skip_verify; + + /** CA CERT, path to a file. */ + std::string ssl_ca_cert_path; + + /** CA CERT, as a string. */ + std::string ssl_ca_cert_string; - std::string ssl_ca_cert_path = GetOtlpDefaultMetricsSslCertificatePath(); - std::string ssl_ca_cert_string = GetOtlpDefaultMetricsSslCertificateString(); + /** CLIENT KEY, path to a file. */ + std::string ssl_client_key_path; - std::string ssl_client_key_path = GetOtlpDefaultMetricsSslClientKeyPath(); - std::string ssl_client_key_string = GetOtlpDefaultMetricsSslClientKeyString(); + /** CLIENT KEY, as a string. */ + std::string ssl_client_key_string; - std::string ssl_client_cert_path = GetOtlpDefaultMetricsSslClientCertificatePath(); - std::string ssl_client_cert_string = GetOtlpDefaultMetricsSslClientCertificateString(); + /** CLIENT CERT, path to a file. */ + std::string ssl_client_cert_path; + + /** CLIENT CERT, as a string. */ + std::string ssl_client_cert_string; #endif /* ENABLE_OTLP_HTTP_SSL_PREVIEW */ #ifdef ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW /** Minimum TLS version. */ - std::string ssl_min_tls = GetOtlpDefaultMetricsSslTlsMinVersion(); + std::string ssl_min_tls; + /** Maximum TLS version. */ - std::string ssl_max_tls = GetOtlpDefaultMetricsSslTlsMaxVersion(); + std::string ssl_max_tls; + /** TLS cipher. */ - std::string ssl_cipher = GetOtlpDefaultMetricsSslTlsCipher(); + std::string ssl_cipher; + /** TLS cipher suite. */ - std::string ssl_cipher_suite = GetOtlpDefaultMetricsSslTlsCipherSuite(); + std::string ssl_cipher_suite; #endif /* ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW */ }; diff --git a/exporters/otlp/src/otlp_grpc_client.cc b/exporters/otlp/src/otlp_grpc_client.cc index 625781025e..c0436eddaf 100644 --- a/exporters/otlp/src/otlp_grpc_client.cc +++ b/exporters/otlp/src/otlp_grpc_client.cc @@ -48,7 +48,7 @@ static std::string GetFileContentsOrInMemoryContents(const std::string &file_pat } // namespace -std::shared_ptr OtlpGrpcClient::MakeChannel(const OtlpGrpcExporterOptions &options) +std::shared_ptr OtlpGrpcClient::MakeChannel(const OtlpGrpcClientOptions &options) { std::shared_ptr channel; @@ -94,7 +94,7 @@ std::shared_ptr OtlpGrpcClient::MakeChannel(const OtlpGrpcExporte } std::unique_ptr OtlpGrpcClient::MakeClientContext( - const OtlpGrpcExporterOptions &options) + const OtlpGrpcClientOptions &options) { std::unique_ptr context{new grpc::ClientContext()}; if (!context) @@ -121,19 +121,19 @@ std::unique_ptr OtlpGrpcClient::MakeCompletionQueue() } std::unique_ptr -OtlpGrpcClient::MakeTraceServiceStub(const OtlpGrpcExporterOptions &options) +OtlpGrpcClient::MakeTraceServiceStub(const OtlpGrpcClientOptions &options) { return proto::collector::trace::v1::TraceService::NewStub(MakeChannel(options)); } std::unique_ptr -OtlpGrpcClient::MakeMetricsServiceStub(const OtlpGrpcExporterOptions &options) +OtlpGrpcClient::MakeMetricsServiceStub(const OtlpGrpcClientOptions &options) { return proto::collector::metrics::v1::MetricsService::NewStub(MakeChannel(options)); } std::unique_ptr -OtlpGrpcClient::MakeLogsServiceStub(const OtlpGrpcExporterOptions &options) +OtlpGrpcClient::MakeLogsServiceStub(const OtlpGrpcClientOptions &options) { return proto::collector::logs::v1::LogsService::NewStub(MakeChannel(options)); } diff --git a/exporters/otlp/src/otlp_grpc_exporter_options.cc b/exporters/otlp/src/otlp_grpc_exporter_options.cc new file mode 100644 index 0000000000..3099303ac4 --- /dev/null +++ b/exporters/otlp/src/otlp_grpc_exporter_options.cc @@ -0,0 +1,38 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" +#include "opentelemetry/version.h" + +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +OtlpGrpcExporterOptions::OtlpGrpcExporterOptions() +{ + endpoint = GetOtlpDefaultGrpcTracesEndpoint(); + use_ssl_credentials = !GetOtlpDefaultGrpcTracesIsInsecure(); /* negation intended. */ + ssl_credentials_cacert_path = GetOtlpDefaultTracesSslCertificatePath(); + ssl_credentials_cacert_as_string = GetOtlpDefaultTracesSslCertificateString(); + +#ifdef ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW + ssl_client_key_path = GetOtlpDefaultTracesSslClientKeyPath(); + ssl_client_key_string = GetOtlpDefaultTracesSslClientKeyString(); + ssl_client_cert_path = GetOtlpDefaultTracesSslClientCertificatePath(); + ssl_client_cert_string = GetOtlpDefaultTracesSslClientCertificateString(); +#endif + + timeout = GetOtlpDefaultTracesTimeout(); + metadata = GetOtlpDefaultTracesHeaders(); + user_agent = GetOtlpDefaultUserAgent(); +} + +OtlpGrpcExporterOptions::~OtlpGrpcExporterOptions() {} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/src/otlp_grpc_log_record_exporter.cc b/exporters/otlp/src/otlp_grpc_log_record_exporter.cc index 01367da886..2b397262b0 100644 --- a/exporters/otlp/src/otlp_grpc_log_record_exporter.cc +++ b/exporters/otlp/src/otlp_grpc_log_record_exporter.cc @@ -30,16 +30,17 @@ namespace otlp // -------------------------------- Constructors -------------------------------- OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter() - : OtlpGrpcLogRecordExporter(OtlpGrpcExporterOptions()) + : OtlpGrpcLogRecordExporter(OtlpGrpcLogRecordExporterOptions()) {} -OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter(const OtlpGrpcExporterOptions &options) +OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter( + const OtlpGrpcLogRecordExporterOptions &options) : options_(options), log_service_stub_(OtlpGrpcClient::MakeLogsServiceStub(options)) {} OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter( std::unique_ptr stub) - : options_(OtlpGrpcExporterOptions()), log_service_stub_(std::move(stub)) + : options_(OtlpGrpcLogRecordExporterOptions()), log_service_stub_(std::move(stub)) {} // ----------------------------- Exporter methods ------------------------------ diff --git a/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc b/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc index b36eefa6cb..7229de569a 100644 --- a/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc +++ b/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc @@ -4,8 +4,8 @@ // MUST be first (absl) #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h" -#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter @@ -16,12 +16,12 @@ namespace otlp std::unique_ptr OtlpGrpcLogRecordExporterFactory::Create() { - OtlpGrpcExporterOptions options; + OtlpGrpcLogRecordExporterOptions options; return Create(options); } std::unique_ptr -OtlpGrpcLogRecordExporterFactory::Create(const OtlpGrpcExporterOptions &options) +OtlpGrpcLogRecordExporterFactory::Create(const OtlpGrpcLogRecordExporterOptions &options) { std::unique_ptr exporter( new OtlpGrpcLogRecordExporter(options)); diff --git a/exporters/otlp/src/otlp_grpc_log_record_exporter_options.cc b/exporters/otlp/src/otlp_grpc_log_record_exporter_options.cc new file mode 100644 index 0000000000..697ef28f2a --- /dev/null +++ b/exporters/otlp/src/otlp_grpc_log_record_exporter_options.cc @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +OtlpGrpcLogRecordExporterOptions::OtlpGrpcLogRecordExporterOptions() +{ + endpoint = GetOtlpDefaultGrpcLogsEndpoint(); + use_ssl_credentials = !GetOtlpDefaultGrpcLogsIsInsecure(); /* negation intended. */ + ssl_credentials_cacert_path = GetOtlpDefaultLogsSslCertificatePath(); + ssl_credentials_cacert_as_string = GetOtlpDefaultLogsSslCertificateString(); + +#ifdef ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW + ssl_client_key_path = GetOtlpDefaultLogsSslClientKeyPath(); + ssl_client_key_string = GetOtlpDefaultLogsSslClientKeyString(); + ssl_client_cert_path = GetOtlpDefaultLogsSslClientCertificatePath(); + ssl_client_cert_string = GetOtlpDefaultLogsSslClientCertificateString(); +#endif + + timeout = GetOtlpDefaultLogsTimeout(); + metadata = GetOtlpDefaultLogsHeaders(); + user_agent = GetOtlpDefaultUserAgent(); +} + +OtlpGrpcLogRecordExporterOptions::~OtlpGrpcLogRecordExporterOptions() {} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/src/otlp_grpc_metric_exporter_options.cc b/exporters/otlp/src/otlp_grpc_metric_exporter_options.cc new file mode 100644 index 0000000000..cb99d1cc5a --- /dev/null +++ b/exporters/otlp/src/otlp_grpc_metric_exporter_options.cc @@ -0,0 +1,38 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +OtlpGrpcMetricExporterOptions::OtlpGrpcMetricExporterOptions() +{ + endpoint = GetOtlpDefaultGrpcMetricsEndpoint(); + use_ssl_credentials = !GetOtlpDefaultGrpcMetricsIsInsecure(); /* negation intended. */ + ssl_credentials_cacert_path = GetOtlpDefaultMetricsSslCertificatePath(); + ssl_credentials_cacert_as_string = GetOtlpDefaultMetricsSslCertificateString(); + +#ifdef ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW + ssl_client_key_path = GetOtlpDefaultMetricsSslClientKeyPath(); + ssl_client_key_string = GetOtlpDefaultMetricsSslClientKeyString(); + ssl_client_cert_path = GetOtlpDefaultMetricsSslClientCertificatePath(); + ssl_client_cert_string = GetOtlpDefaultMetricsSslClientCertificateString(); +#endif + + timeout = GetOtlpDefaultMetricsTimeout(); + metadata = GetOtlpDefaultMetricsHeaders(); + user_agent = GetOtlpDefaultUserAgent(); + + aggregation_temporality = PreferredAggregationTemporality::kCumulative; +} + +OtlpGrpcMetricExporterOptions::~OtlpGrpcMetricExporterOptions() {} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/src/otlp_http_exporter_options.cc b/exporters/otlp/src/otlp_http_exporter_options.cc new file mode 100644 index 0000000000..91121e0c35 --- /dev/null +++ b/exporters/otlp/src/otlp_http_exporter_options.cc @@ -0,0 +1,54 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" + +#include +#include +#include +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +OtlpHttpExporterOptions::OtlpHttpExporterOptions() +{ + url = GetOtlpDefaultHttpTracesEndpoint(); + content_type = HttpRequestContentType::kJson; + json_bytes_mapping = JsonBytesMappingKind::kHexId; + use_json_name = false; + console_debug = false; + timeout = GetOtlpDefaultTracesTimeout(); + http_headers = GetOtlpDefaultTracesHeaders(); + +#ifdef ENABLE_ASYNC_EXPORT + max_concurrent_requests = 64; + max_requests_per_connection = 8; +#endif /* ENABLE_ASYNC_EXPORT */ + +#ifdef ENABLE_OTLP_HTTP_SSL_PREVIEW + ssl_insecure_skip_verify = false; + ssl_ca_cert_path = GetOtlpDefaultTracesSslCertificatePath(); + ssl_ca_cert_string = GetOtlpDefaultTracesSslCertificateString(); + ssl_client_key_path = GetOtlpDefaultTracesSslClientKeyPath(); + ssl_client_key_string = GetOtlpDefaultTracesSslClientKeyString(); + ssl_client_cert_path = GetOtlpDefaultTracesSslClientCertificatePath(); + ssl_client_cert_string = GetOtlpDefaultTracesSslClientCertificateString(); +#endif /* ENABLE_OTLP_HTTP_SSL_PREVIEW */ + +#ifdef ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW + ssl_min_tls = GetOtlpDefaultTracesSslTlsMinVersion(); + ssl_max_tls = GetOtlpDefaultTracesSslTlsMaxVersion(); + ssl_cipher = GetOtlpDefaultTracesSslTlsCipher(); + ssl_cipher_suite = GetOtlpDefaultTracesSslTlsCipherSuite(); +#endif /* ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW */ +} + +OtlpHttpExporterOptions::~OtlpHttpExporterOptions() {} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/src/otlp_http_log_record_exporter_options.cc b/exporters/otlp/src/otlp_http_log_record_exporter_options.cc new file mode 100644 index 0000000000..bda37b9730 --- /dev/null +++ b/exporters/otlp/src/otlp_http_log_record_exporter_options.cc @@ -0,0 +1,54 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" + +#include +#include +#include +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +OtlpHttpLogRecordExporterOptions::OtlpHttpLogRecordExporterOptions() +{ + url = GetOtlpDefaultHttpLogsEndpoint(); + content_type = HttpRequestContentType::kJson; + json_bytes_mapping = JsonBytesMappingKind::kHexId; + use_json_name = false; + console_debug = false; + timeout = GetOtlpDefaultLogsTimeout(); + http_headers = GetOtlpDefaultLogsHeaders(); + +#ifdef ENABLE_ASYNC_EXPORT + max_concurrent_requests = 64; + max_requests_per_connection = 8; +#endif + +#ifdef ENABLE_OTLP_HTTP_SSL_PREVIEW + ssl_insecure_skip_verify = false; + ssl_ca_cert_path = GetOtlpDefaultLogsSslCertificatePath(); + ssl_ca_cert_string = GetOtlpDefaultLogsSslCertificateString(); + ssl_client_key_path = GetOtlpDefaultLogsSslClientKeyPath(); + ssl_client_key_string = GetOtlpDefaultLogsSslClientKeyString(); + ssl_client_cert_path = GetOtlpDefaultLogsSslClientCertificatePath(); + ssl_client_cert_string = GetOtlpDefaultLogsSslClientCertificateString(); +#endif /* ENABLE_OTLP_HTTP_SSL_PREVIEW */ + +#ifdef ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW + ssl_min_tls = GetOtlpDefaultLogsSslTlsMinVersion(); + ssl_max_tls = GetOtlpDefaultLogsSslTlsMaxVersion(); + ssl_cipher = GetOtlpDefaultLogsSslTlsCipher(); + ssl_cipher_suite = GetOtlpDefaultLogsSslTlsCipherSuite(); +#endif /* ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW */ +} + +OtlpHttpLogRecordExporterOptions::~OtlpHttpLogRecordExporterOptions() {} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/src/otlp_http_metric_exporter_options.cc b/exporters/otlp/src/otlp_http_metric_exporter_options.cc new file mode 100644 index 0000000000..4dc0f40631 --- /dev/null +++ b/exporters/otlp/src/otlp_http_metric_exporter_options.cc @@ -0,0 +1,55 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h" + +#include +#include +#include +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +OtlpHttpMetricExporterOptions::OtlpHttpMetricExporterOptions() +{ + url = GetOtlpDefaultMetricsEndpoint(); + content_type = HttpRequestContentType::kJson; + json_bytes_mapping = JsonBytesMappingKind::kHexId; + use_json_name = false; + console_debug = false; + timeout = GetOtlpDefaultMetricsTimeout(); + http_headers = GetOtlpDefaultMetricsHeaders(); + aggregation_temporality = PreferredAggregationTemporality::kCumulative; + +#ifdef ENABLE_ASYNC_EXPORT + max_concurrent_requests = 64; + max_requests_per_connection = 8; +#endif + +#ifdef ENABLE_OTLP_HTTP_SSL_PREVIEW + ssl_insecure_skip_verify = false; + ssl_ca_cert_path = GetOtlpDefaultMetricsSslCertificatePath(); + ssl_ca_cert_string = GetOtlpDefaultMetricsSslCertificateString(); + ssl_client_key_path = GetOtlpDefaultMetricsSslClientKeyPath(); + ssl_client_key_string = GetOtlpDefaultMetricsSslClientKeyString(); + ssl_client_cert_path = GetOtlpDefaultMetricsSslClientCertificatePath(); + ssl_client_cert_string = GetOtlpDefaultMetricsSslClientCertificateString(); +#endif /* ENABLE_OTLP_HTTP_SSL_PREVIEW */ + +#ifdef ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW + ssl_min_tls = GetOtlpDefaultMetricsSslTlsMinVersion(); + ssl_max_tls = GetOtlpDefaultMetricsSslTlsMaxVersion(); + ssl_cipher = GetOtlpDefaultMetricsSslTlsCipher(); + ssl_cipher_suite = GetOtlpDefaultMetricsSslTlsCipherSuite(); +#endif /* ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW */ +} + +OtlpHttpMetricExporterOptions::~OtlpHttpMetricExporterOptions() {} + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc b/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc index 2cc534277d..cb1d1849aa 100644 --- a/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc +++ b/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc @@ -3,8 +3,8 @@ #include -#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h" /* Make sure OtlpGrpcLogRecordExporterFactory does not require, @@ -22,7 +22,7 @@ namespace otlp TEST(OtlpGrpcLogRecordExporterFactoryTest, BuildTest) { - OtlpGrpcExporterOptions opts; + OtlpGrpcLogRecordExporterOptions opts; opts.endpoint = "localhost:45454"; std::unique_ptr exporter = diff --git a/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc b/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc index 547d21d056..6a31639219 100644 --- a/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc @@ -59,7 +59,8 @@ class OtlpGrpcLogRecordExporterTestPeer : public ::testing::Test } // Get the options associated with the given exporter. - const OtlpGrpcExporterOptions &GetOptions(std::unique_ptr &exporter) + const OtlpGrpcLogRecordExporterOptions &GetOptions( + std::unique_ptr &exporter) { return exporter->options_; } diff --git a/exporters/otlp/test/otlp_grpc_metric_exporter_test.cc b/exporters/otlp/test/otlp_grpc_metric_exporter_test.cc new file mode 100644 index 0000000000..dc6dde9d79 --- /dev/null +++ b/exporters/otlp/test/otlp_grpc_metric_exporter_test.cc @@ -0,0 +1,209 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#ifndef OPENTELEMETRY_STL_VERSION +// Unfortunately as of 04/27/2021 the fix is NOT in the vcpkg snapshot of Google Test. +// Remove above `#ifdef` once the GMock fix for C++20 is in the mainline. +// +// Please refer to this GitHub issue for additional details: +// https://github.com/google/googletest/issues/2914 +// https://github.com/google/googletest/commit/61f010d703b32de9bfb20ab90ece38ab2f25977f +// +// If we compile using Visual Studio 2019 with `c++latest` (C++20) without the GMock fix, +// then the compilation here fails in `gmock-actions.h` from: +// .\tools\vcpkg\installed\x64-windows\include\gmock\gmock-actions.h(819): +// error C2653: 'result_of': is not a class or namespace name +// +// That is because `std::result_of` has been removed in C++20. + +# include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h" + +# include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" + +// Problematic code that pulls in Gmock and breaks with vs2019/c++latest : +# include "opentelemetry/proto/collector/metrics/v1/metrics_service_mock.grpc.pb.h" + +# include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" + +# include "opentelemetry/sdk/trace/simple_processor.h" +# include "opentelemetry/sdk/trace/tracer_provider.h" +# include "opentelemetry/trace/provider.h" + +# include + +# if defined(_MSC_VER) +# include "opentelemetry/sdk/common/env_variables.h" +using opentelemetry::sdk::common::setenv; +using opentelemetry::sdk::common::unsetenv; +# endif + +using namespace testing; + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +class OtlpGrpcMetricExporterTestPeer : public ::testing::Test +{ +public: + std::unique_ptr GetExporter( + std::unique_ptr &stub_interface) + { + return std::unique_ptr( + new OtlpGrpcMetricExporter(std::move(stub_interface))); + } + + // Get the options associated with the given exporter. + const OtlpGrpcMetricExporterOptions &GetOptions(std::unique_ptr &exporter) + { + return exporter->options_; + } +}; + +// Test exporter configuration options +TEST_F(OtlpGrpcMetricExporterTestPeer, ConfigTest) +{ + OtlpGrpcMetricExporterOptions opts; + opts.endpoint = "localhost:45454"; + std::unique_ptr exporter(new OtlpGrpcMetricExporter(opts)); + EXPECT_EQ(GetOptions(exporter).endpoint, "localhost:45454"); +} + +// Test exporter configuration options with use_ssl_credentials +TEST_F(OtlpGrpcMetricExporterTestPeer, ConfigSslCredentialsTest) +{ + std::string cacert_str = "--begin and end fake cert--"; + OtlpGrpcMetricExporterOptions opts; + opts.use_ssl_credentials = true; + opts.ssl_credentials_cacert_as_string = cacert_str; + std::unique_ptr exporter(new OtlpGrpcMetricExporter(opts)); + EXPECT_EQ(GetOptions(exporter).ssl_credentials_cacert_as_string, cacert_str); + EXPECT_EQ(GetOptions(exporter).use_ssl_credentials, true); +} + +# ifndef NO_GETENV +// Test exporter configuration options with use_ssl_credentials +TEST_F(OtlpGrpcMetricExporterTestPeer, ConfigFromEnv) +{ + const std::string cacert_str = "--begin and end fake cert--"; + setenv("OTEL_EXPORTER_OTLP_CERTIFICATE_STRING", cacert_str.c_str(), 1); + setenv("OTEL_EXPORTER_OTLP_SSL_ENABLE", "True", 1); + const std::string endpoint = "https://localhost:9999"; + setenv("OTEL_EXPORTER_OTLP_ENDPOINT", endpoint.c_str(), 1); + setenv("OTEL_EXPORTER_OTLP_TIMEOUT", "20050ms", 1); + setenv("OTEL_EXPORTER_OTLP_HEADERS", "k1=v1,k2=v2", 1); + setenv("OTEL_EXPORTER_OTLP_METRICS_HEADERS", "k1=v3,k1=v4", 1); + + std::unique_ptr exporter(new OtlpGrpcMetricExporter()); + EXPECT_EQ(GetOptions(exporter).ssl_credentials_cacert_as_string, cacert_str); + EXPECT_EQ(GetOptions(exporter).use_ssl_credentials, true); + EXPECT_EQ(GetOptions(exporter).endpoint, endpoint); + EXPECT_EQ(GetOptions(exporter).timeout.count(), + std::chrono::duration_cast( + std::chrono::milliseconds{20050}) + .count()); + EXPECT_EQ(GetOptions(exporter).metadata.size(), 3); + { + // Test k2 + auto range = GetOptions(exporter).metadata.equal_range("k2"); + EXPECT_TRUE(range.first != range.second); + EXPECT_EQ(range.first->second, std::string("v2")); + ++range.first; + EXPECT_TRUE(range.first == range.second); + } + { + // Test k1 + auto range = GetOptions(exporter).metadata.equal_range("k1"); + EXPECT_TRUE(range.first != range.second); + EXPECT_EQ(range.first->second, std::string("v3")); + ++range.first; + EXPECT_EQ(range.first->second, std::string("v4")); + ++range.first; + EXPECT_TRUE(range.first == range.second); + } + + unsetenv("OTEL_EXPORTER_OTLP_ENDPOINT"); + unsetenv("OTEL_EXPORTER_OTLP_CERTIFICATE_STRING"); + unsetenv("OTEL_EXPORTER_OTLP_SSL_ENABLE"); + unsetenv("OTEL_EXPORTER_OTLP_TIMEOUT"); + unsetenv("OTEL_EXPORTER_OTLP_HEADERS"); + unsetenv("OTEL_EXPORTER_OTLP_METRICS_HEADERS"); +} +# endif + +# ifndef NO_GETENV +// Test exporter configuration options with use_ssl_credentials +TEST_F(OtlpGrpcMetricExporterTestPeer, ConfigHttpsSecureFromEnv) +{ + // https takes precedence over insecure + const std::string endpoint = "https://localhost:9999"; + setenv("OTEL_EXPORTER_OTLP_ENDPOINT", endpoint.c_str(), 1); + setenv("OTEL_EXPORTER_OTLP_METRICS_INSECURE", "true", 1); + + std::unique_ptr exporter(new OtlpGrpcMetricExporter()); + EXPECT_EQ(GetOptions(exporter).use_ssl_credentials, true); + EXPECT_EQ(GetOptions(exporter).endpoint, endpoint); + + unsetenv("OTEL_EXPORTER_OTLP_ENDPOINT"); + unsetenv("OTEL_EXPORTER_OTLP_METRICS_INSECURE"); +} +# endif + +# ifndef NO_GETENV +// Test exporter configuration options with use_ssl_credentials +TEST_F(OtlpGrpcMetricExporterTestPeer, ConfigHttpInsecureFromEnv) +{ + // http takes precedence over secure + const std::string endpoint = "http://localhost:9999"; + setenv("OTEL_EXPORTER_OTLP_ENDPOINT", endpoint.c_str(), 1); + setenv("OTEL_EXPORTER_OTLP_METRICS_INSECURE", "false", 1); + + std::unique_ptr exporter(new OtlpGrpcMetricExporter()); + EXPECT_EQ(GetOptions(exporter).use_ssl_credentials, false); + EXPECT_EQ(GetOptions(exporter).endpoint, endpoint); + + unsetenv("OTEL_EXPORTER_OTLP_ENDPOINT"); + unsetenv("OTEL_EXPORTER_OTLP_METRICS_INSECURE"); +} +# endif + +# ifndef NO_GETENV +// Test exporter configuration options with use_ssl_credentials +TEST_F(OtlpGrpcMetricExporterTestPeer, ConfigUnknownSecureFromEnv) +{ + const std::string endpoint = "localhost:9999"; + setenv("OTEL_EXPORTER_OTLP_ENDPOINT", endpoint.c_str(), 1); + setenv("OTEL_EXPORTER_OTLP_METRICS_INSECURE", "false", 1); + + std::unique_ptr exporter(new OtlpGrpcMetricExporter()); + EXPECT_EQ(GetOptions(exporter).use_ssl_credentials, true); + EXPECT_EQ(GetOptions(exporter).endpoint, endpoint); + + unsetenv("OTEL_EXPORTER_OTLP_ENDPOINT"); + unsetenv("OTEL_EXPORTER_OTLP_METRICS_INSECURE"); +} +# endif + +# ifndef NO_GETENV +// Test exporter configuration options with use_ssl_credentials +TEST_F(OtlpGrpcMetricExporterTestPeer, ConfigUnknownInsecureFromEnv) +{ + const std::string endpoint = "localhost:9999"; + setenv("OTEL_EXPORTER_OTLP_ENDPOINT", endpoint.c_str(), 1); + setenv("OTEL_EXPORTER_OTLP_METRICS_INSECURE", "true", 1); + + std::unique_ptr exporter(new OtlpGrpcMetricExporter()); + EXPECT_EQ(GetOptions(exporter).use_ssl_credentials, false); + EXPECT_EQ(GetOptions(exporter).endpoint, endpoint); + + unsetenv("OTEL_EXPORTER_OTLP_ENDPOINT"); + unsetenv("OTEL_EXPORTER_OTLP_METRICS_INSECURE"); +} +# endif + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE +#endif /* OPENTELEMETRY_STL_VERSION */ diff --git a/ext/src/dll/opentelemetry_cpp.src b/ext/src/dll/opentelemetry_cpp.src index 10172dbb3f..195b30640a 100644 --- a/ext/src/dll/opentelemetry_cpp.src +++ b/ext/src/dll/opentelemetry_cpp.src @@ -14,22 +14,6 @@ EXPORTS #endif // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::trace::TracerProviderFactory::Create(class std::unique_ptr >) ?Create@TracerProviderFactory@trace@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VTracerProvider@trace@v1@opentelemetry@@U?$default_delete@VTracerProvider@trace@v1@opentelemetry@@@std@@@std@@V?$unique_ptr@VSpanProcessor@trace@sdk@v1@opentelemetry@@U?$default_delete@VSpanProcessor@trace@sdk@v1@opentelemetry@@@std@@@7@@Z -#if defined(WITH_OTLP_GRPC) - // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpGrpcExporterOptions const & __ptr64) -#if defined(_WIN64) - ?Create@OtlpGrpcExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VSpanExporter@trace@sdk@v1@opentelemetry@@U?$default_delete@VSpanExporter@trace@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpGrpcExporterOptions@2345@@Z -#else - ?Create@OtlpGrpcExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VSpanExporter@trace@sdk@v1@opentelemetry@@U?$default_delete@VSpanExporter@trace@sdk@v1@opentelemetry@@@std@@@std@@ABUOtlpGrpcExporterOptions@2345@@Z -#endif // defined(_WIN64) -#endif // defined(WITH_OTLP_GRPC) -#if defined(WITH_OTLP_HTTP) - // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpHttpExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpHttpExporterOptions const & __ptr64) -#if defined(_WIN64) - ?Create@OtlpHttpExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VSpanExporter@trace@sdk@v1@opentelemetry@@U?$default_delete@VSpanExporter@trace@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpHttpExporterOptions@2345@@Z -#else - ?Create@OtlpHttpExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VSpanExporter@trace@sdk@v1@opentelemetry@@U?$default_delete@VSpanExporter@trace@sdk@v1@opentelemetry@@@std@@@std@@ABUOtlpHttpExporterOptions@2345@@Z -#endif // defined(_WIN64) -#endif // defined(WITH_OTLP_HTTP) // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::logs::LoggerProviderFactory::Create(class std::unique_ptr > && __ptr64) #if defined(_WIN64) ?Create@LoggerProviderFactory@logs@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VLoggerProvider@logs@v1@opentelemetry@@U?$default_delete@VLoggerProvider@logs@v1@opentelemetry@@@std@@@std@@$$QEAV?$unique_ptr@VLogRecordProcessor@logs@sdk@v1@opentelemetry@@U?$default_delete@VLogRecordProcessor@logs@sdk@v1@opentelemetry@@@std@@@7@@Z @@ -82,7 +66,6 @@ EXPORTS ?AddMetricReader@MeterProvider@metrics@sdk@v1@opentelemetry@@QEAAXV?$shared_ptr@VMetricReader@metrics@sdk@v1@opentelemetry@@@std@@@Z // public: void __cdecl opentelemetry::v1::sdk::metrics::MeterProvider::AddView(class std::unique_ptr >,class std::unique_ptr >,class std::unique_ptr >) ?AddView@MeterProvider@metrics@sdk@v1@opentelemetry@@QEAAXV?$unique_ptr@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@V?$unique_ptr@VMeterSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterSelector@metrics@sdk@v1@opentelemetry@@@std@@@7@V?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@7@@Z - #if defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP) ?GetOtlpDefaultTracesTimeout@otlp@exporter@v1@opentelemetry@@YA?AV?$duration@_JU?$ratio@$00$0JIJGIA@@std@@@chrono@std@@XZ ?GetOtlpDefaultTracesHeaders@otlp@exporter@v1@opentelemetry@@YA?AV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@Ucmp_ic@otlp@exporter@v1@opentelemetry@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ @@ -90,26 +73,63 @@ EXPORTS ?GetOtlpDefaultLogsHeaders@otlp@exporter@v1@opentelemetry@@YA?AV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@Ucmp_ic@otlp@exporter@v1@opentelemetry@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ ?GetOtlpDefaultMetricsTimeout@otlp@exporter@v1@opentelemetry@@YA?AV?$duration@_JU?$ratio@$00$0JIJGIA@@std@@@chrono@std@@XZ ?GetOtlpDefaultMetricsHeaders@otlp@exporter@v1@opentelemetry@@YA?AV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@Ucmp_ic@otlp@exporter@v1@opentelemetry@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ + ?GetOtlpDefaultTracesSslCertificatePath@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ + ?GetOtlpDefaultMetricsSslCertificatePath@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ + ?GetOtlpDefaultLogsSslCertificatePath@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ + ?GetOtlpDefaultTracesSslCertificateString@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ + ?GetOtlpDefaultMetricsSslCertificateString@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ + ?GetOtlpDefaultLogsSslCertificateString@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ #endif // defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP) #if defined(WITH_OTLP_GRPC) - // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcLogRecordExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpGrpcExporterOptions const & __ptr64) - ?Create@OtlpGrpcLogRecordExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VLogRecordExporter@logs@sdk@v1@opentelemetry@@U?$default_delete@VLogRecordExporter@logs@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpGrpcExporterOptions@2345@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpGrpcExporterOptions const & __ptr64) + ?Create@OtlpGrpcExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VSpanExporter@trace@sdk@v1@opentelemetry@@U?$default_delete@VSpanExporter@trace@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpGrpcExporterOptions@2345@@Z // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporterOptions const & __ptr64) ?Create@OtlpGrpcMetricExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpGrpcMetricExporterOptions@2345@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcLogRecordExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpGrpcLogRecordExporterOptions const &) + ?Create@OtlpGrpcLogRecordExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VLogRecordExporter@logs@sdk@v1@opentelemetry@@U?$default_delete@VLogRecordExporter@logs@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpGrpcLogRecordExporterOptions@2345@@Z + // public: __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcExporterOptions::OtlpGrpcExporterOptions(void) + ??0OtlpGrpcExporterOptions@otlp@exporter@v1@opentelemetry@@QEAA@XZ + // public: __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcExporterOptions::~OtlpGrpcExporterOptions(void) + ??1OtlpGrpcExporterOptions@otlp@exporter@v1@opentelemetry@@QEAA@XZ + // public: __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporterOptions::OtlpGrpcMetricExporterOptions(void) + ??0OtlpGrpcMetricExporterOptions@otlp@exporter@v1@opentelemetry@@QEAA@XZ + // public: __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporterOptions::~OtlpGrpcMetricExporterOptions(void) + ??1OtlpGrpcMetricExporterOptions@otlp@exporter@v1@opentelemetry@@QEAA@XZ + // public: __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcLogRecordExporterOptions::OtlpGrpcLogRecordExporterOptions(void) + ??0OtlpGrpcLogRecordExporterOptions@otlp@exporter@v1@opentelemetry@@QEAA@XZ + // public: __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcLogRecordExporterOptions::~OtlpGrpcLogRecordExporterOptions(void) + ??1OtlpGrpcLogRecordExporterOptions@otlp@exporter@v1@opentelemetry@@QEAA@XZ ?GetOtlpDefaultGrpcTracesEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ + ?GetOtlpDefaultGrpcMetricsEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ + ?GetOtlpDefaultGrpcLogsEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ ?GetOtlpDefaultGrpcTracesIsInsecure@otlp@exporter@v1@opentelemetry@@YA_NXZ - ?GetOtlpDefaultTracesSslCertificatePath@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ - ?GetOtlpDefaultTracesSslCertificateString@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ + ?GetOtlpDefaultGrpcMetricsIsInsecure@otlp@exporter@v1@opentelemetry@@YA_NXZ + ?GetOtlpDefaultGrpcLogsIsInsecure@otlp@exporter@v1@opentelemetry@@YA_NXZ #endif // defined(WITH_OTLP_GRPC) + #if defined(WITH_OTLP_HTTP) + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpHttpExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpHttpExporterOptions const & __ptr64) + ?Create@OtlpHttpExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VSpanExporter@trace@sdk@v1@opentelemetry@@U?$default_delete@VSpanExporter@trace@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpHttpExporterOptions@2345@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpHttpMetricExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpHttpMetricExporterOptions const &) + ?Create@OtlpHttpMetricExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpHttpMetricExporterOptions@2345@@Z // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpHttpLogRecordExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpHttpLogRecordExporterOptions const & __ptr64) ?Create@OtlpHttpLogRecordExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VLogRecordExporter@logs@sdk@v1@opentelemetry@@U?$default_delete@VLogRecordExporter@logs@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpHttpLogRecordExporterOptions@2345@@Z - ?GetOtlpDefaultHttpTracesEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ - ?GetOtlpDefaultHttpLogsEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ + // public: __cdecl opentelemetry::v1::exporter::otlp::OtlpHttpExporterOptions::OtlpHttpExporterOptions(void) + ??0OtlpHttpExporterOptions@otlp@exporter@v1@opentelemetry@@QEAA@XZ + // public: __cdecl opentelemetry::v1::exporter::otlp::OtlpHttpExporterOptions::~OtlpHttpExporterOptions(void) + ??1OtlpHttpExporterOptions@otlp@exporter@v1@opentelemetry@@QEAA@XZ + // public: __cdecl opentelemetry::v1::exporter::otlp::OtlpHttpMetricExporterOptions::OtlpHttpMetricExporterOptions(void) + ??0OtlpHttpMetricExporterOptions@otlp@exporter@v1@opentelemetry@@QEAA@XZ + // public: __cdecl opentelemetry::v1::exporter::otlp::OtlpHttpMetricExporterOptions::~OtlpHttpMetricExporterOptions(void) + ??1OtlpHttpMetricExporterOptions@otlp@exporter@v1@opentelemetry@@QEAA@XZ + // public: __cdecl opentelemetry::v1::exporter::otlp::OtlpHttpLogRecordExporterOptions::OtlpHttpLogRecordExporterOptions(void) + ??0OtlpHttpLogRecordExporterOptions@otlp@exporter@v1@opentelemetry@@QEAA@XZ + // public: __cdecl opentelemetry::v1::exporter::otlp::OtlpHttpLogRecordExporterOptions::~OtlpHttpLogRecordExporterOptions(void) + ??1OtlpHttpLogRecordExporterOptions@otlp@exporter@v1@opentelemetry@@QEAA@XZ - // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpHttpMetricExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpHttpMetricExporterOptions const &) - ?Create@OtlpHttpMetricExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpHttpMetricExporterOptions@2345@@Z + ?GetOtlpDefaultHttpTracesEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ ?GetOtlpDefaultHttpMetricsEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ + ?GetOtlpDefaultHttpLogsEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ #endif // defined(WITH_OTLP_HTTP) // clang-format on From cb603ad97f33e52340e627e1cb43ba73bb1d7ef0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Nov 2023 21:53:05 -0800 Subject: [PATCH 29/29] Bump actions/github-script from 6 to 7 (#2403) Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v6...v7) --- updated-dependencies: - dependency-name: actions/github-script dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/project_management_issue_open.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/project_management_issue_open.yml b/.github/workflows/project_management_issue_open.yml index e68e9ab152..28ee771ed1 100644 --- a/.github/workflows/project_management_issue_open.yml +++ b/.github/workflows/project_management_issue_open.yml @@ -10,7 +10,7 @@ jobs: permissions: issues: write steps: - - uses: actions/github-script@v6 + - uses: actions/github-script@v7 with: script: | github.rest.issues.addLabels({