From da8e377be51edadad514d31c58e0ce7a2eb1b05e Mon Sep 17 00:00:00 2001 From: WenTao Ou <owentou@tencent.com> Date: Mon, 6 May 2024 17:44:17 +0800 Subject: [PATCH 01/17] [BUILD] Link CoreFoundation on apple systems because some dependency packages require it. (#2655) --- api/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index 0f63a49f9b..78e97ad029 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -131,6 +131,10 @@ if(WITH_OTLP_HTTP_COMPRESSION) INTERFACE ENABLE_OTLP_COMPRESSION_PREVIEW) endif() +if(APPLE) + target_link_libraries(opentelemetry_api INTERFACE "-framework CoreFoundation") +endif() + include(${PROJECT_SOURCE_DIR}/cmake/pkgconfig.cmake) if(OPENTELEMETRY_INSTALL) From 4f32bc6f296a186f689f5b8c2cd91899e139dcea Mon Sep 17 00:00:00 2001 From: Rashid Kaleem <rashid.kaleem@gmail.com> Date: Wed, 8 May 2024 07:44:46 -0500 Subject: [PATCH 02/17] [SDK] Avoid missing conditional variable update and simplify atomic bool (#2553) Addresses two issues - 1. Fix the use of a conditional variable where a wait on the variable might not be in flight when a notify is called. This is fixed by ensuring that an associated lock is aquired before calling the notify. 2. Instead of relying on a lock an a boolean, replace the use wit a single atomic boolean. --------- Co-authored-by: Ehsan Saei <71217171+esigo@users.noreply.github.com> Co-authored-by: Marc Alff <marc.alff@oracle.com> Co-authored-by: Marc Alff <marc.alff@free.fr> --- sdk/include/opentelemetry/sdk/metrics/metric_reader.h | 5 ++--- .../metrics/export/periodic_exporting_metric_reader.cc | 8 +++++++- sdk/src/metrics/metric_reader.cc | 10 +++------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/metrics/metric_reader.h b/sdk/include/opentelemetry/sdk/metrics/metric_reader.h index 21249439d6..126ad92282 100644 --- a/sdk/include/opentelemetry/sdk/metrics/metric_reader.h +++ b/sdk/include/opentelemetry/sdk/metrics/metric_reader.h @@ -3,10 +3,10 @@ #pragma once +#include <atomic> #include <chrono> #include <memory> -#include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/instruments.h" @@ -72,8 +72,7 @@ class MetricReader protected: private: MetricProducer *metric_producer_; - mutable opentelemetry::common::SpinLockMutex lock_; - bool shutdown_; + std::atomic<bool> shutdown_{false}; }; } // namespace metrics } // namespace sdk diff --git a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc index 91f604195e..b79b8a32e6 100644 --- a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc +++ b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h" +#include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" @@ -101,6 +102,7 @@ bool PeriodicExportingMetricReader::CollectAndExportOnce() bool notify_force_flush = is_force_flush_pending_.exchange(false, std::memory_order_acq_rel); if (notify_force_flush) { + std::unique_lock<std::mutex> lk(force_flush_m_); is_force_flush_notified_.store(true, std::memory_order_release); force_flush_cv_.notify_one(); } @@ -191,7 +193,11 @@ bool PeriodicExportingMetricReader::OnShutDown(std::chrono::microseconds timeout { if (worker_thread_.joinable()) { - cv_.notify_one(); + { + // ensure that `cv_` is awaiting, and the update doesn't get lost + std::unique_lock<std::mutex> lk(cv_m_); + cv_.notify_all(); + } worker_thread_.join(); } return exporter_->Shutdown(timeout); diff --git a/sdk/src/metrics/metric_reader.cc b/sdk/src/metrics/metric_reader.cc index 8b1998fbd3..8046b1c148 100644 --- a/sdk/src/metrics/metric_reader.cc +++ b/sdk/src/metrics/metric_reader.cc @@ -48,10 +48,7 @@ bool MetricReader::Shutdown(std::chrono::microseconds timeout) noexcept OTEL_INTERNAL_LOG_WARN("MetricReader::Shutdown - Cannot invoke shutdown twice!"); } - { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); - shutdown_ = true; - } + shutdown_.store(true, std::memory_order_release); if (!OnShutDown(timeout)) { @@ -65,7 +62,7 @@ bool MetricReader::Shutdown(std::chrono::microseconds timeout) noexcept bool MetricReader::ForceFlush(std::chrono::microseconds timeout) noexcept { bool status = true; - if (shutdown_) + if (IsShutdown()) { OTEL_INTERNAL_LOG_WARN("MetricReader::Shutdown Cannot invoke Force flush on shutdown reader!"); } @@ -79,8 +76,7 @@ bool MetricReader::ForceFlush(std::chrono::microseconds timeout) noexcept bool MetricReader::IsShutdown() const noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); - return shutdown_; + return shutdown_.load(std::memory_order_acquire); } } // namespace metrics From 6de4ccd4210a8a4f6d742cf258ef1bc4a5b3c8ce Mon Sep 17 00:00:00 2001 From: Marc Alff <marc.alff@oracle.com> Date: Wed, 8 May 2024 17:59:49 +0200 Subject: [PATCH 03/17] [BUILD] Build break in OLTP_FILE tests (#2659) --- exporters/otlp/CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index 228c5cc67f..83b35f16a7 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -489,9 +489,13 @@ if(BUILD_TESTING) if(WITH_OTLP_FILE) add_executable(otlp_file_client_test test/otlp_file_client_test.cc) target_link_libraries( - otlp_file_client_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} - ${GMOCK_LIB} opentelemetry_exporter_otlp_file - opentelemetry_otlp_recordable) + otlp_file_client_test + ${GTEST_BOTH_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + ${GMOCK_LIB} + opentelemetry_exporter_otlp_file + opentelemetry_otlp_recordable + nlohmann_json::nlohmann_json) gtest_add_tests( TARGET otlp_file_client_test TEST_PREFIX exporter.otlp. From ce14bf6520a059ff0bca81df45603722d965ad7c Mon Sep 17 00:00:00 2001 From: Marc Alff <marc.alff@oracle.com> Date: Wed, 8 May 2024 21:09:58 +0200 Subject: [PATCH 04/17] [EXPORTER] General cleanup for is_shutdown_ flags in exporters. (#2663) --- .../elasticsearch/es_log_record_exporter.h | 4 +--- .../elasticsearch/src/es_log_record_exporter.cc | 2 -- .../exporters/memory/in_memory_span_exporter.h | 15 ++++++--------- .../exporters/ostream/log_record_exporter.h | 6 ++---- .../exporters/ostream/metric_exporter.h | 7 ++++--- .../exporters/ostream/span_exporter.h | 5 ++--- exporters/ostream/src/log_record_exporter.cc | 2 -- exporters/ostream/src/metric_exporter.cc | 7 +++---- exporters/ostream/src/span_exporter.cc | 3 +-- .../exporters/otlp/otlp_grpc_exporter.h | 5 ++--- .../otlp/otlp_grpc_log_record_exporter.h | 6 +++--- .../exporters/otlp/otlp_grpc_metric_exporter.h | 6 +++--- .../exporters/otlp/otlp_http_client.h | 1 - exporters/otlp/src/otlp_grpc_exporter.cc | 2 -- .../otlp/src/otlp_grpc_log_record_exporter.cc | 2 -- exporters/otlp/src/otlp_grpc_metric_exporter.cc | 2 -- .../opentelemetry/exporters/prometheus/exporter.h | 2 +- .../exporters/zipkin/zipkin_exporter.h | 6 +++--- exporters/zipkin/src/zipkin_exporter.cc | 2 -- 19 files changed, 31 insertions(+), 54 deletions(-) diff --git a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h index 31d63af983..2035b32d4b 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h @@ -4,7 +4,6 @@ #pragma once #include "nlohmann/json.hpp" -#include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/ext/http/client/http_client_factory.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/logs/exporter.h" @@ -110,14 +109,13 @@ class ElasticsearchLogRecordExporter final : public opentelemetry::sdk::logs::Lo private: // Stores if this exporter had its Shutdown() method called - bool is_shutdown_ = false; + std::atomic<bool> is_shutdown_{false}; // Configuration options for the exporter ElasticsearchExporterOptions options_; // Object that stores the HTTP sessions that have been created std::shared_ptr<ext::http::client::HttpClient> http_client_; - mutable opentelemetry::common::SpinLockMutex lock_; bool isShutdown() const noexcept; #ifdef ENABLE_ASYNC_EXPORT diff --git a/exporters/elasticsearch/src/es_log_record_exporter.cc b/exporters/elasticsearch/src/es_log_record_exporter.cc index e167faf3d9..196474ba77 100644 --- a/exporters/elasticsearch/src/es_log_record_exporter.cc +++ b/exporters/elasticsearch/src/es_log_record_exporter.cc @@ -460,7 +460,6 @@ bool ElasticsearchLogRecordExporter::ForceFlush( bool ElasticsearchLogRecordExporter::Shutdown(std::chrono::microseconds /* timeout */) noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); is_shutdown_ = true; // Shutdown the session manager @@ -472,7 +471,6 @@ bool ElasticsearchLogRecordExporter::Shutdown(std::chrono::microseconds /* timeo bool ElasticsearchLogRecordExporter::isShutdown() const noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); return is_shutdown_; } } // namespace logs diff --git a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h index 27efae379b..0c2a14a673 100644 --- a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h +++ b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h @@ -2,12 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once + +#include <atomic> #include <mutex> -#include "opentelemetry/common/spin_lock_mutex.h" + #include "opentelemetry/exporters/memory/in_memory_span_data.h" #include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/span_data.h" #include "opentelemetry/sdk_config.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter @@ -72,7 +75,6 @@ class InMemorySpanExporter final : public opentelemetry::sdk::trace::SpanExporte */ bool Shutdown(std::chrono::microseconds /* timeout */) noexcept override { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); is_shutdown_ = true; return true; } @@ -84,13 +86,8 @@ class InMemorySpanExporter final : public opentelemetry::sdk::trace::SpanExporte private: std::shared_ptr<InMemorySpanData> data_; - bool is_shutdown_ = false; - mutable opentelemetry::common::SpinLockMutex lock_; - bool isShutdown() const noexcept - { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); - return is_shutdown_; - } + std::atomic<bool> is_shutdown_{false}; + bool isShutdown() const noexcept { return is_shutdown_; } }; } // namespace memory } // namespace exporter diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h index ba5b28b9de..3c11c53aee 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h @@ -4,13 +4,12 @@ #pragma once #include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/logs/exporter.h" - #include "opentelemetry/version.h" +#include <atomic> #include <iostream> #include <sstream> #include <unordered_map> @@ -59,8 +58,7 @@ class OStreamLogRecordExporter final : public opentelemetry::sdk::logs::LogRecor // The OStream to send the logs to std::ostream &sout_; // Whether this exporter has been shut down - bool is_shutdown_ = false; - mutable opentelemetry::common::SpinLockMutex lock_; + std::atomic<bool> is_shutdown_{false}; bool isShutdown() const noexcept; void printAttributes( const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue> &map, diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h index 92419fdea0..0dd22203e5 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h @@ -3,10 +3,11 @@ #pragma once +#include <atomic> #include <iostream> +#include <mutex> #include <string> -#include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/instruments.h" @@ -72,8 +73,8 @@ class OStreamMetricExporter final : public opentelemetry::sdk::metrics::PushMetr private: std::ostream &sout_; - bool is_shutdown_ = false; - mutable opentelemetry::common::SpinLockMutex lock_; + std::atomic<bool> is_shutdown_{false}; + std::mutex serialize_lock_; sdk::metrics::AggregationTemporality aggregation_temporality_; bool isShutdown() const noexcept; void printInstrumentationInfoMetricData(const sdk::metrics::ScopeMetrics &info_metrics, diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h index 139653686d..153aa4701e 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h @@ -3,12 +3,12 @@ #pragma once -#include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/span_data.h" #include "opentelemetry/version.h" +#include <atomic> #include <iostream> #include <map> #include <sstream> @@ -51,8 +51,7 @@ class OStreamSpanExporter final : public opentelemetry::sdk::trace::SpanExporter private: std::ostream &sout_; - bool is_shutdown_ = false; - mutable opentelemetry::common::SpinLockMutex lock_; + std::atomic<bool> is_shutdown_{false}; bool isShutdown() const noexcept; // Mapping status number to the string from api/include/opentelemetry/trace/span_metadata.h diff --git a/exporters/ostream/src/log_record_exporter.cc b/exporters/ostream/src/log_record_exporter.cc index 7edae02b43..88b8ba5ba2 100644 --- a/exporters/ostream/src/log_record_exporter.cc +++ b/exporters/ostream/src/log_record_exporter.cc @@ -126,14 +126,12 @@ bool OStreamLogRecordExporter::ForceFlush(std::chrono::microseconds /* timeout * bool OStreamLogRecordExporter::Shutdown(std::chrono::microseconds) noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); is_shutdown_ = true; return true; } bool OStreamLogRecordExporter::isShutdown() const noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); return is_shutdown_; } diff --git a/exporters/ostream/src/metric_exporter.cc b/exporters/ostream/src/metric_exporter.cc index 003aaa075f..4871a28b3d 100644 --- a/exporters/ostream/src/metric_exporter.cc +++ b/exporters/ostream/src/metric_exporter.cc @@ -129,7 +129,7 @@ void OStreamMetricExporter::printInstrumentationInfoMetricData( const sdk::metrics::ResourceMetrics &data) { // sout_ is shared - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); + const std::lock_guard<std::mutex> serialize(serialize_lock_); sout_ << "{"; sout_ << "\n scope name\t: " << info_metric.scope_->GetName() << "\n schema url\t: " << info_metric.scope_->GetSchemaURL() @@ -246,20 +246,19 @@ void OStreamMetricExporter::printPointAttributes( bool OStreamMetricExporter::ForceFlush(std::chrono::microseconds /* timeout */) noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); + const std::lock_guard<std::mutex> serialize(serialize_lock_); + sout_.flush(); return true; } bool OStreamMetricExporter::Shutdown(std::chrono::microseconds /* timeout */) noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); is_shutdown_ = true; return true; } bool OStreamMetricExporter::isShutdown() const noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); return is_shutdown_; } diff --git a/exporters/ostream/src/span_exporter.cc b/exporters/ostream/src/span_exporter.cc index 6a88c32235..2e6186b6f7 100644 --- a/exporters/ostream/src/span_exporter.cc +++ b/exporters/ostream/src/span_exporter.cc @@ -106,16 +106,15 @@ bool OStreamSpanExporter::ForceFlush(std::chrono::microseconds /* timeout */) no bool OStreamSpanExporter::Shutdown(std::chrono::microseconds /* timeout */) noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); is_shutdown_ = true; return true; } bool OStreamSpanExporter::isShutdown() const noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); return is_shutdown_; } + void OStreamSpanExporter::printAttributes( const std::unordered_map<std::string, sdkcommon::OwnedAttributeValue> &map, const std::string prefix) diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h index fdd6bc4a17..80346a253d 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h @@ -3,11 +3,11 @@ #pragma once +#include <atomic> #include <chrono> #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" -#include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.h" #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" @@ -92,8 +92,7 @@ class OtlpGrpcExporter final : public opentelemetry::sdk::trace::SpanExporter * @param stub the service stub to be used for exporting */ OtlpGrpcExporter(std::unique_ptr<proto::collector::trace::v1::TraceService::StubInterface> stub); - bool is_shutdown_ = false; - mutable opentelemetry::common::SpinLockMutex lock_; + std::atomic<bool> is_shutdown_{false}; bool isShutdown() const noexcept; }; } // 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 e4c2e96617..72af90701f 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 @@ -7,7 +7,6 @@ #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" #include "opentelemetry/proto/collector/logs/v1/logs_service.grpc.pb.h" -#include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // clang-format on @@ -16,6 +15,8 @@ #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h" #include "opentelemetry/sdk/logs/exporter.h" +#include <atomic> + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { @@ -92,8 +93,7 @@ class OtlpGrpcLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExpo */ OtlpGrpcLogRecordExporter( std::unique_ptr<proto::collector::logs::v1::LogsService::StubInterface> stub); - bool is_shutdown_ = false; - mutable opentelemetry::common::SpinLockMutex lock_; + std::atomic<bool> is_shutdown_{false}; bool isShutdown() const noexcept; }; 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 1385c381ec..3899e926f6 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 @@ -7,7 +7,6 @@ #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" #include "opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h" -#include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // clang-format on @@ -16,6 +15,8 @@ #include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include <atomic> + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { @@ -82,8 +83,7 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp */ OtlpGrpcMetricExporter( std::unique_ptr<proto::collector::metrics::v1::MetricsService::StubInterface> stub); - bool is_shutdown_ = false; - mutable opentelemetry::common::SpinLockMutex lock_; + std::atomic<bool> is_shutdown_{false}; bool isShutdown() const noexcept; }; } // namespace otlp diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h index 870ea88544..9d79b5d99b 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h @@ -3,7 +3,6 @@ #pragma once -#include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/ext/http/client/http_client.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/common/exporter_utils.h" diff --git a/exporters/otlp/src/otlp_grpc_exporter.cc b/exporters/otlp/src/otlp_grpc_exporter.cc index 607c5ac7c1..ed0fc74518 100644 --- a/exporters/otlp/src/otlp_grpc_exporter.cc +++ b/exporters/otlp/src/otlp_grpc_exporter.cc @@ -135,7 +135,6 @@ bool OtlpGrpcExporter::ForceFlush( bool OtlpGrpcExporter::Shutdown( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); is_shutdown_ = true; #ifdef ENABLE_ASYNC_EXPORT return client_->Shutdown(timeout); @@ -146,7 +145,6 @@ bool OtlpGrpcExporter::Shutdown( bool OtlpGrpcExporter::isShutdown() const noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); return is_shutdown_; } diff --git a/exporters/otlp/src/otlp_grpc_log_record_exporter.cc b/exporters/otlp/src/otlp_grpc_log_record_exporter.cc index f5971228e9..1069703f96 100644 --- a/exporters/otlp/src/otlp_grpc_log_record_exporter.cc +++ b/exporters/otlp/src/otlp_grpc_log_record_exporter.cc @@ -138,7 +138,6 @@ opentelemetry::sdk::common::ExportResult OtlpGrpcLogRecordExporter::Export( bool OtlpGrpcLogRecordExporter::Shutdown( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); is_shutdown_ = true; #ifdef ENABLE_ASYNC_EXPORT return client_->Shutdown(timeout); @@ -159,7 +158,6 @@ bool OtlpGrpcLogRecordExporter::ForceFlush( bool OtlpGrpcLogRecordExporter::isShutdown() const noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); return is_shutdown_; } diff --git a/exporters/otlp/src/otlp_grpc_metric_exporter.cc b/exporters/otlp/src/otlp_grpc_metric_exporter.cc index 1e0aeb29f9..6a78149eaa 100644 --- a/exporters/otlp/src/otlp_grpc_metric_exporter.cc +++ b/exporters/otlp/src/otlp_grpc_metric_exporter.cc @@ -141,7 +141,6 @@ bool OtlpGrpcMetricExporter::ForceFlush( bool OtlpGrpcMetricExporter::Shutdown( OPENTELEMETRY_MAYBE_UNUSED std::chrono::microseconds timeout) noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); is_shutdown_ = true; #ifdef ENABLE_ASYNC_EXPORT return client_->Shutdown(timeout); @@ -152,7 +151,6 @@ bool OtlpGrpcMetricExporter::Shutdown( bool OtlpGrpcMetricExporter::isShutdown() const noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); return is_shutdown_; } diff --git a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter.h b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter.h index 4bd624d1e2..34bdc4a0f8 100644 --- a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter.h +++ b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter.h @@ -8,7 +8,7 @@ #include <vector> #include <prometheus/exposer.h> -#include "opentelemetry/common/spin_lock_mutex.h" + #include "opentelemetry/exporters/prometheus/collector.h" #include "opentelemetry/exporters/prometheus/exporter_options.h" #include "opentelemetry/nostd/span.h" diff --git a/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h b/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h index 4de6513bfb..effa2dfe75 100644 --- a/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h +++ b/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h @@ -3,7 +3,6 @@ #pragma once -#include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/exporters/zipkin/zipkin_exporter_options.h" #include "opentelemetry/ext/http/client/http_client_factory.h" #include "opentelemetry/ext/http/common/url_parser.h" @@ -13,6 +12,8 @@ #include "nlohmann/json.hpp" +#include <atomic> + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { @@ -69,7 +70,7 @@ class ZipkinExporter final : public opentelemetry::sdk::trace::SpanExporter private: // The configuration options associated with this exporter. - bool is_shutdown_ = false; + std::atomic<bool> is_shutdown_{false}; ZipkinExporterOptions options_; std::shared_ptr<opentelemetry::ext::http::client::HttpClientSync> http_client_; opentelemetry::ext::http::common::UrlParser url_parser_; @@ -84,7 +85,6 @@ class ZipkinExporter final : public opentelemetry::sdk::trace::SpanExporter */ ZipkinExporter(std::shared_ptr<opentelemetry::ext::http::client::HttpClientSync> http_client); - mutable opentelemetry::common::SpinLockMutex lock_; bool isShutdown() const noexcept; }; } // namespace zipkin diff --git a/exporters/zipkin/src/zipkin_exporter.cc b/exporters/zipkin/src/zipkin_exporter.cc index 2dd8a3e884..97fdf4e63a 100644 --- a/exporters/zipkin/src/zipkin_exporter.cc +++ b/exporters/zipkin/src/zipkin_exporter.cc @@ -117,14 +117,12 @@ bool ZipkinExporter::ForceFlush(std::chrono::microseconds /* timeout */) noexcep bool ZipkinExporter::Shutdown(std::chrono::microseconds /* timeout */) noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); is_shutdown_ = true; return true; } bool ZipkinExporter::isShutdown() const noexcept { - const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); return is_shutdown_; } From 4edcebdbff2127dfd36016bf4b6b750e5164b8a9 Mon Sep 17 00:00:00 2001 From: Marc Alff <marc.alff@oracle.com> Date: Thu, 16 May 2024 19:29:04 +0200 Subject: [PATCH 05/17] [CI] Upgrade Maintainers CI to ubuntu-24.04 (#2670) * Upgrade Maintainers CI to ubuntu-24.04 * Disable IWYU --- .github/workflows/ci.yml | 60 ++++++++++++++++++++-------------------- ci/do_ci.sh | 13 ++++++--- 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca395431d4..055b8cfe60 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,16 +29,16 @@ jobs: ./ci/do_ci.sh cmake.test cmake_gcc_maintainer_sync_test: - name: CMake gcc 13 (maintainer mode, sync) - runs-on: ubuntu-latest + name: CMake gcc 14 (maintainer mode, sync) + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: - CC: /usr/bin/gcc-13 - CXX: /usr/bin/g++-13 + CC: /usr/bin/gcc-14 + CXX: /usr/bin/g++-14 PROTOBUF_VERSION: 21.12 run: | sudo -E ./ci/setup_googletest.sh @@ -46,8 +46,8 @@ jobs: sudo -E ./ci/install_protobuf.sh - name: run cmake gcc (maintainer mode, sync) env: - CC: /usr/bin/gcc-13 - CXX: /usr/bin/g++-13 + CC: /usr/bin/gcc-14 + CXX: /usr/bin/g++-14 run: | ./ci/do_ci.sh cmake.maintainer.sync.test - name: generate test cert @@ -61,16 +61,16 @@ jobs: (cd ./functional/otlp; ./run_test.sh) cmake_gcc_maintainer_async_test: - name: CMake gcc 13 (maintainer mode, async) - runs-on: ubuntu-latest + name: CMake gcc 14 (maintainer mode, async) + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: - CC: /usr/bin/gcc-13 - CXX: /usr/bin/g++-13 + CC: /usr/bin/gcc-14 + CXX: /usr/bin/g++-14 PROTOBUF_VERSION: 21.12 run: | sudo -E ./ci/setup_googletest.sh @@ -78,8 +78,8 @@ jobs: sudo -E ./ci/install_protobuf.sh - name: run cmake gcc (maintainer mode, async) env: - CC: /usr/bin/gcc-13 - CXX: /usr/bin/g++-13 + CC: /usr/bin/gcc-14 + CXX: /usr/bin/g++-14 run: | ./ci/do_ci.sh cmake.maintainer.async.test - name: generate test cert @@ -93,16 +93,16 @@ jobs: (cd ./functional/otlp; ./run_test.sh) cmake_clang_maintainer_sync_test: - name: CMake clang 15 (maintainer mode, sync) - runs-on: ubuntu-latest + name: CMake clang 18 (maintainer mode, sync) + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: - CC: /usr/bin/clang-15 - CXX: /usr/bin/clang++-15 + CC: /usr/bin/clang-18 + CXX: /usr/bin/clang++-18 PROTOBUF_VERSION: 21.12 run: | sudo -E ./ci/setup_googletest.sh @@ -110,8 +110,8 @@ jobs: sudo -E ./ci/install_protobuf.sh - name: run cmake clang (maintainer mode, sync) env: - CC: /usr/bin/clang-15 - CXX: /usr/bin/clang++-15 + CC: /usr/bin/clang-18 + CXX: /usr/bin/clang++-18 run: | ./ci/do_ci.sh cmake.maintainer.sync.test - name: generate test cert @@ -125,16 +125,16 @@ jobs: (cd ./functional/otlp; ./run_test.sh) cmake_clang_maintainer_async_test: - name: CMake clang 15 (maintainer mode, async) - runs-on: ubuntu-latest + name: CMake clang 18 (maintainer mode, async) + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: - CC: /usr/bin/clang-15 - CXX: /usr/bin/clang++-15 + CC: /usr/bin/clang-18 + CXX: /usr/bin/clang++-18 PROTOBUF_VERSION: 21.12 run: | sudo -E ./ci/setup_googletest.sh @@ -142,8 +142,8 @@ jobs: sudo -E ./ci/install_protobuf.sh - name: run cmake clang (maintainer mode, async) env: - CC: /usr/bin/clang-15 - CXX: /usr/bin/clang++-15 + CC: /usr/bin/clang-18 + CXX: /usr/bin/clang++-18 run: | ./ci/do_ci.sh cmake.maintainer.async.test - name: generate test cert @@ -157,16 +157,16 @@ jobs: (cd ./functional/otlp; ./run_test.sh) cmake_clang_maintainer_abiv2_test: - name: CMake clang 15 (maintainer mode, abiv2) - runs-on: ubuntu-latest + name: CMake clang 18 (maintainer mode, abiv2) + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: - CC: /usr/bin/clang-15 - CXX: /usr/bin/clang++-15 + CC: /usr/bin/clang-18 + CXX: /usr/bin/clang++-18 PROTOBUF_VERSION: 21.12 run: | sudo -E ./ci/setup_googletest.sh @@ -174,8 +174,8 @@ jobs: sudo -E ./ci/install_protobuf.sh - name: run cmake clang (maintainer mode, abiv2) env: - CC: /usr/bin/clang-15 - CXX: /usr/bin/clang++-15 + CC: /usr/bin/clang-18 + CXX: /usr/bin/clang++-18 run: | ./ci/do_ci.sh cmake.maintainer.abiv2.test - name: generate test cert diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 87bf781da2..b7c97a3800 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -65,10 +65,15 @@ mkdir -p "${PLUGIN_DIR}" IWYU="" MAKE_COMMAND="make -k -j \$(nproc)" -if [[ "${CXX}" == *clang* ]]; then - MAKE_COMMAND="make -k CXX=include-what-you-use CXXFLAGS=\"-Xiwyu --error_always\" -j \$(nproc)" - IWYU="-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=iwyu" -fi + +# Temporarily disable the IWYU build. +# It fails in Ubuntu 24-04 CI with: +# Error running 'iwyu': Segmentation fault +# +# if [[ "${CXX}" == *clang* ]]; then +# MAKE_COMMAND="make -k CXX=include-what-you-use CXXFLAGS=\"-Xiwyu --error_always\" -j \$(nproc)" +# IWYU="-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=iwyu" +# fi echo "make command: ${MAKE_COMMAND}" echo "IWYU option: ${IWYU}" From 2db27ddfd3fae227c04be2cf2f9f78a4bef009c1 Mon Sep 17 00:00:00 2001 From: Marc Alff <marc.alff@oracle.com> Date: Thu, 16 May 2024 21:12:15 +0200 Subject: [PATCH 06/17] [BUILD] Upgrade to opentelemetry-proto 1.3.1 (#2669) --- bazel/repository.bzl | 6 ++-- cmake/opentelemetry-proto.cmake | 55 ++++++++++++++++++++++++++++++--- third_party/opentelemetry-proto | 2 +- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/bazel/repository.bzl b/bazel/repository.bzl index 58245494ac..9ba8ad5388 100644 --- a/bazel/repository.bzl +++ b/bazel/repository.bzl @@ -111,10 +111,10 @@ def opentelemetry_cpp_deps(): http_archive, name = "com_github_opentelemetry_proto", build_file = "@io_opentelemetry_cpp//bazel:opentelemetry_proto.BUILD", - sha256 = "516dc94685dbaa14fb792788f31d2ef2b0c3ad08dfa8a9a8164e3cf60c1ab6f7", - strip_prefix = "opentelemetry-proto-1.2.0", + sha256 = "bed250ceec8e4a83aa5604d7d5595a61945059dc662edd058a9da082283f7a00", + strip_prefix = "opentelemetry-proto-1.3.1", urls = [ - "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.2.0.tar.gz", + "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.1.tar.gz", ], ) diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake index 2208235691..c2982e23c0 100644 --- a/cmake/opentelemetry-proto.cmake +++ b/cmake/opentelemetry-proto.cmake @@ -72,13 +72,18 @@ set(TRACE_PROTO "${PROTO_PATH}/opentelemetry/proto/trace/v1/trace.proto") set(LOGS_PROTO "${PROTO_PATH}/opentelemetry/proto/logs/v1/logs.proto") set(METRICS_PROTO "${PROTO_PATH}/opentelemetry/proto/metrics/v1/metrics.proto") +set(PROFILES_PROTO "${PROTO_PATH}/opentelemetry/proto/profiles/v1experimental/profiles.proto") +set(PROFILES_EXT_PROTO "${PROTO_PATH}/opentelemetry/proto/profiles/v1experimental/pprofextended.proto") + set(TRACE_SERVICE_PROTO "${PROTO_PATH}/opentelemetry/proto/collector/trace/v1/trace_service.proto") set(LOGS_SERVICE_PROTO "${PROTO_PATH}/opentelemetry/proto/collector/logs/v1/logs_service.proto") set(METRICS_SERVICE_PROTO - "${PROTO_PATH}/opentelemetry/proto/collector/metrics/v1/metrics_service.proto" -) + "${PROTO_PATH}/opentelemetry/proto/collector/metrics/v1/metrics_service.proto") + +set(PROFILES_SERVICE_PROTO + "${PROTO_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.proto") set(GENERATED_PROTOBUF_PATH "${CMAKE_BINARY_DIR}/generated/third_party/opentelemetry-proto") @@ -112,6 +117,34 @@ set(TRACE_SERVICE_PB_CPP_FILE set(TRACE_SERVICE_PB_H_FILE "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/trace/v1/trace_service.pb.h" ) + +# +# Notes about the PROFILES signal: +# - *.proto files added in opentelemetry-proto 1.3.0 +# - C++ code is generated from proto files +# - The generated code is not used yet. +# + +set(PROFILES_CPP_FILE + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/profiles.pb.cc") +set(PROFILES_H_FILE + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/profiles.pb.h") +set(PROFILES_EXT_CPP_FILE + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/pprofextended.pb.cc") +set(PROFILES_EXT_H_FILE + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/pprofextended.pb.h") +set(PROFILES_SERVICE_PB_H_FILE + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.pb.h") +set(PROFILES_SERVICE_PB_CPP_FILE + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.pb.cc") + +if(WITH_OTLP_GRPC) + set(PROFILES_SERVICE_GRPC_PB_H_FILE + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.grpc.pb.h") + set(PROFILES_SERVICE_GRPC_PB_CPP_FILE + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.grpc.pb.cc") +endif() + if(WITH_OTLP_GRPC) set(TRACE_SERVICE_GRPC_PB_CPP_FILE "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.cc" @@ -188,12 +221,18 @@ set(PROTOBUF_GENERATED_FILES ${LOGS_PB_CPP_FILE} ${METRICS_PB_H_FILE} ${METRICS_PB_CPP_FILE} + ${PROFILES_H_FILE} + ${PROFILES_CPP_FILE} + ${PROFILES_EXT_H_FILE} + ${PROFILES_EXT_CPP_FILE} ${TRACE_SERVICE_PB_H_FILE} ${TRACE_SERVICE_PB_CPP_FILE} ${LOGS_SERVICE_PB_H_FILE} ${LOGS_SERVICE_PB_CPP_FILE} ${METRICS_SERVICE_PB_H_FILE} - ${METRICS_SERVICE_PB_CPP_FILE}) + ${METRICS_SERVICE_PB_CPP_FILE} + ${PROFILES_SERVICE_PB_H_FILE} + ${PROFILES_SERVICE_PB_CPP_FILE}) if(WITH_OTLP_GRPC) list(APPEND PROTOBUF_COMMON_FLAGS @@ -208,7 +247,9 @@ if(WITH_OTLP_GRPC) ${LOGS_SERVICE_GRPC_PB_H_FILE} ${LOGS_SERVICE_GRPC_PB_CPP_FILE} ${METRICS_SERVICE_GRPC_PB_H_FILE} - ${METRICS_SERVICE_GRPC_PB_CPP_FILE}) + ${METRICS_SERVICE_GRPC_PB_CPP_FILE} + ${PROFILES_SERVICE_GRPC_PB_H_FILE} + ${PROFILES_SERVICE_GRPC_PB_CPP_FILE}) endif() set(PROTOBUF_RUN_PROTOC_COMMAND "\"${PROTOBUF_PROTOC_EXECUTABLE}\"") @@ -221,9 +262,12 @@ foreach( ${TRACE_PROTO} ${LOGS_PROTO} ${METRICS_PROTO} + ${PROFILES_PROTO} + ${PROFILES_EXT_PROTO} ${TRACE_SERVICE_PROTO} ${LOGS_SERVICE_PROTO} - ${METRICS_SERVICE_PROTO}) + ${METRICS_SERVICE_PROTO} + ${PROFILES_SERVICE_PROTO}) set(PROTOBUF_RUN_PROTOC_COMMAND "${PROTOBUF_RUN_PROTOC_COMMAND} \"${PROTOBUF_RUN_PROTOC_ARG}\"") endforeach() @@ -235,6 +279,7 @@ add_custom_command( ${PROTOBUF_INCLUDE_FLAGS} ${COMMON_PROTO} ${RESOURCE_PROTO} ${TRACE_PROTO} ${LOGS_PROTO} ${METRICS_PROTO} ${TRACE_SERVICE_PROTO} ${LOGS_SERVICE_PROTO} ${METRICS_SERVICE_PROTO} + ${PROFILES_PROTO} ${PROFILES_EXT_PROTO} ${PROFILES_SERVICE_PROTO} COMMENT "[Run]: ${PROTOBUF_RUN_PROTOC_COMMAND}") include_directories("${GENERATED_PROTOBUF_PATH}") diff --git a/third_party/opentelemetry-proto b/third_party/opentelemetry-proto index 24d4bc0020..b3060d2104 160000 --- a/third_party/opentelemetry-proto +++ b/third_party/opentelemetry-proto @@ -1 +1 @@ -Subproject commit 24d4bc002003c74db7aa608c8e254155daf8e49d +Subproject commit b3060d2104df364136d75a35779e6bd48bac449a From 9c767df50754a0066f57b6a0add1656669a0ee1c Mon Sep 17 00:00:00 2001 From: Marc Alff <marc.alff@oracle.com> Date: Thu, 16 May 2024 21:48:14 +0200 Subject: [PATCH 07/17] [API] Return NoopLogRecord from NoopLogger (#2668) Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com> --- api/include/opentelemetry/logs/event_logger.h | 4 --- api/include/opentelemetry/logs/logger.h | 4 --- api/include/opentelemetry/logs/noop.h | 30 ++++++++++++++++++- api/test/logs/logger_test.cc | 4 ++- sdk/src/logs/logger.cc | 6 ---- 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/api/include/opentelemetry/logs/event_logger.h b/api/include/opentelemetry/logs/event_logger.h index 2ede6f3fa1..988142fbe2 100644 --- a/api/include/opentelemetry/logs/event_logger.h +++ b/api/include/opentelemetry/logs/event_logger.h @@ -64,10 +64,6 @@ class EventLogger return; } nostd::unique_ptr<LogRecord> log_record = delegate_logger->CreateLogRecord(); - if (!log_record) - { - return; - } IgnoreTraitResult( detail::LogRecordSetterTrait<typename std::decay<ArgumentType>::type>::template Set( diff --git a/api/include/opentelemetry/logs/logger.h b/api/include/opentelemetry/logs/logger.h index 403e884272..6448ff6901 100644 --- a/api/include/opentelemetry/logs/logger.h +++ b/api/include/opentelemetry/logs/logger.h @@ -100,10 +100,6 @@ class Logger void EmitLogRecord(ArgumentType &&... args) { nostd::unique_ptr<LogRecord> log_record = CreateLogRecord(); - if (!log_record) - { - return; - } EmitLogRecord(std::move(log_record), std::forward<ArgumentType>(args)...); } diff --git a/api/include/opentelemetry/logs/noop.h b/api/include/opentelemetry/logs/noop.h index b4590c987f..9876f40bfd 100644 --- a/api/include/opentelemetry/logs/noop.h +++ b/api/include/opentelemetry/logs/noop.h @@ -34,11 +34,39 @@ class NoopLogger final : public Logger public: const nostd::string_view GetName() noexcept override { return "noop logger"; } - nostd::unique_ptr<LogRecord> CreateLogRecord() noexcept override { return nullptr; } + nostd::unique_ptr<LogRecord> CreateLogRecord() noexcept override + { + /* + * Do not return memory shared between threads, + * a `new` + `delete` for each noop record can not be avoided, + * due to the semantic of unique_ptr. + */ + return nostd::unique_ptr<LogRecord>(new NoopLogRecord()); + } using Logger::EmitLogRecord; void EmitLogRecord(nostd::unique_ptr<LogRecord> &&) noexcept override {} + +private: + class NoopLogRecord : public LogRecord + { + public: + NoopLogRecord() = default; + ~NoopLogRecord() override = default; + + void SetTimestamp(common::SystemTimestamp /* timestamp */) noexcept override {} + void SetObservedTimestamp(common::SystemTimestamp /* timestamp */) noexcept override {} + void SetSeverity(logs::Severity /* severity */) noexcept override {} + void SetBody(const common::AttributeValue & /* message */) noexcept override {} + void SetAttribute(nostd::string_view /* key */, + const common::AttributeValue & /* value */) noexcept override + {} + void SetEventId(int64_t /* id */, nostd::string_view /* name */) noexcept override {} + void SetTraceId(const trace::TraceId & /* trace_id */) noexcept override {} + void SetSpanId(const trace::SpanId & /* span_id */) noexcept override {} + void SetTraceFlags(const trace::TraceFlags & /* trace_flags */) noexcept override {} + }; }; /** diff --git a/api/test/logs/logger_test.cc b/api/test/logs/logger_test.cc index a9567a6d3f..43d7afc685 100644 --- a/api/test/logs/logger_test.cc +++ b/api/test/logs/logger_test.cc @@ -28,9 +28,11 @@ TEST(Logger, GetLoggerDefault) auto lp = Provider::GetLoggerProvider(); const std::string schema_url{"https://opentelemetry.io/schemas/1.11.0"}; auto logger = lp->GetLogger("TestLogger", "opentelelemtry_library", "", schema_url); - auto name = logger->GetName(); EXPECT_NE(nullptr, logger); + auto name = logger->GetName(); EXPECT_EQ(name, "noop logger"); + auto record = logger->CreateLogRecord(); + EXPECT_NE(nullptr, record); } // Test the two additional overloads for GetLogger() diff --git a/sdk/src/logs/logger.cc b/sdk/src/logs/logger.cc index 7f85ddd6a3..972b380efc 100644 --- a/sdk/src/logs/logger.cc +++ b/sdk/src/logs/logger.cc @@ -33,12 +33,6 @@ const nostd::string_view Logger::GetName() noexcept nostd::unique_ptr<opentelemetry::logs::LogRecord> Logger::CreateLogRecord() noexcept { - // If this logger does not have a processor, no need to create a log recordable - if (!context_) - { - return nullptr; - } - auto recordable = context_->GetProcessor().MakeRecordable(); recordable->SetObservedTimestamp(std::chrono::system_clock::now()); From 78d488ca44d6a9aed79e63da739b081e20c94207 Mon Sep 17 00:00:00 2001 From: Tom Tan <Tom.Tan@microsoft.com> Date: Thu, 23 May 2024 05:54:53 -0700 Subject: [PATCH 08/17] [BUILD] Remove the hard-coded separator in tracestate (#2672) --- api/include/opentelemetry/trace/trace_state.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/include/opentelemetry/trace/trace_state.h b/api/include/opentelemetry/trace/trace_state.h index 8a25f4da5c..f51410025a 100644 --- a/api/include/opentelemetry/trace/trace_state.h +++ b/api/include/opentelemetry/trace/trace_state.h @@ -95,7 +95,7 @@ class OPENTELEMETRY_EXPORT TraceState [&header_s, &first](nostd::string_view key, nostd::string_view value) noexcept { if (!first) { - header_s.append(","); + header_s.append(1, kMembersSeparator); } else { From 605c3e8ea7307dbc8d2c54db2587476cc6a0cbb7 Mon Sep 17 00:00:00 2001 From: WenTao Ou <owentou@tencent.com> Date: Tue, 28 May 2024 03:50:01 +0800 Subject: [PATCH 09/17] [SDK] Fix forceflush may wait for ever (#2584) Co-authored-by: Marc Alff <marc.alff@oracle.com> Co-authored-by: Tom Tan <Tom.Tan@microsoft.com> --- .../sdk/logs/batch_log_record_processor.h | 15 ++-- .../export/periodic_exporting_metric_reader.h | 5 +- .../sdk/trace/batch_span_processor.h | 16 ++-- sdk/src/logs/batch_log_record_processor.cc | 74 +++++++++--------- .../periodic_exporting_metric_reader.cc | 66 +++++++--------- sdk/src/trace/batch_span_processor.cc | 75 ++++++++++--------- 6 files changed, 128 insertions(+), 123 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h b/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h index d6a44df142..01a39348e2 100644 --- a/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h @@ -115,20 +115,25 @@ class BatchLogRecordProcessor : public LogRecordProcessor /* Important boolean flags to handle the workflow of the processor */ std::atomic<bool> is_force_wakeup_background_worker{false}; - std::atomic<bool> is_force_flush_pending{false}; - std::atomic<bool> is_force_flush_notified{false}; - std::atomic<std::chrono::microseconds::rep> force_flush_timeout_us{0}; std::atomic<bool> is_shutdown{false}; + std::atomic<uint64_t> force_flush_pending_sequence{0}; + std::atomic<uint64_t> force_flush_notified_sequence{0}; + std::atomic<std::chrono::microseconds::rep> force_flush_timeout_us{0}; + + // Do not use SynchronizationData() = default; here, some versions of GCC&Clang have BUGs + // and may not initialize the member correctly. See also + // https://stackoverflow.com/questions/53408962/try-to-understand-compiler-error-message-default-member-initializer-required-be + inline SynchronizationData() {} }; /** * @brief Notify completion of shutdown and force flush. This may be called from the any thread at * any time * - * @param notify_force_flush Flag to indicate whether to notify force flush completion. + * @param notify_force_flush Sequence to indicate whether to notify force flush completion. * @param synchronization_data Synchronization data to be notified. */ - static void NotifyCompletion(bool notify_force_flush, + static void NotifyCompletion(uint64_t notify_force_flush, const std::unique_ptr<LogRecordExporter> &exporter, const std::shared_ptr<SynchronizationData> &synchronization_data); diff --git a/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h b/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h index b9221193fb..9fb0fbf5a0 100644 --- a/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h +++ b/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h @@ -6,6 +6,7 @@ #include <atomic> #include <chrono> #include <condition_variable> +#include <cstdint> #include <memory> #include <mutex> #include <thread> @@ -50,9 +51,9 @@ class PeriodicExportingMetricReader : public MetricReader std::thread worker_thread_; /* Synchronization primitives */ - std::atomic<bool> is_force_flush_pending_{false}; std::atomic<bool> is_force_wakeup_background_worker_{false}; - std::atomic<bool> is_force_flush_notified_{false}; + std::atomic<uint64_t> force_flush_pending_sequence_{0}; + std::atomic<uint64_t> force_flush_notified_sequence_{0}; std::condition_variable cv_, force_flush_cv_; std::mutex cv_m_, force_flush_m_; }; diff --git a/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h b/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h index afbf4486b0..e23b0a2df2 100644 --- a/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h +++ b/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h @@ -5,6 +5,7 @@ #include <atomic> #include <condition_variable> +#include <cstdint> #include <memory> #include <mutex> #include <thread> @@ -115,20 +116,25 @@ class BatchSpanProcessor : public SpanProcessor /* Important boolean flags to handle the workflow of the processor */ std::atomic<bool> is_force_wakeup_background_worker{false}; - std::atomic<bool> is_force_flush_pending{false}; - std::atomic<bool> is_force_flush_notified{false}; - std::atomic<std::chrono::microseconds::rep> force_flush_timeout_us{0}; std::atomic<bool> is_shutdown{false}; + std::atomic<uint64_t> force_flush_pending_sequence{0}; + std::atomic<uint64_t> force_flush_notified_sequence{0}; + std::atomic<std::chrono::microseconds::rep> force_flush_timeout_us{0}; + + // Do not use SynchronizationData() = default; here, some versions of GCC&Clang have BUGs + // and may not initialize the member correctly. See also + // https://stackoverflow.com/questions/53408962/try-to-understand-compiler-error-message-default-member-initializer-required-be + inline SynchronizationData() {} }; /** * @brief Notify completion of shutdown and force flush. This may be called from the any thread at * any time * - * @param notify_force_flush Flag to indicate whether to notify force flush completion. + * @param notify_force_flush Sequence to indicate whether to notify force flush completion. * @param synchronization_data Synchronization data to be notified. */ - static void NotifyCompletion(bool notify_force_flush, + static void NotifyCompletion(uint64_t notify_force_flush, const std::unique_ptr<SpanExporter> &exporter, const std::shared_ptr<SynchronizationData> &synchronization_data); diff --git a/sdk/src/logs/batch_log_record_processor.cc b/sdk/src/logs/batch_log_record_processor.cc index 44e623e4f7..c29e27bdd3 100644 --- a/sdk/src/logs/batch_log_record_processor.cc +++ b/sdk/src/logs/batch_log_record_processor.cc @@ -65,7 +65,7 @@ void BatchLogRecordProcessor::OnEmit(std::unique_ptr<Recordable> &&record) noexc { // signal the worker thread synchronization_data_->is_force_wakeup_background_worker.store(true, std::memory_order_release); - synchronization_data_->cv.notify_one(); + synchronization_data_->cv.notify_all(); } } @@ -79,21 +79,25 @@ bool BatchLogRecordProcessor::ForceFlush(std::chrono::microseconds timeout) noex // Now wait for the worker thread to signal back from the Export method std::unique_lock<std::mutex> lk_cv(synchronization_data_->force_flush_cv_m); - synchronization_data_->is_force_flush_pending.store(true, std::memory_order_release); + std::uint64_t current_sequence = + synchronization_data_->force_flush_pending_sequence.fetch_add(1, std::memory_order_release) + + 1; synchronization_data_->force_flush_timeout_us.store(timeout.count(), std::memory_order_release); - auto break_condition = [this]() { + auto break_condition = [this, current_sequence]() { if (synchronization_data_->is_shutdown.load() == true) { return true; } // Wake up the worker thread once. - if (synchronization_data_->is_force_flush_pending.load(std::memory_order_acquire)) + if (synchronization_data_->force_flush_pending_sequence.load(std::memory_order_acquire) > + synchronization_data_->force_flush_notified_sequence.load(std::memory_order_acquire)) { - synchronization_data_->cv.notify_one(); + synchronization_data_->cv.notify_all(); } - return synchronization_data_->is_force_flush_notified.load(std::memory_order_acquire); + return synchronization_data_->force_flush_notified_sequence.load(std::memory_order_acquire) >= + current_sequence; }; // Fix timeout to meet requirement of wait_for @@ -110,35 +114,22 @@ bool BatchLogRecordProcessor::ForceFlush(std::chrono::microseconds timeout) noex bool result = false; while (!result && timeout_steady > std::chrono::steady_clock::duration::zero()) { - // When is_force_flush_notified.store(true) and force_flush_cv.notify_all() is called - // between is_force_flush_pending.load() and force_flush_cv.wait(). We must not wait - // for ever + // When force_flush_notified_sequence.compare_exchange_strong(...) and + // force_flush_cv.notify_all() is called between force_flush_pending_sequence.load(...) and + // force_flush_cv.wait(). We must not wait for ever std::chrono::steady_clock::time_point start_timepoint = std::chrono::steady_clock::now(); - result = synchronization_data_->force_flush_cv.wait_for(lk_cv, scheduled_delay_millis_, - break_condition); - timeout_steady -= std::chrono::steady_clock::now() - start_timepoint; - } + std::chrono::microseconds wait_timeout = scheduled_delay_millis_; - // If it's already signaled, we must wait util notified. - // We use a spin lock here - if (false == - synchronization_data_->is_force_flush_pending.exchange(false, std::memory_order_acq_rel)) - { - for (int retry_waiting_times = 0; - false == synchronization_data_->is_force_flush_notified.load(std::memory_order_acquire); - ++retry_waiting_times) + if (wait_timeout > timeout_steady) { - opentelemetry::common::SpinLockMutex::fast_yield(); - if ((retry_waiting_times & 127) == 127) - { - std::this_thread::yield(); - } + wait_timeout = std::chrono::duration_cast<std::chrono::microseconds>(timeout_steady); } + result = synchronization_data_->force_flush_cv.wait_for(lk_cv, wait_timeout, break_condition); + timeout_steady -= std::chrono::steady_clock::now() - start_timepoint; } - synchronization_data_->is_force_flush_notified.store(false, std::memory_order_release); - - return result; + return synchronization_data_->force_flush_notified_sequence.load(std::memory_order_acquire) >= + current_sequence; } void BatchLogRecordProcessor::DoBackgroundWork() @@ -182,8 +173,8 @@ void BatchLogRecordProcessor::Export() { std::vector<std::unique_ptr<Recordable>> records_arr; size_t num_records_to_export; - bool notify_force_flush = - synchronization_data_->is_force_flush_pending.exchange(false, std::memory_order_acq_rel); + std::uint64_t notify_force_flush = + synchronization_data_->force_flush_pending_sequence.load(std::memory_order_acquire); if (notify_force_flush) { num_records_to_export = buffer_.size(); @@ -217,7 +208,7 @@ void BatchLogRecordProcessor::Export() } void BatchLogRecordProcessor::NotifyCompletion( - bool notify_force_flush, + std::uint64_t notify_force_flush, const std::unique_ptr<LogRecordExporter> &exporter, const std::shared_ptr<SynchronizationData> &synchronization_data) { @@ -226,7 +217,8 @@ void BatchLogRecordProcessor::NotifyCompletion( return; } - if (notify_force_flush) + if (notify_force_flush > + synchronization_data->force_flush_notified_sequence.load(std::memory_order_acquire)) { if (exporter) { @@ -236,8 +228,15 @@ void BatchLogRecordProcessor::NotifyCompletion( std::chrono::microseconds::zero()); exporter->ForceFlush(timeout); } - synchronization_data->is_force_flush_notified.store(true, std::memory_order_release); - synchronization_data->force_flush_cv.notify_one(); + + std::uint64_t notified_sequence = + synchronization_data->force_flush_notified_sequence.load(std::memory_order_acquire); + while (notify_force_flush > notified_sequence) + { + synchronization_data->force_flush_notified_sequence.compare_exchange_strong( + notified_sequence, notify_force_flush, std::memory_order_acq_rel); + synchronization_data->force_flush_cv.notify_all(); + } } } @@ -246,7 +245,8 @@ void BatchLogRecordProcessor::DrainQueue() while (true) { if (buffer_.empty() && - false == synchronization_data_->is_force_flush_pending.load(std::memory_order_acquire)) + synchronization_data_->force_flush_pending_sequence.load(std::memory_order_acquire) <= + synchronization_data_->force_flush_notified_sequence.load(std::memory_order_acquire)) { break; } @@ -285,7 +285,7 @@ bool BatchLogRecordProcessor::Shutdown(std::chrono::microseconds timeout) noexce if (worker_thread_.joinable()) { synchronization_data_->is_force_wakeup_background_worker.store(true, std::memory_order_release); - synchronization_data_->cv.notify_one(); + synchronization_data_->cv.notify_all(); worker_thread_.join(); } diff --git a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc index b79b8a32e6..1de1ea71c8 100644 --- a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc +++ b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc @@ -90,6 +90,7 @@ bool PeriodicExportingMetricReader::CollectAndExportOnce() }); std::future_status status; + std::uint64_t notify_force_flush = force_flush_pending_sequence_.load(std::memory_order_acquire); do { status = future_receive.wait_for(std::chrono::milliseconds(export_timeout_millis_)); @@ -99,12 +100,13 @@ bool PeriodicExportingMetricReader::CollectAndExportOnce() break; } } while (status != std::future_status::ready); - bool notify_force_flush = is_force_flush_pending_.exchange(false, std::memory_order_acq_rel); - if (notify_force_flush) + + std::uint64_t notified_sequence = force_flush_notified_sequence_.load(std::memory_order_acquire); + while (notify_force_flush > notified_sequence) { - std::unique_lock<std::mutex> lk(force_flush_m_); - is_force_flush_notified_.store(true, std::memory_order_release); - force_flush_cv_.notify_one(); + force_flush_notified_sequence_.compare_exchange_strong(notified_sequence, notify_force_flush, + std::memory_order_acq_rel); + force_flush_cv_.notify_all(); } return true; @@ -113,24 +115,27 @@ bool PeriodicExportingMetricReader::CollectAndExportOnce() bool PeriodicExportingMetricReader::OnForceFlush(std::chrono::microseconds timeout) noexcept { std::unique_lock<std::mutex> lk_cv(force_flush_m_); - is_force_flush_pending_.store(true, std::memory_order_release); - auto break_condition = [this]() { + std::uint64_t current_sequence = + force_flush_pending_sequence_.fetch_add(1, std::memory_order_release) + 1; + auto break_condition = [this, current_sequence]() { if (IsShutdown()) { return true; } - // Wake up the worker thread once. - if (is_force_flush_pending_.load(std::memory_order_acquire)) + // Wake up the worker thread. + if (force_flush_pending_sequence_.load(std::memory_order_acquire) > + force_flush_notified_sequence_.load(std::memory_order_acquire)) { is_force_wakeup_background_worker_.store(true, std::memory_order_release); - cv_.notify_one(); + cv_.notify_all(); } - return is_force_flush_notified_.load(std::memory_order_acquire); + return force_flush_notified_sequence_.load(std::memory_order_acquire) >= current_sequence; }; - auto wait_timeout = opentelemetry::common::DurationUtil::AdjustWaitForTimeout( - timeout, std::chrono::microseconds::zero()); + std::chrono::microseconds wait_timeout = + opentelemetry::common::DurationUtil::AdjustWaitForTimeout(timeout, + std::chrono::microseconds::zero()); std::chrono::steady_clock::duration timeout_steady = std::chrono::duration_cast<std::chrono::steady_clock::duration>(wait_timeout); if (timeout_steady <= std::chrono::steady_clock::duration::zero()) @@ -141,29 +146,19 @@ bool PeriodicExportingMetricReader::OnForceFlush(std::chrono::microseconds timeo bool result = false; while (!result && timeout_steady > std::chrono::steady_clock::duration::zero()) { - // When is_force_flush_notified_.store(true) and force_flush_cv_.notify_all() is called - // between is_force_flush_pending_.load() and force_flush_cv_.wait(). We must not wait - // for ever + // When force_flush_notified_sequence_.compare_exchange_strong(...) and + // force_flush_cv_.notify_all() is called between force_flush_pending_sequence_.load(...) and + // force_flush_cv_.wait(). We must not wait for ever std::chrono::steady_clock::time_point start_timepoint = std::chrono::steady_clock::now(); - result = force_flush_cv_.wait_for(lk_cv, export_interval_millis_, break_condition); - timeout_steady -= std::chrono::steady_clock::now() - start_timepoint; - } - // If it will be already signaled, we must wait until notified. - // We use a spin lock here - if (false == is_force_flush_pending_.exchange(false, std::memory_order_acq_rel)) - { - for (int retry_waiting_times = 0; - false == is_force_flush_notified_.load(std::memory_order_acquire); ++retry_waiting_times) + wait_timeout = export_interval_millis_; + if (wait_timeout > timeout_steady) { - opentelemetry::common::SpinLockMutex::fast_yield(); - if ((retry_waiting_times & 127) == 127) - { - std::this_thread::yield(); - } + wait_timeout = std::chrono::duration_cast<std::chrono::microseconds>(timeout_steady); } + result = force_flush_cv_.wait_for(lk_cv, wait_timeout, break_condition); + timeout_steady -= std::chrono::steady_clock::now() - start_timepoint; } - is_force_flush_notified_.store(false, std::memory_order_release); if (result) { @@ -186,18 +181,15 @@ bool PeriodicExportingMetricReader::OnForceFlush(std::chrono::microseconds timeo result = false; } } - return result; + return result && + force_flush_notified_sequence_.load(std::memory_order_acquire) >= current_sequence; } bool PeriodicExportingMetricReader::OnShutDown(std::chrono::microseconds timeout) noexcept { if (worker_thread_.joinable()) { - { - // ensure that `cv_` is awaiting, and the update doesn't get lost - std::unique_lock<std::mutex> lk(cv_m_); - cv_.notify_all(); - } + cv_.notify_all(); worker_thread_.join(); } return exporter_->Shutdown(timeout); diff --git a/sdk/src/trace/batch_span_processor.cc b/sdk/src/trace/batch_span_processor.cc index d5b96f2cc8..3827fad495 100644 --- a/sdk/src/trace/batch_span_processor.cc +++ b/sdk/src/trace/batch_span_processor.cc @@ -62,7 +62,7 @@ void BatchSpanProcessor::OnEnd(std::unique_ptr<Recordable> &&span) noexcept if (buffer_size >= max_queue_size_ / 2 || buffer_size >= max_export_batch_size_) { // signal the worker thread - synchronization_data_->cv.notify_one(); + synchronization_data_->cv.notify_all(); } } @@ -76,23 +76,27 @@ bool BatchSpanProcessor::ForceFlush(std::chrono::microseconds timeout) noexcept // Now wait for the worker thread to signal back from the Export method std::unique_lock<std::mutex> lk_cv(synchronization_data_->force_flush_cv_m); - synchronization_data_->is_force_flush_pending.store(true, std::memory_order_release); + std::uint64_t current_sequence = + synchronization_data_->force_flush_pending_sequence.fetch_add(1, std::memory_order_release) + + 1; synchronization_data_->force_flush_timeout_us.store(timeout.count(), std::memory_order_release); - auto break_condition = [this]() { + auto break_condition = [this, current_sequence]() { if (synchronization_data_->is_shutdown.load() == true) { return true; } - // Wake up the worker thread once. - if (synchronization_data_->is_force_flush_pending.load(std::memory_order_acquire)) + // Wake up the worker thread. + if (synchronization_data_->force_flush_pending_sequence.load(std::memory_order_acquire) > + synchronization_data_->force_flush_notified_sequence.load(std::memory_order_acquire)) { synchronization_data_->is_force_wakeup_background_worker.store(true, std::memory_order_release); - synchronization_data_->cv.notify_one(); + synchronization_data_->cv.notify_all(); } - return synchronization_data_->is_force_flush_notified.load(std::memory_order_acquire); + return synchronization_data_->force_flush_notified_sequence.load(std::memory_order_acquire) >= + current_sequence; }; // Fix timeout to meet requirement of wait_for @@ -108,34 +112,23 @@ bool BatchSpanProcessor::ForceFlush(std::chrono::microseconds timeout) noexcept bool result = false; while (!result && timeout_steady > std::chrono::steady_clock::duration::zero()) { - // When is_force_flush_notified.store(true) and force_flush_cv.notify_all() is called - // between is_force_flush_pending.load() and force_flush_cv.wait(). We must not wait - // for ever + // When force_flush_notified_sequence.compare_exchange_strong(...) and + // force_flush_cv.notify_all() is called between force_flush_pending_sequence.load(...) and + // force_flush_cv.wait(). We must not wait for ever std::chrono::steady_clock::time_point start_timepoint = std::chrono::steady_clock::now(); - result = synchronization_data_->force_flush_cv.wait_for(lk_cv, schedule_delay_millis_, - break_condition); - timeout_steady -= std::chrono::steady_clock::now() - start_timepoint; - } - // If it will be already signaled, we must wait util notified. - // We use a spin lock here - if (false == - synchronization_data_->is_force_flush_pending.exchange(false, std::memory_order_acq_rel)) - { - for (int retry_waiting_times = 0; - false == synchronization_data_->is_force_flush_notified.load(std::memory_order_acquire); - ++retry_waiting_times) + std::chrono::microseconds wait_timeout = schedule_delay_millis_; + + if (wait_timeout > timeout_steady) { - opentelemetry::common::SpinLockMutex::fast_yield(); - if ((retry_waiting_times & 127) == 127) - { - std::this_thread::yield(); - } + wait_timeout = std::chrono::duration_cast<std::chrono::microseconds>(timeout_steady); } + result = synchronization_data_->force_flush_cv.wait_for(lk_cv, wait_timeout, break_condition); + timeout_steady -= std::chrono::steady_clock::now() - start_timepoint; } - synchronization_data_->is_force_flush_notified.store(false, std::memory_order_release); - return result; + return synchronization_data_->force_flush_notified_sequence.load(std::memory_order_acquire) >= + current_sequence; } void BatchSpanProcessor::DoBackgroundWork() @@ -179,8 +172,8 @@ void BatchSpanProcessor::Export() { std::vector<std::unique_ptr<Recordable>> spans_arr; size_t num_records_to_export; - bool notify_force_flush = - synchronization_data_->is_force_flush_pending.exchange(false, std::memory_order_acq_rel); + std::uint64_t notify_force_flush = + synchronization_data_->force_flush_pending_sequence.load(std::memory_order_acquire); if (notify_force_flush) { num_records_to_export = buffer_.size(); @@ -212,7 +205,7 @@ void BatchSpanProcessor::Export() } void BatchSpanProcessor::NotifyCompletion( - bool notify_force_flush, + std::uint64_t notify_force_flush, const std::unique_ptr<SpanExporter> &exporter, const std::shared_ptr<SynchronizationData> &synchronization_data) { @@ -221,7 +214,8 @@ void BatchSpanProcessor::NotifyCompletion( return; } - if (notify_force_flush) + if (notify_force_flush > + synchronization_data->force_flush_notified_sequence.load(std::memory_order_acquire)) { if (exporter) { @@ -232,8 +226,14 @@ void BatchSpanProcessor::NotifyCompletion( exporter->ForceFlush(timeout); } - synchronization_data->is_force_flush_notified.store(true, std::memory_order_release); - synchronization_data->force_flush_cv.notify_one(); + std::uint64_t notified_sequence = + synchronization_data->force_flush_notified_sequence.load(std::memory_order_acquire); + while (notify_force_flush > notified_sequence) + { + synchronization_data->force_flush_notified_sequence.compare_exchange_strong( + notified_sequence, notify_force_flush, std::memory_order_acq_rel); + synchronization_data->force_flush_cv.notify_all(); + } } } @@ -242,7 +242,8 @@ void BatchSpanProcessor::DrainQueue() while (true) { if (buffer_.empty() && - false == synchronization_data_->is_force_flush_pending.load(std::memory_order_acquire)) + synchronization_data_->force_flush_pending_sequence.load(std::memory_order_acquire) <= + synchronization_data_->force_flush_notified_sequence.load(std::memory_order_acquire)) { break; } @@ -280,7 +281,7 @@ bool BatchSpanProcessor::Shutdown(std::chrono::microseconds timeout) noexcept if (worker_thread_.joinable()) { synchronization_data_->is_force_wakeup_background_worker.store(true, std::memory_order_release); - synchronization_data_->cv.notify_one(); + synchronization_data_->cv.notify_all(); worker_thread_.join(); } From 17c3bc66d44338d1a34ce1456b47897179d8811a Mon Sep 17 00:00:00 2001 From: WenTao Ou <owentou@tencent.com> Date: Tue, 28 May 2024 15:04:49 +0800 Subject: [PATCH 10/17] [API] DO not allow unsafe `Logger::EmitLogRecord` (#2673) --- api/include/opentelemetry/logs/logger_type_traits.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/include/opentelemetry/logs/logger_type_traits.h b/api/include/opentelemetry/logs/logger_type_traits.h index aea2173689..486135137d 100644 --- a/api/include/opentelemetry/logs/logger_type_traits.h +++ b/api/include/opentelemetry/logs/logger_type_traits.h @@ -4,6 +4,7 @@ #pragma once #include <chrono> +#include <memory> #include <type_traits> #include "opentelemetry/common/attribute_value.h" @@ -145,6 +146,10 @@ struct LogRecordSetterTrait<common::KeyValueIterable> template <class ValueType> struct LogRecordSetterTrait { + static_assert(!std::is_same<nostd::unique_ptr<LogRecord>, ValueType>::value && + !std::is_same<std::unique_ptr<LogRecord>, ValueType>::value, + "unique_ptr<LogRecord> is not allowed, please use std::move()"); + template <class ArgumentType, nostd::enable_if_t<std::is_convertible<ArgumentType, nostd::string_view>::value || std::is_convertible<ArgumentType, common::AttributeValue>::value, From 277190d3f2976d423e184032c5a7d26c886481ec Mon Sep 17 00:00:00 2001 From: WenTao Ou <owentou@tencent.com> Date: Tue, 28 May 2024 17:04:00 +0800 Subject: [PATCH 11/17] [BUILD] Read default proto version from `third_party_release` (#2677) --- cmake/opentelemetry-proto.cmake | 66 +++++++++++++++++++++------------ third_party_release | 2 +- 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake index c2982e23c0..19516c3b71 100644 --- a/cmake/opentelemetry-proto.cmake +++ b/cmake/opentelemetry-proto.cmake @@ -43,7 +43,15 @@ else() message( STATUS "opentelemetry-proto dependency satisfied by: github download") if("${opentelemetry-proto}" STREQUAL "") - set(opentelemetry-proto "v1.0.0") + file(READ "${CMAKE_CURRENT_LIST_DIR}/../third_party_release" + OTELCPP_THIRD_PARTY_RELEASE_CONTENT) + if(OTELCPP_THIRD_PARTY_RELEASE_CONTENT MATCHES + "opentelemetry-proto=[ \\t]*([A-Za-z0-9_\\.\\-]+)") + set(opentelemetry-proto "${CMAKE_MATCH_1}") + else() + set(opentelemetry-proto "v1.3.1") + endif() + unset(OTELCPP_THIRD_PARTY_RELEASE_CONTENT) endif() include(ExternalProject) ExternalProject_Add( @@ -72,18 +80,23 @@ set(TRACE_PROTO "${PROTO_PATH}/opentelemetry/proto/trace/v1/trace.proto") set(LOGS_PROTO "${PROTO_PATH}/opentelemetry/proto/logs/v1/logs.proto") set(METRICS_PROTO "${PROTO_PATH}/opentelemetry/proto/metrics/v1/metrics.proto") -set(PROFILES_PROTO "${PROTO_PATH}/opentelemetry/proto/profiles/v1experimental/profiles.proto") -set(PROFILES_EXT_PROTO "${PROTO_PATH}/opentelemetry/proto/profiles/v1experimental/pprofextended.proto") +set(PROFILES_PROTO + "${PROTO_PATH}/opentelemetry/proto/profiles/v1experimental/profiles.proto") +set(PROFILES_EXT_PROTO + "${PROTO_PATH}/opentelemetry/proto/profiles/v1experimental/pprofextended.proto" +) set(TRACE_SERVICE_PROTO "${PROTO_PATH}/opentelemetry/proto/collector/trace/v1/trace_service.proto") set(LOGS_SERVICE_PROTO "${PROTO_PATH}/opentelemetry/proto/collector/logs/v1/logs_service.proto") set(METRICS_SERVICE_PROTO - "${PROTO_PATH}/opentelemetry/proto/collector/metrics/v1/metrics_service.proto") + "${PROTO_PATH}/opentelemetry/proto/collector/metrics/v1/metrics_service.proto" +) set(PROFILES_SERVICE_PROTO - "${PROTO_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.proto") + "${PROTO_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.proto" +) set(GENERATED_PROTOBUF_PATH "${CMAKE_BINARY_DIR}/generated/third_party/opentelemetry-proto") @@ -119,30 +132,37 @@ set(TRACE_SERVICE_PB_H_FILE ) # -# Notes about the PROFILES signal: -# - *.proto files added in opentelemetry-proto 1.3.0 -# - C++ code is generated from proto files -# - The generated code is not used yet. +# Notes about the PROFILES signal: - *.proto files added in opentelemetry-proto +# 1.3.0 - C++ code is generated from proto files - The generated code is not +# used yet. # set(PROFILES_CPP_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/profiles.pb.cc") + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/profiles.pb.cc" +) set(PROFILES_H_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/profiles.pb.h") + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/profiles.pb.h" +) set(PROFILES_EXT_CPP_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/pprofextended.pb.cc") + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/pprofextended.pb.cc" +) set(PROFILES_EXT_H_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/pprofextended.pb.h") + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/profiles/v1experimental/pprofextended.pb.h" +) set(PROFILES_SERVICE_PB_H_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.pb.h") + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.pb.h" +) set(PROFILES_SERVICE_PB_CPP_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.pb.cc") + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.pb.cc" +) if(WITH_OTLP_GRPC) set(PROFILES_SERVICE_GRPC_PB_H_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.grpc.pb.h") + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.grpc.pb.h" + ) set(PROFILES_SERVICE_GRPC_PB_CPP_FILE - "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.grpc.pb.cc") + "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/collector/profiles/v1experimental/profiles_service.grpc.pb.cc" + ) endif() if(WITH_OTLP_GRPC) @@ -278,8 +298,8 @@ add_custom_command( ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTOBUF_COMMON_FLAGS} ${PROTOBUF_INCLUDE_FLAGS} ${COMMON_PROTO} ${RESOURCE_PROTO} ${TRACE_PROTO} ${LOGS_PROTO} ${METRICS_PROTO} ${TRACE_SERVICE_PROTO} ${LOGS_SERVICE_PROTO} - ${METRICS_SERVICE_PROTO} - ${PROFILES_PROTO} ${PROFILES_EXT_PROTO} ${PROFILES_SERVICE_PROTO} + ${METRICS_SERVICE_PROTO} ${PROFILES_PROTO} ${PROFILES_EXT_PROTO} + ${PROFILES_SERVICE_PROTO} COMMENT "[Run]: ${PROTOBUF_RUN_PROTOC_COMMAND}") include_directories("${GENERATED_PROTOBUF_PATH}") @@ -317,13 +337,11 @@ if(WITH_OTLP_GRPC) ${LOGS_SERVICE_GRPC_PB_CPP_FILE} ${METRICS_SERVICE_GRPC_PB_CPP_FILE}) list(APPEND OPENTELEMETRY_PROTO_TARGETS opentelemetry_proto_grpc) - target_link_libraries(opentelemetry_proto_grpc - PUBLIC opentelemetry_proto) + target_link_libraries(opentelemetry_proto_grpc PUBLIC opentelemetry_proto) get_target_property(grpc_lib_type gRPC::grpc++ TYPE) - if (grpc_lib_type STREQUAL "SHARED_LIBRARY") - target_link_libraries(opentelemetry_proto_grpc - PUBLIC gRPC::grpc++) + if(grpc_lib_type STREQUAL "SHARED_LIBRARY") + target_link_libraries(opentelemetry_proto_grpc PUBLIC gRPC::grpc++) endif() set_target_properties(opentelemetry_proto_grpc PROPERTIES EXPORT_NAME proto_grpc) diff --git a/third_party_release b/third_party_release index 092573703b..0bbf67f3af 100644 --- a/third_party_release +++ b/third_party_release @@ -19,7 +19,7 @@ benchmark=v1.8.3 googletest=1.14.0 ms-gsl=v3.1.0-67-g6f45293 nlohmann-json=v3.11.3 -opentelemetry-proto=v1.1.0 +opentelemetry-proto=v1.3.1 opentracing-cpp=v1.6.0 prometheus-cpp=v1.2.4 vcpkg=2024.02.14 From 0dd64e07478b7f6b86f24d469b60941c5bf5ce4c Mon Sep 17 00:00:00 2001 From: Marc Alff <marc.alff@oracle.com> Date: Wed, 29 May 2024 19:06:10 +0200 Subject: [PATCH 12/17] [CI] include-what-you-use (#2629) --- .github/workflows/iwyu.yml | 60 +++++++++++++++++++ .iwyu.imp | 13 ++++ api/include/opentelemetry/version.h | 2 +- sdk/include/opentelemetry/sdk/common/base64.h | 1 - .../sdk/common/global_log_handler.h | 3 +- .../sdk/metrics/async_instruments.h | 6 +- .../sdk/metrics/meter_provider.h | 23 +++---- .../sdk/metrics/meter_provider_factory.h | 7 +-- .../sdk/trace/batch_span_processor.h | 8 ++- .../sdk/trace/batch_span_processor_factory.h | 6 +- .../opentelemetry/sdk/trace/exporter.h | 2 +- .../sdk/trace/random_id_generator.h | 2 + .../sdk/trace/random_id_generator_factory.h | 2 +- .../sdk/trace/samplers/always_off_factory.h | 2 +- .../sdk/trace/samplers/always_on_factory.h | 2 +- .../opentelemetry/sdk/trace/samplers/parent.h | 18 ++---- .../sdk/trace/samplers/parent_factory.h | 2 +- .../sdk/trace/samplers/trace_id_ratio.h | 13 +--- .../trace/samplers/trace_id_ratio_factory.h | 2 +- .../sdk/trace/simple_processor_factory.h | 4 +- sdk/include/opentelemetry/sdk/trace/tracer.h | 19 +++--- .../opentelemetry/sdk/trace/tracer_context.h | 2 + .../sdk/trace/tracer_context_factory.h | 14 ++--- .../opentelemetry/sdk/trace/tracer_provider.h | 12 ++-- .../sdk/trace/tracer_provider_factory.h | 20 ++----- sdk/src/common/BUILD | 1 - sdk/src/common/CMakeLists.txt | 3 +- sdk/src/common/base64.cc | 1 - sdk/src/common/core.cc | 8 --- sdk/src/common/env_variables.cc | 4 +- sdk/src/common/platform/fork_unix.cc | 1 + sdk/src/common/random.h | 2 + sdk/src/metrics/async_instruments.cc | 4 +- sdk/src/metrics/meter_provider.cc | 14 +++-- sdk/src/metrics/meter_provider_factory.cc | 11 +--- sdk/src/resource/resource.cc | 6 +- sdk/src/resource/resource_detector.cc | 3 + sdk/src/trace/batch_span_processor.cc | 23 ++++++- sdk/src/trace/batch_span_processor_factory.cc | 8 ++- sdk/src/trace/random_id_generator.cc | 5 ++ sdk/src/trace/samplers/always_off_factory.cc | 3 +- sdk/src/trace/samplers/always_on_factory.cc | 3 +- sdk/src/trace/samplers/parent.cc | 11 ++++ sdk/src/trace/samplers/parent_factory.cc | 3 +- sdk/src/trace/samplers/trace_id_ratio.cc | 15 ++++- .../trace/samplers/trace_id_ratio_factory.cc | 4 +- sdk/src/trace/simple_processor_factory.cc | 8 ++- sdk/src/trace/span.cc | 9 +-- sdk/src/trace/span.h | 11 ++++ sdk/src/trace/tracer.cc | 27 ++++++++- sdk/src/trace/tracer_context.cc | 12 +++- sdk/src/trace/tracer_context_factory.cc | 12 +++- sdk/src/trace/tracer_provider.cc | 21 ++++++- sdk/src/trace/tracer_provider_factory.cc | 12 +++- 54 files changed, 333 insertions(+), 157 deletions(-) create mode 100644 .github/workflows/iwyu.yml create mode 100644 .iwyu.imp delete mode 100644 sdk/src/common/core.cc diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml new file mode 100644 index 0000000000..de60502794 --- /dev/null +++ b/.github/workflows/iwyu.yml @@ -0,0 +1,60 @@ + +name: include-what-you-use + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + iwyu: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: setup dependencies + run: | + sudo apt update -y + sudo apt install -y --no-install-recommends --no-install-suggests \ + build-essential \ + iwyu \ + cmake \ + ninja-build \ + libssl-dev \ + libcurl4-openssl-dev \ + libprotobuf-dev \ + protobuf-compiler \ + libgmock-dev \ + libgtest-dev \ + libbenchmark-dev + + - name: Prepare CMake + run: | + TOPDIR=`pwd` + mkdir build && cd build + CC="clang" CXX="clang++" cmake \ + -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;" \ + -DBUILD_TESTING=OFF \ + -DBUILD_W3CTRACECONTEXT_TEST=OFF \ + .. + + - name: iwyu_tool + run: | + cd build + make -k 2>&1 | tee -a iwyu.log + + - uses: actions/upload-artifact@v4 + if: success() || failure() + with: + name: Logs (include-what-you-use) + path: ./build/*.log + + - name: count warnings + run: | + cd build + COUNT=`grep -c "Warning:" iwyu.log` + echo "include-what-you-use reported ${COUNT} warning(s)" + diff --git a/.iwyu.imp b/.iwyu.imp new file mode 100644 index 0000000000..53fddd24aa --- /dev/null +++ b/.iwyu.imp @@ -0,0 +1,13 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +# include-what-you-use mapping file + +[ + # Work around for C++ STL + { "include": ["<bits/chrono.h>", "private", "<chrono>", "public"] }, + + # Local opentelemetry-cpp + +] + diff --git a/api/include/opentelemetry/version.h b/api/include/opentelemetry/version.h index 31f6e35acb..6e8a24a2d4 100644 --- a/api/include/opentelemetry/version.h +++ b/api/include/opentelemetry/version.h @@ -3,7 +3,7 @@ #pragma once -#include "opentelemetry/common/macros.h" +#include "opentelemetry/common/macros.h" // IWYU pragma: export #include "opentelemetry/detail/preprocessor.h" #ifndef OPENTELEMETRY_ABI_VERSION_NO diff --git a/sdk/include/opentelemetry/sdk/common/base64.h b/sdk/include/opentelemetry/sdk/common/base64.h index d88204675c..918eaaf14a 100644 --- a/sdk/include/opentelemetry/sdk/common/base64.h +++ b/sdk/include/opentelemetry/sdk/common/base64.h @@ -5,7 +5,6 @@ #include <string> -#include "opentelemetry/common/macros.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" diff --git a/sdk/include/opentelemetry/sdk/common/global_log_handler.h b/sdk/include/opentelemetry/sdk/common/global_log_handler.h index 10bf42a145..59a08e08a6 100644 --- a/sdk/include/opentelemetry/sdk/common/global_log_handler.h +++ b/sdk/include/opentelemetry/sdk/common/global_log_handler.h @@ -3,7 +3,8 @@ #pragma once -#include <sstream> +#include <sstream> // IWYU pragma: keep +#include <string> #include <utility> #include "opentelemetry/nostd/shared_ptr.h" diff --git a/sdk/include/opentelemetry/sdk/metrics/async_instruments.h b/sdk/include/opentelemetry/sdk/metrics/async_instruments.h index 48c7d14ec5..2ff8c9702e 100644 --- a/sdk/include/opentelemetry/sdk/metrics/async_instruments.h +++ b/sdk/include/opentelemetry/sdk/metrics/async_instruments.h @@ -6,8 +6,9 @@ #include <memory> #include "opentelemetry/metrics/async_instruments.h" -#include "opentelemetry/metrics/observer_result.h" #include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/metric_storage.h" +#include "opentelemetry/sdk/metrics/state/observable_registry.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -16,9 +17,6 @@ namespace sdk namespace metrics { -class AsyncWritableMetricStorage; -class ObservableRegistry; - class ObservableInstrument : public opentelemetry::metrics::ObservableInstrument { public: diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h index ddeb6d96ac..a838f2a96a 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h @@ -7,34 +7,29 @@ #include <memory> #include <mutex> +#include "opentelemetry/metrics/meter.h" #include "opentelemetry/metrics/meter_provider.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/metric_reader.h" +#include "opentelemetry/sdk/metrics/view/instrument_selector.h" +#include "opentelemetry/sdk/metrics/view/meter_selector.h" +#include "opentelemetry/sdk/metrics/view/view.h" +#include "opentelemetry/sdk/metrics/view/view_registry.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/version.h" #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW # include "opentelemetry/sdk/metrics/exemplar/filter_type.h" #endif -#include "opentelemetry/sdk/metrics/view/view_registry.h" -#include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/version.h" - OPENTELEMETRY_BEGIN_NAMESPACE -namespace metrics -{ -class Meter; -} // namespace metrics - namespace sdk { namespace metrics { -// forward declaration -class MeterContext; -class MetricCollector; -class MetricReader; - 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 69e77ebf5e..15aa13badc 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h @@ -4,13 +4,10 @@ #pragma once #include <memory> -#include <mutex> -#include <vector> -#include "opentelemetry/metrics/meter.h" + #include "opentelemetry/metrics/meter_provider.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/sdk/metrics/meter.h" #include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/view/view_registry.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" diff --git a/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h b/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h index e23b0a2df2..e069a461e6 100644 --- a/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h +++ b/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h @@ -3,7 +3,9 @@ #pragma once +#include <stddef.h> #include <atomic> +#include <chrono> #include <condition_variable> #include <cstdint> #include <memory> @@ -11,7 +13,11 @@ #include <thread> #include "opentelemetry/sdk/common/circular_buffer.h" +#include "opentelemetry/sdk/trace/batch_span_processor_options.h" +#include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/trace/span_context.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -19,8 +25,6 @@ namespace sdk { namespace trace { -class SpanExporter; -struct BatchSpanProcessorOptions; /** * This is an implementation of the SpanProcessor which creates batches of finished spans and passes diff --git a/sdk/include/opentelemetry/sdk/trace/batch_span_processor_factory.h b/sdk/include/opentelemetry/sdk/trace/batch_span_processor_factory.h index 4f645b2633..bfec277b1d 100644 --- a/sdk/include/opentelemetry/sdk/trace/batch_span_processor_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/batch_span_processor_factory.h @@ -5,6 +5,9 @@ #include <memory> +#include "opentelemetry/sdk/trace/batch_span_processor_options.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,9 +15,6 @@ namespace sdk { namespace trace { -class SpanExporter; -class SpanProcessor; -struct BatchSpanProcessorOptions; /** * Factory class for BatchSpanProcessor. diff --git a/sdk/include/opentelemetry/sdk/trace/exporter.h b/sdk/include/opentelemetry/sdk/trace/exporter.h index 8795b69837..8f207e89f2 100644 --- a/sdk/include/opentelemetry/sdk/trace/exporter.h +++ b/sdk/include/opentelemetry/sdk/trace/exporter.h @@ -8,6 +8,7 @@ #include "opentelemetry/nostd/span.h" #include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -15,7 +16,6 @@ namespace sdk { namespace trace { -class Recordable; /** * SpanExporter defines the interface that protocol-specific span exporters must diff --git a/sdk/include/opentelemetry/sdk/trace/random_id_generator.h b/sdk/include/opentelemetry/sdk/trace/random_id_generator.h index a2adcf55f7..01e460563d 100644 --- a/sdk/include/opentelemetry/sdk/trace/random_id_generator.h +++ b/sdk/include/opentelemetry/sdk/trace/random_id_generator.h @@ -4,6 +4,8 @@ #pragma once #include "opentelemetry/sdk/trace/id_generator.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/trace_id.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/trace/random_id_generator_factory.h b/sdk/include/opentelemetry/sdk/trace/random_id_generator_factory.h index 6c94984403..a1915d3136 100644 --- a/sdk/include/opentelemetry/sdk/trace/random_id_generator_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/random_id_generator_factory.h @@ -5,6 +5,7 @@ #include <memory> +#include "opentelemetry/sdk/trace/id_generator.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,7 +13,6 @@ namespace sdk { namespace trace { -class IdGenerator; /** * Factory class for RandomIdGenerator. diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/always_off_factory.h b/sdk/include/opentelemetry/sdk/trace/samplers/always_off_factory.h index 19f76c715f..af676dead9 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/always_off_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/always_off_factory.h @@ -5,6 +5,7 @@ #include <memory> +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,7 +13,6 @@ namespace sdk { namespace trace { -class Sampler; /** * Factory class for AlwaysOffSampler. diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/always_on_factory.h b/sdk/include/opentelemetry/sdk/trace/samplers/always_on_factory.h index c72d97fdec..80b38f8456 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/always_on_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/always_on_factory.h @@ -5,6 +5,7 @@ #include <memory> +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,7 +13,6 @@ namespace sdk { namespace trace { -class Sampler; /** * Factory class for AlwaysOnSampler. diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/parent.h b/sdk/include/opentelemetry/sdk/trace/samplers/parent.h index 59dd314589..d5054d9218 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/parent.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/parent.h @@ -4,28 +4,22 @@ #pragma once #include <memory> +#include <string> +#include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/trace/sampler.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_id.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace common -{ -class KeyValueIterable; -} // namespace common - -namespace trace -{ -class SpanContext; -class SpanContextKeyValueIterable; -class TraceState; -} // namespace trace - namespace sdk { namespace trace { + /** * The ParentBased sampler is a composite sampler. ParentBased(delegateSampler) either respects * the parent span's sampling decision or delegates to delegateSampler for root spans. diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h b/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h index 2fdf87819d..68557ace79 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h @@ -5,6 +5,7 @@ #include <memory> +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,7 +13,6 @@ namespace sdk { namespace trace { -class Sampler; /** * Factory class for ParentBasedSampler. diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h b/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h index b5df576091..f1b895139f 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h @@ -3,6 +3,7 @@ #pragma once +#include <stdint.h> #include <string> #include "opentelemetry/nostd/string_view.h" @@ -12,18 +13,6 @@ #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace common -{ -class KeyValueIterable; -} // namespace common - -namespace trace -{ -class SpanContext; -class SpanContextKeyValueIterable; -class TraceState; -} // namespace trace - namespace sdk { namespace trace diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio_factory.h b/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio_factory.h index eb434fc6fe..de6d98906b 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio_factory.h @@ -5,6 +5,7 @@ #include <memory> +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,7 +13,6 @@ namespace sdk { namespace trace { -class Sampler; /** * Factory class for TraceIdRatioBasedSampler. diff --git a/sdk/include/opentelemetry/sdk/trace/simple_processor_factory.h b/sdk/include/opentelemetry/sdk/trace/simple_processor_factory.h index 6a106e7f21..2ae40c2f7b 100644 --- a/sdk/include/opentelemetry/sdk/trace/simple_processor_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/simple_processor_factory.h @@ -5,6 +5,8 @@ #include <memory> +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,8 +14,6 @@ namespace sdk { namespace trace { -class SpanExporter; -class SpanProcessor; /** * Factory class for SimpleSpanProcessor. diff --git a/sdk/include/opentelemetry/sdk/trace/tracer.h b/sdk/include/opentelemetry/sdk/trace/tracer.h index 67e606ba97..778ffe8173 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer.h @@ -3,29 +3,30 @@ #pragma once +#include <stdint.h> #include <memory> -#include "opentelemetry/common/macros.h" +#include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" -#include "opentelemetry/sdk/trace/samplers/always_on.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/id_generator.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/tracer_context.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context_kv_iterable.h" +#include "opentelemetry/trace/span_startoptions.h" #include "opentelemetry/trace/tracer.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { -namespace resource -{ -class Resource; -} // namespace resource - namespace trace { -class IdGenerator; -class SpanProcessor; using namespace opentelemetry::sdk::instrumentationscope; diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_context.h b/sdk/include/opentelemetry/sdk/trace/tracer_context.h index 9475c8c0b9..73bbe4f84b 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_context.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_context.h @@ -8,8 +8,10 @@ #include <vector> #include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/id_generator.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/random_id_generator.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_on.h" #include "opentelemetry/version.h" diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_context_factory.h b/sdk/include/opentelemetry/sdk/trace/tracer_context_factory.h index 1911db8f93..4954fd7c3f 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_context_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_context_factory.h @@ -6,22 +6,18 @@ #include <memory> #include <vector> +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/id_generator.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/sampler.h" +#include "opentelemetry/sdk/trace/tracer_context.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { -namespace resource -{ -class Resource; -} // namespace resource - namespace trace { -class IdGenerator; -class Sampler; -class SpanProcessor; -class TracerContext; /** * Factory class for TracerContext. diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h index ce2a6d4401..e0f3ce0c4c 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h @@ -3,17 +3,22 @@ #pragma once -#include <map> +#include <chrono> #include <memory> #include <mutex> -#include <string> #include <vector> #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/id_generator.h" +#include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/random_id_generator.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_on.h" +#include "opentelemetry/sdk/trace/tracer.h" +#include "opentelemetry/sdk/trace/tracer_context.h" +#include "opentelemetry/trace/tracer.h" #include "opentelemetry/trace/tracer_provider.h" #include "opentelemetry/version.h" @@ -22,9 +27,6 @@ namespace sdk { namespace trace { -class SpanProcessor; -class Tracer; -class TracerContext; class TracerProvider final : public opentelemetry::trace::TracerProvider { diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h b/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h index e9dfa82edb..17f7ea395a 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h @@ -6,27 +6,19 @@ #include <memory> #include <vector> +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/id_generator.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/sampler.h" +#include "opentelemetry/sdk/trace/tracer_context.h" +#include "opentelemetry/trace/tracer_provider.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace trace -{ -class TracerProvider; -} // namespace trace - namespace sdk { -namespace resource -{ -class Resource; -} // namespace resource - namespace trace { -class IdGenerator; -class Sampler; -class SpanProcessor; -class TracerContext; /** * Factory class for TracerProvider. diff --git a/sdk/src/common/BUILD b/sdk/src/common/BUILD index fe75f08d7c..9c424cac6b 100644 --- a/sdk/src/common/BUILD +++ b/sdk/src/common/BUILD @@ -6,7 +6,6 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "random", srcs = [ - "core.cc", "random.cc", ], hdrs = [ diff --git a/sdk/src/common/CMakeLists.txt b/sdk/src/common/CMakeLists.txt index 9f0e61f1e2..664db38e17 100644 --- a/sdk/src/common/CMakeLists.txt +++ b/sdk/src/common/CMakeLists.txt @@ -1,8 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -set(COMMON_SRCS random.cc core.cc global_log_handler.cc env_variables.cc - base64.cc) +set(COMMON_SRCS random.cc global_log_handler.cc env_variables.cc base64.cc) if(WIN32) list(APPEND COMMON_SRCS platform/fork_windows.cc) else() diff --git a/sdk/src/common/base64.cc b/sdk/src/common/base64.cc index a19af1f8a3..3c572fe344 100644 --- a/sdk/src/common/base64.cc +++ b/sdk/src/common/base64.cc @@ -9,7 +9,6 @@ # include <assert.h> #endif #include <cstring> -#include <iostream> #include <limits> #if defined(HAVE_ABSEIL) diff --git a/sdk/src/common/core.cc b/sdk/src/common/core.cc deleted file mode 100644 index 16012e765c..0000000000 --- a/sdk/src/common/core.cc +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// clang-format off -// version.h should be included before nostd/variant.h. -#include "opentelemetry/version.h" -#include "opentelemetry/nostd/variant.h" -// clang-format on diff --git a/sdk/src/common/env_variables.cc b/sdk/src/common/env_variables.cc index a3f50b15ba..586a8ed420 100644 --- a/sdk/src/common/env_variables.cc +++ b/sdk/src/common/env_variables.cc @@ -10,8 +10,10 @@ # include <strings.h> #endif -#include <memory> +#include <cstdlib> +#include <ostream> +#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/version.h" diff --git a/sdk/src/common/platform/fork_unix.cc b/sdk/src/common/platform/fork_unix.cc index cfbd8ab778..41926bbfe7 100644 --- a/sdk/src/common/platform/fork_unix.cc +++ b/sdk/src/common/platform/fork_unix.cc @@ -1,6 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include "opentelemetry/version.h" #include "src/common/platform/fork.h" #include <pthread.h> diff --git a/sdk/src/common/random.h b/sdk/src/common/random.h index ecd6dabc1e..28adbaf41c 100644 --- a/sdk/src/common/random.h +++ b/sdk/src/common/random.h @@ -3,6 +3,8 @@ #pragma once +#include <stdint.h> + #include "opentelemetry/nostd/span.h" #include "opentelemetry/version.h" #include "src/common/fast_random_number_generator.h" diff --git a/sdk/src/metrics/async_instruments.cc b/sdk/src/metrics/async_instruments.cc index 5ca56b3969..88f818dad9 100644 --- a/sdk/src/metrics/async_instruments.cc +++ b/sdk/src/metrics/async_instruments.cc @@ -1,10 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include <utility> + #include "opentelemetry/sdk/metrics/async_instruments.h" #include "opentelemetry/sdk/metrics/state/metric_storage.h" #include "opentelemetry/sdk/metrics/state/observable_registry.h" -#include "opentelemetry/sdk_config.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/metrics/meter_provider.cc b/sdk/src/metrics/meter_provider.cc index 943ae137bd..84a0f56bf4 100644 --- a/sdk/src/metrics/meter_provider.cc +++ b/sdk/src/metrics/meter_provider.cc @@ -1,18 +1,20 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/meter_provider.h" +#include <type_traits> +#include <utility> + +#include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/metrics/meter.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/metrics/meter.h" #include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/metric_reader.h" - -#include "opentelemetry/sdk/common/global_log_handler.h" -#include "opentelemetry/sdk_config.h" #include "opentelemetry/version.h" -#include <vector> - OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { diff --git a/sdk/src/metrics/meter_provider_factory.cc b/sdk/src/metrics/meter_provider_factory.cc index bd6bbe932c..43c060e5f9 100644 --- a/sdk/src/metrics/meter_provider_factory.cc +++ b/sdk/src/metrics/meter_provider_factory.cc @@ -1,20 +1,15 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/meter_provider_factory.h" +#include <utility> + #include "opentelemetry/metrics/meter.h" #include "opentelemetry/sdk/metrics/meter_provider.h" -#include "opentelemetry/sdk/metrics/metric_reader.h" +#include "opentelemetry/sdk/metrics/meter_provider_factory.h" #include "opentelemetry/sdk/metrics/view/view_registry_factory.h" - -#include "opentelemetry/sdk/common/global_log_handler.h" -#include "opentelemetry/sdk_config.h" #include "opentelemetry/version.h" -#include <vector> - namespace resource = opentelemetry::sdk::resource; -namespace metrics_api = opentelemetry::metrics; namespace metrics_sdk = opentelemetry::sdk::metrics; OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/sdk/src/resource/resource.cc b/sdk/src/resource/resource.cc index 12f8e16d43..919624686d 100644 --- a/sdk/src/resource/resource.cc +++ b/sdk/src/resource/resource.cc @@ -1,8 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include <string> +#include <unordered_map> +#include <utility> + +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/nostd/span.h" #include "opentelemetry/sdk/resource/resource_detector.h" #include "opentelemetry/sdk/resource/semantic_conventions.h" #include "opentelemetry/sdk/version/version.h" diff --git a/sdk/src/resource/resource_detector.cc b/sdk/src/resource/resource_detector.cc index 2f560e1150..b7c7c7e614 100644 --- a/sdk/src/resource/resource_detector.cc +++ b/sdk/src/resource/resource_detector.cc @@ -5,9 +5,12 @@ #include "opentelemetry/sdk/common/env_variables.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/resource/semantic_conventions.h" +#include "opentelemetry/version.h" +#include <stddef.h> #include <sstream> #include <string> +#include <unordered_map> OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/trace/batch_span_processor.cc b/sdk/src/trace/batch_span_processor.cc index 3827fad495..7759949490 100644 --- a/sdk/src/trace/batch_span_processor.cc +++ b/sdk/src/trace/batch_span_processor.cc @@ -1,15 +1,32 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/batch_span_processor.h" +#include <stddef.h> +#include <algorithm> +#include <atomic> +#include <chrono> +#include <condition_variable> +#include <memory> +#include <mutex> +#include <ratio> +#include <thread> +#include <utility> +#include <vector> + #include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/common/timestamp.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/atomic_unique_ptr.h" +#include "opentelemetry/sdk/common/circular_buffer.h" +#include "opentelemetry/sdk/common/circular_buffer_range.h" #include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/trace/batch_span_processor.h" #include "opentelemetry/sdk/trace/batch_span_processor_options.h" #include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/recordable.h" - -#include <vector> +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/version.h" using opentelemetry::sdk::common::AtomicUniquePtr; using opentelemetry::sdk::common::CircularBuffer; diff --git a/sdk/src/trace/batch_span_processor_factory.cc b/sdk/src/trace/batch_span_processor_factory.cc index b2b23857a1..a21b056cee 100644 --- a/sdk/src/trace/batch_span_processor_factory.cc +++ b/sdk/src/trace/batch_span_processor_factory.cc @@ -1,9 +1,15 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/batch_span_processor_factory.h" +#include <memory> +#include <utility> + #include "opentelemetry/sdk/trace/batch_span_processor.h" +#include "opentelemetry/sdk/trace/batch_span_processor_factory.h" #include "opentelemetry/sdk/trace/batch_span_processor_options.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/trace/random_id_generator.cc b/sdk/src/trace/random_id_generator.cc index e2fa5b0987..f09fa81141 100644 --- a/sdk/src/trace/random_id_generator.cc +++ b/sdk/src/trace/random_id_generator.cc @@ -1,7 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include <stdint.h> + +#include "opentelemetry/nostd/span.h" #include "opentelemetry/sdk/trace/random_id_generator.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/trace_id.h" #include "opentelemetry/version.h" #include "src/common/random.h" diff --git a/sdk/src/trace/samplers/always_off_factory.cc b/sdk/src/trace/samplers/always_off_factory.cc index e7c802dd51..c148d60ee9 100644 --- a/sdk/src/trace/samplers/always_off_factory.cc +++ b/sdk/src/trace/samplers/always_off_factory.cc @@ -3,8 +3,7 @@ #include "opentelemetry/sdk/trace/samplers/always_off_factory.h" #include "opentelemetry/sdk/trace/samplers/always_off.h" - -namespace trace_api = opentelemetry::trace; +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/trace/samplers/always_on_factory.cc b/sdk/src/trace/samplers/always_on_factory.cc index ad371ac1f0..a803596b9c 100644 --- a/sdk/src/trace/samplers/always_on_factory.cc +++ b/sdk/src/trace/samplers/always_on_factory.cc @@ -3,8 +3,7 @@ #include "opentelemetry/sdk/trace/samplers/always_on_factory.h" #include "opentelemetry/sdk/trace/samplers/always_on.h" - -namespace trace_api = opentelemetry::trace; +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/trace/samplers/parent.cc b/sdk/src/trace/samplers/parent.cc index 990e1a954a..a69ede92d4 100644 --- a/sdk/src/trace/samplers/parent.cc +++ b/sdk/src/trace/samplers/parent.cc @@ -1,8 +1,19 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include <map> +#include <memory> +#include <string> + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/parent.h" #include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/version.h" namespace trace_api = opentelemetry::trace; diff --git a/sdk/src/trace/samplers/parent_factory.cc b/sdk/src/trace/samplers/parent_factory.cc index dd15acff23..978fb75946 100644 --- a/sdk/src/trace/samplers/parent_factory.cc +++ b/sdk/src/trace/samplers/parent_factory.cc @@ -3,8 +3,7 @@ #include "opentelemetry/sdk/trace/samplers/parent_factory.h" #include "opentelemetry/sdk/trace/samplers/parent.h" - -namespace trace_api = opentelemetry::trace; +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/trace/samplers/trace_id_ratio.cc b/sdk/src/trace/samplers/trace_id_ratio.cc index 4d5d3453fa..f25edd2735 100644 --- a/sdk/src/trace/samplers/trace_id_ratio.cc +++ b/sdk/src/trace/samplers/trace_id_ratio.cc @@ -2,11 +2,20 @@ // Copyright 2017, OpenCensus Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/samplers/trace_id_ratio.h" - #include <cmath> #include <cstdint> -#include <stdexcept> +#include <cstring> +#include <map> +#include <memory> +#include <string> + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/trace/sampler.h" +#include "opentelemetry/sdk/trace/samplers/trace_id_ratio.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/version.h" namespace trace_api = opentelemetry::trace; diff --git a/sdk/src/trace/samplers/trace_id_ratio_factory.cc b/sdk/src/trace/samplers/trace_id_ratio_factory.cc index aaf5dfa4ef..da4c4cc350 100644 --- a/sdk/src/trace/samplers/trace_id_ratio_factory.cc +++ b/sdk/src/trace/samplers/trace_id_ratio_factory.cc @@ -2,10 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/sdk/trace/samplers/trace_id_ratio_factory.h" -#include "opentelemetry/sdk/trace/samplers/parent.h" #include "opentelemetry/sdk/trace/samplers/trace_id_ratio.h" - -namespace trace_api = opentelemetry::trace; +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/trace/simple_processor_factory.cc b/sdk/src/trace/simple_processor_factory.cc index 59e3ea92f1..7e567d22cf 100644 --- a/sdk/src/trace/simple_processor_factory.cc +++ b/sdk/src/trace/simple_processor_factory.cc @@ -1,8 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include <memory> +#include <utility> + +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/simple_processor.h" +#include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/trace/span.cc b/sdk/src/trace/span.cc index ca3406a154..ca3a475707 100644 --- a/sdk/src/trace/span.cc +++ b/sdk/src/trace/span.cc @@ -1,14 +1,15 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "src/trace/span.h" -#include "src/common/random.h" +#include <chrono> +#include <utility> -#include "opentelemetry/context/runtime_context.h" +#include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/trace/span_id.h" #include "opentelemetry/trace/span_metadata.h" -#include "opentelemetry/trace/trace_flags.h" #include "opentelemetry/version.h" +#include "src/trace/span.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/trace/span.h b/sdk/src/trace/span.h index 7fe86bd3f5..5e0ff2c570 100644 --- a/sdk/src/trace/span.h +++ b/sdk/src/trace/span.h @@ -3,9 +3,20 @@ #pragma once +#include <memory> #include <mutex> +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/tracer.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_context_kv_iterable.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/span_startoptions.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/sdk/src/trace/tracer.cc b/sdk/src/trace/tracer.cc index 838eca88c7..2b38c5d3ca 100644 --- a/sdk/src/trace/tracer.cc +++ b/sdk/src/trace/tracer.cc @@ -1,10 +1,35 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include <stdint.h> +#include <chrono> +#include <map> +#include <memory> +#include <new> +#include <utility> + +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/unique_ptr.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/trace/id_generator.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/tracer.h" -#include "opentelemetry/context/runtime_context.h" +#include "opentelemetry/sdk/trace/tracer_context.h" #include "opentelemetry/trace/context.h" #include "opentelemetry/trace/noop.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_context_kv_iterable.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_startoptions.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" +#include "opentelemetry/version.h" #include "src/trace/span.h" diff --git a/sdk/src/trace/tracer_context.cc b/sdk/src/trace/tracer_context.cc index 0b89c5cefb..0fb4fd35cf 100644 --- a/sdk/src/trace/tracer_context.cc +++ b/sdk/src/trace/tracer_context.cc @@ -1,8 +1,18 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/tracer_context.h" +#include <chrono> +#include <memory> +#include <utility> +#include <vector> + +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/id_generator.h" #include "opentelemetry/sdk/trace/multi_span_processor.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/sampler.h" +#include "opentelemetry/sdk/trace/tracer_context.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/trace/tracer_context_factory.cc b/sdk/src/trace/tracer_context_factory.cc index df9d81a197..68ea39349e 100644 --- a/sdk/src/trace/tracer_context_factory.cc +++ b/sdk/src/trace/tracer_context_factory.cc @@ -1,11 +1,19 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/tracer_context_factory.h" -#include "opentelemetry/sdk/trace/multi_span_processor.h" +#include <memory> +#include <utility> +#include <vector> + +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/id_generator.h" +#include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/random_id_generator_factory.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_on_factory.h" #include "opentelemetry/sdk/trace/tracer_context.h" +#include "opentelemetry/sdk/trace/tracer_context_factory.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/trace/tracer_provider.cc b/sdk/src/trace/tracer_provider.cc index 8569b63f23..7421e07de4 100644 --- a/sdk/src/trace/tracer_provider.cc +++ b/sdk/src/trace/tracer_provider.cc @@ -1,12 +1,29 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/tracer_provider.h" +#include <algorithm> +#include <chrono> +#include <memory> +#include <mutex> +#include <type_traits> +#include <utility> +#include <vector> + +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/id_generator.h" #include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/tracer.h" #include "opentelemetry/sdk/trace/tracer_context.h" -#include "opentelemetry/sdk_config.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/trace/tracer_provider_factory.cc b/sdk/src/trace/tracer_provider_factory.cc index c9b02a13ad..d22330b866 100644 --- a/sdk/src/trace/tracer_provider_factory.cc +++ b/sdk/src/trace/tracer_provider_factory.cc @@ -1,12 +1,22 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/tracer_provider_factory.h" +#include <memory> +#include <utility> +#include <vector> + +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/id_generator.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/random_id_generator_factory.h" +#include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/samplers/always_on_factory.h" #include "opentelemetry/sdk/trace/tracer_context.h" #include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/sdk/trace/tracer_provider_factory.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/tracer_provider.h" +#include "opentelemetry/version.h" namespace trace_api = opentelemetry::trace; namespace trace_sdk = opentelemetry::sdk::trace; From c42dcca9f82a0d008f98f03e24db8030a09adb59 Mon Sep 17 00:00:00 2001 From: Marc Alff <marc.alff@oracle.com> Date: Wed, 29 May 2024 22:01:06 +0200 Subject: [PATCH 13/17] [CI] Upgrade to clang-format 18 (#2684) --- .github/workflows/ci.yml | 2 +- CHANGELOG.md | 3 ++ .../opentelemetry/common/kv_properties.h | 2 +- .../opentelemetry/common/spin_lock_mutex.h | 4 +-- api/include/opentelemetry/logs/event_logger.h | 2 +- api/include/opentelemetry/logs/logger.h | 16 +++++----- api/include/opentelemetry/logs/provider.h | 4 +-- .../opentelemetry/nostd/detail/functional.h | 7 ++-- .../opentelemetry/nostd/detail/invoke.h | 32 +++++++++++-------- .../opentelemetry/nostd/detail/trait.h | 6 ++-- api/include/opentelemetry/nostd/unique_ptr.h | 2 +- api/include/opentelemetry/nostd/utility.h | 2 +- api/include/opentelemetry/plugin/hook.h | 14 ++++---- api/include/opentelemetry/std/utility.h | 2 +- api/include/opentelemetry/std/variant.h | 10 +++--- api/include/opentelemetry/trace/span.h | 6 ++-- api/include/opentelemetry/trace/tracer.h | 2 +- api/test/common/spinlock_benchmark.cc | 3 +- api/test/nostd/shared_ptr_test.cc | 3 +- api/test/nostd/unique_ptr_test.cc | 3 +- api/test/singleton/component_g.cc | 3 +- api/test/singleton/component_h.cc | 9 +++--- .../trace/propagation/b3_propagation_test.cc | 4 +-- api/test/trace/trace_state_test.cc | 2 +- ci/Dockerfile | 20 ------------ ci/install_format_tools.sh | 22 +++++++++++-- examples/grpc/client.cc | 8 ++--- examples/grpc/server.cc | 10 +++--- .../src/es_log_record_exporter.cc | 15 ++++----- .../exporters/etw/etw_properties.h | 4 +-- .../opentelemetry/exporters/etw/etw_tracer.h | 7 ++-- .../opentelemetry/exporters/etw/uuid.h | 6 ++-- exporters/etw/test/etw_perf_test.cc | 4 +-- exporters/ostream/src/span_exporter.cc | 9 ++---- exporters/otlp/src/otlp_grpc_client.cc | 2 +- .../otlp/test/otlp_grpc_exporter_benchmark.cc | 20 ++++++------ .../otlp_http_log_record_exporter_test.cc | 4 +-- .../http/client/curl/http_operation_curl.h | 2 +- .../ext/http/client/http_client.h | 4 +-- .../ext/http/server/socket_tools.h | 2 +- opentracing-shim/test/shim_utils_test.cc | 6 ++-- .../sdk/common/empty_attributes.h | 5 +-- .../sdk/logs/readable_log_record.h | 4 +-- .../sdk/metrics/data/circular_buffer.h | 12 +++---- .../sdk/metrics/data/point_data.h | 16 +++++----- .../sdk/metrics/state/attributes_hashmap.h | 2 +- .../opentelemetry/sdk/trace/span_data.h | 12 +++---- sdk/src/logs/read_write_log_record.cc | 4 +-- sdk/src/trace/tracer.cc | 7 ++-- .../instrumentationscope_test.cc | 4 +-- .../sync_metric_storage_counter_test.cc | 4 +-- .../sync_metric_storage_histogram_test.cc | 4 +-- sdk/test/trace/parent_sampler_test.cc | 2 +- sdk/test/trace/tracer_test.cc | 4 +-- tools/format.sh | 6 ++-- 55 files changed, 187 insertions(+), 187 deletions(-) delete mode 100644 ci/Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 055b8cfe60..32a3f784fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -726,7 +726,7 @@ jobs: format: name: Format - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: setup diff --git a/CHANGELOG.md b/CHANGELOG.md index 9381363300..27c379349f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,9 @@ Increment the: * [SDK] Update ExemplarFilter and ExemplarReservoir for spec [#2372](https://github.com/open-telemetry/opentelemetry-cpp/pull/2372) +* [CI] Upgrade to clang-format 18 + [#2684](https://github.com/open-telemetry/opentelemetry-cpp/pull/2684) + Notes on experimental features: * [#2372](https://github.com/open-telemetry/opentelemetry-cpp/issues/2372) diff --git a/api/include/opentelemetry/common/kv_properties.h b/api/include/opentelemetry/common/kv_properties.h index 00fa2571c2..b5accab403 100644 --- a/api/include/opentelemetry/common/kv_properties.h +++ b/api/include/opentelemetry/common/kv_properties.h @@ -158,7 +158,7 @@ class KeyValueProperties } // Move contructor and assignment operator - Entry(Entry &&other) = default; + Entry(Entry &&other) = default; Entry &operator=(Entry &&other) = default; // Creates an Entry for a given key-value pair. diff --git a/api/include/opentelemetry/common/spin_lock_mutex.h b/api/include/opentelemetry/common/spin_lock_mutex.h index 8cec8dfea3..369183b953 100644 --- a/api/include/opentelemetry/common/spin_lock_mutex.h +++ b/api/include/opentelemetry/common/spin_lock_mutex.h @@ -53,8 +53,8 @@ class SpinLockMutex { public: SpinLockMutex() noexcept {} - ~SpinLockMutex() noexcept = default; - SpinLockMutex(const SpinLockMutex &) = delete; + ~SpinLockMutex() noexcept = default; + SpinLockMutex(const SpinLockMutex &) = delete; SpinLockMutex &operator=(const SpinLockMutex &) = delete; static inline void fast_yield() noexcept diff --git a/api/include/opentelemetry/logs/event_logger.h b/api/include/opentelemetry/logs/event_logger.h index 988142fbe2..b5c94a7067 100644 --- a/api/include/opentelemetry/logs/event_logger.h +++ b/api/include/opentelemetry/logs/event_logger.h @@ -56,7 +56,7 @@ class EventLogger * span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes) */ template <class... ArgumentType> - void EmitEvent(nostd::string_view event_name, ArgumentType &&... args) + void EmitEvent(nostd::string_view event_name, ArgumentType &&...args) { nostd::shared_ptr<Logger> delegate_logger = GetDelegateLogger(); if (!delegate_logger) diff --git a/api/include/opentelemetry/logs/logger.h b/api/include/opentelemetry/logs/logger.h index 6448ff6901..46fd8bca72 100644 --- a/api/include/opentelemetry/logs/logger.h +++ b/api/include/opentelemetry/logs/logger.h @@ -65,7 +65,7 @@ class Logger * span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes) */ template <class... ArgumentType> - void EmitLogRecord(nostd::unique_ptr<LogRecord> &&log_record, ArgumentType &&... args) + void EmitLogRecord(nostd::unique_ptr<LogRecord> &&log_record, ArgumentType &&...args) { if (!log_record) { @@ -97,7 +97,7 @@ class Logger * span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes) */ template <class... ArgumentType> - void EmitLogRecord(ArgumentType &&... args) + void EmitLogRecord(ArgumentType &&...args) { nostd::unique_ptr<LogRecord> log_record = CreateLogRecord(); @@ -120,7 +120,7 @@ class Logger * span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes) */ template <class... ArgumentType> - void Trace(ArgumentType &&... args) noexcept + void Trace(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value, @@ -144,7 +144,7 @@ class Logger * span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes) */ template <class... ArgumentType> - void Debug(ArgumentType &&... args) noexcept + void Debug(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value, @@ -168,7 +168,7 @@ class Logger * span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes) */ template <class... ArgumentType> - void Info(ArgumentType &&... args) noexcept + void Info(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value, @@ -192,7 +192,7 @@ class Logger * span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes) */ template <class... ArgumentType> - void Warn(ArgumentType &&... args) noexcept + void Warn(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value, @@ -216,7 +216,7 @@ class Logger * span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes) */ template <class... ArgumentType> - void Error(ArgumentType &&... args) noexcept + void Error(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value, @@ -240,7 +240,7 @@ class Logger * span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes) */ template <class... ArgumentType> - void Fatal(ArgumentType &&... args) noexcept + void Fatal(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value, diff --git a/api/include/opentelemetry/logs/provider.h b/api/include/opentelemetry/logs/provider.h index bced5c97ea..8f65a1139d 100644 --- a/api/include/opentelemetry/logs/provider.h +++ b/api/include/opentelemetry/logs/provider.h @@ -73,8 +73,8 @@ class OPENTELEMETRY_EXPORT Provider return provider; } - OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr<EventLoggerProvider> - &GetEventProvider() noexcept + OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr<EventLoggerProvider> & + GetEventProvider() noexcept { static nostd::shared_ptr<EventLoggerProvider> provider(new NoopEventLoggerProvider); return provider; diff --git a/api/include/opentelemetry/nostd/detail/functional.h b/api/include/opentelemetry/nostd/detail/functional.h index 437f92f0ad..0da58dd186 100644 --- a/api/include/opentelemetry/nostd/detail/functional.h +++ b/api/include/opentelemetry/nostd/detail/functional.h @@ -7,8 +7,11 @@ #include "opentelemetry/version.h" -#define OPENTELEMETRY_RETURN(...) \ - noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) { return __VA_ARGS__; } +#define OPENTELEMETRY_RETURN(...) \ + noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) \ + { \ + return __VA_ARGS__; \ + } OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd diff --git a/api/include/opentelemetry/nostd/detail/invoke.h b/api/include/opentelemetry/nostd/detail/invoke.h index a0c010a8f9..55a943ed12 100644 --- a/api/include/opentelemetry/nostd/detail/invoke.h +++ b/api/include/opentelemetry/nostd/detail/invoke.h @@ -10,8 +10,11 @@ #include "opentelemetry/nostd/detail/void.h" #include "opentelemetry/version.h" -#define OPENTELEMETRY_RETURN(...) \ - noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) { return __VA_ARGS__; } +#define OPENTELEMETRY_RETURN(...) \ + noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) \ + { \ + return __VA_ARGS__; \ + } OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd @@ -34,7 +37,7 @@ template <> struct Invoke<true /* pmf */, 0 /* is_base_of */> { template <typename R, typename T, typename Arg, typename... Args> - inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args) + inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args) OPENTELEMETRY_RETURN((std::forward<Arg>(arg).*pmf)(std::forward<Args>(args)...)) }; @@ -42,7 +45,7 @@ template <> struct Invoke<true /* pmf */, 1 /* is_reference_wrapper */> { template <typename R, typename T, typename Arg, typename... Args> - inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args) + inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args) OPENTELEMETRY_RETURN((std::forward<Arg>(arg).get().*pmf)(std::forward<Args>(args)...)) }; @@ -50,7 +53,7 @@ template <> struct Invoke<true /* pmf */, 2 /* otherwise */> { template <typename R, typename T, typename Arg, typename... Args> - inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args) + inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args) OPENTELEMETRY_RETURN(((*std::forward<Arg>(arg)).*pmf)(std::forward<Args>(args)...)) }; @@ -79,20 +82,21 @@ struct Invoke<false /* pmo */, 2 /* otherwise */> }; template <typename R, typename T, typename Arg, typename... Args> -inline constexpr auto invoke_impl(R T::*f, Arg &&arg, Args &&... args) - OPENTELEMETRY_RETURN(Invoke<std::is_function<R>::value, - (std::is_base_of<T, decay_t<Arg>>::value - ? 0 - : is_reference_wrapper<decay_t<Arg>>::value ? 1 : 2)>:: - invoke(f, std::forward<Arg>(arg), std::forward<Args>(args)...)) +inline constexpr auto invoke_impl(R T::*f, Arg &&arg, Args &&...args) OPENTELEMETRY_RETURN( + Invoke<std::is_function<R>::value, + (std::is_base_of<T, decay_t<Arg>>::value ? 0 + : is_reference_wrapper<decay_t<Arg>>::value ? 1 + : 2)>::invoke(f, + std::forward<Arg>(arg), + std::forward<Args>(args)...)) #ifdef _MSC_VER # pragma warning(push) # pragma warning(disable : 4100) #endif - template <typename F, typename... Args> - inline constexpr auto invoke_impl(F &&f, Args &&... args) - OPENTELEMETRY_RETURN(std::forward<F>(f)(std::forward<Args>(args)...)) + template <typename F, typename... Args> + inline constexpr auto invoke_impl(F &&f, Args &&...args) + OPENTELEMETRY_RETURN(std::forward<F>(f)(std::forward<Args>(args)...)) #ifdef _MSC_VER # pragma warning(pop) #endif diff --git a/api/include/opentelemetry/nostd/detail/trait.h b/api/include/opentelemetry/nostd/detail/trait.h index 90a568c4f4..8f76fdec8b 100644 --- a/api/include/opentelemetry/nostd/detail/trait.h +++ b/api/include/opentelemetry/nostd/detail/trait.h @@ -27,9 +27,9 @@ template <typename T, class IsAvailable> inline constexpr Trait trait() { - return IsTriviallyAvailable<T>::value - ? Trait::TriviallyAvailable - : IsAvailable<T>::value ? Trait::Available : Trait::Unavailable; + return IsTriviallyAvailable<T>::value ? Trait::TriviallyAvailable + : IsAvailable<T>::value ? Trait::Available + : Trait::Unavailable; } inline constexpr Trait common_trait_impl(Trait result) diff --git a/api/include/opentelemetry/nostd/unique_ptr.h b/api/include/opentelemetry/nostd/unique_ptr.h index f864eb4f04..b3f5e61998 100644 --- a/api/include/opentelemetry/nostd/unique_ptr.h +++ b/api/include/opentelemetry/nostd/unique_ptr.h @@ -96,7 +96,7 @@ class unique_ptr return *this; } - operator std::unique_ptr<T>() &&noexcept { return std::unique_ptr<T>{release()}; } + operator std::unique_ptr<T>() && noexcept { return std::unique_ptr<T>{release()}; } operator bool() const noexcept { return ptr_ != nullptr; } diff --git a/api/include/opentelemetry/nostd/utility.h b/api/include/opentelemetry/nostd/utility.h index e7ad2d77f0..3238b0328d 100644 --- a/api/include/opentelemetry/nostd/utility.h +++ b/api/include/opentelemetry/nostd/utility.h @@ -63,7 +63,7 @@ auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size()) } template <class T, size_t N> -size_t size(T (&/* array */)[N]) noexcept +size_t size(T (& /* array */)[N]) noexcept { return N; } diff --git a/api/include/opentelemetry/plugin/hook.h b/api/include/opentelemetry/plugin/hook.h index c9597e06a0..9b18e2a6a8 100644 --- a/api/include/opentelemetry/plugin/hook.h +++ b/api/include/opentelemetry/plugin/hook.h @@ -16,13 +16,13 @@ * library and a dynamically loaded plugin. The weak linkage allows for multiple implementations to * be linked in without getting multiple definition errors. */ -# define OPENTELEMETRY_DEFINE_PLUGIN_HOOK(X) \ - extern "C" { \ - extern __declspec(dllexport) \ - opentelemetry::plugin::OpenTelemetryHook const OpenTelemetryMakeFactoryImpl; \ - \ - __declspec(selectany) \ - opentelemetry::plugin::OpenTelemetryHook const OpenTelemetryMakeFactoryImpl = X; \ +# define OPENTELEMETRY_DEFINE_PLUGIN_HOOK(X) \ + extern "C" { \ + extern __declspec(dllexport) opentelemetry::plugin::OpenTelemetryHook const \ + OpenTelemetryMakeFactoryImpl; \ + \ + __declspec(selectany) opentelemetry::plugin::OpenTelemetryHook const \ + OpenTelemetryMakeFactoryImpl = X; \ } // extern "C" #else diff --git a/api/include/opentelemetry/std/utility.h b/api/include/opentelemetry/std/utility.h index 9a1c76540b..be0f1e5f46 100644 --- a/api/include/opentelemetry/std/utility.h +++ b/api/include/opentelemetry/std/utility.h @@ -54,7 +54,7 @@ auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size()) } template <class T, std::size_t N> -std::size_t size(T (&/* array */)[N]) noexcept +std::size_t size(T (& /* array */)[N]) noexcept { return N; } diff --git a/api/include/opentelemetry/std/variant.h b/api/include/opentelemetry/std/variant.h index 30d38d9c63..6acdb81e9a 100644 --- a/api/include/opentelemetry/std/variant.h +++ b/api/include/opentelemetry/std/variant.h @@ -56,8 +56,7 @@ class bad_variant_access : public std::exception // nostd::get<...> for Apple Clang // template <typename T, class... Types> -constexpr auto get_type = [](auto &&t) constexpr -> decltype(auto) -{ +constexpr auto get_type = [](auto &&t) constexpr -> decltype(auto) { auto v = t; auto result = std::get_if<T>(&v); // TODO: optimize with std::forward(t) if t is not rvalue if (result) @@ -69,8 +68,7 @@ constexpr auto get_type = [](auto &&t) constexpr -> decltype(auto) }; template <std::size_t I, class... Types> -constexpr auto get_index = [](auto &&t) constexpr -> decltype(auto) -{ +constexpr auto get_index = [](auto &&t) constexpr -> decltype(auto) { auto v = t; auto result = std::get_if<I>(&v); // TODO: optimize with std::forward(t) if t is not rvalue if (result) @@ -132,7 +130,7 @@ constexpr const T &&get(const std::variant<Types...> &&v) }; template <class _Callable, class... _Variants> -constexpr auto visit(_Callable &&_Obj, _Variants &&... _Args) +constexpr auto visit(_Callable &&_Obj, _Variants &&..._Args) { // Ref: // https://stackoverflow.com/questions/52310835/xcode-10-call-to-unavailable-function-stdvisit @@ -193,7 +191,7 @@ constexpr const T &&get(const std::variant<Types...> &&v) } template <class _Callable, class... _Variants> -constexpr auto visit(_Callable &&_Obj, _Variants &&... _Args) +constexpr auto visit(_Callable &&_Obj, _Variants &&..._Args) { return std::visit<_Callable, _Variants...>(static_cast<_Callable &&>(_Obj), static_cast<_Variants &&>(_Args)...); diff --git a/api/include/opentelemetry/trace/span.h b/api/include/opentelemetry/trace/span.h index 27e91ceec4..f26e38e4ee 100644 --- a/api/include/opentelemetry/trace/span.h +++ b/api/include/opentelemetry/trace/span.h @@ -62,10 +62,10 @@ class Span virtual ~Span() = default; // Not copiable or movable. - Span(const Span &) = delete; - Span(Span &&) = delete; + Span(const Span &) = delete; + Span(Span &&) = delete; Span &operator=(const Span &) = delete; - Span &operator=(Span &&) = delete; + Span &operator=(Span &&) = delete; /** * Sets an attribute on the Span (ABI). diff --git a/api/include/opentelemetry/trace/tracer.h b/api/include/opentelemetry/trace/tracer.h index 82b4d0ea02..7fc758511f 100644 --- a/api/include/opentelemetry/trace/tracer.h +++ b/api/include/opentelemetry/trace/tracer.h @@ -66,7 +66,7 @@ class Tracer template <class T, class U, nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr, - nostd::enable_if_t<detail::is_span_context_kv_iterable<U>::value> * = nullptr> + nostd::enable_if_t<detail::is_span_context_kv_iterable<U>::value> * = nullptr> nostd::shared_ptr<Span> StartSpan(nostd::string_view name, const T &attributes, const U &links, diff --git a/api/test/common/spinlock_benchmark.cc b/api/test/common/spinlock_benchmark.cc index 214644cdae..d0fef2c41b 100644 --- a/api/test/common/spinlock_benchmark.cc +++ b/api/test/common/spinlock_benchmark.cc @@ -56,8 +56,7 @@ inline void SpinThrash(benchmark::State &s, SpinLockType &spinlock, LockF lock, static void BM_SpinLockThrashing(benchmark::State &s) { SpinLockMutex spinlock; - SpinThrash( - s, spinlock, [](SpinLockMutex &m) { m.lock(); }, [](SpinLockMutex &m) { m.unlock(); }); + SpinThrash(s, spinlock, [](SpinLockMutex &m) { m.lock(); }, [](SpinLockMutex &m) { m.unlock(); }); } // Naive `while(try_lock()) {}` implementation of lock. diff --git a/api/test/nostd/shared_ptr_test.cc b/api/test/nostd/shared_ptr_test.cc index 6f3d43a771..0c79c7efd2 100644 --- a/api/test/nostd/shared_ptr_test.cc +++ b/api/test/nostd/shared_ptr_test.cc @@ -129,8 +129,7 @@ TEST(SharedPtrTest, PointerOperators) shared_ptr<int> ptr1{value}; EXPECT_EQ(&*ptr1, value); - EXPECT_EQ( - shared_ptr<B> { new B }->f(), 123); + EXPECT_EQ(shared_ptr<B> { new B } -> f(), 123); } TEST(SharedPtrTest, Swap) diff --git a/api/test/nostd/unique_ptr_test.cc b/api/test/nostd/unique_ptr_test.cc index aa49d387b7..f3684be0b8 100644 --- a/api/test/nostd/unique_ptr_test.cc +++ b/api/test/nostd/unique_ptr_test.cc @@ -114,8 +114,7 @@ TEST(UniquePtrTest, PointerOperators) unique_ptr<int> ptr1{value}; EXPECT_EQ(&*ptr1, value); - EXPECT_EQ( - unique_ptr<B> { new B }->f(), 123); + EXPECT_EQ(unique_ptr<B> { new B } -> f(), 123); } TEST(UniquePtrTest, Reset) diff --git a/api/test/singleton/component_g.cc b/api/test/singleton/component_g.cc index 49732d9b1f..50de03ee98 100644 --- a/api/test/singleton/component_g.cc +++ b/api/test/singleton/component_g.cc @@ -34,7 +34,8 @@ extern "C" __declspec(dllexport) #endif - void do_something_in_g() + void + do_something_in_g() { auto scoped_span = trace::Scope(get_tracer()->StartSpan("G::library")); diff --git a/api/test/singleton/component_h.cc b/api/test/singleton/component_h.cc index b486536fc2..3ff6e0cc5a 100644 --- a/api/test/singleton/component_h.cc +++ b/api/test/singleton/component_h.cc @@ -35,12 +35,13 @@ extern "C" __declspec(dllexport) #else -// component_h is a shared library (*.so) -// component_h is compiled with visibility("hidden"), -__attribute__((visibility("default"))) + // component_h is a shared library (*.so) + // component_h is compiled with visibility("hidden"), + __attribute__((visibility("default"))) #endif - void do_something_in_h() + void + do_something_in_h() { auto scoped_span = trace::Scope(get_tracer()->StartSpan("H::library")); diff --git a/api/test/trace/propagation/b3_propagation_test.cc b/api/test/trace/propagation/b3_propagation_test.cc index 9791c54378..5546916abc 100644 --- a/api/test/trace/propagation/b3_propagation_test.cc +++ b/api/test/trace/propagation/b3_propagation_test.cc @@ -155,8 +155,8 @@ TEST(B3PropagationTest, SetRemoteSpanMultiHeader) { TextMapCarrierTest carrier; carrier.headers_ = {{"X-B3-TraceId", "80f198ee56343ba864fe8b2a57d3eff7"}, - {"X-B3-SpanId", "e457b5a2e4d86bd1"}, - {"X-B3-Sampled", "1"}}; + {"X-B3-SpanId", "e457b5a2e4d86bd1"}, + {"X-B3-Sampled", "1"}}; context::Context ctx1 = context::Context{}; context::Context ctx2 = format.Extract(carrier, ctx1); diff --git a/api/test/trace/trace_state_test.cc b/api/test/trace/trace_state_test.cc index ed6c7e8274..7f5a05cfe6 100644 --- a/api/test/trace/trace_state_test.cc +++ b/api/test/trace/trace_state_test.cc @@ -177,7 +177,7 @@ TEST(TraceStateTest, MemorySafe) nostd::string_view key_string = "test_key_1test_key_2test_key_3"; nostd::string_view val_string = "test_val_1test_val_2test_val_3"; nostd::string_view keys[kNumPairs] = {key_string.substr(0, 10), key_string.substr(10, 10), - key_string.substr(20, 10)}; + key_string.substr(20, 10)}; nostd::string_view values[kNumPairs] = {val_string.substr(0, 10), val_string.substr(10, 10), val_string.substr(20, 10)}; diff --git a/ci/Dockerfile b/ci/Dockerfile deleted file mode 100644 index 21473fce96..0000000000 --- a/ci/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -FROM ubuntu:18.04 - -WORKDIR /setup-ci - -ADD setup_ci_environment.sh /setup-ci -ADD setup_cmake.sh /setup-ci -ADD install_gcc48.sh /setup-ci -ADD install_bazelisk.sh /setup-ci -ADD install_protobuf.sh /setup-ci -ADD install_format_tools.sh /setup-ci - -RUN /setup-ci/setup_ci_environment.sh \ - && /setup-ci/setup_cmake.sh \ - && /setup-ci/install_gcc48.sh \ - && /setup-ci/install_bazelisk.sh \ - && /setup-ci/install_protobuf.sh \ - && /setup-ci/install_format_tools.sh diff --git a/ci/install_format_tools.sh b/ci/install_format_tools.sh index fc6960f9dd..3ede569da1 100755 --- a/ci/install_format_tools.sh +++ b/ci/install_format_tools.sh @@ -5,7 +5,23 @@ set -e -apt-get install -y clang-format-10 python3-pip git curl -pip3 install cmake_format==0.6.13 -curl -L -o /usr/local/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/2.2.1/buildifier +CLANG_VERSION=18 +CMAKE_FORMAT_VERSION=0.6.13 +BUILDIFIER_VERSION=3.5.0 + +# +# This script expects ubuntu:24.04 +# + +apt update + +# Install clang-format +apt install -y clang-format-${CLANG_VERSION} python3 python3-pip git curl +# ln /usr/bin/clang-format-${CLANG_VERSION} /usr/bin/clang-format + +# Install cmake_format +pip3 install --break-system-packages cmake_format==${CMAKE_FORMAT_VERSION} + +# Install buildifier +curl -L -o /usr/local/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/${BUILDIFIER_VERSION}/buildifier chmod +x /usr/local/bin/buildifier diff --git a/examples/grpc/client.cc b/examples/grpc/client.cc index 3163b38986..b8f233dcc7 100644 --- a/examples/grpc/client.cc +++ b/examples/grpc/client.cc @@ -51,10 +51,10 @@ class GreeterClient auto span = get_tracer("grpc")->StartSpan( span_name, {{SemanticConventions::kRpcSystem, "grpc"}, - {SemanticConventions::kRpcService, "grpc-example.GreetService"}, - {SemanticConventions::kRpcMethod, "Greet"}, - {SemanticConventions::kNetworkPeerAddress, ip}, - {SemanticConventions::kNetworkPeerPort, port}}, + {SemanticConventions::kRpcService, "grpc-example.GreetService"}, + {SemanticConventions::kRpcMethod, "Greet"}, + {SemanticConventions::kNetworkPeerAddress, ip}, + {SemanticConventions::kNetworkPeerPort, port}}, options); auto scope = get_tracer("grpc-client")->WithActiveSpan(span); diff --git a/examples/grpc/server.cc b/examples/grpc/server.cc index 6ba96a009e..a8fac8b5f0 100644 --- a/examples/grpc/server.cc +++ b/examples/grpc/server.cc @@ -68,11 +68,11 @@ class GreeterServer final : public Greeter::Service std::string span_name = "GreeterService/Greet"; auto span = get_tracer("grpc")->StartSpan(span_name, - {{SemanticConventions::kRpcSystem, "grpc"}, - {SemanticConventions::kRpcService, "GreeterService"}, - {SemanticConventions::kRpcMethod, "Greet"}, - {SemanticConventions::kRpcGrpcStatusCode, 0}}, - options); + {{SemanticConventions::kRpcSystem, "grpc"}, + {SemanticConventions::kRpcService, "GreeterService"}, + {SemanticConventions::kRpcMethod, "Greet"}, + {SemanticConventions::kRpcGrpcStatusCode, 0}}, + options); auto scope = get_tracer("grpc")->WithActiveSpan(span); // Fetch and parse whatever HTTP headers we can from the gRPC request. diff --git a/exporters/elasticsearch/src/es_log_record_exporter.cc b/exporters/elasticsearch/src/es_log_record_exporter.cc index 196474ba77..e58fb1dda4 100644 --- a/exporters/elasticsearch/src/es_log_record_exporter.cc +++ b/exporters/elasticsearch/src/es_log_record_exporter.cc @@ -288,12 +288,11 @@ class AsyncResponseHandler : public http_client::EventHandler #endif ElasticsearchLogRecordExporter::ElasticsearchLogRecordExporter() - : options_{ElasticsearchExporterOptions()}, http_client_ -{ - ext::http::client::HttpClientFactory::Create() -} + : options_{ElasticsearchExporterOptions()}, + http_client_{ext::http::client::HttpClientFactory::Create()} #ifdef ENABLE_ASYNC_EXPORT -, synchronization_data_(new SynchronizationData()) + , + synchronization_data_(new SynchronizationData()) #endif { #ifdef ENABLE_ASYNC_EXPORT @@ -360,13 +359,13 @@ sdk::common::ExportResult ElasticsearchLogRecordExporter::Export( if (result != opentelemetry::sdk::common::ExportResult::kSuccess) { OTEL_INTERNAL_LOG_ERROR("[ES Log Exporter] ERROR: Export " - << span_count - << " trace span(s) error: " << static_cast<int>(result)); + << span_count + << " trace span(s) error: " << static_cast<int>(result)); } else { OTEL_INTERNAL_LOG_DEBUG("[ES Log Exporter] Export " << span_count - << " trace span(s) success"); + << " trace span(s) success"); } synchronization_data->finished_session_counter_.fetch_add(1, std::memory_order_release); diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h index b2de664d12..3a14780d8c 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h @@ -223,8 +223,8 @@ class PropertyValue : public PropertyVariant break; } case opentelemetry::common::AttributeType::kTypeString: { - PropertyVariant::operator= - (std::string{nostd::string_view(nostd::get<nostd::string_view>(v)).data()}); + PropertyVariant::operator=( + std::string{nostd::string_view(nostd::get<nostd::string_view>(v)).data()}); break; } diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h index 454f6cff5a..9071fd47d4 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h @@ -485,10 +485,9 @@ class Tracer : public opentelemetry::trace::Tracer, auto spanContext = std::unique_ptr<opentelemetry::trace::SpanContext>(new opentelemetry::trace::SpanContext( traceId, GetIdGenerator(tracerProvider_).GenerateSpanId(), traceFlags, false, - sampling_result.trace_state - ? sampling_result.trace_state - : parentContext.IsValid() ? parentContext.trace_state() - : opentelemetry::trace::TraceState::GetDefault())); + sampling_result.trace_state ? sampling_result.trace_state + : parentContext.IsValid() ? parentContext.trace_state() + : opentelemetry::trace::TraceState::GetDefault())); if (sampling_result.decision == sdk::trace::Decision::DROP) { diff --git a/exporters/etw/include/opentelemetry/exporters/etw/uuid.h b/exporters/etw/include/opentelemetry/exporters/etw/uuid.h index a004aec9e3..dfe749d831 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/uuid.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/uuid.h @@ -257,15 +257,15 @@ struct UUID void to_bytes(uint8_t (&guid_bytes)[16]) const { // Part 1 - guid_bytes[0] = (uint8_t)((Data1)&0xFF); + guid_bytes[0] = (uint8_t)((Data1) & 0xFF); guid_bytes[1] = (uint8_t)((Data1 >> 8) & 0xFF); guid_bytes[2] = (uint8_t)((Data1 >> 16) & 0xFF); guid_bytes[3] = (uint8_t)((Data1 >> 24) & 0xFF); // Part 2 - guid_bytes[4] = (uint8_t)((Data2)&0xFF); + guid_bytes[4] = (uint8_t)((Data2) & 0xFF); guid_bytes[5] = (uint8_t)((Data2 >> 8) & 0xFF); // Part 3 - guid_bytes[6] = (uint8_t)((Data3)&0xFF); + guid_bytes[6] = (uint8_t)((Data3) & 0xFF); guid_bytes[7] = (uint8_t)((Data3 >> 8) & 0xFF); // Part 4 for (size_t i = 0; i < 8; i++) diff --git a/exporters/etw/test/etw_perf_test.cc b/exporters/etw/test/etw_perf_test.cc index 79052464e8..06af94a5af 100644 --- a/exporters/etw/test/etw_perf_test.cc +++ b/exporters/etw/test/etw_perf_test.cc @@ -62,8 +62,8 @@ class ETWProviderStressTest { std::string eventName = "MyEvent"; Properties event = {{"uint32Key", (uint32_t)1234}, - {"uint64Key", (uint64_t)1234567890}, - {"strKey", "someValue"}}; + {"uint64Key", (uint64_t)1234567890}, + {"strKey", "someValue"}}; span_->AddEvent(eventName, event); return true; } diff --git a/exporters/ostream/src/span_exporter.cc b/exporters/ostream/src/span_exporter.cc index 2e6186b6f7..4faa6854be 100644 --- a/exporters/ostream/src/span_exporter.cc +++ b/exporters/ostream/src/span_exporter.cc @@ -70,8 +70,7 @@ sdk::common::ExportResult OStreamSpanExporter::Export( span->GetSpanId().ToLowerBase16(span_id); span->GetParentSpanId().ToLowerBase16(parent_span_id); - sout_ << "{" - << "\n name : " << span->GetName() + sout_ << "{" << "\n name : " << span->GetName() << "\n trace_id : " << std::string(trace_id, 32) << "\n span_id : " << std::string(span_id, 16) << "\n tracestate : " << span->GetSpanContext().trace_state()->ToHeader() @@ -130,8 +129,7 @@ void OStreamSpanExporter::printEvents(const std::vector<trace_sdk::SpanDataEvent { for (const auto &event : events) { - sout_ << "\n\t{" - << "\n\t name : " << event.GetName() + sout_ << "\n\t{" << "\n\t name : " << event.GetName() << "\n\t timestamp : " << event.GetTimestamp().time_since_epoch().count() << "\n\t attributes : "; printAttributes(event.GetAttributes(), "\n\t\t"); @@ -147,8 +145,7 @@ void OStreamSpanExporter::printLinks(const std::vector<trace_sdk::SpanDataLink> char span_id[16] = {0}; link.GetSpanContext().trace_id().ToLowerBase16(trace_id); link.GetSpanContext().span_id().ToLowerBase16(span_id); - sout_ << "\n\t{" - << "\n\t trace_id : " << std::string(trace_id, 32) + sout_ << "\n\t{" << "\n\t trace_id : " << std::string(trace_id, 32) << "\n\t span_id : " << std::string(span_id, 16) << "\n\t tracestate : " << link.GetSpanContext().trace_state()->ToHeader() << "\n\t attributes : "; diff --git a/exporters/otlp/src/otlp_grpc_client.cc b/exporters/otlp/src/otlp_grpc_client.cc index 90bbd41938..3410726cf8 100644 --- a/exporters/otlp/src/otlp_grpc_client.cc +++ b/exporters/otlp/src/otlp_grpc_client.cc @@ -311,7 +311,7 @@ std::shared_ptr<grpc::Channel> OtlpGrpcClient::MakeChannel(const OtlpGrpcClientO ssl_opts.pem_private_key = GetFileContentsOrInMemoryContents(options.ssl_client_key_path, options.ssl_client_key_string); ssl_opts.pem_cert_chain = GetFileContentsOrInMemoryContents(options.ssl_client_cert_path, - options.ssl_client_cert_string); + options.ssl_client_cert_string); #endif channel = diff --git a/exporters/otlp/test/otlp_grpc_exporter_benchmark.cc b/exporters/otlp/test/otlp_grpc_exporter_benchmark.cc index e03985e3ae..53ea48800f 100644 --- a/exporters/otlp/test/otlp_grpc_exporter_benchmark.cc +++ b/exporters/otlp/test/otlp_grpc_exporter_benchmark.cc @@ -40,7 +40,7 @@ const trace::SpanId kSpanId(std::array<const uint8_t, trace::SpanId::kSize>({0, 2})); const trace::SpanId kParentSpanId(std::array<const uint8_t, trace::SpanId::kSize>({0, 0, 0, 0, 0, 0, 0, 3})); -const auto kTraceState = trace_api::TraceState::GetDefault() -> Set("key1", "value"); +const auto kTraceState = trace_api::TraceState::GetDefault()->Set("key1", "value"); const trace_api::SpanContext kSpanContext{ kTraceId, kSpanId, trace_api::TraceFlags{trace_api::TraceFlags::kIsSampled}, true, kTraceState}; @@ -109,18 +109,20 @@ class FakeServiceStub : public proto::collector::trace::v1::TraceService::StubIn return grpc::Status::OK; } - grpc::ClientAsyncResponseReaderInterface<proto::collector::trace::v1::ExportTraceServiceResponse> - *AsyncExportRaw(grpc::ClientContext *, - const proto::collector::trace::v1::ExportTraceServiceRequest &, - grpc::CompletionQueue *) override + grpc::ClientAsyncResponseReaderInterface< + proto::collector::trace::v1::ExportTraceServiceResponse> * + AsyncExportRaw(grpc::ClientContext *, + const proto::collector::trace::v1::ExportTraceServiceRequest &, + grpc::CompletionQueue *) override { return nullptr; } - grpc::ClientAsyncResponseReaderInterface<proto::collector::trace::v1::ExportTraceServiceResponse> - *PrepareAsyncExportRaw(grpc::ClientContext *, - const proto::collector::trace::v1::ExportTraceServiceRequest &, - grpc::CompletionQueue *) override + grpc::ClientAsyncResponseReaderInterface< + proto::collector::trace::v1::ExportTraceServiceResponse> * + PrepareAsyncExportRaw(grpc::ClientContext *, + const proto::collector::trace::v1::ExportTraceServiceRequest &, + grpc::CompletionQueue *) override { return nullptr; } 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 8f2c2409eb..5fbf95798f 100644 --- a/exporters/otlp/test/otlp_http_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_log_record_exporter_test.cc @@ -133,7 +133,7 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test char trace_id_hex[2 * opentelemetry::trace::TraceId::kSize] = {0}; opentelemetry::trace::TraceId trace_id{trace_id_bin}; uint8_t span_id_bin[opentelemetry::trace::SpanId::kSize] = {'7', '6', '5', '4', - '3', '2', '1', '0'}; + '3', '2', '1', '0'}; char span_id_hex[2 * opentelemetry::trace::SpanId::kSize] = {0}; opentelemetry::trace::SpanId span_id{span_id_bin}; @@ -250,7 +250,7 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test char trace_id_hex[2 * opentelemetry::trace::TraceId::kSize] = {0}; opentelemetry::trace::TraceId trace_id{trace_id_bin}; uint8_t span_id_bin[opentelemetry::trace::SpanId::kSize] = {'7', '6', '5', '4', - '3', '2', '1', '0'}; + '3', '2', '1', '0'}; char span_id_hex[2 * opentelemetry::trace::SpanId::kSize] = {0}; opentelemetry::trace::SpanId span_id{span_id_bin}; diff --git a/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h b/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h index e32d590bdb..58dd154bb7 100644 --- a/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h +++ b/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h @@ -70,7 +70,7 @@ struct HttpCurlEasyResource return *this; } - HttpCurlEasyResource(const HttpCurlEasyResource &other) = delete; + HttpCurlEasyResource(const HttpCurlEasyResource &other) = delete; HttpCurlEasyResource &operator=(const HttpCurlEasyResource &other) = delete; }; diff --git a/ext/include/opentelemetry/ext/http/client/http_client.h b/ext/include/opentelemetry/ext/http/client/http_client.h index 0615284836..b3cf7365eb 100644 --- a/ext/include/opentelemetry/ext/http/client/http_client.h +++ b/ext/include/opentelemetry/ext/http/client/http_client.h @@ -379,13 +379,13 @@ class HttpClientSync virtual Result Get(const nostd::string_view &url, const HttpSslOptions &ssl_options, - const Headers & = {{}}, + const Headers & = {{}}, const Compression &compression = Compression::kNone) noexcept = 0; virtual Result Post(const nostd::string_view &url, const HttpSslOptions &ssl_options, const Body &body, - const Headers & = {{"content-type", "application/json"}}, + const Headers & = {{"content-type", "application/json"}}, const Compression &compression = Compression::kNone) noexcept = 0; virtual ~HttpClientSync() = default; diff --git a/ext/include/opentelemetry/ext/http/server/socket_tools.h b/ext/include/opentelemetry/ext/http/server/socket_tools.h index bb6302bac8..bad76e640a 100644 --- a/ext/include/opentelemetry/ext/http/server/socket_tools.h +++ b/ext/include/opentelemetry/ext/http/server/socket_tools.h @@ -16,7 +16,7 @@ #ifdef _WIN32 -//# include <Windows.h> +// # include <Windows.h> # include <winsock2.h> diff --git a/opentracing-shim/test/shim_utils_test.cc b/opentracing-shim/test/shim_utils_test.cc index aa2316f2d2..d053273984 100644 --- a/opentracing-shim/test/shim_utils_test.cc +++ b/opentracing-shim/test/shim_utils_test.cc @@ -141,8 +141,8 @@ TEST(ShimUtilsTest, MakeOptionsShim_FirstChildOf) options.start_system_timestamp = opentracing::SystemTime::time_point::clock::now(); options.start_steady_timestamp = opentracing::SteadyTime::time_point::clock::now(); options.references = {{opentracing::SpanReferenceType::FollowsFromRef, nullptr}, - {opentracing::SpanReferenceType::ChildOfRef, span_context}, - {opentracing::SpanReferenceType::ChildOfRef, nullptr}}; + {opentracing::SpanReferenceType::ChildOfRef, span_context}, + {opentracing::SpanReferenceType::ChildOfRef, nullptr}}; auto options_shim = shim::utils::makeOptionsShim(options); ASSERT_EQ(options_shim.start_system_time, @@ -162,7 +162,7 @@ TEST(ShimUtilsTest, MakeOptionsShim_FirstInList) options.start_system_timestamp = opentracing::SystemTime::time_point::clock::now(); options.start_steady_timestamp = opentracing::SteadyTime::time_point::clock::now(); options.references = {{opentracing::SpanReferenceType::FollowsFromRef, span_context}, - {opentracing::SpanReferenceType::FollowsFromRef, nullptr}}; + {opentracing::SpanReferenceType::FollowsFromRef, nullptr}}; auto options_shim = shim::utils::makeOptionsShim(options); ASSERT_EQ(options_shim.start_system_time, diff --git a/sdk/include/opentelemetry/sdk/common/empty_attributes.h b/sdk/include/opentelemetry/sdk/common/empty_attributes.h index 1e0a6393bd..0afe439ee6 100644 --- a/sdk/include/opentelemetry/sdk/common/empty_attributes.h +++ b/sdk/include/opentelemetry/sdk/common/empty_attributes.h @@ -20,8 +20,9 @@ namespace sdk * This helps to avoid constructing a new empty container every time a call is made * with default attributes. */ -static const opentelemetry::common::KeyValueIterableView<std::array<std::pair<std::string, int>, 0>> - &GetEmptyAttributes() noexcept +static const opentelemetry::common::KeyValueIterableView< + std::array<std::pair<std::string, int>, 0>> & +GetEmptyAttributes() noexcept { static const std::array<std::pair<std::string, int>, 0> array{}; static const opentelemetry::common::KeyValueIterableView< diff --git a/sdk/include/opentelemetry/sdk/logs/readable_log_record.h b/sdk/include/opentelemetry/sdk/logs/readable_log_record.h index acec5b88f9..a8f366b5b7 100644 --- a/sdk/include/opentelemetry/sdk/logs/readable_log_record.h +++ b/sdk/include/opentelemetry/sdk/logs/readable_log_record.h @@ -107,8 +107,8 @@ class ReadableLogRecord : public Recordable * Get attributes of this log. * @return the body field of this log */ - virtual const std::unordered_map<std::string, opentelemetry::common::AttributeValue> - &GetAttributes() const noexcept = 0; + virtual const std::unordered_map<std::string, opentelemetry::common::AttributeValue> & + GetAttributes() const noexcept = 0; /** * Get resource of this log diff --git a/sdk/include/opentelemetry/sdk/metrics/data/circular_buffer.h b/sdk/include/opentelemetry/sdk/metrics/data/circular_buffer.h index 26f272f837..32605dfd68 100644 --- a/sdk/include/opentelemetry/sdk/metrics/data/circular_buffer.h +++ b/sdk/include/opentelemetry/sdk/metrics/data/circular_buffer.h @@ -31,10 +31,10 @@ class AdaptingIntegerArray public: // Construct an adapting integer array of a given size. explicit AdaptingIntegerArray(size_t size) : backing_(std::vector<uint8_t>(size, 0)) {} - AdaptingIntegerArray(const AdaptingIntegerArray &other) = default; - AdaptingIntegerArray(AdaptingIntegerArray &&other) = default; + AdaptingIntegerArray(const AdaptingIntegerArray &other) = default; + AdaptingIntegerArray(AdaptingIntegerArray &&other) = default; AdaptingIntegerArray &operator=(const AdaptingIntegerArray &other) = default; - AdaptingIntegerArray &operator=(AdaptingIntegerArray &&other) = default; + AdaptingIntegerArray &operator=(AdaptingIntegerArray &&other) = default; /** * Increments the value at the specified index by the given count in the array. @@ -87,10 +87,10 @@ class AdaptingCircularBufferCounter { public: explicit AdaptingCircularBufferCounter(size_t max_size) : backing_(max_size) {} - AdaptingCircularBufferCounter(const AdaptingCircularBufferCounter &other) = default; - AdaptingCircularBufferCounter(AdaptingCircularBufferCounter &&other) = default; + AdaptingCircularBufferCounter(const AdaptingCircularBufferCounter &other) = default; + AdaptingCircularBufferCounter(AdaptingCircularBufferCounter &&other) = default; AdaptingCircularBufferCounter &operator=(const AdaptingCircularBufferCounter &other) = default; - AdaptingCircularBufferCounter &operator=(AdaptingCircularBufferCounter &&other) = default; + AdaptingCircularBufferCounter &operator=(AdaptingCircularBufferCounter &&other) = default; /** * The first index with a recording. May be negative. diff --git a/sdk/include/opentelemetry/sdk/metrics/data/point_data.h b/sdk/include/opentelemetry/sdk/metrics/data/point_data.h index 9bf82e040a..32853316a5 100644 --- a/sdk/include/opentelemetry/sdk/metrics/data/point_data.h +++ b/sdk/include/opentelemetry/sdk/metrics/data/point_data.h @@ -23,8 +23,8 @@ class SumPointData { public: // TODO: remove ctors and initializers when GCC<5 stops shipping on Ubuntu - SumPointData(SumPointData &&) = default; - SumPointData(const SumPointData &) = default; + SumPointData(SumPointData &&) = default; + SumPointData(const SumPointData &) = default; SumPointData &operator=(SumPointData &&) = default; SumPointData() = default; @@ -36,8 +36,8 @@ class LastValuePointData { public: // TODO: remove ctors and initializers when GCC<5 stops shipping on Ubuntu - LastValuePointData(LastValuePointData &&) = default; - LastValuePointData(const LastValuePointData &) = default; + LastValuePointData(LastValuePointData &&) = default; + LastValuePointData(const LastValuePointData &) = default; LastValuePointData &operator=(LastValuePointData &&) = default; LastValuePointData() = default; @@ -50,7 +50,7 @@ class HistogramPointData { public: // TODO: remove ctors and initializers when GCC<5 stops shipping on Ubuntu - HistogramPointData(HistogramPointData &&) = default; + HistogramPointData(HistogramPointData &&) = default; HistogramPointData &operator=(HistogramPointData &&) = default; HistogramPointData(const HistogramPointData &) = default; HistogramPointData() = default; @@ -68,9 +68,9 @@ class DropPointData { public: // TODO: remove ctors and initializers when GCC<5 stops shipping on Ubuntu - DropPointData(DropPointData &&) = default; - DropPointData(const DropPointData &) = default; - DropPointData() = default; + DropPointData(DropPointData &&) = default; + DropPointData(const DropPointData &) = default; + DropPointData() = default; DropPointData &operator=(DropPointData &&) = default; }; diff --git a/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h b/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h index 43c67cb804..a509080318 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h @@ -28,7 +28,7 @@ const std::string kAttributesLimitOverflowKey = "otel.metrics.overflow"; const bool kAttributesLimitOverflowValue = true; const size_t kOverflowAttributesHash = opentelemetry::sdk::common::GetHashForAttributeMap( {{kAttributesLimitOverflowKey, - kAttributesLimitOverflowValue}}); // precalculated for optimization + kAttributesLimitOverflowValue}}); // precalculated for optimization class AttributeHashGenerator { diff --git a/sdk/include/opentelemetry/sdk/trace/span_data.h b/sdk/include/opentelemetry/sdk/trace/span_data.h index a7f8ccc4be..8e301c1a01 100644 --- a/sdk/include/opentelemetry/sdk/trace/span_data.h +++ b/sdk/include/opentelemetry/sdk/trace/span_data.h @@ -55,8 +55,8 @@ class SpanDataEvent * Get the attributes for this event * @return the attributes for this event */ - const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue> - &GetAttributes() const noexcept + const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue> & + GetAttributes() const noexcept { return attribute_map_.GetAttributes(); } @@ -82,8 +82,8 @@ class SpanDataLink * Get the attributes for this link * @return the attributes for this link */ - const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue> - &GetAttributes() const noexcept + const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue> & + GetAttributes() const noexcept { return attribute_map_.GetAttributes(); } @@ -218,8 +218,8 @@ class SpanData final : public Recordable * Get the attributes for this span * @return the attributes for this span */ - const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue> - &GetAttributes() const noexcept + const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue> & + GetAttributes() const noexcept { return attribute_map_.GetAttributes(); } diff --git a/sdk/src/logs/read_write_log_record.cc b/sdk/src/logs/read_write_log_record.cc index 1c2aabffe7..27dd8f7d5f 100644 --- a/sdk/src/logs/read_write_log_record.cc +++ b/sdk/src/logs/read_write_log_record.cc @@ -150,8 +150,8 @@ void ReadWriteLogRecord::SetAttribute(nostd::string_view key, attributes_map_[static_cast<std::string>(key)] = value; } -const std::unordered_map<std::string, opentelemetry::common::AttributeValue> - &ReadWriteLogRecord::GetAttributes() const noexcept +const std::unordered_map<std::string, opentelemetry::common::AttributeValue> & +ReadWriteLogRecord::GetAttributes() const noexcept { return attributes_map_; } diff --git a/sdk/src/trace/tracer.cc b/sdk/src/trace/tracer.cc index 2b38c5d3ca..f23ce5f628 100644 --- a/sdk/src/trace/tracer.cc +++ b/sdk/src/trace/tracer.cc @@ -122,10 +122,9 @@ nostd::shared_ptr<opentelemetry::trace::Span> Tracer::StartSpan( auto span_context = std::unique_ptr<opentelemetry::trace::SpanContext>(new opentelemetry::trace::SpanContext( trace_id, span_id, trace_flags, false, - sampling_result.trace_state - ? sampling_result.trace_state - : is_parent_span_valid ? parent_context.trace_state() - : opentelemetry::trace::TraceState::GetDefault())); + sampling_result.trace_state ? sampling_result.trace_state + : is_parent_span_valid ? parent_context.trace_state() + : opentelemetry::trace::TraceState::GetDefault())); if (!sampling_result.IsRecording()) { diff --git a/sdk/test/instrumentationscope/instrumentationscope_test.cc b/sdk/test/instrumentationscope/instrumentationscope_test.cc index 50800fd136..2f376d5d6b 100644 --- a/sdk/test/instrumentationscope/instrumentationscope_test.cc +++ b/sdk/test/instrumentationscope/instrumentationscope_test.cc @@ -22,8 +22,8 @@ TEST(InstrumentationScope, CreateInstrumentationScope) auto instrumentation_scope = InstrumentationScope::Create( library_name, library_version, schema_url, {{"attribute-key1", "attribute-value"}, - {"attribute-key2", static_cast<int32_t>(123)}, - {"attribute-key3", opentelemetry::nostd::span<uint32_t>(attrubite_value3)}}); + {"attribute-key2", static_cast<int32_t>(123)}, + {"attribute-key3", opentelemetry::nostd::span<uint32_t>(attrubite_value3)}}); EXPECT_EQ(instrumentation_scope->GetName(), library_name); EXPECT_EQ(instrumentation_scope->GetVersion(), library_version); diff --git a/sdk/test/metrics/sync_metric_storage_counter_test.cc b/sdk/test/metrics/sync_metric_storage_counter_test.cc index 220abe6b94..2593b69719 100644 --- a/sdk/test/metrics/sync_metric_storage_counter_test.cc +++ b/sdk/test/metrics/sync_metric_storage_counter_test.cc @@ -35,7 +35,7 @@ TEST_P(WritableMetricStorageTestFixture, LongCounterSumAggregation) int64_t expected_total_get_requests = 0; int64_t expected_total_put_requests = 0; InstrumentDescriptor instr_desc = {"name", "desc", "1unit", InstrumentType::kCounter, - InstrumentValueType::kLong}; + InstrumentValueType::kLong}; std::map<std::string, std::string> attributes_get = {{"RequestType", "GET"}}; std::map<std::string, std::string> attributes_put = {{"RequestType", "PUT"}}; @@ -175,7 +175,7 @@ TEST_P(WritableMetricStorageTestFixture, DoubleCounterSumAggregation) double expected_total_get_requests = 0; double expected_total_put_requests = 0; InstrumentDescriptor instr_desc = {"name", "desc", "1unit", InstrumentType::kCounter, - InstrumentValueType::kDouble}; + InstrumentValueType::kDouble}; std::map<std::string, std::string> attributes_get = {{"RequestType", "GET"}}; std::map<std::string, std::string> attributes_put = {{"RequestType", "PUT"}}; diff --git a/sdk/test/metrics/sync_metric_storage_histogram_test.cc b/sdk/test/metrics/sync_metric_storage_histogram_test.cc index 5ded7f3b46..71a16b85c6 100644 --- a/sdk/test/metrics/sync_metric_storage_histogram_test.cc +++ b/sdk/test/metrics/sync_metric_storage_histogram_test.cc @@ -35,7 +35,7 @@ TEST_P(WritableMetricStorageHistogramTestFixture, LongHistogram) int64_t expected_total_get_requests = 0; int64_t expected_total_put_requests = 0; InstrumentDescriptor instr_desc = {"name", "desc", "1unit", InstrumentType::kHistogram, - InstrumentValueType::kLong}; + InstrumentValueType::kLong}; std::map<std::string, std::string> attributes_get = {{"RequestType", "GET"}}; std::map<std::string, std::string> attributes_put = {{"RequestType", "PUT"}}; @@ -176,7 +176,7 @@ TEST_P(WritableMetricStorageHistogramTestFixture, DoubleHistogram) double expected_total_get_requests = 0; double expected_total_put_requests = 0; InstrumentDescriptor instr_desc = {"name", "desc", "1unit", InstrumentType::kHistogram, - InstrumentValueType::kDouble}; + InstrumentValueType::kDouble}; std::map<std::string, std::string> attributes_get = {{"RequestType", "GET"}}; std::map<std::string, std::string> attributes_put = {{"RequestType", "PUT"}}; diff --git a/sdk/test/trace/parent_sampler_test.cc b/sdk/test/trace/parent_sampler_test.cc index 124287598d..7d2ef7f107 100644 --- a/sdk/test/trace/parent_sampler_test.cc +++ b/sdk/test/trace/parent_sampler_test.cc @@ -42,7 +42,7 @@ TEST(ParentBasedSampler, ShouldSample) // Case 1: Parent doesn't exist. Return result of delegateSampler() auto sampling_result = sampler_off.ShouldSample(trace_api::SpanContext::GetInvalid(), trace_id, - "", span_kind, view, links); + "", span_kind, view, links); auto sampling_result2 = sampler_on.ShouldSample(trace_api::SpanContext::GetInvalid(), trace_id, "", span_kind, view, links); diff --git a/sdk/test/trace/tracer_test.cc b/sdk/test/trace/tracer_test.cc index a84a0125c1..99bab95b0f 100644 --- a/sdk/test/trace/tracer_test.cc +++ b/sdk/test/trace/tracer_test.cc @@ -109,8 +109,8 @@ std::shared_ptr<opentelemetry::trace::Tracer> initTracer( processors.push_back(std::move(processor)); auto resource = Resource::Create({}); auto context = std::make_shared<TracerContext>(std::move(processors), resource, - std::unique_ptr<Sampler>(sampler), - std::unique_ptr<IdGenerator>(id_generator)); + std::unique_ptr<Sampler>(sampler), + std::unique_ptr<IdGenerator>(id_generator)); return std::shared_ptr<opentelemetry::trace::Tracer>(new Tracer(context)); } diff --git a/tools/format.sh b/tools/format.sh index 5b4e91277d..65728b385f 100755 --- a/tools/format.sh +++ b/tools/format.sh @@ -26,11 +26,11 @@ fi # No trailing spaces. "${SED[@]}" 's/ \+$//' $($FIND -type f -print) -# If not overridden, try to use clang-format-10 or clang-format. +# If not overridden, try to use clang-format-18 or clang-format. if [[ -z "$CLANG_FORMAT" ]]; then CLANG_FORMAT=clang-format - if which clang-format-10 >/dev/null; then - CLANG_FORMAT=clang-format-10 + if which clang-format-18 >/dev/null; then + CLANG_FORMAT=clang-format-18 fi fi From c5269cd1d2a8e6295abd175bae6e0d528a97dd1a Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin <lalit_fin@yahoo.com> Date: Thu, 30 May 2024 13:41:04 -0700 Subject: [PATCH 14/17] [CI] Fix CI failures on Ubuntu 24.04 (#2686) --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32a3f784fd..fcdf4f0ed8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,7 @@ jobs: CXX: /usr/bin/g++-14 PROTOBUF_VERSION: 21.12 run: | + sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/install_protobuf.sh @@ -73,6 +74,7 @@ jobs: CXX: /usr/bin/g++-14 PROTOBUF_VERSION: 21.12 run: | + sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/install_protobuf.sh @@ -105,6 +107,7 @@ jobs: CXX: /usr/bin/clang++-18 PROTOBUF_VERSION: 21.12 run: | + sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/install_protobuf.sh @@ -137,6 +140,7 @@ jobs: CXX: /usr/bin/clang++-18 PROTOBUF_VERSION: 21.12 run: | + sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/install_protobuf.sh @@ -169,6 +173,7 @@ jobs: CXX: /usr/bin/clang++-18 PROTOBUF_VERSION: 21.12 run: | + sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/install_protobuf.sh @@ -730,7 +735,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: setup - run: sudo ./ci/install_format_tools.sh + run: sudo apt remove needrestart && sudo ./ci/install_format_tools.sh #refer: https://github.com/actions/runner-images/issues/9937 - name: run tests run: ./ci/do_ci.sh format From 4f37503105d1572423e161ca171ac8d046d66341 Mon Sep 17 00:00:00 2001 From: Marc Alff <marc.alff@oracle.com> Date: Fri, 31 May 2024 20:48:54 +0200 Subject: [PATCH 15/17] [SEMANTIC CONVENTIONS] Upgrade to version 1.26.0 (#2687) --- .../trace/semantic_conventions.h | 2582 ++++++++++------- buildscripts/semantic-convention/generate.sh | 2 +- .../templates/SemanticAttributes.h.j2 | 11 + .../sdk/resource/semantic_conventions.h | 2335 ++++++++++----- 4 files changed, 3151 insertions(+), 1779 deletions(-) diff --git a/api/include/opentelemetry/trace/semantic_conventions.h b/api/include/opentelemetry/trace/semantic_conventions.h index ba783e2333..a9290bff44 100644 --- a/api/include/opentelemetry/trace/semantic_conventions.h +++ b/api/include/opentelemetry/trace/semantic_conventions.h @@ -22,89 +22,14 @@ namespace SemanticConventions /** * The URL of the OpenTelemetry schema for these keys and values. */ -static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.25.0"; +static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.26.0"; /** - * Identifies the class / type of event. - * - * <p>Notes: - <ul> <li>Event names are subject to the same rules as <a - href="https://github.com/open-telemetry/opentelemetry-specification/tree/v1.31.0/specification/common/attribute-naming.md">attribute - names</a>. Notably, event names are namespaced to avoid collisions and provide a clean separation - of semantics for events in separate domains like browser, mobile, and kubernetes.</li> </ul> - */ -static constexpr const char *kEventName = "event.name"; - -/** - * A unique identifier for the Log Record. - * - * <p>Notes: - <ul> <li>If an id is provided, other log records with the same id will be considered duplicates -and can be removed safely. This means, that two distinguishable log records MUST have different -values. The id MAY be an <a href="https://github.com/ulid/spec">Universally Unique Lexicographically -Sortable Identifier (ULID)</a>, but other identifiers (e.g. UUID) may be used as needed.</li> </ul> - */ -static constexpr const char *kLogRecordUid = "log.record.uid"; - -/** - * The stream associated with the log. See below for a list of well-known values. - */ -static constexpr const char *kLogIostream = "log.iostream"; - -/** - * The basename of the file. - */ -static constexpr const char *kLogFileName = "log.file.name"; - -/** - * The basename of the file, with symlinks resolved. - */ -static constexpr const char *kLogFileNameResolved = "log.file.name_resolved"; - -/** - * The full path to the file. - */ -static constexpr const char *kLogFilePath = "log.file.path"; - -/** - * The full path to the file, with symlinks resolved. - */ -static constexpr const char *kLogFilePathResolved = "log.file.path_resolved"; - -/** - * This attribute represents the state the application has transitioned into at the occurrence of - the event. - * - * <p>Notes: - <ul> <li>The iOS lifecycle states are defined in the <a - href="https://developer.apple.com/documentation/uikit/uiapplicationdelegate#1656902">UIApplicationDelegate - documentation</a>, and from which the {@code OS terminology} column values are derived.</li> </ul> - */ -static constexpr const char *kIosState = "ios.state"; - -/** - * This attribute represents the state the application has transitioned into at the occurrence of - the event. - * - * <p>Notes: - <ul> <li>The Android lifecycle states are defined in <a - href="https://developer.android.com/guide/components/activities/activity-lifecycle#lc">Activity - lifecycle callbacks</a>, and from which the {@code OS identifiers} are derived.</li> </ul> - */ -static constexpr const char *kAndroidState = "android.state"; - -/** - * The name of the connection pool; unique within the instrumented application. In case the - * connection pool implementation doesn't provide a name, instrumentation should use a combination - * of {@code server.address} and {@code server.port} attributes formatted as {@code - * server.address:server.port}. - */ -static constexpr const char *kPoolName = "pool.name"; - -/** - * The state of a connection in the pool + * Uniquely identifies the framework API revision offered by a version ({@code os.version}) of the + * android operating system. More information can be found <a + * href="https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels">here</a>. */ -static constexpr const char *kState = "state"; +static constexpr const char *kAndroidOsApiLevel = "android.os.api_level"; /** * Rate-limiting result, shows whether the lease was acquired or contains a rejection reason @@ -119,6 +44,12 @@ static constexpr const char *kAspnetcoreRateLimitingResult = "aspnetcore.rate_li static constexpr const char *kAspnetcoreDiagnosticsHandlerType = "aspnetcore.diagnostics.handler.type"; +/** + * ASP.NET Core exception middleware handling result + */ +static constexpr const char *kAspnetcoreDiagnosticsExceptionResult = + "aspnetcore.diagnostics.exception.result"; + /** * Rate limiting policy name. */ @@ -135,122 +66,15 @@ static constexpr const char *kAspnetcoreRequestIsUnhandled = "aspnetcore.request static constexpr const char *kAspnetcoreRoutingIsFallback = "aspnetcore.routing.is_fallback"; /** - * SignalR HTTP connection closure status. - */ -static constexpr const char *kSignalrConnectionStatus = "signalr.connection.status"; - -/** - * <a - * href="https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/TransportProtocols.md">SignalR - * transport type</a> - */ -static constexpr const char *kSignalrTransport = "signalr.transport"; - -/** - * Name of the buffer pool. - * - * <p>Notes: - <ul> <li>Pool names are generally obtained via <a - href="https://docs.oracle.com/en/java/javase/11/docs/api/java.management/java/lang/management/BufferPoolMXBean.html#getName()">BufferPoolMXBean#getName()</a>.</li> - </ul> - */ -static constexpr const char *kJvmBufferPoolName = "jvm.buffer.pool.name"; - -/** - * Name of the memory pool. - * - * <p>Notes: - <ul> <li>Pool names are generally obtained via <a - href="https://docs.oracle.com/en/java/javase/11/docs/api/java.management/java/lang/management/MemoryPoolMXBean.html#getName()">MemoryPoolMXBean#getName()</a>.</li> - </ul> - */ -static constexpr const char *kJvmMemoryPoolName = "jvm.memory.pool.name"; - -/** - * The type of memory. - */ -static constexpr const char *kJvmMemoryType = "jvm.memory.type"; - -/** - * The CPU state for this data point. A process SHOULD be characterized <em>either</em> by data - * points with no {@code state} labels, <em>or only</em> data points with {@code state} labels. - */ -static constexpr const char *kProcessCpuState = "process.cpu.state"; - -/** - * The device identifier - */ -static constexpr const char *kSystemDevice = "system.device"; - -/** - * The logical CPU number [0..n-1] - */ -static constexpr const char *kSystemCpuLogicalNumber = "system.cpu.logical_number"; - -/** - * The CPU state for this data point. A system's CPU SHOULD be characterized <em>either</em> by data - * points with no {@code state} labels, <em>or only</em> data points with {@code state} labels. - */ -static constexpr const char *kSystemCpuState = "system.cpu.state"; - -/** - * The memory state - */ -static constexpr const char *kSystemMemoryState = "system.memory.state"; - -/** - * The paging access direction - */ -static constexpr const char *kSystemPagingDirection = "system.paging.direction"; - -/** - * The memory paging state - */ -static constexpr const char *kSystemPagingState = "system.paging.state"; - -/** - * The memory paging type - */ -static constexpr const char *kSystemPagingType = "system.paging.type"; - -/** - * The filesystem mode - */ -static constexpr const char *kSystemFilesystemMode = "system.filesystem.mode"; - -/** - * The filesystem mount path - */ -static constexpr const char *kSystemFilesystemMountpoint = "system.filesystem.mountpoint"; - -/** - * The filesystem state - */ -static constexpr const char *kSystemFilesystemState = "system.filesystem.state"; - -/** - * The filesystem type - */ -static constexpr const char *kSystemFilesystemType = "system.filesystem.type"; - -/** - * A stateless protocol MUST NOT set this attribute - */ -static constexpr const char *kSystemNetworkState = "system.network.state"; - -/** - * The process state, e.g., <a - * href="https://man7.org/linux/man-pages/man1/ps.1.html#PROCESS_STATE_CODES">Linux Process State - * Codes</a> + * Match result - success or failure */ -static constexpr const char *kSystemProcessStatus = "system.process.status"; +static constexpr const char *kAspnetcoreRoutingMatchStatus = "aspnetcore.routing.match_status"; /** - * Uniquely identifies the framework API revision offered by a version ({@code os.version}) of the - * android operating system. More information can be found <a - * href="https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels">here</a>. + * The AWS request ID as returned in the response headers {@code x-amz-request-id} or {@code + * x-amz-requestid}. */ -static constexpr const char *kAndroidOsApiLevel = "android.os.api_level"; +static constexpr const char *kAwsRequestId = "aws.request_id"; /** * The JSON-serialized value of each item in the {@code AttributeDefinitions} request field. @@ -370,95 +194,299 @@ static constexpr const char *kAwsDynamodbTableNames = "aws.dynamodb.table_names" static constexpr const char *kAwsDynamodbTotalSegments = "aws.dynamodb.total_segments"; /** - * Array of brand name and version separated by a space - * - * <p>Notes: - <ul> <li>This value is intended to be taken from the <a - href="https://wicg.github.io/ua-client-hints/#interface">UA client hints API</a> ({@code - navigator.userAgentData.brands}).</li> </ul> + * The ID of a running ECS task. The ID MUST be extracted from {@code task.arn}. */ -static constexpr const char *kBrowserBrands = "browser.brands"; +static constexpr const char *kAwsEcsTaskId = "aws.ecs.task.id"; /** - * Preferred language of the user using the browser - * - * <p>Notes: - <ul> <li>This value is intended to be taken from the Navigator API {@code - navigator.language}.</li> </ul> + * The ARN of an <a + * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/clusters.html">ECS cluster</a>. */ -static constexpr const char *kBrowserLanguage = "browser.language"; +static constexpr const char *kAwsEcsClusterArn = "aws.ecs.cluster.arn"; /** - * A boolean that is true if the browser is running on a mobile device - * - * <p>Notes: - <ul> <li>This value is intended to be taken from the <a - href="https://wicg.github.io/ua-client-hints/#interface">UA client hints API</a> ({@code - navigator.userAgentData.mobile}). If unavailable, this attribute SHOULD be left unset.</li> </ul> + * The Amazon Resource Name (ARN) of an <a + * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_instances.html">ECS + * container instance</a>. */ -static constexpr const char *kBrowserMobile = "browser.mobile"; +static constexpr const char *kAwsEcsContainerArn = "aws.ecs.container.arn"; /** - * The platform on which the browser is running - * - * <p>Notes: - <ul> <li>This value is intended to be taken from the <a -href="https://wicg.github.io/ua-client-hints/#interface">UA client hints API</a> ({@code -navigator.userAgentData.platform}). If unavailable, the legacy {@code navigator.platform} API SHOULD -NOT be used instead and this attribute SHOULD be left unset in order for the values to be -consistent. The list of possible values is defined in the <a -href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform">W3C User-Agent Client Hints -specification</a>. Note that some (but not all) of these values can overlap with values in the <a -href="./os.md">{@code os.type} and {@code os.name} attributes</a>. However, for consistency, the -values in the {@code browser.platform} attribute should capture the exact value that the user agent -provides.</li> </ul> + * The <a + * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_types.html">launch + * type</a> for an ECS task. */ -static constexpr const char *kBrowserPlatform = "browser.platform"; +static constexpr const char *kAwsEcsLaunchtype = "aws.ecs.launchtype"; /** - * Client address - domain name if available without reverse DNS lookup; otherwise, IP address or - Unix domain socket name. - * - * <p>Notes: - <ul> <li>When observed from the server side, and when communicating through an intermediary, - {@code client.address} SHOULD represent the client address behind any intermediaries, for example - proxies, if it's available.</li> </ul> + * The ARN of a running <a + * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-account-settings.html#ecs-resource-ids">ECS + * task</a>. */ -static constexpr const char *kClientAddress = "client.address"; +static constexpr const char *kAwsEcsTaskArn = "aws.ecs.task.arn"; /** - * Client port number. - * - * <p>Notes: - <ul> <li>When observed from the server side, and when communicating through an intermediary, - {@code client.port} SHOULD represent the client port behind any intermediaries, for example - proxies, if it's available.</li> </ul> + * The family name of the <a + * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html">ECS task + * definition</a> used to create the ECS task. */ -static constexpr const char *kClientPort = "client.port"; +static constexpr const char *kAwsEcsTaskFamily = "aws.ecs.task.family"; /** - * The cloud account ID the resource is assigned to. + * The revision for the task definition used to create the ECS task. */ -static constexpr const char *kCloudAccountId = "cloud.account.id"; +static constexpr const char *kAwsEcsTaskRevision = "aws.ecs.task.revision"; /** - * Cloud regions often have multiple, isolated locations known as zones to increase availability. - Availability zone represents the zone where the resource is running. + * The ARN of an EKS cluster. + */ +static constexpr const char *kAwsEksClusterArn = "aws.eks.cluster.arn"; + +/** + * The Amazon Resource Name(s) (ARN) of the AWS log group(s). * * <p>Notes: - <ul> <li>Availability zones are called "zones" on Alibaba Cloud and Google Cloud.</li> - </ul> + <ul> <li>See the <a + href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html#CWL_ARN_Format">log + group ARN format documentation</a>.</li> </ul> */ -static constexpr const char *kCloudAvailabilityZone = "cloud.availability_zone"; +static constexpr const char *kAwsLogGroupArns = "aws.log.group.arns"; /** - * The cloud platform in use. + * The name(s) of the AWS log group(s) an application is writing to. * * <p>Notes: - <ul> <li>The prefix of the service SHOULD match the one specified in {@code cloud.provider}.</li> - </ul> + <ul> <li>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.</li> </ul> */ -static constexpr const char *kCloudPlatform = "cloud.platform"; +static constexpr const char *kAwsLogGroupNames = "aws.log.group.names"; + +/** + * The ARN(s) of the AWS log stream(s). + * + * <p>Notes: + <ul> <li>See the <a + href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html#CWL_ARN_Format">log + stream ARN format documentation</a>. One log group can contain several log streams, so these ARNs + necessarily identify both a log group and a log stream.</li> </ul> + */ +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 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). + * + * <p>Notes: + <ul> <li>This may be different from {@code cloud.resource_id} if an alias is involved.</li> </ul> + */ +static constexpr const char *kAwsLambdaInvokedArn = "aws.lambda.invoked_arn"; + +/** + * The S3 bucket name the request refers to. Corresponds to the {@code --bucket} parameter of the <a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html">S3 API</a> operations. + * + * <p>Notes: + <ul> <li>The {@code bucket} attribute is applicable to all S3 operations that reference a bucket, +i.e. that require the bucket name as a mandatory parameter. This applies to almost all S3 operations +except {@code list-buckets}.</li> </ul> + */ +static constexpr const char *kAwsS3Bucket = "aws.s3.bucket"; + +/** + * The source object (in the form {@code bucket}/{@code key}) for the copy operation. + * + * <p>Notes: + <ul> <li>The {@code copy_source} attribute applies to S3 copy operations and corresponds to the +{@code --copy-source} parameter of the <a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html">copy-object operation +within the S3 API</a>. This applies in particular to the following operations:</li><li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html">copy-object</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html">upload-part-copy</a></li> + </ul> + */ +static constexpr const char *kAwsS3CopySource = "aws.s3.copy_source"; + +/** + * The delete request container that specifies the objects to be deleted. + * + * <p>Notes: + <ul> <li>The {@code delete} attribute is only applicable to the <a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-object.html">delete-object</a> +operation. The {@code delete} attribute corresponds to the {@code --delete} parameter of the <a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-objects.html">delete-objects +operation within the S3 API</a>.</li> </ul> + */ +static constexpr const char *kAwsS3Delete = "aws.s3.delete"; + +/** + * The S3 object key the request refers to. Corresponds to the {@code --key} parameter of the <a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html">S3 API</a> operations. + * + * <p>Notes: + <ul> <li>The {@code key} attribute is applicable to all object-related S3 operations, i.e. that +require the object key as a mandatory parameter. This applies in particular to the following +operations:</li><li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html">copy-object</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-object.html">delete-object</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/get-object.html">get-object</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/head-object.html">head-object</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/put-object.html">put-object</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/restore-object.html">restore-object</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/select-object-content.html">select-object-content</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/abort-multipart-upload.html">abort-multipart-upload</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/complete-multipart-upload.html">complete-multipart-upload</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/create-multipart-upload.html">create-multipart-upload</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/list-parts.html">list-parts</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html">upload-part</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html">upload-part-copy</a></li> + </ul> + */ +static constexpr const char *kAwsS3Key = "aws.s3.key"; + +/** + * The part number of the part being uploaded in a multipart-upload operation. This is a positive +integer between 1 and 10,000. + * + * <p>Notes: + <ul> <li>The {@code part_number} attribute is only applicable to the <a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html">upload-part</a> and +<a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html">upload-part-copy</a> +operations. The {@code part_number} attribute corresponds to the {@code --part-number} parameter of +the <a href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html">upload-part +operation within the S3 API</a>.</li> </ul> + */ +static constexpr const char *kAwsS3PartNumber = "aws.s3.part_number"; + +/** + * Upload ID that identifies the multipart upload. + * + * <p>Notes: + <ul> <li>The {@code upload_id} attribute applies to S3 multipart-upload operations and corresponds +to the {@code --upload-id} parameter of the <a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html">S3 API</a> multipart +operations. This applies in particular to the following operations:</li><li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/abort-multipart-upload.html">abort-multipart-upload</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/complete-multipart-upload.html">complete-multipart-upload</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/list-parts.html">list-parts</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html">upload-part</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html">upload-part-copy</a></li> + </ul> + */ +static constexpr const char *kAwsS3UploadId = "aws.s3.upload_id"; + +/** + * Array of brand name and version separated by a space + * + * <p>Notes: + <ul> <li>This value is intended to be taken from the <a + href="https://wicg.github.io/ua-client-hints/#interface">UA client hints API</a> ({@code + navigator.userAgentData.brands}).</li> </ul> + */ +static constexpr const char *kBrowserBrands = "browser.brands"; + +/** + * Preferred language of the user using the browser + * + * <p>Notes: + <ul> <li>This value is intended to be taken from the Navigator API {@code + navigator.language}.</li> </ul> + */ +static constexpr const char *kBrowserLanguage = "browser.language"; + +/** + * A boolean that is true if the browser is running on a mobile device + * + * <p>Notes: + <ul> <li>This value is intended to be taken from the <a + href="https://wicg.github.io/ua-client-hints/#interface">UA client hints API</a> ({@code + navigator.userAgentData.mobile}). If unavailable, this attribute SHOULD be left unset.</li> </ul> + */ +static constexpr const char *kBrowserMobile = "browser.mobile"; + +/** + * The platform on which the browser is running + * + * <p>Notes: + <ul> <li>This value is intended to be taken from the <a +href="https://wicg.github.io/ua-client-hints/#interface">UA client hints API</a> ({@code +navigator.userAgentData.platform}). If unavailable, the legacy {@code navigator.platform} API SHOULD +NOT be used instead and this attribute SHOULD be left unset in order for the values to be +consistent. The list of possible values is defined in the <a +href="https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform">W3C User-Agent Client Hints +specification</a>. Note that some (but not all) of these values can overlap with values in the <a +href="./os.md">{@code os.type} and {@code os.name} attributes</a>. However, for consistency, the +values in the {@code browser.platform} attribute should capture the exact value that the user agent +provides.</li> </ul> + */ +static constexpr const char *kBrowserPlatform = "browser.platform"; + +/** + * Client address - domain name if available without reverse DNS lookup; otherwise, IP address or + Unix domain socket name. + * + * <p>Notes: + <ul> <li>When observed from the server side, and when communicating through an intermediary, + {@code client.address} SHOULD represent the client address behind any intermediaries, for example + proxies, if it's available.</li> </ul> + */ +static constexpr const char *kClientAddress = "client.address"; + +/** + * Client port number. + * + * <p>Notes: + <ul> <li>When observed from the server side, and when communicating through an intermediary, + {@code client.port} SHOULD represent the client port behind any intermediaries, for example + proxies, if it's available.</li> </ul> + */ +static constexpr const char *kClientPort = "client.port"; + +/** + * 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. + * + * <p>Notes: + <ul> <li>Availability zones are called "zones" on Alibaba Cloud and Google Cloud.</li> + </ul> + */ +static constexpr const char *kCloudAvailabilityZone = "cloud.availability_zone"; + +/** + * The cloud platform in use. + * + * <p>Notes: + <ul> <li>The prefix of the service SHOULD match the one specified in {@code cloud.provider}.</li> + </ul> + */ +static constexpr const char *kCloudPlatform = "cloud.platform"; /** * Name of the cloud provider. @@ -620,7 +648,7 @@ href="https://docs.docker.com/engine/api/v1.43/#tag/Container/operation/Containe endpoint. K8s defines a link to the container registry repository with digest {@code "imageID": "registry.azurecr.io /namespace/service/dockerfile@sha256:bdeabd40c3a8a492eaf9e8e44d0ebbb84bac7ee25ac0cf8a7159d25f62555625"}. -The ID is assinged by the container runtime and can vary in different environments. Consider using +The ID is assigned 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.</li> </ul> */ @@ -660,6 +688,67 @@ static constexpr const char *kContainerName = "container.name"; */ static constexpr const char *kContainerRuntime = "container.runtime"; +/** + * The name of the connection pool; unique within the instrumented application. In case the + * connection pool implementation doesn't provide a name, instrumentation should use a combination + * of {@code server.address} and {@code server.port} attributes formatted as {@code + * server.address:server.port}. + */ +static constexpr const char *kDbClientConnectionsPoolName = "db.client.connections.pool.name"; + +/** + * The state of a connection in the pool + */ +static constexpr const char *kDbClientConnectionsState = "db.client.connections.state"; + +/** + * The name of a collection (table, container) within the database. + * + * <p>Notes: + <ul> <li>If the collection name is parsed from the query, it SHOULD match the value provided in +the query and may be qualified with the schema and database name. It is RECOMMENDED to capture the +value as provided by the application without attempting to do any case normalization.</li> </ul> + */ +static constexpr const char *kDbCollectionName = "db.collection.name"; + +/** + * The name of the database, fully qualified within the server address and port. + * + * <p>Notes: + <ul> <li>If a database system has multiple namespace components, they SHOULD be concatenated +(potentially using database system specific conventions) from most general to most specific +namespace component, and more specific namespaces SHOULD NOT be captured without the more general +namespaces, to ensure that "startswith" queries for the more general namespaces will be +valid. Semantic conventions for individual database systems SHOULD document what {@code +db.namespace} means in the context of that system. It is RECOMMENDED to capture the value as +provided by the application without attempting to do any case normalization.</li> </ul> + */ +static constexpr const char *kDbNamespace = "db.namespace"; + +/** + * The name of the operation or command being executed. + * + * <p>Notes: + <ul> <li>It is RECOMMENDED to capture the value as provided by the application without attempting + to do any case normalization.</li> </ul> + */ +static constexpr const char *kDbOperationName = "db.operation.name"; + +/** + * The database query being executed. + */ +static constexpr const char *kDbQueryText = "db.query.text"; + +/** + * The database management system (DBMS) product as identified by the client instrumentation. + * + * <p>Notes: + <ul> <li>The actual DBMS may differ from the one identified by the client. For example, when using + PostgreSQL client libraries to connect to a CockroachDB, the {@code db.system} is set to {@code + postgresql} based on the instrumentation's best knowledge.</li> </ul> + */ +static constexpr const char *kDbSystem = "db.system"; + /** * The consistency level of the query. Based on consistency values from <a * href="https://docs.datastax.com/en/cassandra-oss/3.0/cassandra/dml/dmlConfigConsistency.html">CQL</a>. @@ -693,19 +782,6 @@ static constexpr const char *kDbCassandraPageSize = "db.cassandra.page_size"; static constexpr const char *kDbCassandraSpeculativeExecutionCount = "db.cassandra.speculative_execution_count"; -/** - * The name of the primary Cassandra table that the operation is acting upon, including the keyspace - name (if applicable). - * - * <p>Notes: - <ul> <li>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.</li> </ul> - */ -static constexpr const char *kDbCassandraTable = "db.cassandra.table"; - /** * Unique Cosmos client instance id. */ @@ -716,11 +792,6 @@ static constexpr const char *kDbCosmosdbClientId = "db.cosmosdb.client_id"; */ static constexpr const char *kDbCosmosdbConnectionMode = "db.cosmosdb.connection_mode"; -/** - * Cosmos DB container name. - */ -static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; - /** * CosmosDB Operation Type. */ @@ -752,136 +823,184 @@ static constexpr const char *kDbCosmosdbSubStatusCode = "db.cosmosdb.sub_status_ static constexpr const char *kDbElasticsearchClusterName = "db.elasticsearch.cluster.name"; /** - * An identifier (address, unique name, or any other identifier) of the database instance that is - * executing queries or mutations on the current connection. This is useful in cases where the - * database is running in a clustered environment and the instrumentation is able to record the node - * executing the query. The client may obtain this value in databases like MySQL using queries like - * {@code select @@hostname}. + * Represents the human-readable identifier of the node/instance to which a request was routed. + */ +static constexpr const char *kDbElasticsearchNodeName = "db.elasticsearch.node.name"; + +/** + * Name of the <a href="https://wikipedia.org/wiki/Deployment_environment">deployment +environment</a> (aka deployment tier). + * + * <p>Notes: + <ul> <li>{@code deployment.environment} does not affect the uniqueness constraints defined through +the {@code service.namespace}, {@code service.name} and {@code service.instance.id} resource +attributes. This implies that resources carrying the following attribute combinations MUST be +considered to be identifying the same service:</li><li>{@code service.name=frontend}, {@code +deployment.environment=production}</li> <li>{@code service.name=frontend}, {@code +deployment.environment=staging}.</li> + </ul> + */ +static constexpr const char *kDeploymentEnvironment = "deployment.environment"; + +/** + * Deprecated use the {@code device.app.lifecycle} event definition including {@code android.state} + as a payload field instead. + * + * <p>Notes: + <ul> <li>The Android lifecycle states are defined in <a + href="https://developer.android.com/guide/components/activities/activity-lifecycle#lc">Activity + lifecycle callbacks</a>, and from which the {@code OS identifiers} are derived.</li> </ul> + */ +static constexpr const char *kAndroidState = "android.state"; + +/** + * Deprecated, use {@code db.collection.name} instead. + * + * @deprecated Deprecated, use `db.collection.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbCassandraTable = "db.cassandra.table"; + +/** + * Deprecated, use {@code server.address}, {@code server.port} attributes instead. + * + * @deprecated Deprecated, use `server.address`, `server.port` attributes instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbConnectionString = "db.connection_string"; + +/** + * Deprecated, use {@code db.collection.name} instead. + * + * @deprecated Deprecated, use `db.collection.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; + +/** + * Deprecated, no general replacement at this time. For Elasticsearch, use {@code + * db.elasticsearch.node.name} instead. + * + * @deprecated Deprecated, no general replacement at this time. For Elasticsearch, use + * `db.elasticsearch.node.name` instead. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbInstanceId = "db.instance.id"; /** - * The MongoDB collection being accessed within the database stated in {@code db.name}. + * Removed, no replacement at this time. + * + * @deprecated Removed, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbJdbcDriverClassname = "db.jdbc.driver_classname"; + +/** + * Deprecated, use {@code db.collection.name} instead. + * + * @deprecated Deprecated, use `db.collection.name` instead. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbMongodbCollection = "db.mongodb.collection"; /** - * The Microsoft SQL Server <a - href="https://docs.microsoft.com/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver15">instance - name</a> connecting to. This name is used to determine the port of a named instance. + * Deprecated, SQL Server instance is now populated as a part of {@code db.namespace} attribute. * - * <p>Notes: - <ul> <li>If setting a {@code db.mssql.instance_name}, {@code server.port} is no longer required - (but still recommended if non-standard).</li> </ul> + * @deprecated Deprecated, SQL Server instance is now populated as a part of `db.namespace` + * attribute. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbMssqlInstanceName = "db.mssql.instance_name"; /** - * 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). + * Deprecated, use {@code db.namespace} instead. * - * <p>Notes: - <ul> <li>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).</li> </ul> + * @deprecated Deprecated, use `db.namespace` instead. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbName = "db.name"; /** - * The name of the operation being executed, e.g. the <a - href="https://docs.mongodb.com/manual/reference/command/#database-operations">MongoDB command - name</a> such as {@code findAndModify}, or the SQL keyword. + * Deprecated, use {@code db.operation.name} instead. * - * <p>Notes: - <ul> <li>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.</li> </ul> + * @deprecated Deprecated, use `db.operation.name` instead. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbOperation = "db.operation"; /** - * The index of the database being accessed as used in the <a - * href="https://redis.io/commands/select">{@code SELECT} command</a>, provided as an integer. To be - * used instead of the generic {@code db.name} attribute. + * Deprecated, use {@code db.namespace} instead. + * + * @deprecated Deprecated, use `db.namespace` instead. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbRedisDatabaseIndex = "db.redis.database_index"; /** - * The name of the primary table that the operation is acting upon, including the database name (if - applicable). + * Deprecated, use {@code db.collection.name} instead. * - * <p>Notes: - <ul> <li>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.</li> </ul> + * @deprecated Deprecated, use `db.collection.name` instead. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbSqlTable = "db.sql.table"; /** * The database statement being executed. + * + * @deprecated The database statement being executed. */ +OPENTELEMETRY_DEPRECATED 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. + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbUser = "db.user"; /** - * Name of the <a href="https://wikipedia.org/wiki/Deployment_environment">deployment -environment</a> (aka deployment tier). + * Deprecated, use {@code db.client.connections.pool.name} instead. * - * <p>Notes: - <ul> <li>{@code deployment.environment} does not affect the uniqueness constraints defined through -the {@code service.namespace}, {@code service.name} and {@code service.instance.id} resource -attributes. This implies that resources carrying the following attribute combinations MUST be -considered to be identifying the same service:</li><li>{@code service.name=frontend}, {@code -deployment.environment=production}</li> <li>{@code service.name=frontend}, {@code -deployment.environment=staging}.</li> - </ul> + * @deprecated Deprecated, use `db.client.connections.pool.name` instead. */ -static constexpr const char *kDeploymentEnvironment = "deployment.environment"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kPoolName = "pool.name"; /** - * Deprecated, use {@code server.address}, {@code server.port} attributes instead. + * Deprecated, use {@code db.client.connections.state} instead. * - * @deprecated Deprecated, use `server.address`, `server.port` attributes instead. + * @deprecated Deprecated, use `db.client.connections.state` instead. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kDbConnectionString = "db.connection_string"; +static constexpr const char *kState = "state"; /** - * Deprecated, use {@code db.instance.id} instead. + * Deprecated, use {@code client.address} instead. * - * @deprecated Deprecated, use `db.instance.id` instead. + * @deprecated Deprecated, use `client.address` instead. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kDbElasticsearchNodeName = "db.elasticsearch.node.name"; +static constexpr const char *kHttpClientIp = "http.client_ip"; /** - * Removed, no replacement at this time. + * Deprecated, use {@code network.protocol.name} instead. * - * @deprecated Removed, no replacement at this time. + * @deprecated Deprecated, use `network.protocol.name` instead. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kDbJdbcDriverClassname = "db.jdbc.driver_classname"; +static constexpr const char *kHttpFlavor = "http.flavor"; /** - * Deprecated, use {@code network.protocol.name} instead. + * Deprecated, use one of {@code server.address}, {@code client.address} or {@code + * http.request.header.host} instead, depending on the usage. * - * @deprecated Deprecated, use `network.protocol.name` instead. + * @deprecated Deprecated, use one of `server.address`, `client.address` or + * `http.request.header.host` instead, depending on the usage. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpFlavor = "http.flavor"; +static constexpr const char *kHttpHost = "http.host"; /** * Deprecated, use {@code http.request.method} instead. @@ -899,6 +1018,15 @@ static constexpr const char *kHttpMethod = "http.method"; OPENTELEMETRY_DEPRECATED static constexpr const char *kHttpRequestContentLength = "http.request_content_length"; +/** + * Deprecated, use {@code http.request.body.size} instead. + * + * @deprecated Deprecated, use `http.request.body.size` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpRequestContentLengthUncompressed = + "http.request_content_length_uncompressed"; + /** * Deprecated, use {@code http.response.header.content-length} instead. * @@ -907,6 +1035,15 @@ static constexpr const char *kHttpRequestContentLength = "http.request_content_l OPENTELEMETRY_DEPRECATED static constexpr const char *kHttpResponseContentLength = "http.response_content_length"; +/** + * Deprecated, use {@code http.response.body.size} instead. + * + * @deprecated Deprecated, use `http.response.body.size` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpResponseContentLengthUncompressed = + "http.response_content_length_uncompressed"; + /** * Deprecated, use {@code url.scheme} instead. * @@ -915,6 +1052,14 @@ static constexpr const char *kHttpResponseContentLength = "http.response_content OPENTELEMETRY_DEPRECATED static constexpr const char *kHttpScheme = "http.scheme"; +/** + * Deprecated, use {@code server.address} instead. + * + * @deprecated Deprecated, use `server.address` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpServerName = "http.server_name"; + /** * Deprecated, use {@code http.response.status_code} instead. * @@ -948,14 +1093,45 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kHttpUserAgent = "http.user_agent"; /** - * "Deprecated, use {@code messaging.destination.partition.id} instead." + * Deprecated use the {@code device.app.lifecycle} event definition including {@code ios.state} as a + payload field instead. + * + * <p>Notes: + <ul> <li>The iOS lifecycle states are defined in the <a + href="https://developer.apple.com/documentation/uikit/uiapplicationdelegate#1656902">UIApplicationDelegate + documentation</a>, and from which the {@code OS terminology} column values are derived.</li> </ul> + * + * @deprecated Deprecated use the `device.app.lifecycle` event definition including `ios.state` as a + payload field instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kIosState = "ios.state"; + +/** + * Deprecated, use {@code messaging.destination.partition.id} instead. * - * @deprecated "Deprecated, use `messaging.destination.partition.id` instead.". + * @deprecated Deprecated, use `messaging.destination.partition.id` instead. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kMessagingKafkaDestinationPartition = "messaging.kafka.destination.partition"; +/** + * Deprecated, use {@code messaging.operation.type} instead. + * + * @deprecated Deprecated, use `messaging.operation.type` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingOperation = "messaging.operation"; + +/** + * Deprecated, use {@code network.local.address}. + * + * @deprecated Deprecated, use `network.local.address`. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetHostIp = "net.host.ip"; + /** * Deprecated, use {@code server.address}. * @@ -972,6 +1148,14 @@ static constexpr const char *kNetHostName = "net.host.name"; OPENTELEMETRY_DEPRECATED static constexpr const char *kNetHostPort = "net.host.port"; +/** + * Deprecated, use {@code network.peer.address}. + * + * @deprecated Deprecated, use `network.peer.address`. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetPeerIp = "net.peer.ip"; + /** * Deprecated, use {@code server.address} on client spans and {@code client.address} on server * spans. @@ -1062,6 +1246,54 @@ static constexpr const char *kNetSockPeerPort = "net.sock.peer.port"; OPENTELEMETRY_DEPRECATED static constexpr const char *kNetTransport = "net.transport"; +/** + * None + * + * @deprecated None. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kOtelLibraryName = "otel.library.name"; + +/** + * None + * + * @deprecated None. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kOtelLibraryVersion = "otel.library.version"; + +/** + * Deprecated, use {@code rpc.message.compressed_size} instead. + * + * @deprecated Deprecated, use `rpc.message.compressed_size` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessageCompressedSize = "message.compressed_size"; + +/** + * Deprecated, use {@code rpc.message.id} instead. + * + * @deprecated Deprecated, use `rpc.message.id` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessageId = "message.id"; + +/** + * Deprecated, use {@code rpc.message.type} instead. + * + * @deprecated Deprecated, use `rpc.message.type` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessageType = "message.type"; + +/** + * Deprecated, use {@code rpc.message.uncompressed_size} instead. + * + * @deprecated Deprecated, use `rpc.message.uncompressed_size` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessageUncompressedSize = "message.uncompressed_size"; + /** * Deprecated, use {@code system.process.status} instead. * @@ -1175,20 +1407,33 @@ static constexpr const char *kEnduserScope = "enduser.scope"; * Describes a class of error the operation ended with. * * <p>Notes: - <ul> <li>The {@code error.type} SHOULD be predictable and SHOULD have low cardinality. -Instrumentations SHOULD document the list of errors they report.</li><li>The cardinality of {@code -error.type} within one instrumentation library SHOULD be low. 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.</li><li>If the operation has completed successfully, instrumentations SHOULD NOT set {@code -error.type}.</li><li>If a specific domain defines its own set of error identifiers (such as HTTP or -gRPC status codes), it's RECOMMENDED to:</li><li>Use a domain-specific attribute</li> <li>Set {@code -error.type} to capture all errors, regardless of whether they are defined within the domain-specific -set or not.</li> + <ul> <li>The {@code error.type} SHOULD be predictable, and SHOULD have low +cardinality.</li><li>When {@code error.type} is set to a type (e.g., an exception type), its +canonical class name identifying the type within the artifact SHOULD be +used.</li><li>Instrumentations SHOULD document the list of errors they report.</li><li>The +cardinality of {@code error.type} within one instrumentation library SHOULD be low. 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.</li><li>If the operation has completed successfully, instrumentations SHOULD NOT set +{@code error.type}.</li><li>If a specific domain defines its own set of error identifiers (such as +HTTP or gRPC status codes), it's RECOMMENDED to:</li><li>Use a domain-specific attribute</li> +<li>Set {@code error.type} to capture all errors, regardless of whether they are defined within the +domain-specific set or not.</li> </ul> */ static constexpr const char *kErrorType = "error.type"; +/** + * Identifies the class / type of event. + * + * <p>Notes: + <ul> <li>Event names are subject to the same rules as <a + href="https://github.com/open-telemetry/opentelemetry-specification/tree/v1.33.0/specification/common/attribute-naming.md">attribute + names</a>. Notably, event names are namespaced to avoid collisions and provide a clean separation + of semantics for events in separate domains like browser, mobile, and kubernetes.</li> </ul> + */ +static constexpr const char *kEventName = "event.name"; + /** * SHOULD be set to true if the exception event is recorded at a point where it is known that the exception is escaping the scope of the span. @@ -1201,9 +1446,10 @@ is passed to a Context manager's {@code __exit__} method in Python) but will usually be caught at the point of recording the exception in most languages.</li><li>It is usually not possible to determine at the point where an exception is thrown whether it will escape the scope of a span. However, it is trivial to know that an exception will escape, if one checks for an active -exception just before ending the span, as done in the <a href="#recording-an-exception">example for -recording span exceptions</a>.</li><li>It follows that an exception may still escape the scope of -the span even if the {@code exception.escaped} attribute was not set or set to false, since the +exception just before ending the span, as done in the <a +href="https://opentelemetry.io/docs/specs/semconv/exceptions/exceptions-spans/#recording-an-exception">example +for recording span exceptions</a>.</li><li>It follows that an exception may still escape the scope +of the span even if the {@code exception.escaped} attribute was not set or set to false, since the event might have been recorded at a time where it was not clear whether the exception will escape.</li> </ul> */ @@ -1451,84 +1697,192 @@ static constexpr const char *kGcpGceInstanceHostname = "gcp.gce.instance.hostnam static constexpr const char *kGcpGceInstanceName = "gcp.gce.instance.name"; /** - * The CPU architecture the host system is running on. + * The full response received from the LLM. + * + * <p>Notes: + <ul> <li>It's RECOMMENDED to format completions as JSON string matching <a + href="https://platform.openai.com/docs/guides/text-generation">OpenAI messages format</a></li> + </ul> */ -static constexpr const char *kHostArch = "host.arch"; +static constexpr const char *kGenAiCompletion = "gen_ai.completion"; /** - * The amount of level 2 memory cache available to the processor (in Bytes). + * The full prompt sent to an LLM. + * + * <p>Notes: + <ul> <li>It's RECOMMENDED to format prompts as JSON string matching <a + href="https://platform.openai.com/docs/guides/text-generation">OpenAI messages format</a></li> + </ul> */ -static constexpr const char *kHostCpuCacheL2Size = "host.cpu.cache.l2.size"; +static constexpr const char *kGenAiPrompt = "gen_ai.prompt"; /** - * Family or generation of the CPU. + * The maximum number of tokens the LLM generates for a request. */ -static constexpr const char *kHostCpuFamily = "host.cpu.family"; +static constexpr const char *kGenAiRequestMaxTokens = "gen_ai.request.max_tokens"; /** - * Model identifier. It provides more granular information about the CPU, distinguishing it from - * other CPUs within the same family. + * The name of the LLM a request is being made to. */ -static constexpr const char *kHostCpuModelId = "host.cpu.model.id"; +static constexpr const char *kGenAiRequestModel = "gen_ai.request.model"; /** - * Model designation of the processor. + * The temperature setting for the LLM request. */ -static constexpr const char *kHostCpuModelName = "host.cpu.model.name"; +static constexpr const char *kGenAiRequestTemperature = "gen_ai.request.temperature"; /** - * Stepping or core revisions. + * The top_p sampling setting for the LLM request. */ -static constexpr const char *kHostCpuStepping = "host.cpu.stepping"; +static constexpr const char *kGenAiRequestTopP = "gen_ai.request.top_p"; /** - * Processor manufacturer identifier. A maximum 12-character string. - * - * <p>Notes: - <ul> <li><a href="https://wiki.osdev.org/CPUID">CPUID</a> 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.</li> </ul> + * Array of reasons the model stopped generating tokens, corresponding to each generation received. */ -static constexpr const char *kHostCpuVendorId = "host.cpu.vendor.id"; +static constexpr const char *kGenAiResponseFinishReasons = "gen_ai.response.finish_reasons"; /** - * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For - * non-containerized systems, this should be the {@code machine-id}. See the table below for the - * sources to use to determine the {@code machine-id} based on operating system. + * The unique identifier for the completion. */ -static constexpr const char *kHostId = "host.id"; +static constexpr const char *kGenAiResponseId = "gen_ai.response.id"; /** - * VM image ID or host OS image ID. For Cloud, this value is from the provider. + * The name of the LLM a response was generated from. */ -static constexpr const char *kHostImageId = "host.image.id"; +static constexpr const char *kGenAiResponseModel = "gen_ai.response.model"; /** - * Name of the VM image or OS install the host was instantiated from. + * The Generative AI product as identified by the client instrumentation. + * + * <p>Notes: + <ul> <li>The actual GenAI product may differ from the one identified by the client. For example, + when using OpenAI client libraries to communicate with Mistral, the {@code gen_ai.system} is set to + {@code openai} based on the instrumentation's best knowledge.</li> </ul> */ -static constexpr const char *kHostImageName = "host.image.name"; +static constexpr const char *kGenAiSystem = "gen_ai.system"; /** - * The version string of the VM image or host OS as defined in <a - * href="/docs/resource/README.md#version-attributes">Version Attributes</a>. + * The number of tokens used in the LLM response (completion). */ -static constexpr const char *kHostImageVersion = "host.image.version"; +static constexpr const char *kGenAiUsageCompletionTokens = "gen_ai.usage.completion_tokens"; /** - * Available IP addresses of the host, excluding loopback interfaces. - * - * <p>Notes: - <ul> <li>IPv4 Addresses MUST be specified in dotted-quad notation. IPv6 addresses MUST be - specified in the <a href="https://www.rfc-editor.org/rfc/rfc5952.html">RFC 5952</a> format.</li> - </ul> + * The number of tokens used in the LLM prompt. */ -static constexpr const char *kHostIp = "host.ip"; +static constexpr const char *kGenAiUsagePromptTokens = "gen_ai.usage.prompt_tokens"; /** - * Available MAC addresses of the host, excluding loopback interfaces. + * The GraphQL document being executed. * * <p>Notes: - <ul> <li>MAC Addresses MUST be represented in <a + <ul> <li>The value may be sanitized to exclude sensitive information.</li> </ul> + */ +static constexpr const char *kGraphqlDocument = "graphql.document"; + +/** + * The name of the operation being executed. + */ +static constexpr const char *kGraphqlOperationName = "graphql.operation.name"; + +/** + * The type of the operation being executed. + */ +static constexpr const char *kGraphqlOperationType = "graphql.operation.type"; + +/** + * Unique identifier for the application + */ +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 + */ +static constexpr const char *kHerokuReleaseCreationTimestamp = "heroku.release.creation_timestamp"; + +/** + * The CPU architecture the host system is running on. + */ +static constexpr const char *kHostArch = "host.arch"; + +/** + * The amount of level 2 memory cache available to the processor (in Bytes). + */ +static constexpr const char *kHostCpuCacheL2Size = "host.cpu.cache.l2.size"; + +/** + * Family or generation of the CPU. + */ +static constexpr const char *kHostCpuFamily = "host.cpu.family"; + +/** + * Model identifier. It provides more granular information about the CPU, distinguishing it from + * other CPUs within the same family. + */ +static constexpr const char *kHostCpuModelId = "host.cpu.model.id"; + +/** + * Model designation of the processor. + */ +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. + * + * <p>Notes: + <ul> <li><a href="https://wiki.osdev.org/CPUID">CPUID</a> 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.</li> </ul> + */ +static constexpr const char *kHostCpuVendorId = "host.cpu.vendor.id"; + +/** + * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For + * non-containerized systems, this should be the {@code machine-id}. See the table below for the + * sources to use to determine the {@code machine-id} based on operating system. + */ +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 <a + * href="/docs/resource/README.md#version-attributes">Version Attributes</a>. + */ +static constexpr const char *kHostImageVersion = "host.image.version"; + +/** + * Available IP addresses of the host, excluding loopback interfaces. + * + * <p>Notes: + <ul> <li>IPv4 Addresses MUST be specified in dotted-quad notation. IPv6 addresses MUST be + specified in the <a href="https://www.rfc-editor.org/rfc/rfc5952.html">RFC 5952</a> format.</li> + </ul> + */ +static constexpr const char *kHostIp = "host.ip"; + +/** + * Available MAC addresses of the host, excluding loopback interfaces. + * + * <p>Notes: + <ul> <li>MAC Addresses MUST be represented in <a href="https://standards.ieee.org/wp-content/uploads/import/documents/tutorials/eui.pdf">IEEE RA hexadecimal form</a>: as hyphen-separated octets in uppercase hexadecimal form from most to least significant.</li> </ul> @@ -1635,6 +1989,61 @@ one.</li> </ul> */ static constexpr const char *kHttpRoute = "http.route"; +/** + * Name of the buffer pool. + * + * <p>Notes: + <ul> <li>Pool names are generally obtained via <a + href="https://docs.oracle.com/en/java/javase/11/docs/api/java.management/java/lang/management/BufferPoolMXBean.html#getName()">BufferPoolMXBean#getName()</a>.</li> + </ul> + */ +static constexpr const char *kJvmBufferPoolName = "jvm.buffer.pool.name"; + +/** + * Name of the garbage collector action. + * + * <p>Notes: + <ul> <li>Garbage collector action is generally obtained via <a + href="https://docs.oracle.com/en/java/javase/11/docs/api/jdk.management/com/sun/management/GarbageCollectionNotificationInfo.html#getGcAction()">GarbageCollectionNotificationInfo#getGcAction()</a>.</li> + </ul> + */ +static constexpr const char *kJvmGcAction = "jvm.gc.action"; + +/** + * Name of the garbage collector. + * + * <p>Notes: + <ul> <li>Garbage collector name is generally obtained via <a + href="https://docs.oracle.com/en/java/javase/11/docs/api/jdk.management/com/sun/management/GarbageCollectionNotificationInfo.html#getGcName()">GarbageCollectionNotificationInfo#getGcName()</a>.</li> + </ul> + */ +static constexpr const char *kJvmGcName = "jvm.gc.name"; + +/** + * Name of the memory pool. + * + * <p>Notes: + <ul> <li>Pool names are generally obtained via <a + href="https://docs.oracle.com/en/java/javase/11/docs/api/java.management/java/lang/management/MemoryPoolMXBean.html#getName()">MemoryPoolMXBean#getName()</a>.</li> + </ul> + */ +static constexpr const char *kJvmMemoryPoolName = "jvm.memory.pool.name"; + +/** + * The type of memory. + */ +static constexpr const char *kJvmMemoryType = "jvm.memory.type"; + +/** + * Whether the thread is daemon or not. + */ +static constexpr const char *kJvmThreadDaemon = "jvm.thread.daemon"; + +/** + * State of the thread. + */ +static constexpr const char *kJvmThreadState = "jvm.thread.state"; + /** * The name of the cluster. */ @@ -1676,6 +2085,12 @@ static constexpr const char *kK8sContainerName = "k8s.container.name"; */ static constexpr const char *kK8sContainerRestartCount = "k8s.container.restart_count"; +/** + * Last terminated reason of the Container. + */ +static constexpr const char *kK8sContainerStatusLastTerminatedReason = + "k8s.container.status.last_terminated_reason"; + /** * The name of the CronJob. */ @@ -1761,6 +2176,42 @@ static constexpr const char *kK8sStatefulsetName = "k8s.statefulset.name"; */ static constexpr const char *kK8sStatefulsetUid = "k8s.statefulset.uid"; +/** + * The stream associated with the log. See below for a list of well-known values. + */ +static constexpr const char *kLogIostream = "log.iostream"; + +/** + * The basename of the file. + */ +static constexpr const char *kLogFileName = "log.file.name"; + +/** + * The basename of the file, with symlinks resolved. + */ +static constexpr const char *kLogFileNameResolved = "log.file.name_resolved"; + +/** + * The full path to the file. + */ +static constexpr const char *kLogFilePath = "log.file.path"; + +/** + * The full path to the file, with symlinks resolved. + */ +static constexpr const char *kLogFilePathResolved = "log.file.path_resolved"; + +/** + * A unique identifier for the Log Record. + * + * <p>Notes: + <ul> <li>If an id is provided, other log records with the same id will be considered duplicates +and can be removed safely. This means, that two distinguishable log records MUST have different +values. The id MAY be an <a href="https://github.com/ulid/spec">Universally Unique Lexicographically +Sortable Identifier (ULID)</a>, but other identifiers (e.g. UUID) may be used as needed.</li> </ul> + */ +static constexpr const char *kLogRecordUid = "log.record.uid"; + /** * The number of messages sent, received, or processed in the scope of the batching operation. * @@ -1776,7 +2227,7 @@ static constexpr const char *kMessagingBatchMessageCount = "messaging.batch.mess /** * A unique identifier for the client that consumes or produces a message. */ -static constexpr const char *kMessagingClientId = "messaging.client_id"; +static constexpr const char *kMessagingClientId = "messaging.client.id"; /** * A boolean that is true if the message destination is anonymous (could be unnamed or have @@ -1837,23 +2288,56 @@ static constexpr const char *kMessagingDestinationPublishName = "messaging.destination_publish.name"; /** - * The name of the consumer group the event consumer is associated with. + * The size of the message body in bytes. + * + * <p>Notes: + <ul> <li>This can refer to both the compressed or uncompressed body size. If both sizes are known, +the uncompressed body size should be used.</li> </ul> */ -static constexpr const char *kMessagingEventhubsConsumerGroup = - "messaging.eventhubs.consumer.group"; +static constexpr const char *kMessagingMessageBodySize = "messaging.message.body.size"; /** - * The UTC epoch seconds at which the message has been accepted and stored in the entity. + * The conversation ID identifying the conversation to which the message belongs, represented as a + * string. Sometimes called "Correlation ID". */ -static constexpr const char *kMessagingEventhubsMessageEnqueuedTime = - "messaging.eventhubs.message.enqueued_time"; +static constexpr const char *kMessagingMessageConversationId = "messaging.message.conversation_id"; /** - * The ordering key for a given message. If the attribute is not present, the message does not have - * an ordering key. + * The size of the message body and metadata in bytes. + * + * <p>Notes: + <ul> <li>This can refer to both the compressed or uncompressed size. If both sizes are known, the +uncompressed size should be used.</li> </ul> */ -static constexpr const char *kMessagingGcpPubsubMessageOrderingKey = - "messaging.gcp_pubsub.message.ordering_key"; +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 *kMessagingMessageId = "messaging.message.id"; + +/** + * The system-specific name of the messaging operation. + */ +static constexpr const char *kMessagingOperationName = "messaging.operation.name"; + +/** + * A string identifying the type of the messaging operation. + * + * <p>Notes: + <ul> <li>If a custom value is used, it MUST be of low cardinality.</li> </ul> + */ +static constexpr const char *kMessagingOperationType = "messaging.operation.type"; + +/** + * The messaging system as identified by the client instrumentation. + * + * <p>Notes: + <ul> <li>The actual messaging system may differ from the one known by the client. For example, + when using Kafka client libraries to communicate with Azure Event Hubs, the {@code + messaging.system} is set to {@code kafka} based on the instrumentation's best knowledge.</li> </ul> + */ +static constexpr const char *kMessagingSystem = "messaging.system"; /** * Name of the Kafka Consumer Group that is handling the message. Only applies to consumers, not @@ -1884,62 +2368,25 @@ static constexpr const char *kMessagingKafkaMessageOffset = "messaging.kafka.mes static constexpr const char *kMessagingKafkaMessageTombstone = "messaging.kafka.message.tombstone"; /** - * The size of the message body in bytes. - * - * <p>Notes: - <ul> <li>This can refer to both the compressed or uncompressed body size. If both sizes are known, -the uncompressed body size should be used.</li> </ul> + * RabbitMQ message routing key. */ -static constexpr const char *kMessagingMessageBodySize = "messaging.message.body.size"; +static constexpr const char *kMessagingRabbitmqDestinationRoutingKey = + "messaging.rabbitmq.destination.routing_key"; /** - * The conversation ID identifying the conversation to which the message belongs, represented as a - * string. Sometimes called "Correlation ID". + * RabbitMQ message delivery tag */ -static constexpr const char *kMessagingMessageConversationId = "messaging.message.conversation_id"; +static constexpr const char *kMessagingRabbitmqMessageDeliveryTag = + "messaging.rabbitmq.message.delivery_tag"; /** - * The size of the message body and metadata in bytes. - * - * <p>Notes: - <ul> <li>This can refer to both the compressed or uncompressed size. If both sizes are known, the -uncompressed size should be used.</li> </ul> + * Name of the RocketMQ producer/consumer group that is handling the message. The client type is + * identified by the SpanKind. */ -static constexpr const char *kMessagingMessageEnvelopeSize = "messaging.message.envelope.size"; +static constexpr const char *kMessagingRocketmqClientGroup = "messaging.rocketmq.client_group"; /** - * A value used by the messaging system as an identifier for the message, represented as a string. - */ -static constexpr const char *kMessagingMessageId = "messaging.message.id"; - -/** - * A string identifying the kind of messaging operation. - * - * <p>Notes: - <ul> <li>If a custom value is used, it MUST be of low cardinality.</li> </ul> - */ -static constexpr const char *kMessagingOperation = "messaging.operation"; - -/** - * RabbitMQ message routing key. - */ -static constexpr const char *kMessagingRabbitmqDestinationRoutingKey = - "messaging.rabbitmq.destination.routing_key"; - -/** - * RabbitMQ message delivery tag - */ -static constexpr const char *kMessagingRabbitmqMessageDeliveryTag = - "messaging.rabbitmq.message.delivery_tag"; - -/** - * Name of the RocketMQ producer/consumer group that is handling the message. The client type is - * identified by the SpanKind. - */ -static constexpr const char *kMessagingRocketmqClientGroup = "messaging.rocketmq.client_group"; - -/** - * Model of message consumption. This only applies to consumer spans. + * Model of message consumption. This only applies to consumer spans. */ static constexpr const char *kMessagingRocketmqConsumptionModel = "messaging.rocketmq.consumption_model"; @@ -1982,6 +2429,31 @@ static constexpr const char *kMessagingRocketmqMessageType = "messaging.rocketmq */ static constexpr const char *kMessagingRocketmqNamespace = "messaging.rocketmq.namespace"; +/** + * The ack deadline in seconds set for the modify ack deadline request. + */ +static constexpr const char *kMessagingGcpPubsubMessageAckDeadline = + "messaging.gcp_pubsub.message.ack_deadline"; + +/** + * The ack id for a given message. + */ +static constexpr const char *kMessagingGcpPubsubMessageAckId = + "messaging.gcp_pubsub.message.ack_id"; + +/** + * The delivery attempt for a given message. + */ +static constexpr const char *kMessagingGcpPubsubMessageDeliveryAttempt = + "messaging.gcp_pubsub.message.delivery_attempt"; + +/** + * The ordering key for a given message. If the attribute is not present, the message does not have + * an ordering key. + */ +static constexpr const char *kMessagingGcpPubsubMessageOrderingKey = + "messaging.gcp_pubsub.message.ordering_key"; + /** * The name of the subscription in the topic messages are received from. */ @@ -2009,10 +2481,16 @@ static constexpr const char *kMessagingServicebusMessageEnqueuedTime = "messaging.servicebus.message.enqueued_time"; /** - * An identifier for the messaging system being used. See below for a list of well-known - * identifiers. + * The name of the consumer group the event consumer is associated with. */ -static constexpr const char *kMessagingSystem = "messaging.system"; +static constexpr const char *kMessagingEventhubsConsumerGroup = + "messaging.eventhubs.consumer.group"; + +/** + * The UTC epoch seconds at which the message has been accepted and stored in the entity. + */ +static constexpr const char *kMessagingEventhubsMessageEnqueuedTime = + "messaging.eventhubs.message.enqueued_time"; /** * The ISO 3166-1 alpha-2 2-character country code associated with the mobile carrier network. @@ -2125,6 +2603,14 @@ Manifest</a>.</li> </ul> */ static constexpr const char *kOciManifestDigest = "oci.manifest.digest"; +/** + * Parent-child Reference type + * + * <p>Notes: + <ul> <li>The causal relationship between a child Span and a parent Span.</li> </ul> + */ +static constexpr const char *kOpentracingRefType = "opentracing.ref_type"; + /** * Unique identifier for a particular build or compilation of the operating system. */ @@ -2152,6 +2638,27 @@ static constexpr const char *kOsType = "os.type"; */ static constexpr const char *kOsVersion = "os.version"; +/** + * Name of the code, either "OK" or "ERROR". MUST NOT be set if the status code + * is UNSET. + */ +static constexpr const char *kOtelStatusCode = "otel.status_code"; + +/** + * Description of the Status if it has a value, otherwise not set. + */ +static constexpr const char *kOtelStatusDescription = "otel.status_description"; + +/** + * The name of the instrumentation scope - ({@code InstrumentationScope.Name} in OTLP). + */ +static constexpr const char *kOtelScopeName = "otel.scope.name"; + +/** + * The version of the instrumentation scope - ({@code InstrumentationScope.Version} in OTLP). + */ +static constexpr const char *kOtelScopeVersion = "otel.scope.version"; + /** * The <a href="/docs/resource/README.md#service">{@code service.name}</a> of the remote service. * SHOULD be equal to the actual {@code service.name} resource attribute of the remote service if @@ -2181,6 +2688,16 @@ static constexpr const char *kProcessCommandArgs = "process.command_args"; */ static constexpr const char *kProcessCommandLine = "process.command_line"; +/** + * Specifies whether the context switches for this data point were voluntary or involuntary. + */ +static constexpr const char *kProcessContextSwitchType = "process.context_switch_type"; + +/** + * The date and time the process was created, in ISO 8601 format. + */ +static constexpr const char *kProcessCreationTime = "process.creation.time"; + /** * The name of the process executable. On Linux based systems, can be set to the {@code Name} in * {@code proc/[pid]/status}. On Windows, can be set to the base name of {@code @@ -2194,11 +2711,37 @@ static constexpr const char *kProcessExecutableName = "process.executable.name"; */ static constexpr const char *kProcessExecutablePath = "process.executable.path"; +/** + * The exit code of the process. + */ +static constexpr const char *kProcessExitCode = "process.exit.code"; + +/** + * The date and time the process exited, in ISO 8601 format. + */ +static constexpr const char *kProcessExitTime = "process.exit.time"; + +/** + * The PID of the process's group leader. This is also the process group ID (PGID) of the process. + */ +static constexpr const char *kProcessGroupLeaderPid = "process.group_leader.pid"; + +/** + * Whether the process is connected to an interactive shell. + */ +static constexpr const char *kProcessInteractive = "process.interactive"; + /** * The username of the user that owns the process. */ static constexpr const char *kProcessOwner = "process.owner"; +/** + * The type of page fault for this data point. Type {@code major} is for major/hard page faults, and + * {@code minor} is for minor/soft page faults. + */ +static constexpr const char *kProcessPagingFaultType = "process.paging.fault_type"; + /** * Parent Process identifier (PPID). */ @@ -2209,6 +2752,16 @@ static constexpr const char *kProcessParentPid = "process.parent_pid"; */ static constexpr const char *kProcessPid = "process.pid"; +/** + * The real user ID (RUID) of the process. + */ +static constexpr const char *kProcessRealUserId = "process.real_user.id"; + +/** + * The username of the real user of the process. + */ +static constexpr const char *kProcessRealUserName = "process.real_user.name"; + /** * An additional description about the runtime of the process, for example a specific vendor * customization of the runtime environment. @@ -2226,6 +2779,46 @@ static constexpr const char *kProcessRuntimeName = "process.runtime.name"; */ static constexpr const char *kProcessRuntimeVersion = "process.runtime.version"; +/** + * The saved user ID (SUID) of the process. + */ +static constexpr const char *kProcessSavedUserId = "process.saved_user.id"; + +/** + * The username of the saved user. + */ +static constexpr const char *kProcessSavedUserName = "process.saved_user.name"; + +/** + * The PID of the process's session leader. This is also the session ID (SID) of the process. + */ +static constexpr const char *kProcessSessionLeaderPid = "process.session_leader.pid"; + +/** + * The effective user ID (EUID) of the process. + */ +static constexpr const char *kProcessUserId = "process.user.id"; + +/** + * The username of the effective user of the process. + */ +static constexpr const char *kProcessUserName = "process.user.name"; + +/** + * Virtual process identifier. + * + * <p>Notes: + <ul> <li>The process ID within a PID namespace. This is not necessarily unique across all + processes on the host but it is unique within the process namespace that the process exists + within.</li> </ul> + */ +static constexpr const char *kProcessVpid = "process.vpid"; + +/** + * The CPU state of the process. + */ +static constexpr const char *kProcessCpuState = "process.cpu.state"; + /** * The <a href="https://connect.build/docs/protocol/#error-codes">error codes</a> of the Connect * request. Error codes are always string values. @@ -2261,6 +2854,31 @@ static constexpr const char *kRpcJsonrpcRequestId = "rpc.jsonrpc.request_id"; */ static constexpr const char *kRpcJsonrpcVersion = "rpc.jsonrpc.version"; +/** + * Compressed size of the message in bytes. + */ +static constexpr const char *kRpcMessageCompressedSize = "rpc.message.compressed_size"; + +/** + * MUST be calculated as two different counters starting from {@code 1} one for sent messages and + one for received message. + * + * <p>Notes: + <ul> <li>This way we guarantee that the values will be consistent between different + implementations.</li> </ul> + */ +static constexpr const char *kRpcMessageId = "rpc.message.id"; + +/** + * Whether this is a received or sent message. + */ +static constexpr const char *kRpcMessageType = "rpc.message.type"; + +/** + * Uncompressed size of the message in bytes. + */ +static constexpr const char *kRpcMessageUncompressedSize = "rpc.message.uncompressed_size"; + /** * The name of the (logical) method being called, must be equal to the $method part in the span name. @@ -2347,9 +2965,9 @@ static constexpr const char *kServiceInstanceId = "service.instance.id"; * <p>Notes: <ul> <li>MUST be the same for all instances of horizontally scaled services. If the value was not specified, SDKs MUST fallback to {@code unknown_service:} concatenated with <a - href="process.md#process">{@code process.executable.name}</a>, e.g. {@code unknown_service:bash}. - If {@code process.executable.name} is not available, the value MUST be set to {@code - unknown_service}.</li> </ul> + href="process.md">{@code process.executable.name}</a>, e.g. {@code unknown_service:bash}. If {@code + process.executable.name} is not available, the value MUST be set to {@code unknown_service}.</li> + </ul> */ static constexpr const char *kServiceName = "service.name"; @@ -2382,6 +3000,18 @@ static constexpr const char *kSessionId = "session.id"; */ static constexpr const char *kSessionPreviousId = "session.previous_id"; +/** + * SignalR HTTP connection closure status. + */ +static constexpr const char *kSignalrConnectionStatus = "signalr.connection.status"; + +/** + * <a + * href="https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/TransportProtocols.md">SignalR + * transport type</a> + */ +static constexpr const char *kSignalrTransport = "signalr.transport"; + /** * Source address - domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. @@ -2398,6 +3028,73 @@ static constexpr const char *kSourceAddress = "source.address"; */ static constexpr const char *kSourcePort = "source.port"; +/** + * The device identifier + */ +static constexpr const char *kSystemDevice = "system.device"; + +/** + * The logical CPU number [0..n-1] + */ +static constexpr const char *kSystemCpuLogicalNumber = "system.cpu.logical_number"; + +/** + * The state of the CPU + */ +static constexpr const char *kSystemCpuState = "system.cpu.state"; + +/** + * The memory state + */ +static constexpr const char *kSystemMemoryState = "system.memory.state"; + +/** + * The paging access direction + */ +static constexpr const char *kSystemPagingDirection = "system.paging.direction"; + +/** + * The memory paging state + */ +static constexpr const char *kSystemPagingState = "system.paging.state"; + +/** + * The memory paging type + */ +static constexpr const char *kSystemPagingType = "system.paging.type"; + +/** + * The filesystem mode + */ +static constexpr const char *kSystemFilesystemMode = "system.filesystem.mode"; + +/** + * The filesystem mount path + */ +static constexpr const char *kSystemFilesystemMountpoint = "system.filesystem.mountpoint"; + +/** + * The filesystem state + */ +static constexpr const char *kSystemFilesystemState = "system.filesystem.state"; + +/** + * The filesystem type + */ +static constexpr const char *kSystemFilesystemType = "system.filesystem.type"; + +/** + * A stateless protocol MUST NOT set this attribute + */ +static constexpr const char *kSystemNetworkState = "system.network.state"; + +/** + * The process state, e.g., <a + * href="https://man7.org/linux/man-pages/man1/ps.1.html#PROCESS_STATE_CODES">Linux Process State + * Codes</a> + */ +static constexpr const char *kSystemProcessStatus = "system.process.status"; + /** * The language of the telemetry SDK. */ @@ -2740,6 +3437,12 @@ static constexpr const char *kUrlScheme = "url.scheme"; */ static constexpr const char *kUrlSubdomain = "url.subdomain"; +/** + * The low-cardinality template of an <a + * href="https://www.rfc-editor.org/rfc/rfc3986#section-4.2">absolute path reference</a>. + */ +static constexpr const char *kUrlTemplate = "url.template"; + /** * The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for example.com is {@code com}. @@ -2779,410 +3482,60 @@ static constexpr const char *kUserAgentOriginal = "user_agent.original"; static constexpr const char *kUserAgentVersion = "user_agent.version"; /** - * 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). - * - * <p>Notes: - <ul> <li>This may be different from {@code cloud.resource_id} if an alias is involved.</li> </ul> - */ -static constexpr const char *kAwsLambdaInvokedArn = "aws.lambda.invoked_arn"; - -/** - * Parent-child Reference type - * - * <p>Notes: - <ul> <li>The causal relationship between a child Span and a parent Span.</li> </ul> - */ -static constexpr const char *kOpentracingRefType = "opentracing.ref_type"; - -/** - * Name of the code, either "OK" or "ERROR". MUST NOT be set if the status code - * is UNSET. + * Additional description of the web engine (e.g. detailed version and edition information). */ -static constexpr const char *kOtelStatusCode = "otel.status_code"; +static constexpr const char *kWebengineDescription = "webengine.description"; -/** - * Description of the Status if it has a value, otherwise not set. - */ -static constexpr const char *kOtelStatusDescription = "otel.status_description"; - -/** - * The AWS request ID as returned in the response headers {@code x-amz-request-id} or {@code - * x-amz-requestid}. - */ -static constexpr const char *kAwsRequestId = "aws.request_id"; - -/** - * The S3 bucket name the request refers to. Corresponds to the {@code --bucket} parameter of the <a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html">S3 API</a> operations. - * - * <p>Notes: - <ul> <li>The {@code bucket} attribute is applicable to all S3 operations that reference a bucket, -i.e. that require the bucket name as a mandatory parameter. This applies to almost all S3 operations -except {@code list-buckets}.</li> </ul> - */ -static constexpr const char *kAwsS3Bucket = "aws.s3.bucket"; - -/** - * The source object (in the form {@code bucket}/{@code key}) for the copy operation. - * - * <p>Notes: - <ul> <li>The {@code copy_source} attribute applies to S3 copy operations and corresponds to the -{@code --copy-source} parameter of the <a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html">copy-object operation -within the S3 API</a>. This applies in particular to the following operations:</li><li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html">copy-object</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html">upload-part-copy</a></li> - </ul> - */ -static constexpr const char *kAwsS3CopySource = "aws.s3.copy_source"; - -/** - * The delete request container that specifies the objects to be deleted. - * - * <p>Notes: - <ul> <li>The {@code delete} attribute is only applicable to the <a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-object.html">delete-object</a> -operation. The {@code delete} attribute corresponds to the {@code --delete} parameter of the <a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-objects.html">delete-objects -operation within the S3 API</a>.</li> </ul> - */ -static constexpr const char *kAwsS3Delete = "aws.s3.delete"; - -/** - * The S3 object key the request refers to. Corresponds to the {@code --key} parameter of the <a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html">S3 API</a> operations. - * - * <p>Notes: - <ul> <li>The {@code key} attribute is applicable to all object-related S3 operations, i.e. that -require the object key as a mandatory parameter. This applies in particular to the following -operations:</li><li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html">copy-object</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-object.html">delete-object</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/get-object.html">get-object</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/head-object.html">head-object</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/put-object.html">put-object</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/restore-object.html">restore-object</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/select-object-content.html">select-object-content</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/abort-multipart-upload.html">abort-multipart-upload</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/complete-multipart-upload.html">complete-multipart-upload</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/create-multipart-upload.html">create-multipart-upload</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/list-parts.html">list-parts</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html">upload-part</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html">upload-part-copy</a></li> - </ul> - */ -static constexpr const char *kAwsS3Key = "aws.s3.key"; - -/** - * The part number of the part being uploaded in a multipart-upload operation. This is a positive -integer between 1 and 10,000. - * - * <p>Notes: - <ul> <li>The {@code part_number} attribute is only applicable to the <a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html">upload-part</a> and -<a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html">upload-part-copy</a> -operations. The {@code part_number} attribute corresponds to the {@code --part-number} parameter of -the <a href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html">upload-part -operation within the S3 API</a>.</li> </ul> - */ -static constexpr const char *kAwsS3PartNumber = "aws.s3.part_number"; - -/** - * Upload ID that identifies the multipart upload. - * - * <p>Notes: - <ul> <li>The {@code upload_id} attribute applies to S3 multipart-upload operations and corresponds -to the {@code --upload-id} parameter of the <a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html">S3 API</a> multipart -operations. This applies in particular to the following operations:</li><li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/abort-multipart-upload.html">abort-multipart-upload</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/complete-multipart-upload.html">complete-multipart-upload</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/list-parts.html">list-parts</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html">upload-part</a></li> -<li><a -href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html">upload-part-copy</a></li> - </ul> - */ -static constexpr const char *kAwsS3UploadId = "aws.s3.upload_id"; - -/** - * The GraphQL document being executed. - * - * <p>Notes: - <ul> <li>The value may be sanitized to exclude sensitive information.</li> </ul> - */ -static constexpr const char *kGraphqlDocument = "graphql.document"; - -/** - * The name of the operation being executed. - */ -static constexpr const char *kGraphqlOperationName = "graphql.operation.name"; - -/** - * The type of the operation being executed. - */ -static constexpr const char *kGraphqlOperationType = "graphql.operation.type"; - -/** - * Compressed size of the message in bytes. - */ -static constexpr const char *kMessageCompressedSize = "message.compressed_size"; - -/** - * MUST be calculated as two different counters starting from {@code 1} one for sent messages and - one for received message. - * - * <p>Notes: - <ul> <li>This way we guarantee that the values will be consistent between different - implementations.</li> </ul> - */ -static constexpr const char *kMessageId = "message.id"; - -/** - * Whether this is a received or sent message. - */ -static constexpr const char *kMessageType = "message.type"; - -/** - * Uncompressed size of the message in bytes. - */ -static constexpr const char *kMessageUncompressedSize = "message.uncompressed_size"; - -// Enum definitions -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 IosStateValues -{ -/** The app has become `active`. Associated with UIKit notification `applicationDidBecomeActive`. */ -static constexpr const char *kActive = "active"; -/** The app is now `inactive`. Associated with UIKit notification `applicationWillResignActive`. */ -static constexpr const char *kInactive = "inactive"; -/** The app is now in the background. This value is associated with UIKit notification - * `applicationDidEnterBackground`. */ -static constexpr const char *kBackground = "background"; -/** The app is now in the foreground. This value is associated with UIKit notification - * `applicationWillEnterForeground`. */ -static constexpr const char *kForeground = "foreground"; -/** The app is about to terminate. Associated with UIKit notification `applicationWillTerminate`. */ -static constexpr const char *kTerminate = "terminate"; -} // namespace IosStateValues - -namespace AndroidStateValues -{ -/** Any time before Activity.onResume() or, if the app has no Activity, Context.startService() has - * been called in the app for the first time. */ -static constexpr const char *kCreated = "created"; -/** Any time after Activity.onPause() or, if the app has no Activity, Context.stopService() has been - * called when the app was in the foreground state. */ -static constexpr const char *kBackground = "background"; -/** Any time after Activity.onResume() or, if the app has no Activity, Context.startService() has - * been called when the app was in either the created or background states. */ -static constexpr const char *kForeground = "foreground"; -} // namespace AndroidStateValues - -namespace StateValues -{ -/** idle. */ -static constexpr const char *kIdle = "idle"; -/** used. */ -static constexpr const char *kUsed = "used"; -} // namespace StateValues - -namespace AspnetcoreRateLimitingResultValues -{ -/** Lease was acquired. */ -static constexpr const char *kAcquired = "acquired"; -/** Lease request was rejected by the endpoint limiter. */ -static constexpr const char *kEndpointLimiter = "endpoint_limiter"; -/** Lease request was rejected by the global limiter. */ -static constexpr const char *kGlobalLimiter = "global_limiter"; -/** Lease request was canceled. */ -static constexpr const char *kRequestCanceled = "request_canceled"; -} // namespace AspnetcoreRateLimitingResultValues - -namespace SignalrConnectionStatusValues -{ -/** The connection was closed normally. */ -static constexpr const char *kNormalClosure = "normal_closure"; -/** The connection was closed due to a timeout. */ -static constexpr const char *kTimeout = "timeout"; -/** The connection was closed because the app is shutting down. */ -static constexpr const char *kAppShutdown = "app_shutdown"; -} // namespace SignalrConnectionStatusValues - -namespace SignalrTransportValues -{ -/** ServerSentEvents protocol. */ -static constexpr const char *kServerSentEvents = "server_sent_events"; -/** LongPolling protocol. */ -static constexpr const char *kLongPolling = "long_polling"; -/** WebSockets protocol. */ -static constexpr const char *kWebSockets = "web_sockets"; -} // namespace SignalrTransportValues - -namespace JvmMemoryTypeValues -{ -/** Heap memory. */ -static constexpr const char *kHeap = "heap"; -/** Non-heap memory. */ -static constexpr const char *kNonHeap = "non_heap"; -} // namespace JvmMemoryTypeValues - -namespace ProcessCpuStateValues -{ -/** system. */ -static constexpr const char *kSystem = "system"; -/** user. */ -static constexpr const char *kUser = "user"; -/** wait. */ -static constexpr const char *kWait = "wait"; -} // namespace ProcessCpuStateValues - -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 -{ -/** 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 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 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 +/** + * The name of the web engine. + */ +static constexpr const char *kWebengineName = "webengine.name"; -namespace SystemProcessStatusValues +/** + * The version of the web engine. + */ +static constexpr const char *kWebengineVersion = "webengine.version"; + +// Enum definitions +namespace AspnetcoreRateLimitingResultValues { -/** 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 SystemProcessStatusValues +/** Lease was acquired. */ +static constexpr const char *kAcquired = "acquired"; +/** Lease request was rejected by the endpoint limiter. */ +static constexpr const char *kEndpointLimiter = "endpoint_limiter"; +/** Lease request was rejected by the global limiter. */ +static constexpr const char *kGlobalLimiter = "global_limiter"; +/** Lease request was canceled. */ +static constexpr const char *kRequestCanceled = "request_canceled"; +} // namespace AspnetcoreRateLimitingResultValues + +namespace AspnetcoreDiagnosticsExceptionResultValues +{ +/** Exception was handled by the exception handling middleware. */ +static constexpr const char *kHandled = "handled"; +/** Exception was not handled by the exception handling middleware. */ +static constexpr const char *kUnhandled = "unhandled"; +/** Exception handling was skipped because the response had started. */ +static constexpr const char *kSkipped = "skipped"; +/** Exception handling didn't run because the request was aborted. */ +static constexpr const char *kAborted = "aborted"; +} // namespace AspnetcoreDiagnosticsExceptionResultValues + +namespace AspnetcoreRoutingMatchStatusValues +{ +/** Match succeeded. */ +static constexpr const char *kSuccess = "success"; +/** Match failed. */ +static constexpr const char *kFailure = "failure"; +} // namespace AspnetcoreRoutingMatchStatusValues + +namespace AwsEcsLaunchtypeValues +{ +/** ec2. */ +static constexpr const char *kEc2 = "ec2"; +/** fargate. */ +static constexpr const char *kFargate = "fargate"; +} // namespace AwsEcsLaunchtypeValues namespace CloudPlatformValues { @@ -3274,73 +3627,13 @@ static constexpr const char *kSystem = "system"; static constexpr const char *kKernel = "kernel"; } // namespace ContainerCpuStateValues -namespace DbCassandraConsistencyLevelValues -{ -/** all. */ -static constexpr const char *kAll = "all"; -/** each_quorum. */ -static constexpr const char *kEachQuorum = "each_quorum"; -/** quorum. */ -static constexpr const char *kQuorum = "quorum"; -/** local_quorum. */ -static constexpr const char *kLocalQuorum = "local_quorum"; -/** one. */ -static constexpr const char *kOne = "one"; -/** two. */ -static constexpr const char *kTwo = "two"; -/** three. */ -static constexpr const char *kThree = "three"; -/** local_one. */ -static constexpr const char *kLocalOne = "local_one"; -/** any. */ -static constexpr const char *kAny = "any"; -/** serial. */ -static constexpr const char *kSerial = "serial"; -/** local_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 +namespace DbClientConnectionsStateValues { -/** invalid. */ -static constexpr const char *kInvalid = "Invalid"; -/** create. */ -static constexpr const char *kCreate = "Create"; -/** patch. */ -static constexpr const char *kPatch = "Patch"; -/** read. */ -static constexpr const char *kRead = "Read"; -/** read_feed. */ -static constexpr const char *kReadFeed = "ReadFeed"; -/** delete. */ -static constexpr const char *kDelete = "Delete"; -/** replace. */ -static constexpr const char *kReplace = "Replace"; -/** execute. */ -static constexpr const char *kExecute = "Execute"; -/** query. */ -static constexpr const char *kQuery = "Query"; -/** head. */ -static constexpr const char *kHead = "Head"; -/** head_feed. */ -static constexpr const char *kHeadFeed = "HeadFeed"; -/** upsert. */ -static constexpr const char *kUpsert = "Upsert"; -/** batch. */ -static constexpr const char *kBatch = "Batch"; -/** query_plan. */ -static constexpr const char *kQueryPlan = "QueryPlan"; -/** execute_javascript. */ -static constexpr const char *kExecuteJavascript = "ExecuteJavaScript"; -} // namespace DbCosmosdbOperationTypeValues +/** idle. */ +static constexpr const char *kIdle = "idle"; +/** used. */ +static constexpr const char *kUsed = "used"; +} // namespace DbClientConnectionsStateValues namespace DbSystemValues { @@ -3450,6 +3743,95 @@ static constexpr const char *kSpanner = "spanner"; static constexpr const char *kTrino = "trino"; } // namespace DbSystemValues +namespace DbCassandraConsistencyLevelValues +{ +/** all. */ +static constexpr const char *kAll = "all"; +/** each_quorum. */ +static constexpr const char *kEachQuorum = "each_quorum"; +/** quorum. */ +static constexpr const char *kQuorum = "quorum"; +/** local_quorum. */ +static constexpr const char *kLocalQuorum = "local_quorum"; +/** one. */ +static constexpr const char *kOne = "one"; +/** two. */ +static constexpr const char *kTwo = "two"; +/** three. */ +static constexpr const char *kThree = "three"; +/** local_one. */ +static constexpr const char *kLocalOne = "local_one"; +/** any. */ +static constexpr const char *kAny = "any"; +/** serial. */ +static constexpr const char *kSerial = "serial"; +/** local_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. */ +static constexpr const char *kInvalid = "Invalid"; +/** create. */ +static constexpr const char *kCreate = "Create"; +/** patch. */ +static constexpr const char *kPatch = "Patch"; +/** read. */ +static constexpr const char *kRead = "Read"; +/** read_feed. */ +static constexpr const char *kReadFeed = "ReadFeed"; +/** delete. */ +static constexpr const char *kDelete = "Delete"; +/** replace. */ +static constexpr const char *kReplace = "Replace"; +/** execute. */ +static constexpr const char *kExecute = "Execute"; +/** query. */ +static constexpr const char *kQuery = "Query"; +/** head. */ +static constexpr const char *kHead = "Head"; +/** head_feed. */ +static constexpr const char *kHeadFeed = "HeadFeed"; +/** upsert. */ +static constexpr const char *kUpsert = "Upsert"; +/** batch. */ +static constexpr const char *kBatch = "Batch"; +/** query_plan. */ +static constexpr const char *kQueryPlan = "QueryPlan"; +/** execute_javascript. */ +static constexpr const char *kExecuteJavascript = "ExecuteJavaScript"; +} // namespace DbCosmosdbOperationTypeValues + +namespace AndroidStateValues +{ +/** Any time before Activity.onResume() or, if the app has no Activity, Context.startService() has + * been called in the app for the first time. */ +static constexpr const char *kCreated = "created"; +/** Any time after Activity.onPause() or, if the app has no Activity, Context.stopService() has been + * called when the app was in the foreground state. */ +static constexpr const char *kBackground = "background"; +/** Any time after Activity.onResume() or, if the app has no Activity, Context.startService() has + * been called when the app was in either the created or background states. */ +static constexpr const char *kForeground = "foreground"; +} // namespace AndroidStateValues + +namespace StateValues +{ +/** idle. */ +static constexpr const char *kIdle = "idle"; +/** used. */ +static constexpr const char *kUsed = "used"; +} // namespace StateValues + namespace HttpFlavorValues { /** HTTP/1.0. */ @@ -3466,6 +3848,22 @@ static constexpr const char *kSpdy = "SPDY"; static constexpr const char *kQuic = "QUIC"; } // namespace HttpFlavorValues +namespace IosStateValues +{ +/** The app has become `active`. Associated with UIKit notification `applicationDidBecomeActive`. */ +static constexpr const char *kActive = "active"; +/** The app is now `inactive`. Associated with UIKit notification `applicationWillResignActive`. */ +static constexpr const char *kInactive = "inactive"; +/** The app is now in the background. This value is associated with UIKit notification + * `applicationDidEnterBackground`. */ +static constexpr const char *kBackground = "background"; +/** The app is now in the foreground. This value is associated with UIKit notification + * `applicationWillEnterForeground`. */ +static constexpr const char *kForeground = "foreground"; +/** The app is about to terminate. Associated with UIKit notification `applicationWillTerminate`. */ +static constexpr const char *kTerminate = "terminate"; +} // namespace IosStateValues + namespace NetSockFamilyValues { /** IPv4 address. */ @@ -3490,6 +3888,14 @@ static constexpr const char *kInproc = "inproc"; static constexpr const char *kOther = "other"; } // namespace NetTransportValues +namespace MessageTypeValues +{ +/** sent. */ +static constexpr const char *kSent = "SENT"; +/** received. */ +static constexpr const char *kReceived = "RECEIVED"; +} // namespace MessageTypeValues + namespace SystemProcessesStatusValues { /** running. */ @@ -3554,6 +3960,22 @@ static constexpr const char *kTimer = "timer"; static constexpr const char *kOther = "other"; } // namespace FaasTriggerValues +namespace GenAiSystemValues +{ +/** OpenAI. */ +static constexpr const char *kOpenai = "openai"; +} // namespace GenAiSystemValues + +namespace GraphqlOperationTypeValues +{ +/** GraphQL query. */ +static constexpr const char *kQuery = "query"; +/** GraphQL mutation. */ +static constexpr const char *kMutation = "mutation"; +/** GraphQL subscription. */ +static constexpr const char *kSubscription = "subscription"; +} // namespace GraphqlOperationTypeValues + namespace HostArchValues { /** AMD64. */ @@ -3606,7 +4028,41 @@ static constexpr const char *kTrace = "TRACE"; static constexpr const char *kOther = "_OTHER"; } // namespace HttpRequestMethodValues -namespace MessagingOperationValues +namespace JvmMemoryTypeValues +{ +/** Heap memory. */ +static constexpr const char *kHeap = "heap"; +/** Non-heap memory. */ +static constexpr const char *kNonHeap = "non_heap"; +} // namespace JvmMemoryTypeValues + +namespace JvmThreadStateValues +{ +/** A thread that has not yet started is in this state. */ +static constexpr const char *kNew = "new"; +/** A thread executing in the Java virtual machine is in this state. */ +static constexpr const char *kRunnable = "runnable"; +/** A thread that is blocked waiting for a monitor lock is in this state. */ +static constexpr const char *kBlocked = "blocked"; +/** A thread that is waiting indefinitely for another thread to perform a particular action is in + * this state. */ +static constexpr const char *kWaiting = "waiting"; +/** A thread that is waiting for another thread to perform an action for up to a specified waiting + * time is in this state. */ +static constexpr const char *kTimedWaiting = "timed_waiting"; +/** A thread that has exited is in this state. */ +static constexpr const char *kTerminated = "terminated"; +} // namespace JvmThreadStateValues + +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 MessagingOperationTypeValues { /** One or more messages are provided for publishing to an intermediary. If a single message is * published, the context of the "Publish" span can be used as the creation context and no @@ -3622,7 +4078,31 @@ static constexpr const char *kReceive = "receive"; static constexpr const char *kDeliver = "process"; /** One or more messages are settled. */ static constexpr const char *kSettle = "settle"; -} // namespace MessagingOperationValues +} // namespace MessagingOperationTypeValues + +namespace MessagingSystemValues +{ +/** Apache ActiveMQ. */ +static constexpr const char *kActivemq = "activemq"; +/** Amazon Simple Queue Service (SQS). */ +static constexpr const char *kAwsSqs = "aws_sqs"; +/** Azure Event Grid. */ +static constexpr const char *kEventgrid = "eventgrid"; +/** Azure Event Hubs. */ +static constexpr const char *kEventhubs = "eventhubs"; +/** Azure Service Bus. */ +static constexpr const char *kServicebus = "servicebus"; +/** Google Cloud Pub/Sub. */ +static constexpr const char *kGcpPubsub = "gcp_pubsub"; +/** Java Message Service. */ +static constexpr const char *kJms = "jms"; +/** Apache Kafka. */ +static constexpr const char *kKafka = "kafka"; +/** RabbitMQ. */ +static constexpr const char *kRabbitmq = "rabbitmq"; +/** Apache RocketMQ. */ +static constexpr const char *kRocketmq = "rocketmq"; +} // namespace MessagingSystemValues namespace MessagingRocketmqConsumptionModelValues { @@ -3656,30 +4136,6 @@ static constexpr const char *kDeadLetter = "dead_letter"; static constexpr const char *kDefer = "defer"; } // namespace MessagingServicebusDispositionStatusValues -namespace MessagingSystemValues -{ -/** Apache ActiveMQ. */ -static constexpr const char *kActivemq = "activemq"; -/** Amazon Simple Queue Service (SQS). */ -static constexpr const char *kAwsSqs = "aws_sqs"; -/** Azure Event Grid. */ -static constexpr const char *kEventgrid = "eventgrid"; -/** Azure Event Hubs. */ -static constexpr const char *kEventhubs = "eventhubs"; -/** Azure Service Bus. */ -static constexpr const char *kServicebus = "servicebus"; -/** Google Cloud Pub/Sub. */ -static constexpr const char *kGcpPubsub = "gcp_pubsub"; -/** Java Message Service. */ -static constexpr const char *kJms = "jms"; -/** Apache Kafka. */ -static constexpr const char *kKafka = "kafka"; -/** RabbitMQ. */ -static constexpr const char *kRabbitmq = "rabbitmq"; -/** Apache RocketMQ. */ -static constexpr const char *kRocketmq = "rocketmq"; -} // namespace MessagingSystemValues - namespace NetworkConnectionSubtypeValues { /** GPRS. */ @@ -3768,6 +4224,14 @@ static constexpr const char *kIpv4 = "ipv4"; static constexpr const char *kIpv6 = "ipv6"; } // namespace NetworkTypeValues +namespace OpentracingRefTypeValues +{ +/** The parent Span depends on the child Span in some capacity. */ +static constexpr const char *kChildOf = "child_of"; +/** The parent Span doesn't depend in any way on the result of the child Span. */ +static constexpr const char *kFollowsFrom = "follows_from"; +} // namespace OpentracingRefTypeValues + namespace OsTypeValues { /** Microsoft Windows. */ @@ -3794,6 +4258,41 @@ static constexpr const char *kSolaris = "solaris"; static constexpr const char *kZOs = "z_os"; } // namespace OsTypeValues +namespace OtelStatusCodeValues +{ +/** The operation has been validated by an Application developer or Operator to have completed + * successfully. */ +static constexpr const char *kOk = "OK"; +/** The operation contains an error. */ +static constexpr const char *kError = "ERROR"; +} // namespace OtelStatusCodeValues + +namespace ProcessContextSwitchTypeValues +{ +/** voluntary. */ +static constexpr const char *kVoluntary = "voluntary"; +/** involuntary. */ +static constexpr const char *kInvoluntary = "involuntary"; +} // namespace ProcessContextSwitchTypeValues + +namespace ProcessPagingFaultTypeValues +{ +/** major. */ +static constexpr const char *kMajor = "major"; +/** minor. */ +static constexpr const char *kMinor = "minor"; +} // namespace ProcessPagingFaultTypeValues + +namespace ProcessCpuStateValues +{ +/** system. */ +static constexpr const char *kSystem = "system"; +/** user. */ +static constexpr const char *kUser = "user"; +/** wait. */ +static constexpr const char *kWait = "wait"; +} // namespace ProcessCpuStateValues + namespace RpcConnectRpcErrorCodeValues { /** cancelled. */ @@ -3868,6 +4367,14 @@ static constexpr const int kDataLoss = 15; static constexpr const int kUnauthenticated = 16; } // namespace RpcGrpcStatusCodeValues +namespace RpcMessageTypeValues +{ +/** sent. */ +static constexpr const char *kSent = "SENT"; +/** received. */ +static constexpr const char *kReceived = "RECEIVED"; +} // namespace RpcMessageTypeValues + namespace RpcSystemValues { /** gRPC. */ @@ -3882,6 +4389,148 @@ static constexpr const char *kApacheDubbo = "apache_dubbo"; static constexpr const char *kConnectRpc = "connect_rpc"; } // namespace RpcSystemValues +namespace SignalrConnectionStatusValues +{ +/** The connection was closed normally. */ +static constexpr const char *kNormalClosure = "normal_closure"; +/** The connection was closed due to a timeout. */ +static constexpr const char *kTimeout = "timeout"; +/** The connection was closed because the app is shutting down. */ +static constexpr const char *kAppShutdown = "app_shutdown"; +} // namespace SignalrConnectionStatusValues + +namespace SignalrTransportValues +{ +/** ServerSentEvents protocol. */ +static constexpr const char *kServerSentEvents = "server_sent_events"; +/** LongPolling protocol. */ +static constexpr const char *kLongPolling = "long_polling"; +/** WebSockets protocol. */ +static constexpr const char *kWebSockets = "web_sockets"; +} // namespace SignalrTransportValues + +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 +{ +/** 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 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 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 SystemProcessStatusValues +{ +/** 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 SystemProcessStatusValues + namespace TelemetrySdkLanguageValues { /** cpp. */ @@ -3918,41 +4567,6 @@ static constexpr const char *kSsl = "ssl"; static constexpr const char *kTls = "tls"; } // namespace TlsProtocolNameValues -namespace OpentracingRefTypeValues -{ -/** The parent Span depends on the child Span in some capacity. */ -static constexpr const char *kChildOf = "child_of"; -/** The parent Span doesn't depend in any way on the result of the child Span. */ -static constexpr const char *kFollowsFrom = "follows_from"; -} // namespace OpentracingRefTypeValues - -namespace OtelStatusCodeValues -{ -/** The operation has been validated by an Application developer or Operator to have completed - * successfully. */ -static constexpr const char *kOk = "OK"; -/** The operation contains an error. */ -static constexpr const char *kError = "ERROR"; -} // namespace OtelStatusCodeValues - -namespace GraphqlOperationTypeValues -{ -/** GraphQL query. */ -static constexpr const char *kQuery = "query"; -/** GraphQL mutation. */ -static constexpr const char *kMutation = "mutation"; -/** GraphQL subscription. */ -static constexpr const char *kSubscription = "subscription"; -} // namespace GraphqlOperationTypeValues - -namespace MessageTypeValues -{ -/** sent. */ -static constexpr const char *kSent = "SENT"; -/** received. */ -static constexpr const char *kReceived = "RECEIVED"; -} // namespace MessageTypeValues - } // namespace SemanticConventions } // namespace trace OPENTELEMETRY_END_NAMESPACE diff --git a/buildscripts/semantic-convention/generate.sh b/buildscripts/semantic-convention/generate.sh index eccc066c1c..2bcd07e2f9 100755 --- a/buildscripts/semantic-convention/generate.sh +++ b/buildscripts/semantic-convention/generate.sh @@ -19,7 +19,7 @@ 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.25.0 +SEMCONV_VERSION=1.26.0 # repository: https://github.com/open-telemetry/build-tools GENERATOR_VERSION=0.24.0 diff --git a/buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 b/buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 index 3ec0317d4d..0ed9ce8dab 100644 --- a/buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 +++ b/buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 @@ -58,7 +58,17 @@ namespace {{class}} */ static constexpr const char *kSchemaUrl = "{{schemaUrl}}"; {%- for attribute in attributes if attribute.is_local and not attribute.ref %} +{# + MAINTAINER: + semconv "messaging.client_id" is deprecated + semconv "messaging.client.id" is to be used instead + + Now, because we use k{{attribute.fqn | to_camelcase(True)}}, + both names collide on C++ symbol kMessagingClientId. + Do not generate code for semconv "messaging.client_id" +#} +{%- if (attribute.fqn != "messaging.client_id") %} /** * {{attribute.brief | render_markdown(code="{{@code {0}}}", paragraph="{0}")}} {%- if attribute.note %} @@ -75,6 +85,7 @@ static constexpr const char *kSchemaUrl = "{{schemaUrl}}"; OPENTELEMETRY_DEPRECATED {%- endif %} static constexpr const char *k{{attribute.fqn | to_camelcase(True)}} = "{{attribute.fqn}}"; +{%- endif %} {%- endfor %} // Enum definitions diff --git a/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h b/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h index 7e550f238a..03996f2621 100644 --- a/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h +++ b/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h @@ -24,67 +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.25.0"; +static constexpr const char *kSchemaUrl = "https://opentelemetry.io/schemas/1.26.0"; /** - * Identifies the class / type of event. - * - * <p>Notes: - <ul> <li>Event names are subject to the same rules as <a - href="https://github.com/open-telemetry/opentelemetry-specification/tree/v1.31.0/specification/common/attribute-naming.md">attribute - names</a>. Notably, event names are namespaced to avoid collisions and provide a clean separation - of semantics for events in separate domains like browser, mobile, and kubernetes.</li> </ul> - */ -static constexpr const char *kEventName = "event.name"; - -/** - * A unique identifier for the Log Record. - * - * <p>Notes: - <ul> <li>If an id is provided, other log records with the same id will be considered duplicates -and can be removed safely. This means, that two distinguishable log records MUST have different -values. The id MAY be an <a href="https://github.com/ulid/spec">Universally Unique Lexicographically -Sortable Identifier (ULID)</a>, but other identifiers (e.g. UUID) may be used as needed.</li> </ul> - */ -static constexpr const char *kLogRecordUid = "log.record.uid"; - -/** - * The stream associated with the log. See below for a list of well-known values. - */ -static constexpr const char *kLogIostream = "log.iostream"; - -/** - * The basename of the file. - */ -static constexpr const char *kLogFileName = "log.file.name"; - -/** - * The basename of the file, with symlinks resolved. - */ -static constexpr const char *kLogFileNameResolved = "log.file.name_resolved"; - -/** - * The full path to the file. - */ -static constexpr const char *kLogFilePath = "log.file.path"; - -/** - * The full path to the file, with symlinks resolved. - */ -static constexpr const char *kLogFilePathResolved = "log.file.path_resolved"; - -/** - * The name of the connection pool; unique within the instrumented application. In case the - * connection pool implementation doesn't provide a name, instrumentation should use a combination - * of {@code server.address} and {@code server.port} attributes formatted as {@code - * server.address:server.port}. - */ -static constexpr const char *kPoolName = "pool.name"; - -/** - * The state of a connection in the pool + * Uniquely identifies the framework API revision offered by a version ({@code os.version}) of the + * android operating system. More information can be found <a + * href="https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels">here</a>. */ -static constexpr const char *kState = "state"; +static constexpr const char *kAndroidOsApiLevel = "android.os.api_level"; /** * Rate-limiting result, shows whether the lease was acquired or contains a rejection reason @@ -99,6 +46,12 @@ static constexpr const char *kAspnetcoreRateLimitingResult = "aspnetcore.rate_li static constexpr const char *kAspnetcoreDiagnosticsHandlerType = "aspnetcore.diagnostics.handler.type"; +/** + * ASP.NET Core exception middleware handling result + */ +static constexpr const char *kAspnetcoreDiagnosticsExceptionResult = + "aspnetcore.diagnostics.exception.result"; + /** * Rate limiting policy name. */ @@ -115,239 +68,336 @@ static constexpr const char *kAspnetcoreRequestIsUnhandled = "aspnetcore.request static constexpr const char *kAspnetcoreRoutingIsFallback = "aspnetcore.routing.is_fallback"; /** - * SignalR HTTP connection closure status. + * Match result - success or failure */ -static constexpr const char *kSignalrConnectionStatus = "signalr.connection.status"; +static constexpr const char *kAspnetcoreRoutingMatchStatus = "aspnetcore.routing.match_status"; /** - * <a - * href="https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/TransportProtocols.md">SignalR - * transport type</a> + * The AWS request ID as returned in the response headers {@code x-amz-request-id} or {@code + * x-amz-requestid}. */ -static constexpr const char *kSignalrTransport = "signalr.transport"; +static constexpr const char *kAwsRequestId = "aws.request_id"; /** - * Name of the buffer pool. - * - * <p>Notes: - <ul> <li>Pool names are generally obtained via <a - href="https://docs.oracle.com/en/java/javase/11/docs/api/java.management/java/lang/management/BufferPoolMXBean.html#getName()">BufferPoolMXBean#getName()</a>.</li> - </ul> + * The JSON-serialized value of each item in the {@code AttributeDefinitions} request field. */ -static constexpr const char *kJvmBufferPoolName = "jvm.buffer.pool.name"; +static constexpr const char *kAwsDynamodbAttributeDefinitions = + "aws.dynamodb.attribute_definitions"; /** - * Name of the memory pool. - * - * <p>Notes: - <ul> <li>Pool names are generally obtained via <a - href="https://docs.oracle.com/en/java/javase/11/docs/api/java.management/java/lang/management/MemoryPoolMXBean.html#getName()">MemoryPoolMXBean#getName()</a>.</li> - </ul> + * The value of the {@code AttributesToGet} request parameter. */ -static constexpr const char *kJvmMemoryPoolName = "jvm.memory.pool.name"; +static constexpr const char *kAwsDynamodbAttributesToGet = "aws.dynamodb.attributes_to_get"; /** - * The type of memory. + * The value of the {@code ConsistentRead} request parameter. */ -static constexpr const char *kJvmMemoryType = "jvm.memory.type"; +static constexpr const char *kAwsDynamodbConsistentRead = "aws.dynamodb.consistent_read"; /** - * The CPU state for this data point. A process SHOULD be characterized <em>either</em> by data - * points with no {@code state} labels, <em>or only</em> data points with {@code state} labels. + * The JSON-serialized value of each item in the {@code ConsumedCapacity} response field. */ -static constexpr const char *kProcessCpuState = "process.cpu.state"; +static constexpr const char *kAwsDynamodbConsumedCapacity = "aws.dynamodb.consumed_capacity"; /** - * The device identifier + * The value of the {@code Count} response parameter. */ -static constexpr const char *kSystemDevice = "system.device"; +static constexpr const char *kAwsDynamodbCount = "aws.dynamodb.count"; /** - * The logical CPU number [0..n-1] + * The value of the {@code ExclusiveStartTableName} request parameter. */ -static constexpr const char *kSystemCpuLogicalNumber = "system.cpu.logical_number"; +static constexpr const char *kAwsDynamodbExclusiveStartTable = "aws.dynamodb.exclusive_start_table"; /** - * The CPU state for this data point. A system's CPU SHOULD be characterized <em>either</em> by data - * points with no {@code state} labels, <em>or only</em> data points with {@code state} labels. + * The JSON-serialized value of each item in the {@code GlobalSecondaryIndexUpdates} request field. */ -static constexpr const char *kSystemCpuState = "system.cpu.state"; +static constexpr const char *kAwsDynamodbGlobalSecondaryIndexUpdates = + "aws.dynamodb.global_secondary_index_updates"; /** - * The memory state + * The JSON-serialized value of each item of the {@code GlobalSecondaryIndexes} request field */ -static constexpr const char *kSystemMemoryState = "system.memory.state"; +static constexpr const char *kAwsDynamodbGlobalSecondaryIndexes = + "aws.dynamodb.global_secondary_indexes"; /** - * The paging access direction + * The value of the {@code IndexName} request parameter. */ -static constexpr const char *kSystemPagingDirection = "system.paging.direction"; +static constexpr const char *kAwsDynamodbIndexName = "aws.dynamodb.index_name"; /** - * The memory paging state + * The JSON-serialized value of the {@code ItemCollectionMetrics} response field. */ -static constexpr const char *kSystemPagingState = "system.paging.state"; +static constexpr const char *kAwsDynamodbItemCollectionMetrics = + "aws.dynamodb.item_collection_metrics"; /** - * The memory paging type + * The value of the {@code Limit} request parameter. */ -static constexpr const char *kSystemPagingType = "system.paging.type"; +static constexpr const char *kAwsDynamodbLimit = "aws.dynamodb.limit"; /** - * The filesystem mode + * The JSON-serialized value of each item of the {@code LocalSecondaryIndexes} request field. */ -static constexpr const char *kSystemFilesystemMode = "system.filesystem.mode"; +static constexpr const char *kAwsDynamodbLocalSecondaryIndexes = + "aws.dynamodb.local_secondary_indexes"; /** - * The filesystem mount path + * The value of the {@code ProjectionExpression} request parameter. */ -static constexpr const char *kSystemFilesystemMountpoint = "system.filesystem.mountpoint"; +static constexpr const char *kAwsDynamodbProjection = "aws.dynamodb.projection"; /** - * The filesystem state + * The value of the {@code ProvisionedThroughput.ReadCapacityUnits} request parameter. */ -static constexpr const char *kSystemFilesystemState = "system.filesystem.state"; +static constexpr const char *kAwsDynamodbProvisionedReadCapacity = + "aws.dynamodb.provisioned_read_capacity"; /** - * The filesystem type + * The value of the {@code ProvisionedThroughput.WriteCapacityUnits} request parameter. */ -static constexpr const char *kSystemFilesystemType = "system.filesystem.type"; +static constexpr const char *kAwsDynamodbProvisionedWriteCapacity = + "aws.dynamodb.provisioned_write_capacity"; /** - * A stateless protocol MUST NOT set this attribute + * The value of the {@code ScanIndexForward} request parameter. */ -static constexpr const char *kSystemNetworkState = "system.network.state"; +static constexpr const char *kAwsDynamodbScanForward = "aws.dynamodb.scan_forward"; /** - * The process state, e.g., <a - * href="https://man7.org/linux/man-pages/man1/ps.1.html#PROCESS_STATE_CODES">Linux Process State - * Codes</a> + * The value of the {@code ScannedCount} response parameter. */ -static constexpr const char *kSystemProcessStatus = "system.process.status"; +static constexpr const char *kAwsDynamodbScannedCount = "aws.dynamodb.scanned_count"; /** - * Uniquely identifies the framework API revision offered by a version ({@code os.version}) of the - * android operating system. More information can be found <a - * href="https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels">here</a>. + * The value of the {@code Segment} request parameter. */ -static constexpr const char *kAndroidOsApiLevel = "android.os.api_level"; +static constexpr const char *kAwsDynamodbSegment = "aws.dynamodb.segment"; /** - * The JSON-serialized value of each item in the {@code AttributeDefinitions} request field. + * The value of the {@code Select} request parameter. */ -static constexpr const char *kAwsDynamodbAttributeDefinitions = - "aws.dynamodb.attribute_definitions"; +static constexpr const char *kAwsDynamodbSelect = "aws.dynamodb.select"; /** - * The value of the {@code AttributesToGet} request parameter. + * The number of items in the {@code TableNames} response parameter. */ -static constexpr const char *kAwsDynamodbAttributesToGet = "aws.dynamodb.attributes_to_get"; +static constexpr const char *kAwsDynamodbTableCount = "aws.dynamodb.table_count"; /** - * The value of the {@code ConsistentRead} request parameter. + * The keys in the {@code RequestItems} object field. */ -static constexpr const char *kAwsDynamodbConsistentRead = "aws.dynamodb.consistent_read"; +static constexpr const char *kAwsDynamodbTableNames = "aws.dynamodb.table_names"; /** - * The JSON-serialized value of each item in the {@code ConsumedCapacity} response field. + * The value of the {@code TotalSegments} request parameter. */ -static constexpr const char *kAwsDynamodbConsumedCapacity = "aws.dynamodb.consumed_capacity"; +static constexpr const char *kAwsDynamodbTotalSegments = "aws.dynamodb.total_segments"; /** - * The value of the {@code Count} response parameter. + * The ID of a running ECS task. The ID MUST be extracted from {@code task.arn}. */ -static constexpr const char *kAwsDynamodbCount = "aws.dynamodb.count"; +static constexpr const char *kAwsEcsTaskId = "aws.ecs.task.id"; /** - * The value of the {@code ExclusiveStartTableName} request parameter. + * The ARN of an <a + * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/clusters.html">ECS cluster</a>. */ -static constexpr const char *kAwsDynamodbExclusiveStartTable = "aws.dynamodb.exclusive_start_table"; +static constexpr const char *kAwsEcsClusterArn = "aws.ecs.cluster.arn"; /** - * The JSON-serialized value of each item in the {@code GlobalSecondaryIndexUpdates} request field. + * The Amazon Resource Name (ARN) of an <a + * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_instances.html">ECS + * container instance</a>. */ -static constexpr const char *kAwsDynamodbGlobalSecondaryIndexUpdates = - "aws.dynamodb.global_secondary_index_updates"; +static constexpr const char *kAwsEcsContainerArn = "aws.ecs.container.arn"; /** - * The JSON-serialized value of each item of the {@code GlobalSecondaryIndexes} request field + * The <a + * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_types.html">launch + * type</a> for an ECS task. */ -static constexpr const char *kAwsDynamodbGlobalSecondaryIndexes = - "aws.dynamodb.global_secondary_indexes"; +static constexpr const char *kAwsEcsLaunchtype = "aws.ecs.launchtype"; /** - * The value of the {@code IndexName} request parameter. + * The ARN of a running <a + * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-account-settings.html#ecs-resource-ids">ECS + * task</a>. */ -static constexpr const char *kAwsDynamodbIndexName = "aws.dynamodb.index_name"; +static constexpr const char *kAwsEcsTaskArn = "aws.ecs.task.arn"; /** - * The JSON-serialized value of the {@code ItemCollectionMetrics} response field. + * The family name of the <a + * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html">ECS task + * definition</a> used to create the ECS task. */ -static constexpr const char *kAwsDynamodbItemCollectionMetrics = - "aws.dynamodb.item_collection_metrics"; +static constexpr const char *kAwsEcsTaskFamily = "aws.ecs.task.family"; /** - * The value of the {@code Limit} request parameter. + * The revision for the task definition used to create the ECS task. */ -static constexpr const char *kAwsDynamodbLimit = "aws.dynamodb.limit"; +static constexpr const char *kAwsEcsTaskRevision = "aws.ecs.task.revision"; /** - * The JSON-serialized value of each item of the {@code LocalSecondaryIndexes} request field. + * The ARN of an EKS cluster. */ -static constexpr const char *kAwsDynamodbLocalSecondaryIndexes = - "aws.dynamodb.local_secondary_indexes"; +static constexpr const char *kAwsEksClusterArn = "aws.eks.cluster.arn"; /** - * The value of the {@code ProjectionExpression} request parameter. + * The Amazon Resource Name(s) (ARN) of the AWS log group(s). + * + * <p>Notes: + <ul> <li>See the <a + href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html#CWL_ARN_Format">log + group ARN format documentation</a>.</li> </ul> */ -static constexpr const char *kAwsDynamodbProjection = "aws.dynamodb.projection"; +static constexpr const char *kAwsLogGroupArns = "aws.log.group.arns"; /** - * The value of the {@code ProvisionedThroughput.ReadCapacityUnits} request parameter. + * The name(s) of the AWS log group(s) an application is writing to. + * + * <p>Notes: + <ul> <li>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.</li> </ul> */ -static constexpr const char *kAwsDynamodbProvisionedReadCapacity = - "aws.dynamodb.provisioned_read_capacity"; +static constexpr const char *kAwsLogGroupNames = "aws.log.group.names"; /** - * The value of the {@code ProvisionedThroughput.WriteCapacityUnits} request parameter. + * The ARN(s) of the AWS log stream(s). + * + * <p>Notes: + <ul> <li>See the <a + href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html#CWL_ARN_Format">log + stream ARN format documentation</a>. One log group can contain several log streams, so these ARNs + necessarily identify both a log group and a log stream.</li> </ul> */ -static constexpr const char *kAwsDynamodbProvisionedWriteCapacity = - "aws.dynamodb.provisioned_write_capacity"; +static constexpr const char *kAwsLogStreamArns = "aws.log.stream.arns"; /** - * The value of the {@code ScanIndexForward} request parameter. + * The name(s) of the AWS log stream(s) an application is writing to. */ -static constexpr const char *kAwsDynamodbScanForward = "aws.dynamodb.scan_forward"; +static constexpr const char *kAwsLogStreamNames = "aws.log.stream.names"; /** - * The value of the {@code ScannedCount} response parameter. + * 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). + * + * <p>Notes: + <ul> <li>This may be different from {@code cloud.resource_id} if an alias is involved.</li> </ul> */ -static constexpr const char *kAwsDynamodbScannedCount = "aws.dynamodb.scanned_count"; +static constexpr const char *kAwsLambdaInvokedArn = "aws.lambda.invoked_arn"; /** - * The value of the {@code Segment} request parameter. + * The S3 bucket name the request refers to. Corresponds to the {@code --bucket} parameter of the <a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html">S3 API</a> operations. + * + * <p>Notes: + <ul> <li>The {@code bucket} attribute is applicable to all S3 operations that reference a bucket, +i.e. that require the bucket name as a mandatory parameter. This applies to almost all S3 operations +except {@code list-buckets}.</li> </ul> */ -static constexpr const char *kAwsDynamodbSegment = "aws.dynamodb.segment"; +static constexpr const char *kAwsS3Bucket = "aws.s3.bucket"; /** - * The value of the {@code Select} request parameter. + * The source object (in the form {@code bucket}/{@code key}) for the copy operation. + * + * <p>Notes: + <ul> <li>The {@code copy_source} attribute applies to S3 copy operations and corresponds to the +{@code --copy-source} parameter of the <a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html">copy-object operation +within the S3 API</a>. This applies in particular to the following operations:</li><li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html">copy-object</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html">upload-part-copy</a></li> + </ul> + */ +static constexpr const char *kAwsS3CopySource = "aws.s3.copy_source"; + +/** + * The delete request container that specifies the objects to be deleted. + * + * <p>Notes: + <ul> <li>The {@code delete} attribute is only applicable to the <a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-object.html">delete-object</a> +operation. The {@code delete} attribute corresponds to the {@code --delete} parameter of the <a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-objects.html">delete-objects +operation within the S3 API</a>.</li> </ul> */ -static constexpr const char *kAwsDynamodbSelect = "aws.dynamodb.select"; +static constexpr const char *kAwsS3Delete = "aws.s3.delete"; /** - * The number of items in the {@code TableNames} response parameter. + * The S3 object key the request refers to. Corresponds to the {@code --key} parameter of the <a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html">S3 API</a> operations. + * + * <p>Notes: + <ul> <li>The {@code key} attribute is applicable to all object-related S3 operations, i.e. that +require the object key as a mandatory parameter. This applies in particular to the following +operations:</li><li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html">copy-object</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-object.html">delete-object</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/get-object.html">get-object</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/head-object.html">head-object</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/put-object.html">put-object</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/restore-object.html">restore-object</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/select-object-content.html">select-object-content</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/abort-multipart-upload.html">abort-multipart-upload</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/complete-multipart-upload.html">complete-multipart-upload</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/create-multipart-upload.html">create-multipart-upload</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/list-parts.html">list-parts</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html">upload-part</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html">upload-part-copy</a></li> + </ul> */ -static constexpr const char *kAwsDynamodbTableCount = "aws.dynamodb.table_count"; +static constexpr const char *kAwsS3Key = "aws.s3.key"; /** - * The keys in the {@code RequestItems} object field. + * The part number of the part being uploaded in a multipart-upload operation. This is a positive +integer between 1 and 10,000. + * + * <p>Notes: + <ul> <li>The {@code part_number} attribute is only applicable to the <a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html">upload-part</a> and +<a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html">upload-part-copy</a> +operations. The {@code part_number} attribute corresponds to the {@code --part-number} parameter of +the <a href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html">upload-part +operation within the S3 API</a>.</li> </ul> */ -static constexpr const char *kAwsDynamodbTableNames = "aws.dynamodb.table_names"; +static constexpr const char *kAwsS3PartNumber = "aws.s3.part_number"; /** - * The value of the {@code TotalSegments} request parameter. + * Upload ID that identifies the multipart upload. + * + * <p>Notes: + <ul> <li>The {@code upload_id} attribute applies to S3 multipart-upload operations and corresponds +to the {@code --upload-id} parameter of the <a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html">S3 API</a> multipart +operations. This applies in particular to the following operations:</li><li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/abort-multipart-upload.html">abort-multipart-upload</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/complete-multipart-upload.html">complete-multipart-upload</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/list-parts.html">list-parts</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html">upload-part</a></li> +<li><a +href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html">upload-part-copy</a></li> + </ul> */ -static constexpr const char *kAwsDynamodbTotalSegments = "aws.dynamodb.total_segments"; +static constexpr const char *kAwsS3UploadId = "aws.s3.upload_id"; /** * Array of brand name and version separated by a space @@ -600,7 +650,7 @@ href="https://docs.docker.com/engine/api/v1.43/#tag/Container/operation/Containe endpoint. K8s defines a link to the container registry repository with digest {@code "imageID": "registry.azurecr.io /namespace/service/dockerfile@sha256:bdeabd40c3a8a492eaf9e8e44d0ebbb84bac7ee25ac0cf8a7159d25f62555625"}. -The ID is assinged by the container runtime and can vary in different environments. Consider using +The ID is assigned 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.</li> </ul> */ @@ -640,6 +690,67 @@ static constexpr const char *kContainerName = "container.name"; */ static constexpr const char *kContainerRuntime = "container.runtime"; +/** + * The name of the connection pool; unique within the instrumented application. In case the + * connection pool implementation doesn't provide a name, instrumentation should use a combination + * of {@code server.address} and {@code server.port} attributes formatted as {@code + * server.address:server.port}. + */ +static constexpr const char *kDbClientConnectionsPoolName = "db.client.connections.pool.name"; + +/** + * The state of a connection in the pool + */ +static constexpr const char *kDbClientConnectionsState = "db.client.connections.state"; + +/** + * The name of a collection (table, container) within the database. + * + * <p>Notes: + <ul> <li>If the collection name is parsed from the query, it SHOULD match the value provided in +the query and may be qualified with the schema and database name. It is RECOMMENDED to capture the +value as provided by the application without attempting to do any case normalization.</li> </ul> + */ +static constexpr const char *kDbCollectionName = "db.collection.name"; + +/** + * The name of the database, fully qualified within the server address and port. + * + * <p>Notes: + <ul> <li>If a database system has multiple namespace components, they SHOULD be concatenated +(potentially using database system specific conventions) from most general to most specific +namespace component, and more specific namespaces SHOULD NOT be captured without the more general +namespaces, to ensure that "startswith" queries for the more general namespaces will be +valid. Semantic conventions for individual database systems SHOULD document what {@code +db.namespace} means in the context of that system. It is RECOMMENDED to capture the value as +provided by the application without attempting to do any case normalization.</li> </ul> + */ +static constexpr const char *kDbNamespace = "db.namespace"; + +/** + * The name of the operation or command being executed. + * + * <p>Notes: + <ul> <li>It is RECOMMENDED to capture the value as provided by the application without attempting + to do any case normalization.</li> </ul> + */ +static constexpr const char *kDbOperationName = "db.operation.name"; + +/** + * The database query being executed. + */ +static constexpr const char *kDbQueryText = "db.query.text"; + +/** + * The database management system (DBMS) product as identified by the client instrumentation. + * + * <p>Notes: + <ul> <li>The actual DBMS may differ from the one identified by the client. For example, when using + PostgreSQL client libraries to connect to a CockroachDB, the {@code db.system} is set to {@code + postgresql} based on the instrumentation's best knowledge.</li> </ul> + */ +static constexpr const char *kDbSystem = "db.system"; + /** * The consistency level of the query. Based on consistency values from <a * href="https://docs.datastax.com/en/cassandra-oss/3.0/cassandra/dml/dmlConfigConsistency.html">CQL</a>. @@ -673,19 +784,6 @@ static constexpr const char *kDbCassandraPageSize = "db.cassandra.page_size"; static constexpr const char *kDbCassandraSpeculativeExecutionCount = "db.cassandra.speculative_execution_count"; -/** - * The name of the primary Cassandra table that the operation is acting upon, including the keyspace - name (if applicable). - * - * <p>Notes: - <ul> <li>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.</li> </ul> - */ -static constexpr const char *kDbCassandraTable = "db.cassandra.table"; - /** * Unique Cosmos client instance id. */ @@ -696,11 +794,6 @@ static constexpr const char *kDbCosmosdbClientId = "db.cosmosdb.client_id"; */ static constexpr const char *kDbCosmosdbConnectionMode = "db.cosmosdb.connection_mode"; -/** - * Cosmos DB container name. - */ -static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; - /** * CosmosDB Operation Type. */ @@ -732,136 +825,184 @@ static constexpr const char *kDbCosmosdbSubStatusCode = "db.cosmosdb.sub_status_ static constexpr const char *kDbElasticsearchClusterName = "db.elasticsearch.cluster.name"; /** - * An identifier (address, unique name, or any other identifier) of the database instance that is - * executing queries or mutations on the current connection. This is useful in cases where the - * database is running in a clustered environment and the instrumentation is able to record the node - * executing the query. The client may obtain this value in databases like MySQL using queries like - * {@code select @@hostname}. + * Represents the human-readable identifier of the node/instance to which a request was routed. + */ +static constexpr const char *kDbElasticsearchNodeName = "db.elasticsearch.node.name"; + +/** + * Name of the <a href="https://wikipedia.org/wiki/Deployment_environment">deployment +environment</a> (aka deployment tier). + * + * <p>Notes: + <ul> <li>{@code deployment.environment} does not affect the uniqueness constraints defined through +the {@code service.namespace}, {@code service.name} and {@code service.instance.id} resource +attributes. This implies that resources carrying the following attribute combinations MUST be +considered to be identifying the same service:</li><li>{@code service.name=frontend}, {@code +deployment.environment=production}</li> <li>{@code service.name=frontend}, {@code +deployment.environment=staging}.</li> + </ul> + */ +static constexpr const char *kDeploymentEnvironment = "deployment.environment"; + +/** + * Deprecated use the {@code device.app.lifecycle} event definition including {@code android.state} + as a payload field instead. + * + * <p>Notes: + <ul> <li>The Android lifecycle states are defined in <a + href="https://developer.android.com/guide/components/activities/activity-lifecycle#lc">Activity + lifecycle callbacks</a>, and from which the {@code OS identifiers} are derived.</li> </ul> + */ +static constexpr const char *kAndroidState = "android.state"; + +/** + * Deprecated, use {@code db.collection.name} instead. + * + * @deprecated Deprecated, use `db.collection.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbCassandraTable = "db.cassandra.table"; + +/** + * Deprecated, use {@code server.address}, {@code server.port} attributes instead. + * + * @deprecated Deprecated, use `server.address`, `server.port` attributes instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbConnectionString = "db.connection_string"; + +/** + * Deprecated, use {@code db.collection.name} instead. + * + * @deprecated Deprecated, use `db.collection.name` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbCosmosdbContainer = "db.cosmosdb.container"; + +/** + * Deprecated, no general replacement at this time. For Elasticsearch, use {@code + * db.elasticsearch.node.name} instead. + * + * @deprecated Deprecated, no general replacement at this time. For Elasticsearch, use + * `db.elasticsearch.node.name` instead. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbInstanceId = "db.instance.id"; /** - * The MongoDB collection being accessed within the database stated in {@code db.name}. + * Removed, no replacement at this time. + * + * @deprecated Removed, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kDbJdbcDriverClassname = "db.jdbc.driver_classname"; + +/** + * Deprecated, use {@code db.collection.name} instead. + * + * @deprecated Deprecated, use `db.collection.name` instead. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbMongodbCollection = "db.mongodb.collection"; /** - * The Microsoft SQL Server <a - href="https://docs.microsoft.com/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver15">instance - name</a> connecting to. This name is used to determine the port of a named instance. + * Deprecated, SQL Server instance is now populated as a part of {@code db.namespace} attribute. * - * <p>Notes: - <ul> <li>If setting a {@code db.mssql.instance_name}, {@code server.port} is no longer required - (but still recommended if non-standard).</li> </ul> + * @deprecated Deprecated, SQL Server instance is now populated as a part of `db.namespace` + * attribute. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbMssqlInstanceName = "db.mssql.instance_name"; /** - * 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). + * Deprecated, use {@code db.namespace} instead. * - * <p>Notes: - <ul> <li>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).</li> </ul> + * @deprecated Deprecated, use `db.namespace` instead. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbName = "db.name"; /** - * The name of the operation being executed, e.g. the <a - href="https://docs.mongodb.com/manual/reference/command/#database-operations">MongoDB command - name</a> such as {@code findAndModify}, or the SQL keyword. + * Deprecated, use {@code db.operation.name} instead. * - * <p>Notes: - <ul> <li>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.</li> </ul> + * @deprecated Deprecated, use `db.operation.name` instead. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbOperation = "db.operation"; /** - * The index of the database being accessed as used in the <a - * href="https://redis.io/commands/select">{@code SELECT} command</a>, provided as an integer. To be - * used instead of the generic {@code db.name} attribute. + * Deprecated, use {@code db.namespace} instead. + * + * @deprecated Deprecated, use `db.namespace` instead. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbRedisDatabaseIndex = "db.redis.database_index"; /** - * The name of the primary table that the operation is acting upon, including the database name (if - applicable). + * Deprecated, use {@code db.collection.name} instead. * - * <p>Notes: - <ul> <li>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.</li> </ul> + * @deprecated Deprecated, use `db.collection.name` instead. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbSqlTable = "db.sql.table"; /** * The database statement being executed. + * + * @deprecated The database statement being executed. */ +OPENTELEMETRY_DEPRECATED 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. + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. */ +OPENTELEMETRY_DEPRECATED static constexpr const char *kDbUser = "db.user"; /** - * Name of the <a href="https://wikipedia.org/wiki/Deployment_environment">deployment -environment</a> (aka deployment tier). + * Deprecated, use {@code db.client.connections.pool.name} instead. * - * <p>Notes: - <ul> <li>{@code deployment.environment} does not affect the uniqueness constraints defined through -the {@code service.namespace}, {@code service.name} and {@code service.instance.id} resource -attributes. This implies that resources carrying the following attribute combinations MUST be -considered to be identifying the same service:</li><li>{@code service.name=frontend}, {@code -deployment.environment=production}</li> <li>{@code service.name=frontend}, {@code -deployment.environment=staging}.</li> - </ul> + * @deprecated Deprecated, use `db.client.connections.pool.name` instead. */ -static constexpr const char *kDeploymentEnvironment = "deployment.environment"; +OPENTELEMETRY_DEPRECATED +static constexpr const char *kPoolName = "pool.name"; /** - * Deprecated, use {@code server.address}, {@code server.port} attributes instead. + * Deprecated, use {@code db.client.connections.state} instead. * - * @deprecated Deprecated, use `server.address`, `server.port` attributes instead. + * @deprecated Deprecated, use `db.client.connections.state` instead. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kDbConnectionString = "db.connection_string"; +static constexpr const char *kState = "state"; /** - * Deprecated, use {@code db.instance.id} instead. + * Deprecated, use {@code client.address} instead. * - * @deprecated Deprecated, use `db.instance.id` instead. + * @deprecated Deprecated, use `client.address` instead. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kDbElasticsearchNodeName = "db.elasticsearch.node.name"; +static constexpr const char *kHttpClientIp = "http.client_ip"; /** - * Removed, no replacement at this time. + * Deprecated, use {@code network.protocol.name} instead. * - * @deprecated Removed, no replacement at this time. + * @deprecated Deprecated, use `network.protocol.name` instead. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kDbJdbcDriverClassname = "db.jdbc.driver_classname"; +static constexpr const char *kHttpFlavor = "http.flavor"; /** - * Deprecated, use {@code network.protocol.name} instead. + * Deprecated, use one of {@code server.address}, {@code client.address} or {@code + * http.request.header.host} instead, depending on the usage. * - * @deprecated Deprecated, use `network.protocol.name` instead. + * @deprecated Deprecated, use one of `server.address`, `client.address` or + * `http.request.header.host` instead, depending on the usage. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kHttpFlavor = "http.flavor"; +static constexpr const char *kHttpHost = "http.host"; /** * Deprecated, use {@code http.request.method} instead. @@ -879,6 +1020,15 @@ static constexpr const char *kHttpMethod = "http.method"; OPENTELEMETRY_DEPRECATED static constexpr const char *kHttpRequestContentLength = "http.request_content_length"; +/** + * Deprecated, use {@code http.request.body.size} instead. + * + * @deprecated Deprecated, use `http.request.body.size` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpRequestContentLengthUncompressed = + "http.request_content_length_uncompressed"; + /** * Deprecated, use {@code http.response.header.content-length} instead. * @@ -887,6 +1037,15 @@ static constexpr const char *kHttpRequestContentLength = "http.request_content_l OPENTELEMETRY_DEPRECATED static constexpr const char *kHttpResponseContentLength = "http.response_content_length"; +/** + * Deprecated, use {@code http.response.body.size} instead. + * + * @deprecated Deprecated, use `http.response.body.size` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpResponseContentLengthUncompressed = + "http.response_content_length_uncompressed"; + /** * Deprecated, use {@code url.scheme} instead. * @@ -895,6 +1054,14 @@ static constexpr const char *kHttpResponseContentLength = "http.response_content OPENTELEMETRY_DEPRECATED static constexpr const char *kHttpScheme = "http.scheme"; +/** + * Deprecated, use {@code server.address} instead. + * + * @deprecated Deprecated, use `server.address` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kHttpServerName = "http.server_name"; + /** * Deprecated, use {@code http.response.status_code} instead. * @@ -928,14 +1095,45 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kHttpUserAgent = "http.user_agent"; /** - * "Deprecated, use {@code messaging.destination.partition.id} instead." + * Deprecated use the {@code device.app.lifecycle} event definition including {@code ios.state} as a + payload field instead. + * + * <p>Notes: + <ul> <li>The iOS lifecycle states are defined in the <a + href="https://developer.apple.com/documentation/uikit/uiapplicationdelegate#1656902">UIApplicationDelegate + documentation</a>, and from which the {@code OS terminology} column values are derived.</li> </ul> + * + * @deprecated Deprecated use the `device.app.lifecycle` event definition including `ios.state` as a + payload field instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kIosState = "ios.state"; + +/** + * Deprecated, use {@code messaging.destination.partition.id} instead. * - * @deprecated "Deprecated, use `messaging.destination.partition.id` instead.". + * @deprecated Deprecated, use `messaging.destination.partition.id` instead. */ OPENTELEMETRY_DEPRECATED static constexpr const char *kMessagingKafkaDestinationPartition = "messaging.kafka.destination.partition"; +/** + * Deprecated, use {@code messaging.operation.type} instead. + * + * @deprecated Deprecated, use `messaging.operation.type` instead. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kMessagingOperation = "messaging.operation"; + +/** + * Deprecated, use {@code network.local.address}. + * + * @deprecated Deprecated, use `network.local.address`. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetHostIp = "net.host.ip"; + /** * Deprecated, use {@code server.address}. * @@ -952,6 +1150,14 @@ static constexpr const char *kNetHostName = "net.host.name"; OPENTELEMETRY_DEPRECATED static constexpr const char *kNetHostPort = "net.host.port"; +/** + * Deprecated, use {@code network.peer.address}. + * + * @deprecated Deprecated, use `network.peer.address`. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetPeerIp = "net.peer.ip"; + /** * Deprecated, use {@code server.address} on client spans and {@code client.address} on server * spans. @@ -987,60 +1193,108 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kNetProtocolVersion = "net.protocol.version"; /** - * Deprecated, use {@code network.transport} and {@code network.type}. + * Deprecated, use {@code network.transport} and {@code network.type}. + * + * @deprecated Deprecated, use `network.transport` and `network.type`. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockFamily = "net.sock.family"; + +/** + * Deprecated, use {@code network.local.address}. + * + * @deprecated Deprecated, use `network.local.address`. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockHostAddr = "net.sock.host.addr"; + +/** + * Deprecated, use {@code network.local.port}. + * + * @deprecated Deprecated, use `network.local.port`. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockHostPort = "net.sock.host.port"; + +/** + * Deprecated, use {@code network.peer.address}. + * + * @deprecated Deprecated, use `network.peer.address`. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockPeerAddr = "net.sock.peer.addr"; + +/** + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockPeerName = "net.sock.peer.name"; + +/** + * Deprecated, use {@code network.peer.port}. + * + * @deprecated Deprecated, use `network.peer.port`. + */ +OPENTELEMETRY_DEPRECATED +static constexpr const char *kNetSockPeerPort = "net.sock.peer.port"; + +/** + * Deprecated, use {@code network.transport}. * - * @deprecated Deprecated, use `network.transport` and `network.type`. + * @deprecated Deprecated, use `network.transport`. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockFamily = "net.sock.family"; +static constexpr const char *kNetTransport = "net.transport"; /** - * Deprecated, use {@code network.local.address}. + * None * - * @deprecated Deprecated, use `network.local.address`. + * @deprecated None. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockHostAddr = "net.sock.host.addr"; +static constexpr const char *kOtelLibraryName = "otel.library.name"; /** - * Deprecated, use {@code network.local.port}. + * None * - * @deprecated Deprecated, use `network.local.port`. + * @deprecated None. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockHostPort = "net.sock.host.port"; +static constexpr const char *kOtelLibraryVersion = "otel.library.version"; /** - * Deprecated, use {@code network.peer.address}. + * Deprecated, use {@code rpc.message.compressed_size} instead. * - * @deprecated Deprecated, use `network.peer.address`. + * @deprecated Deprecated, use `rpc.message.compressed_size` instead. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockPeerAddr = "net.sock.peer.addr"; +static constexpr const char *kMessageCompressedSize = "message.compressed_size"; /** - * Deprecated, no replacement at this time. + * Deprecated, use {@code rpc.message.id} instead. * - * @deprecated Deprecated, no replacement at this time. + * @deprecated Deprecated, use `rpc.message.id` instead. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockPeerName = "net.sock.peer.name"; +static constexpr const char *kMessageId = "message.id"; /** - * Deprecated, use {@code network.peer.port}. + * Deprecated, use {@code rpc.message.type} instead. * - * @deprecated Deprecated, use `network.peer.port`. + * @deprecated Deprecated, use `rpc.message.type` instead. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetSockPeerPort = "net.sock.peer.port"; +static constexpr const char *kMessageType = "message.type"; /** - * Deprecated, use {@code network.transport}. + * Deprecated, use {@code rpc.message.uncompressed_size} instead. * - * @deprecated Deprecated, use `network.transport`. + * @deprecated Deprecated, use `rpc.message.uncompressed_size` instead. */ OPENTELEMETRY_DEPRECATED -static constexpr const char *kNetTransport = "net.transport"; +static constexpr const char *kMessageUncompressedSize = "message.uncompressed_size"; /** * Deprecated, use {@code system.process.status} instead. @@ -1155,20 +1409,33 @@ static constexpr const char *kEnduserScope = "enduser.scope"; * Describes a class of error the operation ended with. * * <p>Notes: - <ul> <li>The {@code error.type} SHOULD be predictable and SHOULD have low cardinality. -Instrumentations SHOULD document the list of errors they report.</li><li>The cardinality of {@code -error.type} within one instrumentation library SHOULD be low. 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.</li><li>If the operation has completed successfully, instrumentations SHOULD NOT set {@code -error.type}.</li><li>If a specific domain defines its own set of error identifiers (such as HTTP or -gRPC status codes), it's RECOMMENDED to:</li><li>Use a domain-specific attribute</li> <li>Set {@code -error.type} to capture all errors, regardless of whether they are defined within the domain-specific -set or not.</li> + <ul> <li>The {@code error.type} SHOULD be predictable, and SHOULD have low +cardinality.</li><li>When {@code error.type} is set to a type (e.g., an exception type), its +canonical class name identifying the type within the artifact SHOULD be +used.</li><li>Instrumentations SHOULD document the list of errors they report.</li><li>The +cardinality of {@code error.type} within one instrumentation library SHOULD be low. 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.</li><li>If the operation has completed successfully, instrumentations SHOULD NOT set +{@code error.type}.</li><li>If a specific domain defines its own set of error identifiers (such as +HTTP or gRPC status codes), it's RECOMMENDED to:</li><li>Use a domain-specific attribute</li> +<li>Set {@code error.type} to capture all errors, regardless of whether they are defined within the +domain-specific set or not.</li> </ul> */ static constexpr const char *kErrorType = "error.type"; +/** + * Identifies the class / type of event. + * + * <p>Notes: + <ul> <li>Event names are subject to the same rules as <a + href="https://github.com/open-telemetry/opentelemetry-specification/tree/v1.33.0/specification/common/attribute-naming.md">attribute + names</a>. Notably, event names are namespaced to avoid collisions and provide a clean separation + of semantics for events in separate domains like browser, mobile, and kubernetes.</li> </ul> + */ +static constexpr const char *kEventName = "event.name"; + /** * SHOULD be set to true if the exception event is recorded at a point where it is known that the exception is escaping the scope of the span. @@ -1181,9 +1448,10 @@ is passed to a Context manager's {@code __exit__} method in Python) but will usually be caught at the point of recording the exception in most languages.</li><li>It is usually not possible to determine at the point where an exception is thrown whether it will escape the scope of a span. However, it is trivial to know that an exception will escape, if one checks for an active -exception just before ending the span, as done in the <a href="#recording-an-exception">example for -recording span exceptions</a>.</li><li>It follows that an exception may still escape the scope of -the span even if the {@code exception.escaped} attribute was not set or set to false, since the +exception just before ending the span, as done in the <a +href="https://opentelemetry.io/docs/specs/semconv/exceptions/exceptions-spans/#recording-an-exception">example +for recording span exceptions</a>.</li><li>It follows that an exception may still escape the scope +of the span even if the {@code exception.escaped} attribute was not set or set to false, since the event might have been recorded at a time where it was not clear whether the exception will escape.</li> </ul> */ @@ -1430,6 +1698,114 @@ static constexpr const char *kGcpGceInstanceHostname = "gcp.gce.instance.hostnam */ static constexpr const char *kGcpGceInstanceName = "gcp.gce.instance.name"; +/** + * The full response received from the LLM. + * + * <p>Notes: + <ul> <li>It's RECOMMENDED to format completions as JSON string matching <a + href="https://platform.openai.com/docs/guides/text-generation">OpenAI messages format</a></li> + </ul> + */ +static constexpr const char *kGenAiCompletion = "gen_ai.completion"; + +/** + * The full prompt sent to an LLM. + * + * <p>Notes: + <ul> <li>It's RECOMMENDED to format prompts as JSON string matching <a + href="https://platform.openai.com/docs/guides/text-generation">OpenAI messages format</a></li> + </ul> + */ +static constexpr const char *kGenAiPrompt = "gen_ai.prompt"; + +/** + * The maximum number of tokens the LLM generates for a request. + */ +static constexpr const char *kGenAiRequestMaxTokens = "gen_ai.request.max_tokens"; + +/** + * The name of the LLM a request is being made to. + */ +static constexpr const char *kGenAiRequestModel = "gen_ai.request.model"; + +/** + * The temperature setting for the LLM request. + */ +static constexpr const char *kGenAiRequestTemperature = "gen_ai.request.temperature"; + +/** + * The top_p sampling setting for the LLM request. + */ +static constexpr const char *kGenAiRequestTopP = "gen_ai.request.top_p"; + +/** + * Array of reasons the model stopped generating tokens, corresponding to each generation received. + */ +static constexpr const char *kGenAiResponseFinishReasons = "gen_ai.response.finish_reasons"; + +/** + * The unique identifier for the completion. + */ +static constexpr const char *kGenAiResponseId = "gen_ai.response.id"; + +/** + * The name of the LLM a response was generated from. + */ +static constexpr const char *kGenAiResponseModel = "gen_ai.response.model"; + +/** + * The Generative AI product as identified by the client instrumentation. + * + * <p>Notes: + <ul> <li>The actual GenAI product may differ from the one identified by the client. For example, + when using OpenAI client libraries to communicate with Mistral, the {@code gen_ai.system} is set to + {@code openai} based on the instrumentation's best knowledge.</li> </ul> + */ +static constexpr const char *kGenAiSystem = "gen_ai.system"; + +/** + * The number of tokens used in the LLM response (completion). + */ +static constexpr const char *kGenAiUsageCompletionTokens = "gen_ai.usage.completion_tokens"; + +/** + * The number of tokens used in the LLM prompt. + */ +static constexpr const char *kGenAiUsagePromptTokens = "gen_ai.usage.prompt_tokens"; + +/** + * The GraphQL document being executed. + * + * <p>Notes: + <ul> <li>The value may be sanitized to exclude sensitive information.</li> </ul> + */ +static constexpr const char *kGraphqlDocument = "graphql.document"; + +/** + * The name of the operation being executed. + */ +static constexpr const char *kGraphqlOperationName = "graphql.operation.name"; + +/** + * The type of the operation being executed. + */ +static constexpr const char *kGraphqlOperationType = "graphql.operation.type"; + +/** + * Unique identifier for the application + */ +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 + */ +static constexpr const char *kHerokuReleaseCreationTimestamp = "heroku.release.creation_timestamp"; + /** * The CPU architecture the host system is running on. */ @@ -1615,6 +1991,61 @@ one.</li> </ul> */ static constexpr const char *kHttpRoute = "http.route"; +/** + * Name of the buffer pool. + * + * <p>Notes: + <ul> <li>Pool names are generally obtained via <a + href="https://docs.oracle.com/en/java/javase/11/docs/api/java.management/java/lang/management/BufferPoolMXBean.html#getName()">BufferPoolMXBean#getName()</a>.</li> + </ul> + */ +static constexpr const char *kJvmBufferPoolName = "jvm.buffer.pool.name"; + +/** + * Name of the garbage collector action. + * + * <p>Notes: + <ul> <li>Garbage collector action is generally obtained via <a + href="https://docs.oracle.com/en/java/javase/11/docs/api/jdk.management/com/sun/management/GarbageCollectionNotificationInfo.html#getGcAction()">GarbageCollectionNotificationInfo#getGcAction()</a>.</li> + </ul> + */ +static constexpr const char *kJvmGcAction = "jvm.gc.action"; + +/** + * Name of the garbage collector. + * + * <p>Notes: + <ul> <li>Garbage collector name is generally obtained via <a + href="https://docs.oracle.com/en/java/javase/11/docs/api/jdk.management/com/sun/management/GarbageCollectionNotificationInfo.html#getGcName()">GarbageCollectionNotificationInfo#getGcName()</a>.</li> + </ul> + */ +static constexpr const char *kJvmGcName = "jvm.gc.name"; + +/** + * Name of the memory pool. + * + * <p>Notes: + <ul> <li>Pool names are generally obtained via <a + href="https://docs.oracle.com/en/java/javase/11/docs/api/java.management/java/lang/management/MemoryPoolMXBean.html#getName()">MemoryPoolMXBean#getName()</a>.</li> + </ul> + */ +static constexpr const char *kJvmMemoryPoolName = "jvm.memory.pool.name"; + +/** + * The type of memory. + */ +static constexpr const char *kJvmMemoryType = "jvm.memory.type"; + +/** + * Whether the thread is daemon or not. + */ +static constexpr const char *kJvmThreadDaemon = "jvm.thread.daemon"; + +/** + * State of the thread. + */ +static constexpr const char *kJvmThreadState = "jvm.thread.state"; + /** * The name of the cluster. */ @@ -1656,6 +2087,12 @@ static constexpr const char *kK8sContainerName = "k8s.container.name"; */ static constexpr const char *kK8sContainerRestartCount = "k8s.container.restart_count"; +/** + * Last terminated reason of the Container. + */ +static constexpr const char *kK8sContainerStatusLastTerminatedReason = + "k8s.container.status.last_terminated_reason"; + /** * The name of the CronJob. */ @@ -1741,6 +2178,42 @@ static constexpr const char *kK8sStatefulsetName = "k8s.statefulset.name"; */ static constexpr const char *kK8sStatefulsetUid = "k8s.statefulset.uid"; +/** + * The stream associated with the log. See below for a list of well-known values. + */ +static constexpr const char *kLogIostream = "log.iostream"; + +/** + * The basename of the file. + */ +static constexpr const char *kLogFileName = "log.file.name"; + +/** + * The basename of the file, with symlinks resolved. + */ +static constexpr const char *kLogFileNameResolved = "log.file.name_resolved"; + +/** + * The full path to the file. + */ +static constexpr const char *kLogFilePath = "log.file.path"; + +/** + * The full path to the file, with symlinks resolved. + */ +static constexpr const char *kLogFilePathResolved = "log.file.path_resolved"; + +/** + * A unique identifier for the Log Record. + * + * <p>Notes: + <ul> <li>If an id is provided, other log records with the same id will be considered duplicates +and can be removed safely. This means, that two distinguishable log records MUST have different +values. The id MAY be an <a href="https://github.com/ulid/spec">Universally Unique Lexicographically +Sortable Identifier (ULID)</a>, but other identifiers (e.g. UUID) may be used as needed.</li> </ul> + */ +static constexpr const char *kLogRecordUid = "log.record.uid"; + /** * The number of messages sent, received, or processed in the scope of the batching operation. * @@ -1756,7 +2229,7 @@ static constexpr const char *kMessagingBatchMessageCount = "messaging.batch.mess /** * A unique identifier for the client that consumes or produces a message. */ -static constexpr const char *kMessagingClientId = "messaging.client_id"; +static constexpr const char *kMessagingClientId = "messaging.client.id"; /** * A boolean that is true if the message destination is anonymous (could be unnamed or have @@ -1786,82 +2259,35 @@ static constexpr const char *kMessagingDestinationPartitionId = * * <p>Notes: <ul> <li>Destination names could be constructed from templates. An example would be a destination - name involving a user name or product id. Although the destination name in this case is of high - cardinality, the underlying template is of low cardinality and can be effectively used for grouping - and aggregation.</li> </ul> - */ -static constexpr const char *kMessagingDestinationTemplate = "messaging.destination.template"; - -/** - * 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 publish message destination is anonymous (could be unnamed or have - * auto-generated name). - */ -static constexpr const char *kMessagingDestinationPublishAnonymous = - "messaging.destination_publish.anonymous"; - -/** - * The name of the original destination the message was published to - * - * <p>Notes: - <ul> <li>The name SHOULD uniquely identify a specific queue, topic, or other entity within the -broker. If the broker doesn't have such notion, the original destination name SHOULD uniquely -identify the broker.</li> </ul> - */ -static constexpr const char *kMessagingDestinationPublishName = - "messaging.destination_publish.name"; - -/** - * The name of the consumer group the event consumer is associated with. - */ -static constexpr const char *kMessagingEventhubsConsumerGroup = - "messaging.eventhubs.consumer.group"; - -/** - * The UTC epoch seconds at which the message has been accepted and stored in the entity. - */ -static constexpr const char *kMessagingEventhubsMessageEnqueuedTime = - "messaging.eventhubs.message.enqueued_time"; - -/** - * The ordering key for a given message. If the attribute is not present, the message does not have - * an ordering key. - */ -static constexpr const char *kMessagingGcpPubsubMessageOrderingKey = - "messaging.gcp_pubsub.message.ordering_key"; - -/** - * Name of the Kafka Consumer Group that is handling the message. Only applies to consumers, not - * producers. - */ -static constexpr const char *kMessagingKafkaConsumerGroup = "messaging.kafka.consumer.group"; - -/** - * 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. - * - * <p>Notes: - <ul> <li>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.</li> - </ul> + name involving a user name or product id. Although the destination name in this case is of high + cardinality, the underlying template is of low cardinality and can be effectively used for grouping + and aggregation.</li> </ul> */ -static constexpr const char *kMessagingKafkaMessageKey = "messaging.kafka.message.key"; +static constexpr const char *kMessagingDestinationTemplate = "messaging.destination.template"; /** - * The offset of a record in the corresponding Kafka partition. + * A boolean that is true if the message destination is temporary and might not exist anymore after + * messages are processed. */ -static constexpr const char *kMessagingKafkaMessageOffset = "messaging.kafka.message.offset"; +static constexpr const char *kMessagingDestinationTemporary = "messaging.destination.temporary"; /** - * A boolean that is true if the message is a tombstone. + * A boolean that is true if the publish message destination is anonymous (could be unnamed or have + * auto-generated name). */ -static constexpr const char *kMessagingKafkaMessageTombstone = "messaging.kafka.message.tombstone"; +static constexpr const char *kMessagingDestinationPublishAnonymous = + "messaging.destination_publish.anonymous"; + +/** + * The name of the original destination the message was published to + * + * <p>Notes: + <ul> <li>The name SHOULD uniquely identify a specific queue, topic, or other entity within the +broker. If the broker doesn't have such notion, the original destination name SHOULD uniquely +identify the broker.</li> </ul> + */ +static constexpr const char *kMessagingDestinationPublishName = + "messaging.destination_publish.name"; /** * The size of the message body in bytes. @@ -1893,12 +2319,55 @@ static constexpr const char *kMessagingMessageEnvelopeSize = "messaging.message. static constexpr const char *kMessagingMessageId = "messaging.message.id"; /** - * A string identifying the kind of messaging operation. + * The system-specific name of the messaging operation. + */ +static constexpr const char *kMessagingOperationName = "messaging.operation.name"; + +/** + * A string identifying the type of the messaging operation. * * <p>Notes: <ul> <li>If a custom value is used, it MUST be of low cardinality.</li> </ul> */ -static constexpr const char *kMessagingOperation = "messaging.operation"; +static constexpr const char *kMessagingOperationType = "messaging.operation.type"; + +/** + * The messaging system as identified by the client instrumentation. + * + * <p>Notes: + <ul> <li>The actual messaging system may differ from the one known by the client. For example, + when using Kafka client libraries to communicate with Azure Event Hubs, the {@code + messaging.system} is set to {@code kafka} based on the instrumentation's best knowledge.</li> </ul> + */ +static constexpr const char *kMessagingSystem = "messaging.system"; + +/** + * Name of the Kafka Consumer Group that is handling the message. Only applies to consumers, not + * producers. + */ +static constexpr const char *kMessagingKafkaConsumerGroup = "messaging.kafka.consumer.group"; + +/** + * 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. + * + * <p>Notes: + <ul> <li>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.</li> + </ul> + */ +static constexpr const char *kMessagingKafkaMessageKey = "messaging.kafka.message.key"; + +/** + * The offset of a record in the corresponding Kafka partition. + */ +static constexpr const char *kMessagingKafkaMessageOffset = "messaging.kafka.message.offset"; + +/** + * A boolean that is true if the message is a tombstone. + */ +static constexpr const char *kMessagingKafkaMessageTombstone = "messaging.kafka.message.tombstone"; /** * RabbitMQ message routing key. @@ -1962,6 +2431,31 @@ static constexpr const char *kMessagingRocketmqMessageType = "messaging.rocketmq */ static constexpr const char *kMessagingRocketmqNamespace = "messaging.rocketmq.namespace"; +/** + * The ack deadline in seconds set for the modify ack deadline request. + */ +static constexpr const char *kMessagingGcpPubsubMessageAckDeadline = + "messaging.gcp_pubsub.message.ack_deadline"; + +/** + * The ack id for a given message. + */ +static constexpr const char *kMessagingGcpPubsubMessageAckId = + "messaging.gcp_pubsub.message.ack_id"; + +/** + * The delivery attempt for a given message. + */ +static constexpr const char *kMessagingGcpPubsubMessageDeliveryAttempt = + "messaging.gcp_pubsub.message.delivery_attempt"; + +/** + * The ordering key for a given message. If the attribute is not present, the message does not have + * an ordering key. + */ +static constexpr const char *kMessagingGcpPubsubMessageOrderingKey = + "messaging.gcp_pubsub.message.ordering_key"; + /** * The name of the subscription in the topic messages are received from. */ @@ -1989,10 +2483,16 @@ static constexpr const char *kMessagingServicebusMessageEnqueuedTime = "messaging.servicebus.message.enqueued_time"; /** - * An identifier for the messaging system being used. See below for a list of well-known - * identifiers. + * The name of the consumer group the event consumer is associated with. */ -static constexpr const char *kMessagingSystem = "messaging.system"; +static constexpr const char *kMessagingEventhubsConsumerGroup = + "messaging.eventhubs.consumer.group"; + +/** + * The UTC epoch seconds at which the message has been accepted and stored in the entity. + */ +static constexpr const char *kMessagingEventhubsMessageEnqueuedTime = + "messaging.eventhubs.message.enqueued_time"; /** * The ISO 3166-1 alpha-2 2-character country code associated with the mobile carrier network. @@ -2105,6 +2605,14 @@ Manifest</a>.</li> </ul> */ static constexpr const char *kOciManifestDigest = "oci.manifest.digest"; +/** + * Parent-child Reference type + * + * <p>Notes: + <ul> <li>The causal relationship between a child Span and a parent Span.</li> </ul> + */ +static constexpr const char *kOpentracingRefType = "opentracing.ref_type"; + /** * Unique identifier for a particular build or compilation of the operating system. */ @@ -2132,6 +2640,34 @@ static constexpr const char *kOsType = "os.type"; */ static constexpr const char *kOsVersion = "os.version"; +/** + * Name of the code, either "OK" or "ERROR". MUST NOT be set if the status code + * is UNSET. + */ +static constexpr const char *kOtelStatusCode = "otel.status_code"; + +/** + * Description of the Status if it has a value, otherwise not set. + */ +static constexpr const char *kOtelStatusDescription = "otel.status_description"; + +/** + * The name of the instrumentation scope - ({@code InstrumentationScope.Name} in OTLP). + */ +static constexpr const char *kOtelScopeName = "otel.scope.name"; + +/** + * The version of the instrumentation scope - ({@code InstrumentationScope.Version} in OTLP). + */ +static constexpr const char *kOtelScopeVersion = "otel.scope.version"; + +/** + * The <a href="/docs/resource/README.md#service">{@code service.name}</a> 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 *kPeerService = "peer.service"; + /** * 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 @@ -2154,6 +2690,16 @@ static constexpr const char *kProcessCommandArgs = "process.command_args"; */ static constexpr const char *kProcessCommandLine = "process.command_line"; +/** + * Specifies whether the context switches for this data point were voluntary or involuntary. + */ +static constexpr const char *kProcessContextSwitchType = "process.context_switch_type"; + +/** + * The date and time the process was created, in ISO 8601 format. + */ +static constexpr const char *kProcessCreationTime = "process.creation.time"; + /** * The name of the process executable. On Linux based systems, can be set to the {@code Name} in * {@code proc/[pid]/status}. On Windows, can be set to the base name of {@code @@ -2167,11 +2713,37 @@ static constexpr const char *kProcessExecutableName = "process.executable.name"; */ static constexpr const char *kProcessExecutablePath = "process.executable.path"; +/** + * The exit code of the process. + */ +static constexpr const char *kProcessExitCode = "process.exit.code"; + +/** + * The date and time the process exited, in ISO 8601 format. + */ +static constexpr const char *kProcessExitTime = "process.exit.time"; + +/** + * The PID of the process's group leader. This is also the process group ID (PGID) of the process. + */ +static constexpr const char *kProcessGroupLeaderPid = "process.group_leader.pid"; + +/** + * Whether the process is connected to an interactive shell. + */ +static constexpr const char *kProcessInteractive = "process.interactive"; + /** * The username of the user that owns the process. */ static constexpr const char *kProcessOwner = "process.owner"; +/** + * The type of page fault for this data point. Type {@code major} is for major/hard page faults, and + * {@code minor} is for minor/soft page faults. + */ +static constexpr const char *kProcessPagingFaultType = "process.paging.fault_type"; + /** * Parent Process identifier (PPID). */ @@ -2182,6 +2754,16 @@ static constexpr const char *kProcessParentPid = "process.parent_pid"; */ static constexpr const char *kProcessPid = "process.pid"; +/** + * The real user ID (RUID) of the process. + */ +static constexpr const char *kProcessRealUserId = "process.real_user.id"; + +/** + * The username of the real user of the process. + */ +static constexpr const char *kProcessRealUserName = "process.real_user.name"; + /** * An additional description about the runtime of the process, for example a specific vendor * customization of the runtime environment. @@ -2199,6 +2781,46 @@ static constexpr const char *kProcessRuntimeName = "process.runtime.name"; */ static constexpr const char *kProcessRuntimeVersion = "process.runtime.version"; +/** + * The saved user ID (SUID) of the process. + */ +static constexpr const char *kProcessSavedUserId = "process.saved_user.id"; + +/** + * The username of the saved user. + */ +static constexpr const char *kProcessSavedUserName = "process.saved_user.name"; + +/** + * The PID of the process's session leader. This is also the session ID (SID) of the process. + */ +static constexpr const char *kProcessSessionLeaderPid = "process.session_leader.pid"; + +/** + * The effective user ID (EUID) of the process. + */ +static constexpr const char *kProcessUserId = "process.user.id"; + +/** + * The username of the effective user of the process. + */ +static constexpr const char *kProcessUserName = "process.user.name"; + +/** + * Virtual process identifier. + * + * <p>Notes: + <ul> <li>The process ID within a PID namespace. This is not necessarily unique across all + processes on the host but it is unique within the process namespace that the process exists + within.</li> </ul> + */ +static constexpr const char *kProcessVpid = "process.vpid"; + +/** + * The CPU state of the process. + */ +static constexpr const char *kProcessCpuState = "process.cpu.state"; + /** * The <a href="https://connect.build/docs/protocol/#error-codes">error codes</a> of the Connect * request. Error codes are always string values. @@ -2234,6 +2856,31 @@ static constexpr const char *kRpcJsonrpcRequestId = "rpc.jsonrpc.request_id"; */ static constexpr const char *kRpcJsonrpcVersion = "rpc.jsonrpc.version"; +/** + * Compressed size of the message in bytes. + */ +static constexpr const char *kRpcMessageCompressedSize = "rpc.message.compressed_size"; + +/** + * MUST be calculated as two different counters starting from {@code 1} one for sent messages and + one for received message. + * + * <p>Notes: + <ul> <li>This way we guarantee that the values will be consistent between different + implementations.</li> </ul> + */ +static constexpr const char *kRpcMessageId = "rpc.message.id"; + +/** + * Whether this is a received or sent message. + */ +static constexpr const char *kRpcMessageType = "rpc.message.type"; + +/** + * Uncompressed size of the message in bytes. + */ +static constexpr const char *kRpcMessageUncompressedSize = "rpc.message.uncompressed_size"; + /** * The name of the (logical) method being called, must be equal to the $method part in the span name. @@ -2320,9 +2967,9 @@ static constexpr const char *kServiceInstanceId = "service.instance.id"; * <p>Notes: <ul> <li>MUST be the same for all instances of horizontally scaled services. If the value was not specified, SDKs MUST fallback to {@code unknown_service:} concatenated with <a - href="process.md#process">{@code process.executable.name}</a>, e.g. {@code unknown_service:bash}. - If {@code process.executable.name} is not available, the value MUST be set to {@code - unknown_service}.</li> </ul> + href="process.md">{@code process.executable.name}</a>, e.g. {@code unknown_service:bash}. If {@code + process.executable.name} is not available, the value MUST be set to {@code unknown_service}.</li> + </ul> */ static constexpr const char *kServiceName = "service.name"; @@ -2355,6 +3002,18 @@ static constexpr const char *kSessionId = "session.id"; */ static constexpr const char *kSessionPreviousId = "session.previous_id"; +/** + * SignalR HTTP connection closure status. + */ +static constexpr const char *kSignalrConnectionStatus = "signalr.connection.status"; + +/** + * <a + * href="https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/TransportProtocols.md">SignalR + * transport type</a> + */ +static constexpr const char *kSignalrTransport = "signalr.transport"; + /** * Source address - domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. @@ -2367,9 +3026,76 @@ static constexpr const char *kSessionPreviousId = "session.previous_id"; static constexpr const char *kSourceAddress = "source.address"; /** - * Source port number + * Source port number + */ +static constexpr const char *kSourcePort = "source.port"; + +/** + * The device identifier + */ +static constexpr const char *kSystemDevice = "system.device"; + +/** + * The logical CPU number [0..n-1] + */ +static constexpr const char *kSystemCpuLogicalNumber = "system.cpu.logical_number"; + +/** + * The state of the CPU + */ +static constexpr const char *kSystemCpuState = "system.cpu.state"; + +/** + * The memory state + */ +static constexpr const char *kSystemMemoryState = "system.memory.state"; + +/** + * The paging access direction + */ +static constexpr const char *kSystemPagingDirection = "system.paging.direction"; + +/** + * The memory paging state + */ +static constexpr const char *kSystemPagingState = "system.paging.state"; + +/** + * The memory paging type + */ +static constexpr const char *kSystemPagingType = "system.paging.type"; + +/** + * The filesystem mode + */ +static constexpr const char *kSystemFilesystemMode = "system.filesystem.mode"; + +/** + * The filesystem mount path + */ +static constexpr const char *kSystemFilesystemMountpoint = "system.filesystem.mountpoint"; + +/** + * The filesystem state + */ +static constexpr const char *kSystemFilesystemState = "system.filesystem.state"; + +/** + * The filesystem type + */ +static constexpr const char *kSystemFilesystemType = "system.filesystem.type"; + +/** + * A stateless protocol MUST NOT set this attribute + */ +static constexpr const char *kSystemNetworkState = "system.network.state"; + +/** + * The process state, e.g., <a + * href="https://man7.org/linux/man-pages/man1/ps.1.html#PROCESS_STATE_CODES">Linux Process State + * Codes</a> */ -static constexpr const char *kSourcePort = "source.port"; +static constexpr const char *kSystemProcessStatus = "system.process.status"; /** * The language of the telemetry SDK. @@ -2713,6 +3439,12 @@ static constexpr const char *kUrlScheme = "url.scheme"; */ static constexpr const char *kUrlSubdomain = "url.subdomain"; +/** + * The low-cardinality template of an <a + * href="https://www.rfc-editor.org/rfc/rfc3986#section-4.2">absolute path reference</a>. + */ +static constexpr const char *kUrlTemplate = "url.template"; + /** * The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for example.com is {@code com}. @@ -2743,342 +3475,69 @@ static constexpr const char *kUserAgentOriginal = "user_agent.original"; /** * Version of the user-agent extracted from original. Usually refers to the browser's version * - * <p>Notes: - <ul> <li><a href="https://www.whatsmyua.info">Example</a> of extracting browser's version from - original string. In the case of using a user-agent for non-browser products, such as microservices - with multiple names/versions inside the {@code user_agent.original}, the most significant version - SHOULD be selected. In such a scenario it should align with {@code user_agent.name}</li> </ul> - */ -static constexpr const char *kUserAgentVersion = "user_agent.version"; - -/** - * The ID of a running ECS task. The ID MUST be extracted from {@code task.arn}. - */ -static constexpr const char *kAwsEcsTaskId = "aws.ecs.task.id"; - -/** - * The ARN of an <a - * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/clusters.html">ECS cluster</a>. - */ -static constexpr const char *kAwsEcsClusterArn = "aws.ecs.cluster.arn"; - -/** - * The Amazon Resource Name (ARN) of an <a - * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_instances.html">ECS - * container instance</a>. - */ -static constexpr const char *kAwsEcsContainerArn = "aws.ecs.container.arn"; - -/** - * The <a - * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_types.html">launch - * type</a> for an ECS task. - */ -static constexpr const char *kAwsEcsLaunchtype = "aws.ecs.launchtype"; - -/** - * The ARN of a running <a - * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-account-settings.html#ecs-resource-ids">ECS - * task</a>. - */ -static constexpr const char *kAwsEcsTaskArn = "aws.ecs.task.arn"; - -/** - * The family name of the <a - * href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html">ECS task - * definition</a> used to create the ECS task. - */ -static constexpr const char *kAwsEcsTaskFamily = "aws.ecs.task.family"; - -/** - * The revision for the task definition used to create the ECS task. - */ -static constexpr const char *kAwsEcsTaskRevision = "aws.ecs.task.revision"; - -/** - * The ARN of an EKS cluster. - */ -static constexpr const char *kAwsEksClusterArn = "aws.eks.cluster.arn"; - -/** - * The Amazon Resource Name(s) (ARN) of the AWS log group(s). - * - * <p>Notes: - <ul> <li>See the <a - href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html#CWL_ARN_Format">log - group ARN format documentation</a>.</li> </ul> - */ -static constexpr const char *kAwsLogGroupArns = "aws.log.group.arns"; - -/** - * The name(s) of the AWS log group(s) an application is writing to. - * - * <p>Notes: - <ul> <li>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.</li> </ul> - */ -static constexpr const char *kAwsLogGroupNames = "aws.log.group.names"; - -/** - * The ARN(s) of the AWS log stream(s). - * - * <p>Notes: - <ul> <li>See the <a - href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html#CWL_ARN_Format">log - stream ARN format documentation</a>. One log group can contain several log streams, so these ARNs - necessarily identify both a log group and a log stream.</li> </ul> - */ -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"; - -/** - * Unique identifier for the application - */ -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 - */ -static constexpr const char *kHerokuReleaseCreationTimestamp = "heroku.release.creation_timestamp"; - -/** - * The name of the web engine. - */ -static constexpr const char *kWebengineName = "webengine.name"; - -/** - * Additional description of the web engine (e.g. detailed version and edition information). - */ -static constexpr const char *kWebengineDescription = "webengine.description"; - -/** - * The version of the web engine. - */ -static constexpr const char *kWebengineVersion = "webengine.version"; - -/** - * The name of the instrumentation scope - ({@code InstrumentationScope.Name} in OTLP). - */ -static constexpr const char *kOtelScopeName = "otel.scope.name"; - -/** - * The version of the instrumentation scope - ({@code InstrumentationScope.Version} in OTLP). - */ -static constexpr const char *kOtelScopeVersion = "otel.scope.version"; - -/** - * None - * - * @deprecated None. - */ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kOtelLibraryName = "otel.library.name"; - -/** - * None - * - * @deprecated None. - */ -OPENTELEMETRY_DEPRECATED -static constexpr const char *kOtelLibraryVersion = "otel.library.version"; - -// Enum definitions -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 AspnetcoreRateLimitingResultValues -{ -/** Lease was acquired. */ -static constexpr const char *kAcquired = "acquired"; -/** Lease request was rejected by the endpoint limiter. */ -static constexpr const char *kEndpointLimiter = "endpoint_limiter"; -/** Lease request was rejected by the global limiter. */ -static constexpr const char *kGlobalLimiter = "global_limiter"; -/** Lease request was canceled. */ -static constexpr const char *kRequestCanceled = "request_canceled"; -} // namespace AspnetcoreRateLimitingResultValues - -namespace SignalrConnectionStatusValues -{ -/** The connection was closed normally. */ -static constexpr const char *kNormalClosure = "normal_closure"; -/** The connection was closed due to a timeout. */ -static constexpr const char *kTimeout = "timeout"; -/** The connection was closed because the app is shutting down. */ -static constexpr const char *kAppShutdown = "app_shutdown"; -} // namespace SignalrConnectionStatusValues - -namespace SignalrTransportValues -{ -/** ServerSentEvents protocol. */ -static constexpr const char *kServerSentEvents = "server_sent_events"; -/** LongPolling protocol. */ -static constexpr const char *kLongPolling = "long_polling"; -/** WebSockets protocol. */ -static constexpr const char *kWebSockets = "web_sockets"; -} // namespace SignalrTransportValues - -namespace JvmMemoryTypeValues -{ -/** Heap memory. */ -static constexpr const char *kHeap = "heap"; -/** Non-heap memory. */ -static constexpr const char *kNonHeap = "non_heap"; -} // namespace JvmMemoryTypeValues - -namespace ProcessCpuStateValues -{ -/** system. */ -static constexpr const char *kSystem = "system"; -/** user. */ -static constexpr const char *kUser = "user"; -/** wait. */ -static constexpr const char *kWait = "wait"; -} // namespace ProcessCpuStateValues - -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 -{ -/** 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 + * <p>Notes: + <ul> <li><a href="https://www.whatsmyua.info">Example</a> of extracting browser's version from + original string. In the case of using a user-agent for non-browser products, such as microservices + with multiple names/versions inside the {@code user_agent.original}, the most significant version + SHOULD be selected. In such a scenario it should align with {@code user_agent.name}</li> </ul> + */ +static constexpr const char *kUserAgentVersion = "user_agent.version"; -namespace SystemPagingDirectionValues -{ -/** in. */ -static constexpr const char *kIn = "in"; -/** out. */ -static constexpr const char *kOut = "out"; -} // namespace SystemPagingDirectionValues +/** + * Additional description of the web engine (e.g. detailed version and edition information). + */ +static constexpr const char *kWebengineDescription = "webengine.description"; -namespace SystemPagingStateValues -{ -/** used. */ -static constexpr const char *kUsed = "used"; -/** free. */ -static constexpr const char *kFree = "free"; -} // namespace SystemPagingStateValues +/** + * The name of the web engine. + */ +static constexpr const char *kWebengineName = "webengine.name"; -namespace SystemPagingTypeValues -{ -/** major. */ -static constexpr const char *kMajor = "major"; -/** minor. */ -static constexpr const char *kMinor = "minor"; -} // namespace SystemPagingTypeValues +/** + * The version of the web engine. + */ +static constexpr const char *kWebengineVersion = "webengine.version"; -namespace SystemFilesystemStateValues +// Enum definitions +namespace AspnetcoreRateLimitingResultValues { -/** used. */ -static constexpr const char *kUsed = "used"; -/** free. */ -static constexpr const char *kFree = "free"; -/** reserved. */ -static constexpr const char *kReserved = "reserved"; -} // namespace SystemFilesystemStateValues +/** Lease was acquired. */ +static constexpr const char *kAcquired = "acquired"; +/** Lease request was rejected by the endpoint limiter. */ +static constexpr const char *kEndpointLimiter = "endpoint_limiter"; +/** Lease request was rejected by the global limiter. */ +static constexpr const char *kGlobalLimiter = "global_limiter"; +/** Lease request was canceled. */ +static constexpr const char *kRequestCanceled = "request_canceled"; +} // namespace AspnetcoreRateLimitingResultValues -namespace SystemFilesystemTypeValues +namespace AspnetcoreDiagnosticsExceptionResultValues { -/** 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 +/** Exception was handled by the exception handling middleware. */ +static constexpr const char *kHandled = "handled"; +/** Exception was not handled by the exception handling middleware. */ +static constexpr const char *kUnhandled = "unhandled"; +/** Exception handling was skipped because the response had started. */ +static constexpr const char *kSkipped = "skipped"; +/** Exception handling didn't run because the request was aborted. */ +static constexpr const char *kAborted = "aborted"; +} // namespace AspnetcoreDiagnosticsExceptionResultValues -namespace SystemNetworkStateValues +namespace AspnetcoreRoutingMatchStatusValues { -/** 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 +/** Match succeeded. */ +static constexpr const char *kSuccess = "success"; +/** Match failed. */ +static constexpr const char *kFailure = "failure"; +} // namespace AspnetcoreRoutingMatchStatusValues -namespace SystemProcessStatusValues +namespace AwsEcsLaunchtypeValues { -/** 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 SystemProcessStatusValues +/** ec2. */ +static constexpr const char *kEc2 = "ec2"; +/** fargate. */ +static constexpr const char *kFargate = "fargate"; +} // namespace AwsEcsLaunchtypeValues namespace CloudPlatformValues { @@ -3170,73 +3629,13 @@ static constexpr const char *kSystem = "system"; static constexpr const char *kKernel = "kernel"; } // namespace ContainerCpuStateValues -namespace DbCassandraConsistencyLevelValues -{ -/** all. */ -static constexpr const char *kAll = "all"; -/** each_quorum. */ -static constexpr const char *kEachQuorum = "each_quorum"; -/** quorum. */ -static constexpr const char *kQuorum = "quorum"; -/** local_quorum. */ -static constexpr const char *kLocalQuorum = "local_quorum"; -/** one. */ -static constexpr const char *kOne = "one"; -/** two. */ -static constexpr const char *kTwo = "two"; -/** three. */ -static constexpr const char *kThree = "three"; -/** local_one. */ -static constexpr const char *kLocalOne = "local_one"; -/** any. */ -static constexpr const char *kAny = "any"; -/** serial. */ -static constexpr const char *kSerial = "serial"; -/** local_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 +namespace DbClientConnectionsStateValues { -/** invalid. */ -static constexpr const char *kInvalid = "Invalid"; -/** create. */ -static constexpr const char *kCreate = "Create"; -/** patch. */ -static constexpr const char *kPatch = "Patch"; -/** read. */ -static constexpr const char *kRead = "Read"; -/** read_feed. */ -static constexpr const char *kReadFeed = "ReadFeed"; -/** delete. */ -static constexpr const char *kDelete = "Delete"; -/** replace. */ -static constexpr const char *kReplace = "Replace"; -/** execute. */ -static constexpr const char *kExecute = "Execute"; -/** query. */ -static constexpr const char *kQuery = "Query"; -/** head. */ -static constexpr const char *kHead = "Head"; -/** head_feed. */ -static constexpr const char *kHeadFeed = "HeadFeed"; -/** upsert. */ -static constexpr const char *kUpsert = "Upsert"; -/** batch. */ -static constexpr const char *kBatch = "Batch"; -/** query_plan. */ -static constexpr const char *kQueryPlan = "QueryPlan"; -/** execute_javascript. */ -static constexpr const char *kExecuteJavascript = "ExecuteJavaScript"; -} // namespace DbCosmosdbOperationTypeValues +/** idle. */ +static constexpr const char *kIdle = "idle"; +/** used. */ +static constexpr const char *kUsed = "used"; +} // namespace DbClientConnectionsStateValues namespace DbSystemValues { @@ -3346,6 +3745,95 @@ static constexpr const char *kSpanner = "spanner"; static constexpr const char *kTrino = "trino"; } // namespace DbSystemValues +namespace DbCassandraConsistencyLevelValues +{ +/** all. */ +static constexpr const char *kAll = "all"; +/** each_quorum. */ +static constexpr const char *kEachQuorum = "each_quorum"; +/** quorum. */ +static constexpr const char *kQuorum = "quorum"; +/** local_quorum. */ +static constexpr const char *kLocalQuorum = "local_quorum"; +/** one. */ +static constexpr const char *kOne = "one"; +/** two. */ +static constexpr const char *kTwo = "two"; +/** three. */ +static constexpr const char *kThree = "three"; +/** local_one. */ +static constexpr const char *kLocalOne = "local_one"; +/** any. */ +static constexpr const char *kAny = "any"; +/** serial. */ +static constexpr const char *kSerial = "serial"; +/** local_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. */ +static constexpr const char *kInvalid = "Invalid"; +/** create. */ +static constexpr const char *kCreate = "Create"; +/** patch. */ +static constexpr const char *kPatch = "Patch"; +/** read. */ +static constexpr const char *kRead = "Read"; +/** read_feed. */ +static constexpr const char *kReadFeed = "ReadFeed"; +/** delete. */ +static constexpr const char *kDelete = "Delete"; +/** replace. */ +static constexpr const char *kReplace = "Replace"; +/** execute. */ +static constexpr const char *kExecute = "Execute"; +/** query. */ +static constexpr const char *kQuery = "Query"; +/** head. */ +static constexpr const char *kHead = "Head"; +/** head_feed. */ +static constexpr const char *kHeadFeed = "HeadFeed"; +/** upsert. */ +static constexpr const char *kUpsert = "Upsert"; +/** batch. */ +static constexpr const char *kBatch = "Batch"; +/** query_plan. */ +static constexpr const char *kQueryPlan = "QueryPlan"; +/** execute_javascript. */ +static constexpr const char *kExecuteJavascript = "ExecuteJavaScript"; +} // namespace DbCosmosdbOperationTypeValues + +namespace AndroidStateValues +{ +/** Any time before Activity.onResume() or, if the app has no Activity, Context.startService() has + * been called in the app for the first time. */ +static constexpr const char *kCreated = "created"; +/** Any time after Activity.onPause() or, if the app has no Activity, Context.stopService() has been + * called when the app was in the foreground state. */ +static constexpr const char *kBackground = "background"; +/** Any time after Activity.onResume() or, if the app has no Activity, Context.startService() has + * been called when the app was in either the created or background states. */ +static constexpr const char *kForeground = "foreground"; +} // namespace AndroidStateValues + +namespace StateValues +{ +/** idle. */ +static constexpr const char *kIdle = "idle"; +/** used. */ +static constexpr const char *kUsed = "used"; +} // namespace StateValues + namespace HttpFlavorValues { /** HTTP/1.0. */ @@ -3362,6 +3850,22 @@ static constexpr const char *kSpdy = "SPDY"; static constexpr const char *kQuic = "QUIC"; } // namespace HttpFlavorValues +namespace IosStateValues +{ +/** The app has become `active`. Associated with UIKit notification `applicationDidBecomeActive`. */ +static constexpr const char *kActive = "active"; +/** The app is now `inactive`. Associated with UIKit notification `applicationWillResignActive`. */ +static constexpr const char *kInactive = "inactive"; +/** The app is now in the background. This value is associated with UIKit notification + * `applicationDidEnterBackground`. */ +static constexpr const char *kBackground = "background"; +/** The app is now in the foreground. This value is associated with UIKit notification + * `applicationWillEnterForeground`. */ +static constexpr const char *kForeground = "foreground"; +/** The app is about to terminate. Associated with UIKit notification `applicationWillTerminate`. */ +static constexpr const char *kTerminate = "terminate"; +} // namespace IosStateValues + namespace NetSockFamilyValues { /** IPv4 address. */ @@ -3386,6 +3890,14 @@ static constexpr const char *kInproc = "inproc"; static constexpr const char *kOther = "other"; } // namespace NetTransportValues +namespace MessageTypeValues +{ +/** sent. */ +static constexpr const char *kSent = "SENT"; +/** received. */ +static constexpr const char *kReceived = "RECEIVED"; +} // namespace MessageTypeValues + namespace SystemProcessesStatusValues { /** running. */ @@ -3450,6 +3962,22 @@ static constexpr const char *kTimer = "timer"; static constexpr const char *kOther = "other"; } // namespace FaasTriggerValues +namespace GenAiSystemValues +{ +/** OpenAI. */ +static constexpr const char *kOpenai = "openai"; +} // namespace GenAiSystemValues + +namespace GraphqlOperationTypeValues +{ +/** GraphQL query. */ +static constexpr const char *kQuery = "query"; +/** GraphQL mutation. */ +static constexpr const char *kMutation = "mutation"; +/** GraphQL subscription. */ +static constexpr const char *kSubscription = "subscription"; +} // namespace GraphqlOperationTypeValues + namespace HostArchValues { /** AMD64. */ @@ -3502,7 +4030,41 @@ static constexpr const char *kTrace = "TRACE"; static constexpr const char *kOther = "_OTHER"; } // namespace HttpRequestMethodValues -namespace MessagingOperationValues +namespace JvmMemoryTypeValues +{ +/** Heap memory. */ +static constexpr const char *kHeap = "heap"; +/** Non-heap memory. */ +static constexpr const char *kNonHeap = "non_heap"; +} // namespace JvmMemoryTypeValues + +namespace JvmThreadStateValues +{ +/** A thread that has not yet started is in this state. */ +static constexpr const char *kNew = "new"; +/** A thread executing in the Java virtual machine is in this state. */ +static constexpr const char *kRunnable = "runnable"; +/** A thread that is blocked waiting for a monitor lock is in this state. */ +static constexpr const char *kBlocked = "blocked"; +/** A thread that is waiting indefinitely for another thread to perform a particular action is in + * this state. */ +static constexpr const char *kWaiting = "waiting"; +/** A thread that is waiting for another thread to perform an action for up to a specified waiting + * time is in this state. */ +static constexpr const char *kTimedWaiting = "timed_waiting"; +/** A thread that has exited is in this state. */ +static constexpr const char *kTerminated = "terminated"; +} // namespace JvmThreadStateValues + +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 MessagingOperationTypeValues { /** One or more messages are provided for publishing to an intermediary. If a single message is * published, the context of the "Publish" span can be used as the creation context and no @@ -3518,7 +4080,31 @@ static constexpr const char *kReceive = "receive"; static constexpr const char *kDeliver = "process"; /** One or more messages are settled. */ static constexpr const char *kSettle = "settle"; -} // namespace MessagingOperationValues +} // namespace MessagingOperationTypeValues + +namespace MessagingSystemValues +{ +/** Apache ActiveMQ. */ +static constexpr const char *kActivemq = "activemq"; +/** Amazon Simple Queue Service (SQS). */ +static constexpr const char *kAwsSqs = "aws_sqs"; +/** Azure Event Grid. */ +static constexpr const char *kEventgrid = "eventgrid"; +/** Azure Event Hubs. */ +static constexpr const char *kEventhubs = "eventhubs"; +/** Azure Service Bus. */ +static constexpr const char *kServicebus = "servicebus"; +/** Google Cloud Pub/Sub. */ +static constexpr const char *kGcpPubsub = "gcp_pubsub"; +/** Java Message Service. */ +static constexpr const char *kJms = "jms"; +/** Apache Kafka. */ +static constexpr const char *kKafka = "kafka"; +/** RabbitMQ. */ +static constexpr const char *kRabbitmq = "rabbitmq"; +/** Apache RocketMQ. */ +static constexpr const char *kRocketmq = "rocketmq"; +} // namespace MessagingSystemValues namespace MessagingRocketmqConsumptionModelValues { @@ -3552,30 +4138,6 @@ static constexpr const char *kDeadLetter = "dead_letter"; static constexpr const char *kDefer = "defer"; } // namespace MessagingServicebusDispositionStatusValues -namespace MessagingSystemValues -{ -/** Apache ActiveMQ. */ -static constexpr const char *kActivemq = "activemq"; -/** Amazon Simple Queue Service (SQS). */ -static constexpr const char *kAwsSqs = "aws_sqs"; -/** Azure Event Grid. */ -static constexpr const char *kEventgrid = "eventgrid"; -/** Azure Event Hubs. */ -static constexpr const char *kEventhubs = "eventhubs"; -/** Azure Service Bus. */ -static constexpr const char *kServicebus = "servicebus"; -/** Google Cloud Pub/Sub. */ -static constexpr const char *kGcpPubsub = "gcp_pubsub"; -/** Java Message Service. */ -static constexpr const char *kJms = "jms"; -/** Apache Kafka. */ -static constexpr const char *kKafka = "kafka"; -/** RabbitMQ. */ -static constexpr const char *kRabbitmq = "rabbitmq"; -/** Apache RocketMQ. */ -static constexpr const char *kRocketmq = "rocketmq"; -} // namespace MessagingSystemValues - namespace NetworkConnectionSubtypeValues { /** GPRS. */ @@ -3664,6 +4226,14 @@ static constexpr const char *kIpv4 = "ipv4"; static constexpr const char *kIpv6 = "ipv6"; } // namespace NetworkTypeValues +namespace OpentracingRefTypeValues +{ +/** The parent Span depends on the child Span in some capacity. */ +static constexpr const char *kChildOf = "child_of"; +/** The parent Span doesn't depend in any way on the result of the child Span. */ +static constexpr const char *kFollowsFrom = "follows_from"; +} // namespace OpentracingRefTypeValues + namespace OsTypeValues { /** Microsoft Windows. */ @@ -3690,6 +4260,41 @@ static constexpr const char *kSolaris = "solaris"; static constexpr const char *kZOs = "z_os"; } // namespace OsTypeValues +namespace OtelStatusCodeValues +{ +/** The operation has been validated by an Application developer or Operator to have completed + * successfully. */ +static constexpr const char *kOk = "OK"; +/** The operation contains an error. */ +static constexpr const char *kError = "ERROR"; +} // namespace OtelStatusCodeValues + +namespace ProcessContextSwitchTypeValues +{ +/** voluntary. */ +static constexpr const char *kVoluntary = "voluntary"; +/** involuntary. */ +static constexpr const char *kInvoluntary = "involuntary"; +} // namespace ProcessContextSwitchTypeValues + +namespace ProcessPagingFaultTypeValues +{ +/** major. */ +static constexpr const char *kMajor = "major"; +/** minor. */ +static constexpr const char *kMinor = "minor"; +} // namespace ProcessPagingFaultTypeValues + +namespace ProcessCpuStateValues +{ +/** system. */ +static constexpr const char *kSystem = "system"; +/** user. */ +static constexpr const char *kUser = "user"; +/** wait. */ +static constexpr const char *kWait = "wait"; +} // namespace ProcessCpuStateValues + namespace RpcConnectRpcErrorCodeValues { /** cancelled. */ @@ -3764,6 +4369,14 @@ static constexpr const int kDataLoss = 15; static constexpr const int kUnauthenticated = 16; } // namespace RpcGrpcStatusCodeValues +namespace RpcMessageTypeValues +{ +/** sent. */ +static constexpr const char *kSent = "SENT"; +/** received. */ +static constexpr const char *kReceived = "RECEIVED"; +} // namespace RpcMessageTypeValues + namespace RpcSystemValues { /** gRPC. */ @@ -3778,6 +4391,148 @@ static constexpr const char *kApacheDubbo = "apache_dubbo"; static constexpr const char *kConnectRpc = "connect_rpc"; } // namespace RpcSystemValues +namespace SignalrConnectionStatusValues +{ +/** The connection was closed normally. */ +static constexpr const char *kNormalClosure = "normal_closure"; +/** The connection was closed due to a timeout. */ +static constexpr const char *kTimeout = "timeout"; +/** The connection was closed because the app is shutting down. */ +static constexpr const char *kAppShutdown = "app_shutdown"; +} // namespace SignalrConnectionStatusValues + +namespace SignalrTransportValues +{ +/** ServerSentEvents protocol. */ +static constexpr const char *kServerSentEvents = "server_sent_events"; +/** LongPolling protocol. */ +static constexpr const char *kLongPolling = "long_polling"; +/** WebSockets protocol. */ +static constexpr const char *kWebSockets = "web_sockets"; +} // namespace SignalrTransportValues + +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 +{ +/** 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 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 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 SystemProcessStatusValues +{ +/** 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 SystemProcessStatusValues + namespace TelemetrySdkLanguageValues { /** cpp. */ @@ -3814,14 +4569,6 @@ static constexpr const char *kSsl = "ssl"; static constexpr const char *kTls = "tls"; } // namespace TlsProtocolNameValues -namespace AwsEcsLaunchtypeValues -{ -/** ec2. */ -static constexpr const char *kEc2 = "ec2"; -/** fargate. */ -static constexpr const char *kFargate = "fargate"; -} // namespace AwsEcsLaunchtypeValues - } // namespace SemanticConventions } // namespace resource } // namespace sdk From 2535c70c4e4c1a92cb535413283b7c022c65554e Mon Sep 17 00:00:00 2001 From: Marc Alff <marc.alff@oracle.com> Date: Mon, 3 Jun 2024 22:46:08 +0200 Subject: [PATCH 16/17] [API/SDK] Provider cleanup (#2664) --- CHANGELOG.md | 54 +++++++++ CMakeLists.txt | 8 ++ DEPRECATED.md | 80 ++++++++++++- api/CMakeLists.txt | 5 + api/include/opentelemetry/plugin/tracer.h | 4 + api/include/opentelemetry/trace/noop.h | 4 + api/include/opentelemetry/trace/tracer.h | 9 ++ api/test/singleton/singleton_test.cc | 4 + ci/do_ci.ps1 | 2 + ci/do_ci.sh | 4 + examples/logs_simple/main.cc | 39 ++++-- examples/metrics_simple/metrics_ostream.cc | 29 +++-- examples/otlp/file_log_main.cc | 59 ++++++---- examples/otlp/file_main.cc | 28 +++-- examples/otlp/grpc_log_main.cc | 60 ++++++---- examples/otlp/grpc_main.cc | 30 +++-- examples/otlp/http_log_main.cc | 65 ++++++---- examples/otlp/http_main.cc | 27 +++-- examples/plugin/plugin/tracer.h | 4 + examples/simple/main.cc | 12 +- .../otlp/test/otlp_file_exporter_test.cc | 4 +- .../otlp_grpc_log_record_exporter_test.cc | 9 +- .../otlp/test/otlp_http_exporter_test.cc | 16 +-- ext/src/dll/input.src | 7 +- functional/otlp/func_http_main.cc | 2 - .../sdk/logs/event_logger_provider.h | 3 +- .../sdk/logs/event_logger_provider_factory.h | 17 ++- .../opentelemetry/sdk/logs/logger_provider.h | 2 +- .../sdk/logs/logger_provider_factory.h | 58 ++++++--- .../sdk/metrics/meter_context_factory.h | 10 +- .../sdk/metrics/meter_provider_factory.h | 61 ++++------ sdk/include/opentelemetry/sdk/trace/tracer.h | 29 +++++ .../opentelemetry/sdk/trace/tracer_provider.h | 2 +- .../sdk/trace/tracer_provider_factory.h | 65 ++++++++++ sdk/src/logs/event_logger_provider_factory.cc | 13 +- sdk/src/logs/logger_provider_factory.cc | 50 +++++++- sdk/src/metrics/meter_provider_factory.cc | 48 +++++++- sdk/src/trace/tracer_provider_factory.cc | 111 +++++++++++++++--- 38 files changed, 806 insertions(+), 228 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27c379349f..cd92d15ba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,60 @@ Increment the: * [CI] Upgrade to clang-format 18 [#2684](https://github.com/open-telemetry/opentelemetry-cpp/pull/2684) +* [API/SDK] Provider cleanup + [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) + +Important changes: + +* [API/SDK] Provider cleanup + [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) + * Before this fix: + * The API class `opentelemetry::trace::Tracer` exposed methods such + as `ForceFlush()`, `ForceFlushWithMicroseconds()`, `Close()` + and `CloseWithMicroseconds()`. + * These methods are meant to be used when configuring the SDK, + and should not be part of the API. Exposing them was an oversight. + * Two of these methods are virtual, and therefore part of the ABI. + * After this fix: + * In `OPENTELEMETRY_ABI_VERSION_NO 1`, nothing is changed, + because removing this code would break the ABI. + * In `OPENTELEMETRY_ABI_VERSION_NO 2`, these methods are moved + from the API to the SDK. This is a breaking change for ABI version 2, + which is still experimental. + * In all cases, instrumenting an application should not + invoke flush or close on a tracer, do not use these methods. + +Breaking changes: + +* [API/SDK] Provider cleanup + [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) + * Before this fix: + * SDK factory methods such as: + * opentelemetry::sdk::trace::TracerProviderFactory::Create() + * opentelemetry::sdk::metrics::MeterProviderFactory::Create() + * opentelemetry::sdk::logs::LoggerProviderFactory::Create() + * opentelemetry::sdk::logs::EventLoggerProviderFactory::Create() + returned an API object (opentelemetry::trace::TracerProvider) + to the caller. + * After this fix, these methods return an SDK level object + (opentelemetry::sdk::trace::TracerProvider) to the caller. + * Returning an SDK object is necessary for the application to + cleanup and invoke SDK level methods, such as ForceFlush(), + on a provider. + * The application code that configures the SDK, by calling + the various provider factories, may need adjustment. + * All the examples have been updated, and in particular no + longer perform static_cast do convert an API object to an SDK object. + Please refer to examples for guidance on how to adjust. + * If adjusting application code is impractical, + an alternate and temporary solution is to build with option + WITH_DEPRECATED_SDK_FACTORY=ON in CMake. + * Option WITH_DEPRECATED_SDK_FACTORY=ON will allow to build code + without application changes, posponing changes for later. + * WITH_DEPRECATED_SDK_FACTORY=ON is temporary, only to provide + an easier migration path. Expect this flag to be removed, + as early as by the next release. + Notes on experimental features: * [#2372](https://github.com/open-telemetry/opentelemetry-cpp/issues/2372) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc085b1af4..d01d7054ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,6 +154,14 @@ message(STATUS "OPENTELEMETRY_VERSION=${OPENTELEMETRY_VERSION}") option(WITH_NO_DEPRECATED_CODE "Do not include deprecated code" OFF) +# This option is temporary, and will be removed. Set +# WITH_DEPRECATED_SDK_FACTORY=OFF to migrate to the new SDK code. +option(WITH_DEPRECATED_SDK_FACTORY "Use deprecated SDK provider factory" ON) + +if(WITH_DEPRECATED_SDK_FACTORY) + message(WARNING "WITH_DEPRECATED_SDK_FACTORY=ON is temporary and deprecated") +endif() + set(WITH_STL "OFF" CACHE STRING "Which version of the Standard Library for C++ to use") diff --git a/DEPRECATED.md b/DEPRECATED.md index 0632f50503..7db5ba9d93 100644 --- a/DEPRECATED.md +++ b/DEPRECATED.md @@ -88,7 +88,85 @@ No date set yet for the Jaeger Propagator. ## [opentelemetry-cpp SDK] -N/A +### SDK ProviderFactory cleanup + +#### Announcement (SDK ProviderFactory cleanup) + +* Version: 1.15.0 +* Date: 2024-06-03 +* PR: [API/SDK] Provider cleanup + [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) + +This PR introduces changes to SDK ProviderFactory methods. + +#### Motivation (SDK ProviderFactory cleanup) + +SDK Factory methods for signal providers, such as: + +* opentelemetry::sdk::trace::TracerProviderFactory +* opentelemetry::sdk::metrics::MeterProviderFactory +* opentelemetry::sdk::logs::LoggerProviderFactory +* opentelemetry::sdk::logs::EventLoggerProviderFactory + +currently returns a unique pointer on a API class. + +This is incorrect, the proper return type should be +a unique pointer on a SDK class instead. + +#### Scope (SDK ProviderFactory cleanup) + +All the current Create methods in: + +* class opentelemetry::sdk::trace::TracerProviderFactory +* class opentelemetry::sdk::metrics::MeterProviderFactory +* class opentelemetry::sdk::logs::LoggerProviderFactory +* class opentelemetry::sdk::logs::EventLoggerProviderFactory + +are marked as deprecated, as they return an API object. + +Instead, another set of Create methods is provided, +with a different return type, an SDK object. + +Both sets can not be exposed at the same time, +as this would cause build breaks, +so a compilation flag is defined to select which methods to use. + +When OPENTELEMETRY_DEPRECATED_SDK_FACTORY is defined, +the old, deprecated, methods are available. + +When OPENTELEMETRY_DEPRECATED_SDK_FACTORY is not defined, +the new methods are available. + +The scope of this deprecation and removal, +is to remove the flag OPENTELEMETRY_DEPRECATED_SDK_FACTORY itself, +which implies that only the new set of Create() methods, +returning an SDK object, are supported. + +#### Mitigation (SDK ProviderFactory cleanup) + +Build without defining flag OPENTELEMETRY_DEPRECATED_SDK_FACTORY. + +Existing code, such as: + +```cpp + std::shared_ptr<opentelemetry::trace::TracerProvider> tracer_provider; + tracer_provider = opentelemetry::sdk::trace::TracerProviderFactory::Create(...); +``` + +should be adjusted to: + +```cpp + std::shared_ptr<opentelemetry::sdk::trace::TracerProvider> tracer_provider; + tracer_provider = opentelemetry::sdk::trace::TracerProviderFactory::Create(...); +``` + +#### Planned removal (SDK ProviderFactory cleanup) + +Flag OPENTELEMETRY_DEPRECATED_SDK_FACTORY is introduced in release 1.16.0, +to provide a migration path. + +This flag is meant to be temporary, and short lived. +Expect removal by release 1.17.0 ## [opentelemetry-cpp Exporter] diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index 78e97ad029..e07275efed 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -35,6 +35,11 @@ if(WITH_NO_DEPRECATED_CODE) INTERFACE OPENTELEMETRY_NO_DEPRECATED_CODE) endif() +if(WITH_DEPRECATED_SDK_FACTORY) + target_compile_definitions(opentelemetry_api + INTERFACE OPENTELEMETRY_DEPRECATED_SDK_FACTORY) +endif() + if(WITH_ABSEIL) target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL) target_link_libraries( diff --git a/api/include/opentelemetry/plugin/tracer.h b/api/include/opentelemetry/plugin/tracer.h index 068b08071d..9f3c7c76d1 100644 --- a/api/include/opentelemetry/plugin/tracer.h +++ b/api/include/opentelemetry/plugin/tracer.h @@ -104,6 +104,8 @@ class Tracer final : public trace::Tracer, public std::enable_shared_from_this<T return nostd::shared_ptr<trace::Span>{new (std::nothrow) Span{this->shared_from_this(), span}}; } +#if OPENTELEMETRY_ABI_VERSION_NO == 1 + void ForceFlushWithMicroseconds(uint64_t timeout) noexcept override { tracer_handle_->tracer().ForceFlushWithMicroseconds(timeout); @@ -114,6 +116,8 @@ class Tracer final : public trace::Tracer, public std::enable_shared_from_this<T tracer_handle_->tracer().CloseWithMicroseconds(timeout); } +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ + private: // Note: The order is important here. // diff --git a/api/include/opentelemetry/trace/noop.h b/api/include/opentelemetry/trace/noop.h index 407f3c1ac9..345c4ba0c9 100644 --- a/api/include/opentelemetry/trace/noop.h +++ b/api/include/opentelemetry/trace/noop.h @@ -102,9 +102,13 @@ class OPENTELEMETRY_EXPORT NoopTracer final : public Tracer, return noop_span; } +#if OPENTELEMETRY_ABI_VERSION_NO == 1 + void ForceFlushWithMicroseconds(uint64_t /*timeout*/) noexcept override {} void CloseWithMicroseconds(uint64_t /*timeout*/) noexcept override {} + +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ }; /** diff --git a/api/include/opentelemetry/trace/tracer.h b/api/include/opentelemetry/trace/tracer.h index 7fc758511f..c10fff6c60 100644 --- a/api/include/opentelemetry/trace/tracer.h +++ b/api/include/opentelemetry/trace/tracer.h @@ -163,6 +163,13 @@ class Tracer } } +#if OPENTELEMETRY_ABI_VERSION_NO == 1 + + /* + * The following is removed from the API in ABI version 2. + * It belongs to the SDK. + */ + /** * Force any buffered spans to flush. * @param timeout to complete the flush @@ -188,6 +195,8 @@ class Tracer } virtual void CloseWithMicroseconds(uint64_t timeout) noexcept = 0; + +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ }; } // namespace trace OPENTELEMETRY_END_NAMESPACE diff --git a/api/test/singleton/singleton_test.cc b/api/test/singleton/singleton_test.cc index 0973a1427f..fb4551cfe9 100644 --- a/api/test/singleton/singleton_test.cc +++ b/api/test/singleton/singleton_test.cc @@ -250,9 +250,13 @@ class MyTracer : public trace::Tracer return result; } +#if OPENTELEMETRY_ABI_VERSION_NO == 1 + void ForceFlushWithMicroseconds(uint64_t /* timeout */) noexcept override {} void CloseWithMicroseconds(uint64_t /* timeout */) noexcept override {} + +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ }; class MyTracerProvider : public trace::TracerProvider diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index bdab94ae04..f6a12e3877 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -133,6 +133,7 @@ switch ($action) { cmake $SRC_DIR ` -DOTELCPP_MAINTAINER_MODE=ON ` -DWITH_NO_DEPRECATED_CODE=ON ` + -DWITH_DEPRECATED_SDK_FACTORY=OFF ` -DVCPKG_TARGET_TRIPLET=x64-windows ` "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" $exit = $LASTEXITCODE @@ -157,6 +158,7 @@ switch ($action) { -DCMAKE_CXX_STANDARD=20 ` -DOTELCPP_MAINTAINER_MODE=ON ` -DWITH_NO_DEPRECATED_CODE=ON ` + -DWITH_DEPRECATED_SDK_FACTORY=OFF ` -DVCPKG_TARGET_TRIPLET=x64-windows ` "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" $exit = $LASTEXITCODE diff --git a/ci/do_ci.sh b/ci/do_ci.sh index b7c97a3800..2d089ef21e 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -130,6 +130,7 @@ elif [[ "$1" == "cmake.maintainer.sync.test" ]]; then -DWITH_ASYNC_EXPORT_PREVIEW=OFF \ -DOTELCPP_MAINTAINER_MODE=ON \ -DWITH_NO_DEPRECATED_CODE=ON \ + -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DWITH_OTLP_HTTP_COMPRESSION=ON \ ${IWYU} \ "${SRC_DIR}" @@ -152,6 +153,7 @@ elif [[ "$1" == "cmake.maintainer.async.test" ]]; then -DWITH_ASYNC_EXPORT_PREVIEW=ON \ -DOTELCPP_MAINTAINER_MODE=ON \ -DWITH_NO_DEPRECATED_CODE=ON \ + -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DWITH_OTLP_HTTP_COMPRESSION=ON \ ${IWYU} \ "${SRC_DIR}" @@ -175,6 +177,7 @@ elif [[ "$1" == "cmake.maintainer.cpp11.async.test" ]]; then -DWITH_ASYNC_EXPORT_PREVIEW=ON \ -DOTELCPP_MAINTAINER_MODE=ON \ -DWITH_NO_DEPRECATED_CODE=ON \ + -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DWITH_OTLP_HTTP_COMPRESSION=ON \ "${SRC_DIR}" make -k -j $(nproc) @@ -196,6 +199,7 @@ elif [[ "$1" == "cmake.maintainer.abiv2.test" ]]; then -DWITH_ASYNC_EXPORT_PREVIEW=OFF \ -DOTELCPP_MAINTAINER_MODE=ON \ -DWITH_NO_DEPRECATED_CODE=ON \ + -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DWITH_ABI_VERSION_1=OFF \ -DWITH_ABI_VERSION_2=ON \ -DWITH_OTLP_HTTP_COMPRESSION=ON \ diff --git a/examples/logs_simple/main.cc b/examples/logs_simple/main.cc index 54a872ad0e..e104724e2a 100644 --- a/examples/logs_simple/main.cc +++ b/examples/logs_simple/main.cc @@ -1,19 +1,20 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include "opentelemetry/exporters/ostream/log_record_exporter.h" #include "opentelemetry/exporters/ostream/span_exporter_factory.h" +#include "opentelemetry/logs/provider.h" +#include "opentelemetry/sdk/logs/logger_provider.h" +#include "opentelemetry/sdk/logs/logger_provider_factory.h" +#include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h" #include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/provider.h" -#include "opentelemetry/exporters/ostream/log_record_exporter.h" -#include "opentelemetry/logs/provider.h" -#include "opentelemetry/sdk/logs/logger_provider_factory.h" -#include "opentelemetry/sdk/logs/processor.h" -#include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h" - #ifdef BAZEL_BUILD # include "examples/common/logs_foo_library/foo_library.h" #else @@ -35,11 +36,18 @@ void InitTracer() // Create ostream span exporter instance auto exporter = trace_exporter::OStreamSpanExporterFactory::Create(); auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - std::shared_ptr<trace_api::TracerProvider> provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + std::shared_ptr<opentelemetry::trace::TracerProvider> provider = + opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); +#else + std::shared_ptr<opentelemetry::sdk::trace::TracerProvider> provider = + opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global trace provider - trace_api::Provider::SetTracerProvider(provider); + std::shared_ptr<trace_api::TracerProvider> api_provider = provider; + trace_api::Provider::SetTracerProvider(api_provider); } void CleanupTracer() @@ -54,11 +62,18 @@ void InitLogger() auto exporter = std::unique_ptr<logs_sdk::LogRecordExporter>(new logs_exporter::OStreamLogRecordExporter); auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); - std::shared_ptr<logs_api::LoggerProvider> provider( - logs_sdk::LoggerProviderFactory::Create(std::move(processor))); + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + std::shared_ptr<opentelemetry::logs::LoggerProvider> provider( + opentelemetry::sdk::logs::LoggerProviderFactory::Create(std::move(processor))); +#else + std::shared_ptr<opentelemetry::sdk::logs::LoggerProvider> provider( + opentelemetry::sdk::logs::LoggerProviderFactory::Create(std::move(processor))); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global logger provider - logs_api::Provider::SetLoggerProvider(provider); + std::shared_ptr<logs_api::LoggerProvider> api_provider = provider; + logs_api::Provider::SetLoggerProvider(api_provider); } void CleanupLogger() diff --git a/examples/metrics_simple/metrics_ostream.cc b/examples/metrics_simple/metrics_ostream.cc index 7248bc9148..770b2db81a 100644 --- a/examples/metrics_simple/metrics_ostream.cc +++ b/examples/metrics_simple/metrics_ostream.cc @@ -46,10 +46,14 @@ void InitMetrics(const std::string &name) auto reader = metrics_sdk::PeriodicExportingMetricReaderFactory::Create(std::move(exporter), options); - auto u_provider = metrics_sdk::MeterProviderFactory::Create(); - auto *p = static_cast<metrics_sdk::MeterProvider *>(u_provider.get()); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + auto u_provider = opentelemetry::sdk::metrics::MeterProviderFactory::Create(); + auto *provider = static_cast<opentelemetry::sdk::metrics::MeterProvider *>(u_provider.get()); +#else + auto provider = opentelemetry::sdk::metrics::MeterProviderFactory::Create(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - p->AddMetricReader(std::move(reader)); + provider->AddMetricReader(std::move(reader)); // counter view std::string counter_name = name + "_counter"; @@ -63,7 +67,7 @@ void InitMetrics(const std::string &name) auto sum_view = metrics_sdk::ViewFactory::Create(name, "description", unit, metrics_sdk::AggregationType::kSum); - p->AddView(std::move(instrument_selector), std::move(meter_selector), std::move(sum_view)); + provider->AddView(std::move(instrument_selector), std::move(meter_selector), std::move(sum_view)); // observable counter view std::string observable_counter_name = name + "_observable_counter"; @@ -76,8 +80,8 @@ void InitMetrics(const std::string &name) auto observable_sum_view = metrics_sdk::ViewFactory::Create(name, "test_description", unit, metrics_sdk::AggregationType::kSum); - p->AddView(std::move(observable_instrument_selector), std::move(observable_meter_selector), - std::move(observable_sum_view)); + provider->AddView(std::move(observable_instrument_selector), std::move(observable_meter_selector), + std::move(observable_sum_view)); // histogram view std::string histogram_name = name + "_histogram"; @@ -100,11 +104,16 @@ void InitMetrics(const std::string &name) auto histogram_view = metrics_sdk::ViewFactory::Create( name, "description", unit, metrics_sdk::AggregationType::kHistogram, aggregation_config); - p->AddView(std::move(histogram_instrument_selector), std::move(histogram_meter_selector), - std::move(histogram_view)); + provider->AddView(std::move(histogram_instrument_selector), std::move(histogram_meter_selector), + std::move(histogram_view)); + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + std::shared_ptr<opentelemetry::metrics::MeterProvider> api_provider(std::move(u_provider)); +#else + std::shared_ptr<opentelemetry::metrics::MeterProvider> api_provider(std::move(provider)); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - std::shared_ptr<opentelemetry::metrics::MeterProvider> provider(std::move(u_provider)); - metrics_api::Provider::SetMeterProvider(provider); + metrics_api::Provider::SetMeterProvider(api_provider); } void CleanupMetrics() diff --git a/examples/otlp/file_log_main.cc b/examples/otlp/file_log_main.cc index f903449c56..9254c9947f 100644 --- a/examples/otlp/file_log_main.cc +++ b/examples/otlp/file_log_main.cc @@ -8,20 +8,17 @@ #include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter_options.h" #include "opentelemetry/logs/provider.h" #include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/logger_provider.h" #include "opentelemetry/sdk/logs/logger_provider_factory.h" #include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h" #include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/provider.h" -// sdk::TracerProvider and sdk::LoggerProvider is just used to call ForceFlush and prevent to cancel -// running exportings when destroy and shutdown exporters.It's optional to users. -#include "opentelemetry/sdk/logs/logger_provider.h" -#include "opentelemetry/sdk/trace/tracer_provider.h" - #include <iostream> #include <string> #include <utility> @@ -43,27 +40,40 @@ namespace { opentelemetry::exporter::otlp::OtlpFileExporterOptions opts; opentelemetry::exporter::otlp::OtlpFileLogRecordExporterOptions log_opts; + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY +std::shared_ptr<opentelemetry::trace::TracerProvider> tracer_provider; +std::shared_ptr<opentelemetry::logs::LoggerProvider> logger_provider; +#else +std::shared_ptr<opentelemetry::sdk::trace::TracerProvider> tracer_provider; +std::shared_ptr<opentelemetry::sdk::logs::LoggerProvider> logger_provider; +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ + void InitTracer() { // Create OTLP exporter instance - auto exporter = otlp::OtlpFileExporterFactory::Create(opts); - auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - std::shared_ptr<opentelemetry::trace::TracerProvider> provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + auto exporter = otlp::OtlpFileExporterFactory::Create(opts); + auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); + tracer_provider = trace_sdk::TracerProviderFactory::Create(std::move(processor)); + // Set the global trace provider - trace::Provider::SetTracerProvider(provider); + std::shared_ptr<opentelemetry::trace::TracerProvider> api_provider = tracer_provider; + trace::Provider::SetTracerProvider(api_provider); } void CleanupTracer() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider> provider = - trace::Provider::GetTracerProvider(); - if (provider) + if (tracer_provider) { - static_cast<trace_sdk::TracerProvider *>(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast<opentelemetry::sdk::trace::TracerProvider *>(tracer_provider.get())->ForceFlush(); +#else + tracer_provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + tracer_provider.reset(); std::shared_ptr<opentelemetry::trace::TracerProvider> none; trace::Provider::SetTracerProvider(none); } @@ -71,24 +81,27 @@ void CleanupTracer() void InitLogger() { // Create OTLP exporter instance - auto exporter = otlp::OtlpFileLogRecordExporterFactory::Create(log_opts); - auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); - nostd::shared_ptr<logs::LoggerProvider> provider( - logs_sdk::LoggerProviderFactory::Create(std::move(processor))); + auto exporter = otlp::OtlpFileLogRecordExporterFactory::Create(log_opts); + auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); + logger_provider = logs_sdk::LoggerProviderFactory::Create(std::move(processor)); - opentelemetry::logs::Provider::SetLoggerProvider(provider); + std::shared_ptr<opentelemetry::logs::LoggerProvider> api_provider = logger_provider; + opentelemetry::logs::Provider::SetLoggerProvider(api_provider); } void CleanupLogger() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr<logs::LoggerProvider> provider = - logs::Provider::GetLoggerProvider(); - if (provider) + if (logger_provider) { - static_cast<logs_sdk::LoggerProvider *>(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast<opentelemetry::sdk::logs::LoggerProvider *>(logger_provider.get())->ForceFlush(); +#else + logger_provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + logger_provider.reset(); nostd::shared_ptr<logs::LoggerProvider> none; opentelemetry::logs::Provider::SetLoggerProvider(none); } diff --git a/examples/otlp/file_main.cc b/examples/otlp/file_main.cc index e0a1264fb6..13db0e4ad1 100644 --- a/examples/otlp/file_main.cc +++ b/examples/otlp/file_main.cc @@ -4,13 +4,10 @@ #include "opentelemetry/exporters/otlp/otlp_file_exporter_factory.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/provider.h" -// sdk::TracerProvider is just used to call ForceFlush and prevent to cancel running exportings when -// destroy and shutdown exporters.It's optional to users. -#include "opentelemetry/sdk/trace/tracer_provider.h" - #include <iostream> #include <string> #include <utility> @@ -28,27 +25,38 @@ namespace otlp = opentelemetry::exporter::otlp; namespace { opentelemetry::exporter::otlp::OtlpFileExporterOptions opts; + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY +std::shared_ptr<opentelemetry::trace::TracerProvider> provider; +#else +std::shared_ptr<opentelemetry::sdk::trace::TracerProvider> provider; +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ + void InitTracer() { // Create OTLP exporter instance auto exporter = otlp::OtlpFileExporterFactory::Create(opts); auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - std::shared_ptr<opentelemetry::trace::TracerProvider> provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + provider = trace_sdk::TracerProviderFactory::Create(std::move(processor)); + // Set the global trace provider - trace::Provider::SetTracerProvider(provider); + std::shared_ptr<opentelemetry::trace::TracerProvider> api_provider = provider; + trace::Provider::SetTracerProvider(api_provider); } void CleanupTracer() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider> provider = - trace::Provider::GetTracerProvider(); if (provider) { - static_cast<trace_sdk::TracerProvider *>(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast<opentelemetry::sdk::trace::TracerProvider *>(provider.get())->ForceFlush(); +#else + provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + provider.reset(); std::shared_ptr<opentelemetry::trace::TracerProvider> none; trace::Provider::SetTracerProvider(none); } diff --git a/examples/otlp/grpc_log_main.cc b/examples/otlp/grpc_log_main.cc index 9d7399dbaf..24037f6190 100644 --- a/examples/otlp/grpc_log_main.cc +++ b/examples/otlp/grpc_log_main.cc @@ -7,20 +7,17 @@ #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.h" #include "opentelemetry/sdk/logs/logger_provider_factory.h" #include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h" #include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/provider.h" -// sdk::TracerProvider and sdk::LoggerProvider is just used to call ForceFlush and prevent to cancel -// running exportings when destroy and shutdown exporters.It's optional to users. -#include "opentelemetry/sdk/logs/logger_provider.h" -#include "opentelemetry/sdk/trace/tracer_provider.h" - #include <string> #ifdef BAZEL_BUILD @@ -40,27 +37,40 @@ namespace { opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts; opentelemetry::exporter::otlp::OtlpGrpcLogRecordExporterOptions log_opts; + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY +std::shared_ptr<opentelemetry::trace::TracerProvider> tracer_provider; +std::shared_ptr<opentelemetry::logs::LoggerProvider> logger_provider; +#else +std::shared_ptr<opentelemetry::sdk::trace::TracerProvider> tracer_provider; +std::shared_ptr<opentelemetry::sdk::logs::LoggerProvider> logger_provider; +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ + void InitTracer() { // Create OTLP exporter instance - auto exporter = otlp::OtlpGrpcExporterFactory::Create(opts); - auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - std::shared_ptr<opentelemetry::trace::TracerProvider> provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + auto exporter = otlp::OtlpGrpcExporterFactory::Create(opts); + auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); + tracer_provider = trace_sdk::TracerProviderFactory::Create(std::move(processor)); + // Set the global trace provider - trace::Provider::SetTracerProvider(provider); + std::shared_ptr<opentelemetry::trace::TracerProvider> api_provider = tracer_provider; + trace::Provider::SetTracerProvider(api_provider); } void CleanupTracer() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider> provider = - trace::Provider::GetTracerProvider(); - if (provider) + if (tracer_provider) { - static_cast<trace_sdk::TracerProvider *>(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast<opentelemetry::sdk::trace::TracerProvider *>(tracer_provider.get())->ForceFlush(); +#else + tracer_provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + tracer_provider.reset(); std::shared_ptr<opentelemetry::trace::TracerProvider> none; trace::Provider::SetTracerProvider(none); } @@ -68,24 +78,28 @@ void CleanupTracer() void InitLogger() { // Create OTLP exporter instance - auto exporter = otlp::OtlpGrpcLogRecordExporterFactory::Create(log_opts); - auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); - nostd::shared_ptr<logs::LoggerProvider> provider( - logs_sdk::LoggerProviderFactory::Create(std::move(processor))); + auto exporter = otlp::OtlpGrpcLogRecordExporterFactory::Create(log_opts); + auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); + logger_provider = logs_sdk::LoggerProviderFactory::Create(std::move(processor)); - opentelemetry::logs::Provider::SetLoggerProvider(provider); + // Set the global logger provider + std::shared_ptr<opentelemetry::logs::LoggerProvider> api_provider = logger_provider; + opentelemetry::logs::Provider::SetLoggerProvider(api_provider); } void CleanupLogger() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr<logs::LoggerProvider> provider = - logs::Provider::GetLoggerProvider(); - if (provider) + if (logger_provider) { - static_cast<logs_sdk::LoggerProvider *>(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast<opentelemetry::sdk::logs::LoggerProvider *>(logger_provider.get())->ForceFlush(); +#else + logger_provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + logger_provider.reset(); nostd::shared_ptr<logs::LoggerProvider> none; opentelemetry::logs::Provider::SetLoggerProvider(none); } diff --git a/examples/otlp/grpc_main.cc b/examples/otlp/grpc_main.cc index c238d9ad2a..15499985af 100644 --- a/examples/otlp/grpc_main.cc +++ b/examples/otlp/grpc_main.cc @@ -2,14 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/provider.h" - -// sdk::TracerProvider is just used to call ForceFlush and prevent to cancel running exportings when -// destroy and shutdown exporters.It's optional to users. -#include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/trace/tracer_provider.h" #ifdef BAZEL_BUILD # include "examples/common/foo_library/foo_library.h" @@ -24,27 +23,38 @@ namespace otlp = opentelemetry::exporter::otlp; namespace { opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts; + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY +std::shared_ptr<opentelemetry::trace::TracerProvider> provider; +#else +std::shared_ptr<opentelemetry::sdk::trace::TracerProvider> provider; +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ + void InitTracer() { // Create OTLP exporter instance auto exporter = otlp::OtlpGrpcExporterFactory::Create(opts); auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - std::shared_ptr<opentelemetry::trace::TracerProvider> provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + provider = trace_sdk::TracerProviderFactory::Create(std::move(processor)); + // Set the global trace provider - trace::Provider::SetTracerProvider(provider); + std::shared_ptr<opentelemetry::trace::TracerProvider> api_provider = provider; + trace::Provider::SetTracerProvider(api_provider); } void CleanupTracer() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider> provider = - trace::Provider::GetTracerProvider(); if (provider) { - static_cast<trace_sdk::TracerProvider *>(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast<opentelemetry::sdk::trace::TracerProvider *>(provider.get())->ForceFlush(); +#else + provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + provider.reset(); std::shared_ptr<opentelemetry::trace::TracerProvider> none; trace::Provider::SetTracerProvider(none); } diff --git a/examples/otlp/http_log_main.cc b/examples/otlp/http_log_main.cc index 7b68ad44c7..e2b219de1c 100644 --- a/examples/otlp/http_log_main.cc +++ b/examples/otlp/http_log_main.cc @@ -6,19 +6,16 @@ #include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" #include "opentelemetry/logs/provider.h" #include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/logs/logger_provider.h" #include "opentelemetry/sdk/logs/logger_provider_factory.h" #include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/provider.h" -// sdk::TracerProvider and sdk::LoggerProvider is just used to call ForceFlush and prevent to cancel -// running exportings when destroy and shutdown exporters.It's optional to users. -#include "opentelemetry/sdk/logs/logger_provider.h" -#include "opentelemetry/sdk/trace/tracer_provider.h" - #include <iostream> #include <string> @@ -40,6 +37,13 @@ namespace { opentelemetry::exporter::otlp::OtlpHttpExporterOptions trace_opts; + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY +std::shared_ptr<opentelemetry::trace::TracerProvider> tracer_provider; +#else +std::shared_ptr<opentelemetry::sdk::trace::TracerProvider> tracer_provider; +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ + void InitTracer() { if (trace_opts.url.size() > 9) @@ -58,53 +62,68 @@ void InitTracer() } } std::cout << "Using " << trace_opts.url << " to export trace spans." << std::endl; + // Create OTLP exporter instance - auto exporter = otlp::OtlpHttpExporterFactory::Create(trace_opts); - auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - std::shared_ptr<opentelemetry::trace::TracerProvider> provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + auto exporter = otlp::OtlpHttpExporterFactory::Create(trace_opts); + auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); + tracer_provider = trace_sdk::TracerProviderFactory::Create(std::move(processor)); + // Set the global trace provider - trace::Provider::SetTracerProvider(provider); + std::shared_ptr<opentelemetry::trace::TracerProvider> api_provider = tracer_provider; + trace::Provider::SetTracerProvider(api_provider); } void CleanupTracer() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider> provider = - trace::Provider::GetTracerProvider(); - if (provider) + if (tracer_provider) { - static_cast<trace_sdk::TracerProvider *>(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast<opentelemetry::sdk::trace::TracerProvider *>(tracer_provider.get())->ForceFlush(); +#else + tracer_provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + tracer_provider.reset(); std::shared_ptr<opentelemetry::trace::TracerProvider> none; trace::Provider::SetTracerProvider(none); } opentelemetry::exporter::otlp::OtlpHttpLogRecordExporterOptions logger_opts; + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY +std::shared_ptr<opentelemetry::logs::LoggerProvider> logger_provider; +#else +std::shared_ptr<opentelemetry::sdk::logs::LoggerProvider> logger_provider; +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ + void InitLogger() { std::cout << "Using " << logger_opts.url << " to export log records." << std::endl; logger_opts.console_debug = true; // Create OTLP exporter instance - auto exporter = otlp::OtlpHttpLogRecordExporterFactory::Create(logger_opts); - auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); - std::shared_ptr<logs::LoggerProvider> provider = - logs_sdk::LoggerProviderFactory::Create(std::move(processor)); + auto exporter = otlp::OtlpHttpLogRecordExporterFactory::Create(logger_opts); + auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); + logger_provider = logs_sdk::LoggerProviderFactory::Create(std::move(processor)); - opentelemetry::logs::Provider::SetLoggerProvider(provider); + std::shared_ptr<opentelemetry::logs::LoggerProvider> api_provider = logger_provider; + opentelemetry::logs::Provider::SetLoggerProvider(api_provider); } void CleanupLogger() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr<logs::LoggerProvider> provider = - logs::Provider::GetLoggerProvider(); - if (provider) + if (logger_provider) { - static_cast<logs_sdk::LoggerProvider *>(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast<opentelemetry::sdk::logs::LoggerProvider *>(logger_provider.get())->ForceFlush(); +#else + logger_provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + logger_provider.reset(); std::shared_ptr<logs::LoggerProvider> none; opentelemetry::logs::Provider::SetLoggerProvider(none); } diff --git a/examples/otlp/http_main.cc b/examples/otlp/http_main.cc index 6a0667b918..9ad476bd47 100644 --- a/examples/otlp/http_main.cc +++ b/examples/otlp/http_main.cc @@ -6,13 +6,10 @@ #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/provider.h" -// sdk::TracerProvider is just used to call ForceFlush and prevent to cancel running exportings when -// destroy and shutdown exporters.It's optional to users. -#include "opentelemetry/sdk/trace/tracer_provider.h" - #include <string> #ifdef BAZEL_BUILD @@ -30,27 +27,37 @@ namespace internal_log = opentelemetry::sdk::common::internal_log; namespace { opentelemetry::exporter::otlp::OtlpHttpExporterOptions opts; + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY +std::shared_ptr<opentelemetry::trace::TracerProvider> provider; +#else +std::shared_ptr<opentelemetry::sdk::trace::TracerProvider> provider; +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ + void InitTracer() { // Create OTLP exporter instance auto exporter = otlp::OtlpHttpExporterFactory::Create(opts); auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); - std::shared_ptr<opentelemetry::trace::TracerProvider> provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + provider = trace_sdk::TracerProviderFactory::Create(std::move(processor)); // Set the global trace provider - trace::Provider::SetTracerProvider(provider); + std::shared_ptr<opentelemetry::trace::TracerProvider> api_provider = provider; + trace::Provider::SetTracerProvider(api_provider); } void CleanupTracer() { // We call ForceFlush to prevent to cancel running exportings, It's optional. - opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider> provider = - trace::Provider::GetTracerProvider(); if (provider) { - static_cast<trace_sdk::TracerProvider *>(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast<opentelemetry::sdk::trace::TracerProvider *>(provider.get())->ForceFlush(); +#else + provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + provider.reset(); std::shared_ptr<opentelemetry::trace::TracerProvider> none; trace::Provider::SetTracerProvider(none); } diff --git a/examples/plugin/plugin/tracer.h b/examples/plugin/plugin/tracer.h index af2a4c5e92..1480b44541 100644 --- a/examples/plugin/plugin/tracer.h +++ b/examples/plugin/plugin/tracer.h @@ -20,7 +20,11 @@ class Tracer final : public opentelemetry::trace::Tracer, const opentelemetry::trace::SpanContextKeyValueIterable & /*links*/, const opentelemetry::trace::StartSpanOptions & /*options */) noexcept override; +#if OPENTELEMETRY_ABI_VERSION_NO == 1 + void ForceFlushWithMicroseconds(uint64_t /*timeout*/) noexcept override {} void CloseWithMicroseconds(uint64_t /*timeout*/) noexcept override {} + +#endif /* OPENTELEMETRY_ABI_VERSION_NO */ }; diff --git a/examples/simple/main.cc b/examples/simple/main.cc index 48768b6448..284ec2f693 100644 --- a/examples/simple/main.cc +++ b/examples/simple/main.cc @@ -5,6 +5,7 @@ #include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/provider.h" @@ -24,11 +25,18 @@ void InitTracer() { auto exporter = trace_exporter::OStreamSpanExporterFactory::Create(); auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY std::shared_ptr<opentelemetry::trace::TracerProvider> provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); +#else + std::shared_ptr<opentelemetry::sdk::trace::TracerProvider> provider = + opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global trace provider - trace_api::Provider::SetTracerProvider(provider); + std::shared_ptr<opentelemetry::trace::TracerProvider> api_provider = provider; + trace_api::Provider::SetTracerProvider(api_provider); } void CleanupTracer() diff --git a/exporters/otlp/test/otlp_file_exporter_test.cc b/exporters/otlp/test/otlp_file_exporter_test.cc index 497bb0b203..16a1306f88 100644 --- a/exporters/otlp/test/otlp_file_exporter_test.cc +++ b/exporters/otlp/test/otlp_file_exporter_test.cc @@ -88,7 +88,7 @@ class OtlpFileExporterTestPeer : public ::testing::Test auto processor = std::unique_ptr<sdk::trace::SpanProcessor>( new sdk::trace::BatchSpanProcessor(std::move(exporter), processor_opts)); - auto provider = nostd::shared_ptr<trace::TracerProvider>( + auto provider = nostd::shared_ptr<sdk::trace::TracerProvider>( new sdk::trace::TracerProvider(std::move(processor), resource)); std::string report_trace_id; @@ -110,7 +110,7 @@ class OtlpFileExporterTestPeer : public ::testing::Test child_span->End(); parent_span->End(); - static_cast<sdk::trace::TracerProvider *>(provider.get())->ForceFlush(); + provider->ForceFlush(); { auto check_json = nlohmann::json::parse(output.str(), nullptr, false); 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 c0c04c577a..4c7a9fd7f1 100644 --- a/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc @@ -288,10 +288,17 @@ TEST_F(OtlpGrpcLogRecordExporterTestPeer, ExportIntegrationTest) std::unique_ptr<proto::collector::trace::v1::TraceService::StubInterface> trace_stub_interface( trace_mock_stub); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY auto trace_provider = opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider>( opentelemetry::sdk::trace::TracerProviderFactory::Create( opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create( GetExporter(trace_stub_interface)))); +#else + auto trace_provider = opentelemetry::nostd::shared_ptr<opentelemetry::sdk::trace::TracerProvider>( + opentelemetry::sdk::trace::TracerProviderFactory::Create( + opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create( + GetExporter(trace_stub_interface)))); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Trace and Logs should both receive datas when links static gRPC on ELF ABI. EXPECT_CALL(*trace_mock_stub, Export(_, _, _)) @@ -331,7 +338,7 @@ TEST_F(OtlpGrpcLogRecordExporterTestPeer, ExportIntegrationTest) opentelemetry::trace::Provider::SetTracerProvider( opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider>( new opentelemetry::trace::NoopTracerProvider())); - trace_provider = opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider>(); + trace_provider = opentelemetry::nostd::shared_ptr<opentelemetry::sdk::trace::TracerProvider>(); } } // namespace otlp diff --git a/exporters/otlp/test/otlp_http_exporter_test.cc b/exporters/otlp/test/otlp_http_exporter_test.cc index 8f4b938b78..e4f69f502b 100644 --- a/exporters/otlp/test/otlp_http_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_exporter_test.cc @@ -135,7 +135,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto processor = std::unique_ptr<sdk::trace::SpanProcessor>( new sdk::trace::BatchSpanProcessor(std::move(exporter), processor_opts)); - auto provider = nostd::shared_ptr<trace::TracerProvider>( + auto provider = nostd::shared_ptr<sdk::trace::TracerProvider>( new sdk::trace::TracerProvider(std::move(processor), resource)); std::string report_trace_id; @@ -190,7 +190,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test child_span->End(); parent_span->End(); - static_cast<sdk::trace::TracerProvider *>(provider.get())->ForceFlush(); + provider->ForceFlush(); } # ifdef ENABLE_ASYNC_EXPORT @@ -226,7 +226,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto processor = std::unique_ptr<sdk::trace::SpanProcessor>( new sdk::trace::BatchSpanProcessor(std::move(exporter), processor_opts)); - auto provider = nostd::shared_ptr<trace::TracerProvider>( + auto provider = nostd::shared_ptr<sdk::trace::TracerProvider>( new sdk::trace::TracerProvider(std::move(processor), resource)); std::string report_trace_id; @@ -285,7 +285,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test child_span->End(); parent_span->End(); - static_cast<sdk::trace::TracerProvider *>(provider.get())->ForceFlush(); + provider->ForceFlush(); } # endif @@ -321,7 +321,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto processor = std::unique_ptr<sdk::trace::SpanProcessor>( new sdk::trace::BatchSpanProcessor(std::move(exporter), processor_opts)); - auto provider = nostd::shared_ptr<trace::TracerProvider>( + auto provider = nostd::shared_ptr<sdk::trace::TracerProvider>( new sdk::trace::TracerProvider(std::move(processor), resource)); std::string report_trace_id; @@ -366,7 +366,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test child_span->End(); parent_span->End(); - static_cast<sdk::trace::TracerProvider *>(provider.get())->ForceFlush(); + provider->ForceFlush(); } # ifdef ENABLE_ASYNC_EXPORT @@ -402,7 +402,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto processor = std::unique_ptr<sdk::trace::SpanProcessor>( new sdk::trace::BatchSpanProcessor(std::move(exporter), processor_opts)); - auto provider = nostd::shared_ptr<trace::TracerProvider>( + auto provider = nostd::shared_ptr<sdk::trace::TracerProvider>( new sdk::trace::TracerProvider(std::move(processor), resource)); std::string report_trace_id; @@ -452,7 +452,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test child_span->End(); parent_span->End(); - static_cast<sdk::trace::TracerProvider *>(provider.get())->ForceFlush(); + provider->ForceFlush(); } # endif }; diff --git a/ext/src/dll/input.src b/ext/src/dll/input.src index 91ed42d303..98c4c140fe 100644 --- a/ext/src/dll/input.src +++ b/ext/src/dll/input.src @@ -9,8 +9,8 @@ Create@LoggerProviderFactory@logs@sdk@v1@opentelemetry Create@BatchLogRecordProcessorFactory@logs@sdk@v1@opentelemetry Create@SimpleLogRecordProcessorFactory@logs@sdk@v1@opentelemetry Create@MultiLogRecordProcessorFactory@logs@sdk@v1@opentelemetry -ForceFlush@TracerProvider@trace@sdk@v1@opentelemetry -ForceFlush@LoggerProvider@logs@sdk@v1@opentelemetry +TracerProvider@trace@sdk@v1@opentelemetry +LoggerProvider@logs@sdk@v1@opentelemetry OStreamLogRecordExporter@logs@exporter@v1@opentelemetry Create@OStreamMetricExporterFactory@metrics@exporter@v1@opentelemetry Create@PeriodicExportingMetricReaderFactory@metrics@sdk@v1@opentelemetry @@ -21,6 +21,7 @@ Create@MeterSelectorFactory@metrics@sdk@v1@opentelemetry Create@InstrumentSelectorFactory@metrics@sdk@v1@opentelemetry AddMetricReader@MeterContext@metrics@sdk@v1@opentelemetry AddMetricReader@MeterProvider@metrics@sdk@v1@opentelemetry +MeterProvider@metrics@sdk@v1@opentelemetry AddView@MeterProvider@metrics@sdk@v1@opentelemetry #if defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP) @@ -64,4 +65,4 @@ GetOtlpDefaultHttpTracesEndpoint@otlp@exporter@v1@opentelemetry GetOtlpDefaultHttpMetricsEndpoint@otlp@exporter@v1@opentelemetry GetOtlpDefaultHttpLogsEndpoint@otlp@exporter@v1@opentelemetry #endif // defined(WITH_OTLP_HTTP) -// clang-format on \ No newline at end of file +// clang-format on diff --git a/functional/otlp/func_http_main.cc b/functional/otlp/func_http_main.cc index d584a85687..9cd3585668 100644 --- a/functional/otlp/func_http_main.cc +++ b/functional/otlp/func_http_main.cc @@ -173,8 +173,6 @@ void payload() auto span = tracer->StartSpan(k_span_name); span->SetAttribute(k_attr_test_name, opt_test_name); span->End(); - - tracer->ForceFlushWithMicroseconds(1000000); } void cleanup() diff --git a/sdk/include/opentelemetry/sdk/logs/event_logger_provider.h b/sdk/include/opentelemetry/sdk/logs/event_logger_provider.h index 2f3d2a0afd..4572647356 100644 --- a/sdk/include/opentelemetry/sdk/logs/event_logger_provider.h +++ b/sdk/include/opentelemetry/sdk/logs/event_logger_provider.h @@ -20,7 +20,8 @@ namespace logs class EventLogger; class Logger; -class EventLoggerProvider final : public opentelemetry::logs::EventLoggerProvider +class OPENTELEMETRY_EXPORT EventLoggerProvider final + : public opentelemetry::logs::EventLoggerProvider { public: EventLoggerProvider() noexcept; diff --git a/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h b/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h index 0b8c066fc6..621cbea6c8 100644 --- a/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h @@ -4,14 +4,11 @@ #pragma once #include <memory> + +#include "opentelemetry/sdk/logs/event_logger_provider.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace logs -{ -class EventLoggerProvider; -} // namespace logs - namespace sdk { namespace logs @@ -26,7 +23,17 @@ class EventLoggerProviderFactory /** * Create a EventLoggerProvider. */ + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + +# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE + OPENTELEMETRY_DEPRECATED static std::unique_ptr<opentelemetry::logs::EventLoggerProvider> Create(); +# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ + +#else + static std::unique_ptr<opentelemetry::sdk::logs::EventLoggerProvider> Create(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace logs diff --git a/sdk/include/opentelemetry/sdk/logs/logger_provider.h b/sdk/include/opentelemetry/sdk/logs/logger_provider.h index 0ab5683d3e..bced6061f5 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_provider.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_provider.h @@ -26,7 +26,7 @@ class Logger; class LoggerContext; class LogRecordProcessor; -class LoggerProvider final : public opentelemetry::logs::LoggerProvider +class OPENTELEMETRY_EXPORT LoggerProvider final : public opentelemetry::logs::LoggerProvider { public: /** diff --git a/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h b/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h index 987a09fe16..7b8f636e68 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h @@ -6,25 +6,17 @@ #include <memory> #include <vector> +#include "opentelemetry/sdk/logs/logger_context.h" +#include "opentelemetry/sdk/logs/logger_provider.h" +#include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace logs -{ -class LoggerProvider; -} // namespace logs - namespace sdk { -namespace resource -{ -class Resource; -} // namespace resource - namespace logs { -class LoggerContext; -class LogRecordProcessor; /** * Factory class for LoggerProvider. @@ -32,37 +24,69 @@ class LogRecordProcessor; class OPENTELEMETRY_EXPORT LoggerProviderFactory { public: +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + +# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE + + OPENTELEMETRY_DEPRECATED + static std::unique_ptr<opentelemetry::logs::LoggerProvider> Create( + std::unique_ptr<LogRecordProcessor> &&processor); + + OPENTELEMETRY_DEPRECATED + static std::unique_ptr<opentelemetry::logs::LoggerProvider> Create( + std::unique_ptr<LogRecordProcessor> &&processor, + const opentelemetry::sdk::resource::Resource &resource); + + OPENTELEMETRY_DEPRECATED + static std::unique_ptr<opentelemetry::logs::LoggerProvider> Create( + std::vector<std::unique_ptr<LogRecordProcessor>> &&processors); + + OPENTELEMETRY_DEPRECATED + static std::unique_ptr<opentelemetry::logs::LoggerProvider> Create( + std::vector<std::unique_ptr<LogRecordProcessor>> &&processors, + const opentelemetry::sdk::resource::Resource &resource); + + OPENTELEMETRY_DEPRECATED + static std::unique_ptr<opentelemetry::logs::LoggerProvider> Create( + std::unique_ptr<LoggerContext> context); + +# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ + +#else + /** * Create a LoggerProvider. */ - static std::unique_ptr<opentelemetry::logs::LoggerProvider> Create( + static std::unique_ptr<opentelemetry::sdk::logs::LoggerProvider> Create( std::unique_ptr<LogRecordProcessor> &&processor); /** * Create a LoggerProvider. */ - static std::unique_ptr<opentelemetry::logs::LoggerProvider> Create( + static std::unique_ptr<opentelemetry::sdk::logs::LoggerProvider> Create( std::unique_ptr<LogRecordProcessor> &&processor, const opentelemetry::sdk::resource::Resource &resource); /** * Create a LoggerProvider. */ - static std::unique_ptr<opentelemetry::logs::LoggerProvider> Create( + static std::unique_ptr<opentelemetry::sdk::logs::LoggerProvider> Create( std::vector<std::unique_ptr<LogRecordProcessor>> &&processors); /** * Create a LoggerProvider. */ - static std::unique_ptr<opentelemetry::logs::LoggerProvider> Create( + static std::unique_ptr<opentelemetry::sdk::logs::LoggerProvider> Create( std::vector<std::unique_ptr<LogRecordProcessor>> &&processors, const opentelemetry::sdk::resource::Resource &resource); /** * Create a LoggerProvider. */ - static std::unique_ptr<opentelemetry::logs::LoggerProvider> Create( + static std::unique_ptr<opentelemetry::sdk::logs::LoggerProvider> Create( std::unique_ptr<LoggerContext> context); + +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace logs diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h b/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h index 13e3a9f290..1185a6075a 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h @@ -3,21 +3,19 @@ #pragma once +#include <memory> + +#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/view/view_registry.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" -#include <memory> - OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { namespace metrics { -// forward declaration -class MeterContext; -class ViewRegistry; - /** * Factory class for MeterContext. */ diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h index 15aa13badc..cb9106ddc8 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h @@ -7,6 +7,7 @@ #include "opentelemetry/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/view/view_registry.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" @@ -17,56 +18,46 @@ namespace sdk namespace metrics { -/* - MAINTAINER: +class OPENTELEMETRY_EXPORT MeterProviderFactory +{ +public: +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - The best design is to return an API object: - std::unique_ptr<opentelemetry::metrics::MeterProvider> - to shield the calling application from SDK implementation details. +# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE - This however assumes that the SDK object can be created in one call, - instead of making multiple calls to the SDK to setup a meter provider. + OPENTELEMETRY_DEPRECATED + static std::unique_ptr<opentelemetry::metrics::MeterProvider> Create(); - Because existing code, already advertised in examples: - - creates an instance of sdk::MeterProvider - - calls SDK methods on it to continue the setup, such as - MeterProvider::AddMetricReader() - MeterProvider::AddView() - existing applications will need to access the underlying - class sdk::MeterProvider. + OPENTELEMETRY_DEPRECATED + static std::unique_ptr<opentelemetry::metrics::MeterProvider> Create( + std::unique_ptr<ViewRegistry> views); - We need to decide whether to return: - - (1) std::unique_ptr<opentelemetry::metrics::MeterProvider> - - (2) std::unique_ptr<opentelemetry::metrics::sdk::MeterProvider> - from a Create() method. + OPENTELEMETRY_DEPRECATED + static std::unique_ptr<opentelemetry::metrics::MeterProvider> Create( + std::unique_ptr<ViewRegistry> views, + const opentelemetry::sdk::resource::Resource &resource); - In the long term, (1) is better, but forces users to use a down cast, - to make additional calls to the SDK class, until such a time when - the builders can take all the necessary input at once, - for example using a std::vector<MetricReader> to add all readers. + OPENTELEMETRY_DEPRECATED + static std::unique_ptr<opentelemetry::metrics::MeterProvider> Create( + std::unique_ptr<sdk::metrics::MeterContext> context); - Implementing (2) is forcing technical debt, and prevents the - calling application configuring the SDK to be decoupled from it, - making deployment of shared libraries much more difficult. +# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ - The design choice here is to return (1) an API MeterProvider, - even if this forces, temporarily, existing applications to use a downcast. -*/ +#else -class OPENTELEMETRY_EXPORT MeterProviderFactory -{ -public: - static std::unique_ptr<opentelemetry::metrics::MeterProvider> Create(); + static std::unique_ptr<opentelemetry::sdk::metrics::MeterProvider> Create(); - static std::unique_ptr<opentelemetry::metrics::MeterProvider> Create( + static std::unique_ptr<opentelemetry::sdk::metrics::MeterProvider> Create( std::unique_ptr<ViewRegistry> views); - static std::unique_ptr<opentelemetry::metrics::MeterProvider> Create( + static std::unique_ptr<opentelemetry::sdk::metrics::MeterProvider> Create( std::unique_ptr<ViewRegistry> views, const opentelemetry::sdk::resource::Resource &resource); - static std::unique_ptr<opentelemetry::metrics::MeterProvider> Create( + static std::unique_ptr<opentelemetry::sdk::metrics::MeterProvider> Create( std::unique_ptr<sdk::metrics::MeterContext> context); + +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace metrics diff --git a/sdk/include/opentelemetry/sdk/trace/tracer.h b/sdk/include/opentelemetry/sdk/trace/tracer.h index 778ffe8173..fb8342c1d5 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer.h @@ -45,9 +45,38 @@ class Tracer final : public opentelemetry::trace::Tracer, const opentelemetry::trace::SpanContextKeyValueIterable &links, const opentelemetry::trace::StartSpanOptions &options = {}) noexcept override; +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + /** + * Force any buffered spans to flush. + * @param timeout to complete the flush + */ + template <class Rep, class Period> + void ForceFlush(std::chrono::duration<Rep, Period> timeout) noexcept + { + this->ForceFlushWithMicroseconds(static_cast<uint64_t>( + std::chrono::duration_cast<std::chrono::microseconds>(timeout).count())); + } + + void ForceFlushWithMicroseconds(uint64_t timeout) noexcept; + + /** + * ForceFlush any buffered spans and stop reporting spans. + * @param timeout to complete the flush + */ + template <class Rep, class Period> + void Close(std::chrono::duration<Rep, Period> timeout) noexcept + { + this->CloseWithMicroseconds(static_cast<uint64_t>( + std::chrono::duration_cast<std::chrono::microseconds>(timeout).count())); + } + + void CloseWithMicroseconds(uint64_t timeout) noexcept; +#else + /* Exposed in the API in ABI version 1, but does not belong to the API */ void ForceFlushWithMicroseconds(uint64_t timeout) noexcept override; void CloseWithMicroseconds(uint64_t timeout) noexcept override; +#endif /** Returns the configured span processor. */ SpanProcessor &GetProcessor() noexcept { return context_->GetProcessor(); } diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h index e0f3ce0c4c..0d05a94043 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h @@ -28,7 +28,7 @@ namespace sdk namespace trace { -class TracerProvider final : public opentelemetry::trace::TracerProvider +class OPENTELEMETRY_EXPORT TracerProvider final : public opentelemetry::trace::TracerProvider { public: /** diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h b/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h index 17f7ea395a..7c4b6903de 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h @@ -11,6 +11,7 @@ #include "opentelemetry/sdk/trace/processor.h" #include "opentelemetry/sdk/trace/sampler.h" #include "opentelemetry/sdk/trace/tracer_context.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/trace/tracer_provider.h" #include "opentelemetry/version.h" @@ -27,20 +28,28 @@ namespace trace class OPENTELEMETRY_EXPORT TracerProviderFactory { public: +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + +# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE + /* Serie of builders with a single processor. */ + OPENTELEMETRY_DEPRECATED static std::unique_ptr<opentelemetry::trace::TracerProvider> Create( std::unique_ptr<SpanProcessor> processor); + OPENTELEMETRY_DEPRECATED static std::unique_ptr<opentelemetry::trace::TracerProvider> Create( std::unique_ptr<SpanProcessor> processor, const opentelemetry::sdk::resource::Resource &resource); + OPENTELEMETRY_DEPRECATED static std::unique_ptr<opentelemetry::trace::TracerProvider> Create( std::unique_ptr<SpanProcessor> processor, const opentelemetry::sdk::resource::Resource &resource, std::unique_ptr<Sampler> sampler); + OPENTELEMETRY_DEPRECATED static std::unique_ptr<opentelemetry::trace::TracerProvider> Create( std::unique_ptr<SpanProcessor> processor, const opentelemetry::sdk::resource::Resource &resource, @@ -49,18 +58,22 @@ class OPENTELEMETRY_EXPORT TracerProviderFactory /* Serie of builders with a vector of processor. */ + OPENTELEMETRY_DEPRECATED static std::unique_ptr<opentelemetry::trace::TracerProvider> Create( std::vector<std::unique_ptr<SpanProcessor>> &&processors); + OPENTELEMETRY_DEPRECATED static std::unique_ptr<opentelemetry::trace::TracerProvider> Create( std::vector<std::unique_ptr<SpanProcessor>> &&processors, const opentelemetry::sdk::resource::Resource &resource); + OPENTELEMETRY_DEPRECATED static std::unique_ptr<opentelemetry::trace::TracerProvider> Create( std::vector<std::unique_ptr<SpanProcessor>> &&processors, const opentelemetry::sdk::resource::Resource &resource, std::unique_ptr<Sampler> sampler); + OPENTELEMETRY_DEPRECATED static std::unique_ptr<opentelemetry::trace::TracerProvider> Create( std::vector<std::unique_ptr<SpanProcessor>> &&processors, const opentelemetry::sdk::resource::Resource &resource, @@ -69,8 +82,60 @@ class OPENTELEMETRY_EXPORT TracerProviderFactory /* Create with a tracer context. */ + OPENTELEMETRY_DEPRECATED static std::unique_ptr<opentelemetry::trace::TracerProvider> Create( std::unique_ptr<TracerContext> context); + +# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ + +#else + + /* Serie of builders with a single processor. */ + + static std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> Create( + std::unique_ptr<SpanProcessor> processor); + + static std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> Create( + std::unique_ptr<SpanProcessor> processor, + const opentelemetry::sdk::resource::Resource &resource); + + static std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> Create( + std::unique_ptr<SpanProcessor> processor, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr<Sampler> sampler); + + static std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> Create( + std::unique_ptr<SpanProcessor> processor, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr<Sampler> sampler, + std::unique_ptr<IdGenerator> id_generator); + + /* Serie of builders with a vector of processor. */ + + static std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> Create( + std::vector<std::unique_ptr<SpanProcessor>> &&processors); + + static std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> Create( + std::vector<std::unique_ptr<SpanProcessor>> &&processors, + const opentelemetry::sdk::resource::Resource &resource); + + static std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> Create( + std::vector<std::unique_ptr<SpanProcessor>> &&processors, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr<Sampler> sampler); + + static std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> Create( + std::vector<std::unique_ptr<SpanProcessor>> &&processors, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr<Sampler> sampler, + std::unique_ptr<IdGenerator> id_generator); + + /* Create with a tracer context. */ + + static std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> Create( + std::unique_ptr<TracerContext> context); + +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace trace diff --git a/sdk/src/logs/event_logger_provider_factory.cc b/sdk/src/logs/event_logger_provider_factory.cc index 0c9eff4570..7f5c8cadf1 100644 --- a/sdk/src/logs/event_logger_provider_factory.cc +++ b/sdk/src/logs/event_logger_provider_factory.cc @@ -3,7 +3,7 @@ #include "opentelemetry/sdk/logs/event_logger_provider_factory.h" #include "opentelemetry/sdk/logs/event_logger_provider.h" -#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -11,11 +11,22 @@ namespace sdk namespace logs { +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + std::unique_ptr<opentelemetry::logs::EventLoggerProvider> EventLoggerProviderFactory::Create() { return std::unique_ptr<opentelemetry::logs::EventLoggerProvider>(new EventLoggerProvider()); } +#else + +std::unique_ptr<opentelemetry::sdk::logs::EventLoggerProvider> EventLoggerProviderFactory::Create() +{ + return std::unique_ptr<opentelemetry::sdk::logs::EventLoggerProvider>(new EventLoggerProvider()); +} + +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ + } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/src/logs/logger_provider_factory.cc b/sdk/src/logs/logger_provider_factory.cc index 76e662a909..8c169866ff 100644 --- a/sdk/src/logs/logger_provider_factory.cc +++ b/sdk/src/logs/logger_provider_factory.cc @@ -1,9 +1,11 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/logger_provider_factory.h" +#include <utility> + #include "opentelemetry/sdk/logs/logger_context.h" #include "opentelemetry/sdk/logs/logger_provider.h" +#include "opentelemetry/sdk/logs/logger_provider_factory.h" #include "opentelemetry/sdk/resource/resource.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,6 +14,8 @@ namespace sdk namespace logs { +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + std::unique_ptr<opentelemetry::logs::LoggerProvider> LoggerProviderFactory::Create( std::unique_ptr<LogRecordProcessor> &&processor) { @@ -52,6 +56,50 @@ std::unique_ptr<opentelemetry::logs::LoggerProvider> LoggerProviderFactory::Crea return provider; } +#else + +std::unique_ptr<opentelemetry::sdk::logs::LoggerProvider> LoggerProviderFactory::Create( + std::unique_ptr<LogRecordProcessor> &&processor) +{ + auto resource = opentelemetry::sdk::resource::Resource::Create({}); + return Create(std::move(processor), resource); +} + +std::unique_ptr<opentelemetry::sdk::logs::LoggerProvider> LoggerProviderFactory::Create( + std::unique_ptr<LogRecordProcessor> &&processor, + const opentelemetry::sdk::resource::Resource &resource) +{ + std::unique_ptr<opentelemetry::sdk::logs::LoggerProvider> provider( + new LoggerProvider(std::move(processor), resource)); + return provider; +} + +std::unique_ptr<opentelemetry::sdk::logs::LoggerProvider> LoggerProviderFactory::Create( + std::vector<std::unique_ptr<LogRecordProcessor>> &&processors) +{ + auto resource = opentelemetry::sdk::resource::Resource::Create({}); + return Create(std::move(processors), resource); +} + +std::unique_ptr<opentelemetry::sdk::logs::LoggerProvider> LoggerProviderFactory::Create( + std::vector<std::unique_ptr<LogRecordProcessor>> &&processors, + const opentelemetry::sdk::resource::Resource &resource) +{ + std::unique_ptr<opentelemetry::sdk::logs::LoggerProvider> provider( + new LoggerProvider(std::move(processors), resource)); + return provider; +} + +std::unique_ptr<opentelemetry::sdk::logs::LoggerProvider> LoggerProviderFactory::Create( + std::unique_ptr<LoggerContext> context) +{ + std::unique_ptr<opentelemetry::sdk::logs::LoggerProvider> provider( + new LoggerProvider(std::move(context))); + return provider; +} + +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ + } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/src/metrics/meter_provider_factory.cc b/sdk/src/metrics/meter_provider_factory.cc index 43c060e5f9..7749a13124 100644 --- a/sdk/src/metrics/meter_provider_factory.cc +++ b/sdk/src/metrics/meter_provider_factory.cc @@ -1,23 +1,25 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include <memory> #include <utility> -#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/sdk/metrics/meter_context.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/meter_provider_factory.h" +#include "opentelemetry/sdk/metrics/view/view_registry.h" #include "opentelemetry/sdk/metrics/view/view_registry_factory.h" +#include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" -namespace resource = opentelemetry::sdk::resource; -namespace metrics_sdk = opentelemetry::sdk::metrics; - OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { namespace metrics { +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + std::unique_ptr<opentelemetry::metrics::MeterProvider> MeterProviderFactory::Create() { auto views = ViewRegistryFactory::Create(); @@ -36,7 +38,7 @@ std::unique_ptr<opentelemetry::metrics::MeterProvider> MeterProviderFactory::Cre const opentelemetry::sdk::resource::Resource &resource) { std::unique_ptr<opentelemetry::metrics::MeterProvider> provider( - new metrics_sdk::MeterProvider(std::move(views), resource)); + new opentelemetry::sdk::metrics::MeterProvider(std::move(views), resource)); return provider; } @@ -44,10 +46,44 @@ std::unique_ptr<opentelemetry::metrics::MeterProvider> MeterProviderFactory::Cre std::unique_ptr<sdk::metrics::MeterContext> context) { std::unique_ptr<opentelemetry::metrics::MeterProvider> provider( - new metrics_sdk::MeterProvider(std::move(context))); + new opentelemetry::sdk::metrics::MeterProvider(std::move(context))); + return provider; +} + +#else + +std::unique_ptr<opentelemetry::sdk::metrics::MeterProvider> MeterProviderFactory::Create() +{ + auto views = ViewRegistryFactory::Create(); + return Create(std::move(views)); +} + +std::unique_ptr<opentelemetry::sdk::metrics::MeterProvider> MeterProviderFactory::Create( + std::unique_ptr<ViewRegistry> views) +{ + auto resource = opentelemetry::sdk::resource::Resource::Create({}); + return Create(std::move(views), resource); +} + +std::unique_ptr<opentelemetry::sdk::metrics::MeterProvider> MeterProviderFactory::Create( + std::unique_ptr<ViewRegistry> views, + const opentelemetry::sdk::resource::Resource &resource) +{ + std::unique_ptr<opentelemetry::sdk::metrics::MeterProvider> provider( + new opentelemetry::sdk::metrics::MeterProvider(std::move(views), resource)); return provider; } +std::unique_ptr<opentelemetry::sdk::metrics::MeterProvider> MeterProviderFactory::Create( + std::unique_ptr<sdk::metrics::MeterContext> context) +{ + std::unique_ptr<opentelemetry::sdk::metrics::MeterProvider> provider( + new opentelemetry::sdk::metrics::MeterProvider(std::move(context))); + return provider; +} + +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ + } // namespace metrics } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/src/trace/tracer_provider_factory.cc b/sdk/src/trace/tracer_provider_factory.cc index d22330b866..eeb18a1e59 100644 --- a/sdk/src/trace/tracer_provider_factory.cc +++ b/sdk/src/trace/tracer_provider_factory.cc @@ -14,27 +14,24 @@ #include "opentelemetry/sdk/trace/tracer_context.h" #include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" -#include "opentelemetry/trace/span_id.h" -#include "opentelemetry/trace/tracer_provider.h" #include "opentelemetry/version.h" -namespace trace_api = opentelemetry::trace; -namespace trace_sdk = opentelemetry::sdk::trace; - OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { namespace trace { -std::unique_ptr<trace_api::TracerProvider> TracerProviderFactory::Create( +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + +std::unique_ptr<opentelemetry::trace::TracerProvider> TracerProviderFactory::Create( std::unique_ptr<SpanProcessor> processor) { auto resource = opentelemetry::sdk::resource::Resource::Create({}); return Create(std::move(processor), resource); } -std::unique_ptr<trace_api::TracerProvider> TracerProviderFactory::Create( +std::unique_ptr<opentelemetry::trace::TracerProvider> TracerProviderFactory::Create( std::unique_ptr<SpanProcessor> processor, const opentelemetry::sdk::resource::Resource &resource) { @@ -57,8 +54,9 @@ std::unique_ptr<opentelemetry::trace::TracerProvider> TracerProviderFactory::Cre std::unique_ptr<Sampler> sampler, std::unique_ptr<IdGenerator> id_generator) { - std::unique_ptr<trace_api::TracerProvider> provider(new trace_sdk::TracerProvider( - std::move(processor), resource, std::move(sampler), std::move(id_generator))); + std::unique_ptr<opentelemetry::trace::TracerProvider> provider( + new opentelemetry::sdk::trace::TracerProvider(std::move(processor), resource, + std::move(sampler), std::move(id_generator))); return provider; } @@ -92,19 +90,104 @@ std::unique_ptr<opentelemetry::trace::TracerProvider> TracerProviderFactory::Cre std::unique_ptr<Sampler> sampler, std::unique_ptr<IdGenerator> id_generator) { - std::unique_ptr<trace_api::TracerProvider> provider(new trace_sdk::TracerProvider( - std::move(processors), resource, std::move(sampler), std::move(id_generator))); + std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> provider( + new opentelemetry::sdk::trace::TracerProvider(std::move(processors), resource, + std::move(sampler), std::move(id_generator))); + return provider; +} + +std::unique_ptr<opentelemetry::trace::TracerProvider> TracerProviderFactory::Create( + std::unique_ptr<TracerContext> context) +{ + std::unique_ptr<opentelemetry::trace::TracerProvider> provider( + new opentelemetry::sdk::trace::TracerProvider(std::move(context))); + return provider; +} + +#else + +std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> TracerProviderFactory::Create( + std::unique_ptr<SpanProcessor> processor) +{ + auto resource = opentelemetry::sdk::resource::Resource::Create({}); + return Create(std::move(processor), resource); +} + +std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> TracerProviderFactory::Create( + std::unique_ptr<SpanProcessor> processor, + const opentelemetry::sdk::resource::Resource &resource) +{ + auto sampler = AlwaysOnSamplerFactory::Create(); + return Create(std::move(processor), resource, std::move(sampler)); +} + +std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> TracerProviderFactory::Create( + std::unique_ptr<SpanProcessor> processor, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr<Sampler> sampler) +{ + auto id_generator = RandomIdGeneratorFactory::Create(); + return Create(std::move(processor), resource, std::move(sampler), std::move(id_generator)); +} + +std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> TracerProviderFactory::Create( + std::unique_ptr<SpanProcessor> processor, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr<Sampler> sampler, + std::unique_ptr<IdGenerator> id_generator) +{ + std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> provider( + new opentelemetry::sdk::trace::TracerProvider(std::move(processor), resource, + std::move(sampler), std::move(id_generator))); + return provider; +} + +std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> TracerProviderFactory::Create( + std::vector<std::unique_ptr<SpanProcessor>> &&processors) +{ + auto resource = opentelemetry::sdk::resource::Resource::Create({}); + return Create(std::move(processors), resource); +} + +std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> TracerProviderFactory::Create( + std::vector<std::unique_ptr<SpanProcessor>> &&processors, + const opentelemetry::sdk::resource::Resource &resource) +{ + auto sampler = AlwaysOnSamplerFactory::Create(); + return Create(std::move(processors), resource, std::move(sampler)); +} + +std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> TracerProviderFactory::Create( + std::vector<std::unique_ptr<SpanProcessor>> &&processors, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr<Sampler> sampler) +{ + auto id_generator = RandomIdGeneratorFactory::Create(); + return Create(std::move(processors), resource, std::move(sampler), std::move(id_generator)); +} + +std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> TracerProviderFactory::Create( + std::vector<std::unique_ptr<SpanProcessor>> &&processors, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr<Sampler> sampler, + std::unique_ptr<IdGenerator> id_generator) +{ + std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> provider( + new opentelemetry::sdk::trace::TracerProvider(std::move(processors), resource, + std::move(sampler), std::move(id_generator))); return provider; } -std::unique_ptr<trace_api::TracerProvider> TracerProviderFactory::Create( +std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> TracerProviderFactory::Create( std::unique_ptr<TracerContext> context) { - std::unique_ptr<trace_api::TracerProvider> provider( - new trace_sdk::TracerProvider(std::move(context))); + std::unique_ptr<opentelemetry::sdk::trace::TracerProvider> provider( + new opentelemetry::sdk::trace::TracerProvider(std::move(context))); return provider; } +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ + } // namespace trace } // namespace sdk OPENTELEMETRY_END_NAMESPACE From cb9cd1d1d13a5c6b6a99287dcb8b0d7bb62f277e Mon Sep 17 00:00:00 2001 From: Tom Tan <Tom.Tan@microsoft.com> Date: Wed, 5 Jun 2024 10:52:19 -0700 Subject: [PATCH 17/17] [ETW] Add table name mapping for Logs other than the default Log table (#2691) --- .../opentelemetry/exporters/etw/etw_config.h | 8 +++- .../opentelemetry/exporters/etw/etw_logger.h | 29 ++++++++--- exporters/etw/test/etw_logger_test.cc | 48 +++++++++++++++++++ 3 files changed, 77 insertions(+), 8 deletions(-) diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_config.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_config.h index dae8f5b075..d343589699 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_config.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_config.h @@ -23,8 +23,9 @@ namespace etw /** * @brief TelemetryProvider Options passed via SDK API. */ -using TelemetryProviderOptions = - std::map<std::string, nostd::variant<std::string, uint64_t, float, bool>>; +using TelemetryProviderOptions = std::map< + std::string, + nostd::variant<std::string, uint64_t, float, bool, std::map<std::string, std::string>>>; /** * @brief TelemetryProvider runtime configuration class. Internal representation @@ -41,6 +42,9 @@ typedef struct bool enableAutoParent; // Start new spans as children of current active span, Not used for Logs ETWProvider::EventFormat encoding; // Event encoding to use for this provider (TLD, MsgPack, XML, etc.). + bool enableTableNameMappings; // Map instrumentation scope name to table name with + // `tableNameMappings` + std::map<std::string, std::string> tableNameMappings; } TelemetryProviderConfiguration; /** diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_logger.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_logger.h index 494211ea0b..c464d572d5 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_logger.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_logger.h @@ -145,6 +145,8 @@ class Logger : public opentelemetry::logs::Logger */ std::string provId; + std::string eventName_; + /** * @brief Encoding (Manifest, MessagePack or XML) */ @@ -179,10 +181,12 @@ class Logger : public opentelemetry::logs::Logger * @param encoding ETW encoding format to use. */ Logger(etw::LoggerProvider &parent, + nostd::string_view eventName, nostd::string_view providerId = "", ETWProvider::EventFormat encoding = ETWProvider::EventFormat::ETW_MANIFEST) : opentelemetry::logs::Logger(), loggerProvider_(parent), + eventName_(eventName), provId(providerId.data(), providerId.size()), encoding(encoding), provHandle(initProvHandle()) @@ -271,7 +275,7 @@ class Logger : public opentelemetry::logs::Logger #endif // defined(ENABLE_ENV_PROPERTIES) // Populate Etw.EventName attribute at envelope level - evt[ETW_FIELD_NAME] = ETW_VALUE_LOG; + evt[ETW_FIELD_NAME] = eventName_.data(); #ifdef HAVE_FIELD_TIME { @@ -347,6 +351,8 @@ class LoggerProvider : public opentelemetry::logs::LoggerProvider GetOption(options, "enableTraceId", config_.enableTraceId, true); GetOption(options, "enableSpanId", config_.enableSpanId, true); GetOption(options, "enableActivityId", config_.enableActivityId, false); + GetOption(options, "enableTableNameMappings", config_.enableTableNameMappings, false); + GetOption(options, "tableNameMappings", config_.tableNameMappings, {}); // Determines what encoding to use for ETW events: TraceLogging Dynamic, MsgPack, XML, etc. config_.encoding = GetEncoding(options); @@ -359,19 +365,30 @@ class LoggerProvider : public opentelemetry::logs::LoggerProvider nostd::shared_ptr<opentelemetry::logs::Logger> GetLogger( opentelemetry::nostd::string_view logger_name, - opentelemetry::nostd::string_view library_name, - opentelemetry::nostd::string_view version = "", - opentelemetry::nostd::string_view schema_url = "", + opentelemetry::nostd::string_view library_name = "", + opentelemetry::nostd::string_view version = "", + opentelemetry::nostd::string_view schema_url = "", const opentelemetry::common::KeyValueIterable &attributes = opentelemetry::common::NoopKeyValueIterable()) override { - UNREFERENCED_PARAMETER(library_name); UNREFERENCED_PARAMETER(version); UNREFERENCED_PARAMETER(schema_url); UNREFERENCED_PARAMETER(attributes); + + std::string event_name{ETW_VALUE_LOG}; + if (config_.enableTableNameMappings) + { + auto it = + config_.tableNameMappings.find(std::string(library_name.data(), library_name.size())); + if (it != config_.tableNameMappings.end()) + { + event_name = it->second; + } + } + ETWProvider::EventFormat evtFmt = config_.encoding; return nostd::shared_ptr<opentelemetry::logs::Logger>{ - new (std::nothrow) etw::Logger(*this, logger_name, evtFmt)}; + new (std::nothrow) etw::Logger(*this, event_name, logger_name, evtFmt)}; } }; diff --git a/exporters/etw/test/etw_logger_test.cc b/exporters/etw/test/etw_logger_test.cc index f27d47880b..c64769d6ee 100644 --- a/exporters/etw/test/etw_logger_test.cc +++ b/exporters/etw/test/etw_logger_test.cc @@ -14,6 +14,7 @@ using namespace OPENTELEMETRY_NAMESPACE; using namespace opentelemetry::exporter::etw; +// The ETW provider ID is {4533CB59-77E2-54E9-E340-F0F0549058B7} const char *kGlobalProviderName = "OpenTelemetry-ETW-TLD"; /** @@ -98,4 +99,51 @@ TEST(ETWLogger, LoggerCheckWithAttributes) opentelemetry::common::MakeAttributes(attribs))); } +/** + * @brief Logger Test with structured attributes + * + * Example Event for below test: + * { + * "Timestamp": "2024-06-02T15:04:15.4227815-07:00", + * "ProviderName": "OpenTelemetry-ETW-TLD", + * "Id": 1, + * "Message": null, + * "ProcessId": 37696, + * "Level": "Always", + * "Keywords": "0x0000000000000000", + * "EventName": "table1", + * "ActivityID": null, + * "RelatedActivityID": null, + * "Payload": { + * "SpanId": "0000000000000000", + * "Timestamp": "2021-09-30T22:04:15.066411500Z", + * "TraceId": "00000000000000000000000000000000", + * "_name": "table1", + * "attrib1": 1, + * "attrib2": "value2", + * "body": "This is a debug log body", + * "severityNumber": 5, + * "severityText": "DEBUG" + * } + * } + * + */ + +TEST(ETWLogger, LoggerCheckWithTableNameMappings) +{ + std::string providerName = kGlobalProviderName; // supply unique instrumentation name here + std::map<std::string, std::string> tableNameMappings = {{"name1", "table1"}, {"name2", "table2"}}; + exporter::etw::TelemetryProviderOptions options = {{"enableTableNameMappings", true}, + {"tableNameMappings", tableNameMappings}}; + exporter::etw::LoggerProvider lp{options}; + + auto logger = lp.GetLogger(providerName, "name1"); + + // Log attributes + Properties attribs = {{"attrib1", 1}, {"attrib2", "value2"}}; + + EXPECT_NO_THROW( + logger->Debug("This is a debug log body", opentelemetry::common::MakeAttributes(attribs))); +} + #endif // _WIN32