From 78d488ca44d6a9aed79e63da739b081e20c94207 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Thu, 23 May 2024 05:54:53 -0700 Subject: [PATCH 01/44] [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 Date: Tue, 28 May 2024 03:50:01 +0800 Subject: [PATCH 02/44] [SDK] Fix forceflush may wait for ever (#2584) Co-authored-by: Marc Alff Co-authored-by: Tom Tan --- .../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 is_force_wakeup_background_worker{false}; - std::atomic is_force_flush_pending{false}; - std::atomic is_force_flush_notified{false}; - std::atomic force_flush_timeout_us{0}; std::atomic is_shutdown{false}; + std::atomic force_flush_pending_sequence{0}; + std::atomic force_flush_notified_sequence{0}; + std::atomic 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 &exporter, const std::shared_ptr &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 #include #include +#include #include #include #include @@ -50,9 +51,9 @@ class PeriodicExportingMetricReader : public MetricReader std::thread worker_thread_; /* Synchronization primitives */ - std::atomic is_force_flush_pending_{false}; std::atomic is_force_wakeup_background_worker_{false}; - std::atomic is_force_flush_notified_{false}; + std::atomic force_flush_pending_sequence_{0}; + std::atomic 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 #include +#include #include #include #include @@ -115,20 +116,25 @@ class BatchSpanProcessor : public SpanProcessor /* Important boolean flags to handle the workflow of the processor */ std::atomic is_force_wakeup_background_worker{false}; - std::atomic is_force_flush_pending{false}; - std::atomic is_force_flush_notified{false}; - std::atomic force_flush_timeout_us{0}; std::atomic is_shutdown{false}; + std::atomic force_flush_pending_sequence{0}; + std::atomic force_flush_notified_sequence{0}; + std::atomic 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 &exporter, const std::shared_ptr &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 &&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 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(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> 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 &exporter, const std::shared_ptr &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 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 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(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(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 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 &&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 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(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> 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 &exporter, const std::shared_ptr &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 Date: Tue, 28 May 2024 15:04:49 +0800 Subject: [PATCH 03/44] [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 +#include #include #include "opentelemetry/common/attribute_value.h" @@ -145,6 +146,10 @@ struct LogRecordSetterTrait template struct LogRecordSetterTrait { + static_assert(!std::is_same, ValueType>::value && + !std::is_same, ValueType>::value, + "unique_ptr is not allowed, please use std::move()"); + template ::value || std::is_convertible::value, From 277190d3f2976d423e184032c5a7d26c886481ec Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Tue, 28 May 2024 17:04:00 +0800 Subject: [PATCH 04/44] [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 Date: Wed, 29 May 2024 19:06:10 +0200 Subject: [PATCH 05/44] [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": ["", "private", "", "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 -#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 +#include // IWYU pragma: keep +#include #include #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 #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 #include +#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 -#include -#include -#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 #include +#include #include #include #include @@ -11,7 +13,11 @@ #include #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 +#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 +#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 +#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 +#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 +#include +#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 +#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 #include #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 +#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 +#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 #include -#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 #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 #include +#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 +#include #include #include -#include #include #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 #include +#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 #endif #include -#include #include #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 #endif -#include +#include +#include +#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 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 + #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 + #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 +#include + +#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 - 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 + #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 - 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 +#include +#include + +#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 #include #include +#include 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #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 +#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 +#include + #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 + +#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 +#include +#include + +#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 #include -#include +#include +#include +#include +#include + +#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 +#include + +#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 +#include -#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 #include +#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 +#include +#include +#include +#include +#include + +#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 +#include +#include +#include + +#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 +#include +#include + +#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 +#include +#include +#include +#include +#include +#include + +#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 +#include +#include + +#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 Date: Wed, 29 May 2024 22:01:06 +0200 Subject: [PATCH 06/44] [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> -> attributes(return type of MakeAttributes) */ template - void EmitEvent(nostd::string_view event_name, ArgumentType &&... args) + void EmitEvent(nostd::string_view event_name, ArgumentType &&...args) { nostd::shared_ptr 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> -> attributes(return type of MakeAttributes) */ template - void EmitLogRecord(nostd::unique_ptr &&log_record, ArgumentType &&... args) + void EmitLogRecord(nostd::unique_ptr &&log_record, ArgumentType &&...args) { if (!log_record) { @@ -97,7 +97,7 @@ class Logger * span> -> attributes(return type of MakeAttributes) */ template - void EmitLogRecord(ArgumentType &&... args) + void EmitLogRecord(ArgumentType &&...args) { nostd::unique_ptr log_record = CreateLogRecord(); @@ -120,7 +120,7 @@ class Logger * span> -> attributes(return type of MakeAttributes) */ template - void Trace(ArgumentType &&... args) noexcept + void Trace(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType::type...>::value, @@ -144,7 +144,7 @@ class Logger * span> -> attributes(return type of MakeAttributes) */ template - void Debug(ArgumentType &&... args) noexcept + void Debug(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType::type...>::value, @@ -168,7 +168,7 @@ class Logger * span> -> attributes(return type of MakeAttributes) */ template - void Info(ArgumentType &&... args) noexcept + void Info(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType::type...>::value, @@ -192,7 +192,7 @@ class Logger * span> -> attributes(return type of MakeAttributes) */ template - void Warn(ArgumentType &&... args) noexcept + void Warn(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType::type...>::value, @@ -216,7 +216,7 @@ class Logger * span> -> attributes(return type of MakeAttributes) */ template - void Error(ArgumentType &&... args) noexcept + void Error(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType::type...>::value, @@ -240,7 +240,7 @@ class Logger * span> -> attributes(return type of MakeAttributes) */ template - void Fatal(ArgumentType &&... args) noexcept + void Fatal(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType::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 - &GetEventProvider() noexcept + OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr & + GetEventProvider() noexcept { static nostd::shared_ptr 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 { template - 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).*pmf)(std::forward(args)...)) }; @@ -42,7 +45,7 @@ template <> struct Invoke { template - 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).get().*pmf)(std::forward(args)...)) }; @@ -50,7 +53,7 @@ template <> struct Invoke { template - 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)).*pmf)(std::forward(args)...)) }; @@ -79,20 +82,21 @@ struct Invoke }; template -inline constexpr auto invoke_impl(R T::*f, Arg &&arg, Args &&... args) - OPENTELEMETRY_RETURN(Invoke::value, - (std::is_base_of>::value - ? 0 - : is_reference_wrapper>::value ? 1 : 2)>:: - invoke(f, std::forward(arg), std::forward(args)...)) +inline constexpr auto invoke_impl(R T::*f, Arg &&arg, Args &&...args) OPENTELEMETRY_RETURN( + Invoke::value, + (std::is_base_of>::value ? 0 + : is_reference_wrapper>::value ? 1 + : 2)>::invoke(f, + std::forward(arg), + std::forward(args)...)) #ifdef _MSC_VER # pragma warning(push) # pragma warning(disable : 4100) #endif - template - inline constexpr auto invoke_impl(F &&f, Args &&... args) - OPENTELEMETRY_RETURN(std::forward(f)(std::forward(args)...)) + template + inline constexpr auto invoke_impl(F &&f, Args &&...args) + OPENTELEMETRY_RETURN(std::forward(f)(std::forward(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 inline constexpr Trait trait() { - return IsTriviallyAvailable::value - ? Trait::TriviallyAvailable - : IsAvailable::value ? Trait::Available : Trait::Unavailable; + return IsTriviallyAvailable::value ? Trait::TriviallyAvailable + : IsAvailable::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() &&noexcept { return std::unique_ptr{release()}; } + operator std::unique_ptr() && noexcept { return std::unique_ptr{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 -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 -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 -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(&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 -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(&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 &&v) }; template -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 &&v) } template -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 ::value> * = nullptr, - nostd::enable_if_t::value> * = nullptr> + nostd::enable_if_t::value> * = nullptr> nostd::shared_ptr 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 ptr1{value}; EXPECT_EQ(&*ptr1, value); - EXPECT_EQ( - shared_ptr { new B }->f(), 123); + EXPECT_EQ(shared_ptr { 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 ptr1{value}; EXPECT_EQ(&*ptr1, value); - EXPECT_EQ( - unique_ptr { new B }->f(), 123); + EXPECT_EQ(unique_ptr { 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(result)); + << span_count + << " trace span(s) error: " << static_cast(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(v)).data()}); + PropertyVariant::operator=( + std::string{nostd::string_view(nostd::get(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(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 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 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({0, 2})); const trace::SpanId kParentSpanId(std::array({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 - *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 - *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 +// # include # include 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, 0>> - &GetEmptyAttributes() noexcept +static const opentelemetry::common::KeyValueIterableView< + std::array, 0>> & +GetEmptyAttributes() noexcept { static const std::array, 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 - &GetAttributes() const noexcept = 0; + virtual const std::unordered_map & + 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(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 - &GetAttributes() const noexcept + const std::unordered_map & + 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 - &GetAttributes() const noexcept + const std::unordered_map & + 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 - &GetAttributes() const noexcept + const std::unordered_map & + 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(key)] = value; } -const std::unordered_map - &ReadWriteLogRecord::GetAttributes() const noexcept +const std::unordered_map & +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 Tracer::StartSpan( auto span_context = std::unique_ptr(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(123)}, - {"attribute-key3", opentelemetry::nostd::span(attrubite_value3)}}); + {"attribute-key2", static_cast(123)}, + {"attribute-key3", opentelemetry::nostd::span(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 attributes_get = {{"RequestType", "GET"}}; std::map 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 attributes_get = {{"RequestType", "GET"}}; std::map 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 attributes_get = {{"RequestType", "GET"}}; std::map 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 attributes_get = {{"RequestType", "GET"}}; std::map 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 initTracer( processors.push_back(std::move(processor)); auto resource = Resource::Create({}); auto context = std::make_shared(std::move(processors), resource, - std::unique_ptr(sampler), - std::unique_ptr(id_generator)); + std::unique_ptr(sampler), + std::unique_ptr(id_generator)); return std::shared_ptr(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 Date: Thu, 30 May 2024 13:41:04 -0700 Subject: [PATCH 07/44] [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 Date: Fri, 31 May 2024 20:48:54 +0200 Subject: [PATCH 08/44] [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. - * - *

Notes: -

  • Event names are subject to the same rules as attribute - names. 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.
- */ -static constexpr const char *kEventName = "event.name"; - -/** - * A unique identifier for the Log Record. - * - *

Notes: -

  • 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 Universally Unique Lexicographically -Sortable Identifier (ULID), but other identifiers (e.g. UUID) may be used as needed.
- */ -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. - * - *

Notes: -

- */ -static constexpr const char *kIosState = "ios.state"; - -/** - * This attribute represents the state the application has transitioned into at the occurrence of - the event. - * - *

Notes: -

- */ -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 here. */ -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"; - -/** - * SignalR - * transport type - */ -static constexpr const char *kSignalrTransport = "signalr.transport"; - -/** - * Name of the buffer pool. - * - *

Notes: -

- */ -static constexpr const char *kJvmBufferPoolName = "jvm.buffer.pool.name"; - -/** - * Name of the memory pool. - * - *

Notes: -

- */ -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 either by data - * points with no {@code state} labels, or only 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 either by data - * points with no {@code state} labels, or only 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., Linux Process State - * Codes + * 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 here. + * 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 - * - *

Notes: -

  • This value is intended to be taken from the UA client hints API ({@code - navigator.userAgentData.brands}).
+ * 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 - * - *

Notes: -

  • This value is intended to be taken from the Navigator API {@code - navigator.language}.
+ * The ARN of an ECS cluster. */ -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 - * - *

Notes: -

  • This value is intended to be taken from the UA client hints API ({@code - navigator.userAgentData.mobile}). If unavailable, this attribute SHOULD be left unset.
+ * The Amazon Resource Name (ARN) of an ECS + * container instance. */ -static constexpr const char *kBrowserMobile = "browser.mobile"; +static constexpr const char *kAwsEcsContainerArn = "aws.ecs.container.arn"; /** - * The platform on which the browser is running - * - *

Notes: -

  • This value is intended to be taken from the UA client hints API ({@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 W3C User-Agent Client Hints -specification. Note that some (but not all) of these values can overlap with values in the {@code os.type} and {@code os.name} attributes. However, for consistency, the -values in the {@code browser.platform} attribute should capture the exact value that the user agent -provides.
+ * The launch + * type 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. - * - *

Notes: -

  • 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.
+ * The ARN of a running ECS + * task. */ -static constexpr const char *kClientAddress = "client.address"; +static constexpr const char *kAwsEcsTaskArn = "aws.ecs.task.arn"; /** - * Client port number. - * - *

Notes: -

  • 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.
+ * The family name of the ECS task + * definition 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). * *

Notes: -

  • Availability zones are called "zones" on Alibaba Cloud and Google Cloud.
  • -
+ */ -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. * *

Notes: -

  • The prefix of the service SHOULD match the one specified in {@code cloud.provider}.
  • -
+
  • Multiple log groups must be supported for cases like multi-container applications, where + a single application has sidecar containers, and each write to their own log group.
*/ -static constexpr const char *kCloudPlatform = "cloud.platform"; +static constexpr const char *kAwsLogGroupNames = "aws.log.group.names"; + +/** + * The ARN(s) of the AWS log stream(s). + * + *

Notes: +

+ */ +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). + * + *

Notes: +

  • This may be different from {@code cloud.resource_id} if an alias is involved.
+ */ +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 S3 API operations. + * + *

Notes: +

  • 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}.
+ */ +static constexpr const char *kAwsS3Bucket = "aws.s3.bucket"; + +/** + * The source object (in the form {@code bucket}/{@code key}) for the copy operation. + * + *

Notes: +

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

Notes: +

+ */ +static constexpr const char *kAwsS3Delete = "aws.s3.delete"; + +/** + * The S3 object key the request refers to. Corresponds to the {@code --key} parameter of the S3 API operations. + * + *

Notes: +

+ */ +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. + * + *

Notes: +

+ */ +static constexpr const char *kAwsS3PartNumber = "aws.s3.part_number"; + +/** + * Upload ID that identifies the multipart upload. + * + *

Notes: +

+ */ +static constexpr const char *kAwsS3UploadId = "aws.s3.upload_id"; + +/** + * Array of brand name and version separated by a space + * + *

Notes: +

  • This value is intended to be taken from the UA client hints API ({@code + navigator.userAgentData.brands}).
+ */ +static constexpr const char *kBrowserBrands = "browser.brands"; + +/** + * Preferred language of the user using the browser + * + *

Notes: +

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

Notes: +

  • This value is intended to be taken from the UA client hints API ({@code + navigator.userAgentData.mobile}). If unavailable, this attribute SHOULD be left unset.
+ */ +static constexpr const char *kBrowserMobile = "browser.mobile"; + +/** + * The platform on which the browser is running + * + *

Notes: +

  • This value is intended to be taken from the UA client hints API ({@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 W3C User-Agent Client Hints +specification. Note that some (but not all) of these values can overlap with values in the {@code os.type} and {@code os.name} attributes. However, for consistency, the +values in the {@code browser.platform} attribute should capture the exact value that the user agent +provides.
+ */ +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. + * + *

Notes: +

  • 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.
+ */ +static constexpr const char *kClientAddress = "client.address"; + +/** + * Client port number. + * + *

Notes: +

  • 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.
+ */ +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. + * + *

Notes: +

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

Notes: +

  • The prefix of the service SHOULD match the one specified in {@code cloud.provider}.
  • +
+ */ +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. */ @@ -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. + * + *

Notes: +

  • 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.
+ */ +static constexpr const char *kDbCollectionName = "db.collection.name"; + +/** + * The name of the database, fully qualified within the server address and port. + * + *

Notes: +

  • 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.
+ */ +static constexpr const char *kDbNamespace = "db.namespace"; + +/** + * The name of the operation or command being executed. + * + *

Notes: +

  • It is RECOMMENDED to capture the value as provided by the application without attempting + to do any case normalization.
+ */ +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. + * + *

Notes: +

  • 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.
+ */ +static constexpr const char *kDbSystem = "db.system"; + /** * The consistency level of the query. Based on consistency values from CQL. @@ -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). - * - *

Notes: -

  • This mirrors the db.sql.table attribute but references cassandra rather than sql. It is - not recommended to attempt any client-side parsing of {@code db.statement} just to get this - property, but it should be set if it is provided by the library being instrumented. If the - operation is acting upon an anonymous table, or more than one table, this value MUST NOT be - set.
- */ -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 deployment +environment (aka deployment tier). + * + *

Notes: +

  • {@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:
  • {@code service.name=frontend}, {@code +deployment.environment=production}
  • {@code service.name=frontend}, {@code +deployment.environment=staging}.
  • +
+ */ +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. + * + *

Notes: +

+ */ +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 instance - name 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. * - *

Notes: -

  • If setting a {@code db.mssql.instance_name}, {@code server.port} is no longer required - (but still recommended if non-standard).
+ * @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. * - *

Notes: -

  • In some SQL databases, the database name to be used is called "schema name". In - case there are multiple layers that could be considered for database name (e.g. Oracle instance - name and schema name), the database name to be used is the more specific layer (e.g. Oracle schema - name).
+ * @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 MongoDB command - name such as {@code findAndModify}, or the SQL keyword. + * Deprecated, use {@code db.operation.name} instead. * - *

Notes: -

  • When setting this to an SQL keyword, it is not recommended to attempt any client-side - parsing of {@code db.statement} just to get this property, but it should be set if the operation - name is provided by the library being instrumented. If the SQL statement has an ambiguous - operation, or performs more than one operation, this value may be omitted.
+ * @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 {@code SELECT} command, 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. * - *

Notes: -

  • It is not recommended to attempt any client-side parsing of {@code db.statement} just to - get this property, but it should be set if it is provided by the library being instrumented. If the - operation is acting upon an anonymous table, or more than one table, this value MUST NOT be - set.
+ * @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 deployment -environment (aka deployment tier). + * Deprecated, use {@code db.client.connections.pool.name} instead. * - *

Notes: -

  • {@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:
  • {@code service.name=frontend}, {@code -deployment.environment=production}
  • {@code service.name=frontend}, {@code -deployment.environment=staging}.
  • -
+ * @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. + * + *

Notes: +

+ * + * @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. * *

Notes: -

  • The {@code error.type} SHOULD be predictable and SHOULD have low cardinality. -Instrumentations SHOULD document the list of errors they report.
  • The cardinality of {@code -error.type} within one instrumentation library SHOULD be low. Telemetry consumers that aggregate -data from multiple instrumentation libraries and applications should be prepared for {@code -error.type} to have high cardinality at query time when no additional filters are -applied.
  • If the operation has completed successfully, instrumentations SHOULD NOT set {@code -error.type}.
  • If a specific domain defines its own set of error identifiers (such as HTTP or -gRPC status codes), it's RECOMMENDED to:
  • Use a domain-specific attribute
  • Set {@code -error.type} to capture all errors, regardless of whether they are defined within the domain-specific -set or not.
  • +
    • The {@code error.type} SHOULD be predictable, and SHOULD have low +cardinality.
    • 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.
    • Instrumentations SHOULD document the list of errors they report.
    • 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.
    • If the operation has completed successfully, instrumentations SHOULD NOT set +{@code error.type}.
    • If a specific domain defines its own set of error identifiers (such as +HTTP or gRPC status codes), it's RECOMMENDED to:
    • Use a domain-specific attribute
    • +
    • Set {@code error.type} to capture all errors, regardless of whether they are defined within the +domain-specific set or not.
    */ static constexpr const char *kErrorType = "error.type"; +/** + * Identifies the class / type of event. + * + *

    Notes: +

    • Event names are subject to the same rules as attribute + names. 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.
    + */ +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.
  • 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 example for -recording span exceptions.
  • 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 example +for recording span exceptions.
  • 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.
*/ @@ -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. + * + *

Notes: +

*/ -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. + * + *

Notes: +

*/ -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. - * - *

Notes: -

  • CPUID command returns the vendor ID string in - EBX, EDX and ECX registers. Writing these to memory in this order results in a 12-character - string.
+ * 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. + * + *

Notes: +

  • 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.
*/ -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 Version Attributes. + * 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. - * - *

Notes: -

  • IPv4 Addresses MUST be specified in dotted-quad notation. IPv6 addresses MUST be - specified in the RFC 5952 format.
  • -
+ * 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. * *

Notes: -

+ */ +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. + * + *

Notes: +

  • CPUID command returns the vendor ID string in + EBX, EDX and ECX registers. Writing these to memory in this order results in a 12-character + string.
+ */ +static constexpr const char *kHostCpuVendorId = "host.cpu.vendor.id"; + +/** + * 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 Version Attributes. + */ +static constexpr const char *kHostImageVersion = "host.image.version"; + +/** + * Available IP addresses of the host, excluding loopback interfaces. + * + *

Notes: +

  • IPv4 Addresses MUST be specified in dotted-quad notation. IPv6 addresses MUST be + specified in the RFC 5952 format.
  • +
+ */ +static constexpr const char *kHostIp = "host.ip"; + +/** + * Available MAC addresses of the host, excluding loopback interfaces. + * + *

Notes: +

  • MAC Addresses MUST be represented in IEEE RA hexadecimal form: as hyphen-separated octets in uppercase hexadecimal form from most to least significant.
@@ -1635,6 +1989,61 @@ one. */ static constexpr const char *kHttpRoute = "http.route"; +/** + * Name of the buffer pool. + * + *

Notes: +

+ */ +static constexpr const char *kJvmBufferPoolName = "jvm.buffer.pool.name"; + +/** + * Name of the garbage collector action. + * + *

Notes: +

+ */ +static constexpr const char *kJvmGcAction = "jvm.gc.action"; + +/** + * Name of the garbage collector. + * + *

Notes: +

+ */ +static constexpr const char *kJvmGcName = "jvm.gc.name"; + +/** + * Name of the memory pool. + * + *

Notes: +

+ */ +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. + * + *

Notes: +

  • 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 Universally Unique Lexicographically +Sortable Identifier (ULID), but other identifiers (e.g. UUID) may be used as needed.
+ */ +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. + * + *

Notes: +

  • This can refer to both the compressed or uncompressed body size. If both sizes are known, +the uncompressed body size should be used.
*/ -static constexpr const char *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. + * + *

Notes: +

  • This can refer to both the compressed or uncompressed size. If both sizes are known, the +uncompressed size should be used.
*/ -static constexpr const char *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. + * + *

Notes: +

  • If a custom value is used, it MUST be of low cardinality.
+ */ +static constexpr const char *kMessagingOperationType = "messaging.operation.type"; + +/** + * The messaging system as identified by the client instrumentation. + * + *

Notes: +

  • 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.
+ */ +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. - * - *

Notes: -

  • This can refer to both the compressed or uncompressed body size. If both sizes are known, -the uncompressed body size should be used.
+ * 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. - * - *

Notes: -

  • This can refer to both the compressed or uncompressed size. If both sizes are known, the -uncompressed size should be used.
+ * 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. - * - *

Notes: -

  • If a custom value is used, it MUST be of low cardinality.
- */ -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. */ static constexpr const char *kOciManifestDigest = "oci.manifest.digest"; +/** + * Parent-child Reference type + * + *

Notes: +

  • The causal relationship between a child Span and a parent Span.
+ */ +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 {@code service.name} 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. + * + *

Notes: +

  • 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.
+ */ +static constexpr const char *kProcessVpid = "process.vpid"; + +/** + * The CPU state of the process. + */ +static constexpr const char *kProcessCpuState = "process.cpu.state"; + /** * The error codes 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. + * + *

Notes: +

  • This way we guarantee that the values will be consistent between different + implementations.
+ */ +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"; *

Notes:

  • 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 {@code process.executable.name}, e.g. {@code unknown_service:bash}. - If {@code process.executable.name} is not available, the value MUST be set to {@code - unknown_service}.
+ href="process.md">{@code process.executable.name}, e.g. {@code unknown_service:bash}. If {@code + process.executable.name} is not available, the value MUST be set to {@code unknown_service}. + */ 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"; + +/** + * SignalR + * transport type + */ +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., Linux Process State + * Codes + */ +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 absolute path reference. + */ +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). - * - *

Notes: -

  • This may be different from {@code cloud.resource_id} if an alias is involved.
- */ -static constexpr const char *kAwsLambdaInvokedArn = "aws.lambda.invoked_arn"; - -/** - * Parent-child Reference type - * - *

Notes: -

  • The causal relationship between a child Span and a parent Span.
- */ -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 S3 API operations. - * - *

Notes: -

  • 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}.
- */ -static constexpr const char *kAwsS3Bucket = "aws.s3.bucket"; - -/** - * The source object (in the form {@code bucket}/{@code key}) for the copy operation. - * - *

Notes: -

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

Notes: -

- */ -static constexpr const char *kAwsS3Delete = "aws.s3.delete"; - -/** - * The S3 object key the request refers to. Corresponds to the {@code --key} parameter of the S3 API operations. - * - *

Notes: -

- */ -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. - * - *

Notes: -

- */ -static constexpr const char *kAwsS3PartNumber = "aws.s3.part_number"; - -/** - * Upload ID that identifies the multipart upload. - * - *

Notes: -

- */ -static constexpr const char *kAwsS3UploadId = "aws.s3.upload_id"; - -/** - * The GraphQL document being executed. - * - *

Notes: -

  • The value may be sanitized to exclude sensitive information.
- */ -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. - * - *

Notes: -

  • This way we guarantee that the values will be consistent between different - implementations.
- */ -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. - * - *

Notes: -

  • Event names are subject to the same rules as attribute - names. 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.
- */ -static constexpr const char *kEventName = "event.name"; - -/** - * A unique identifier for the Log Record. - * - *

Notes: -

  • 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 Universally Unique Lexicographically -Sortable Identifier (ULID), but other identifiers (e.g. UUID) may be used as needed.
- */ -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 here. */ -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"; /** - * SignalR - * transport type + * 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. - * - *

Notes: -

+ * 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. - * - *

Notes: -

+ * 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 either by data - * points with no {@code state} labels, or only 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 either by data - * points with no {@code state} labels, or only 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., Linux Process State - * Codes + * 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 here. + * 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 ECS cluster. */ -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 ECS + * container instance. */ -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 launch + * type 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 ECS + * task. */ -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 ECS task + * definition 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). + * + *

Notes: +

*/ -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. + * + *

Notes: +

  • Multiple log groups must be supported for cases like multi-container applications, where + a single application has sidecar containers, and each write to their own log group.
*/ -static constexpr const char *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). + * + *

Notes: +

*/ -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). + * + *

Notes: +

  • This may be different from {@code cloud.resource_id} if an alias is involved.
*/ -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 S3 API operations. + * + *

Notes: +

  • 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}.
*/ -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. + * + *

Notes: +

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

Notes: +

*/ -static constexpr const char *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 S3 API operations. + * + *

Notes: +

*/ -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. + * + *

Notes: +

*/ -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. + * + *

Notes: +

*/ -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. */ @@ -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. + * + *

Notes: +

  • 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.
+ */ +static constexpr const char *kDbCollectionName = "db.collection.name"; + +/** + * The name of the database, fully qualified within the server address and port. + * + *

Notes: +

  • 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.
+ */ +static constexpr const char *kDbNamespace = "db.namespace"; + +/** + * The name of the operation or command being executed. + * + *

Notes: +

  • It is RECOMMENDED to capture the value as provided by the application without attempting + to do any case normalization.
+ */ +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. + * + *

Notes: +

  • 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.
+ */ +static constexpr const char *kDbSystem = "db.system"; + /** * The consistency level of the query. Based on consistency values from CQL. @@ -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). - * - *

Notes: -

  • This mirrors the db.sql.table attribute but references cassandra rather than sql. It is - not recommended to attempt any client-side parsing of {@code db.statement} just to get this - property, but it should be set if it is provided by the library being instrumented. If the - operation is acting upon an anonymous table, or more than one table, this value MUST NOT be - set.
- */ -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 deployment +environment (aka deployment tier). + * + *

Notes: +

  • {@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:
  • {@code service.name=frontend}, {@code +deployment.environment=production}
  • {@code service.name=frontend}, {@code +deployment.environment=staging}.
  • +
+ */ +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. + * + *

Notes: +

+ */ +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 instance - name 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. * - *

Notes: -

  • If setting a {@code db.mssql.instance_name}, {@code server.port} is no longer required - (but still recommended if non-standard).
+ * @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. * - *

Notes: -

  • In some SQL databases, the database name to be used is called "schema name". In - case there are multiple layers that could be considered for database name (e.g. Oracle instance - name and schema name), the database name to be used is the more specific layer (e.g. Oracle schema - name).
+ * @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 MongoDB command - name such as {@code findAndModify}, or the SQL keyword. + * Deprecated, use {@code db.operation.name} instead. * - *

Notes: -

  • When setting this to an SQL keyword, it is not recommended to attempt any client-side - parsing of {@code db.statement} just to get this property, but it should be set if the operation - name is provided by the library being instrumented. If the SQL statement has an ambiguous - operation, or performs more than one operation, this value may be omitted.
+ * @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 {@code SELECT} command, 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. * - *

Notes: -

  • It is not recommended to attempt any client-side parsing of {@code db.statement} just to - get this property, but it should be set if it is provided by the library being instrumented. If the - operation is acting upon an anonymous table, or more than one table, this value MUST NOT be - set.
+ * @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 deployment -environment (aka deployment tier). + * Deprecated, use {@code db.client.connections.pool.name} instead. * - *

Notes: -

  • {@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:
  • {@code service.name=frontend}, {@code -deployment.environment=production}
  • {@code service.name=frontend}, {@code -deployment.environment=staging}.
  • -
+ * @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. + * + *

Notes: +

+ * + * @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. * *

Notes: -

  • The {@code error.type} SHOULD be predictable and SHOULD have low cardinality. -Instrumentations SHOULD document the list of errors they report.
  • The cardinality of {@code -error.type} within one instrumentation library SHOULD be low. Telemetry consumers that aggregate -data from multiple instrumentation libraries and applications should be prepared for {@code -error.type} to have high cardinality at query time when no additional filters are -applied.
  • If the operation has completed successfully, instrumentations SHOULD NOT set {@code -error.type}.
  • If a specific domain defines its own set of error identifiers (such as HTTP or -gRPC status codes), it's RECOMMENDED to:
  • Use a domain-specific attribute
  • Set {@code -error.type} to capture all errors, regardless of whether they are defined within the domain-specific -set or not.
  • +
    • The {@code error.type} SHOULD be predictable, and SHOULD have low +cardinality.
    • 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.
    • Instrumentations SHOULD document the list of errors they report.
    • 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.
    • If the operation has completed successfully, instrumentations SHOULD NOT set +{@code error.type}.
    • If a specific domain defines its own set of error identifiers (such as +HTTP or gRPC status codes), it's RECOMMENDED to:
    • Use a domain-specific attribute
    • +
    • Set {@code error.type} to capture all errors, regardless of whether they are defined within the +domain-specific set or not.
    */ static constexpr const char *kErrorType = "error.type"; +/** + * Identifies the class / type of event. + * + *

    Notes: +

    • Event names are subject to the same rules as attribute + names. 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.
    + */ +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.
  • 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 example for -recording span exceptions.
  • 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 example +for recording span exceptions.
  • 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.
*/ @@ -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. + * + *

Notes: +

+ */ +static constexpr const char *kGenAiCompletion = "gen_ai.completion"; + +/** + * The full prompt sent to an LLM. + * + *

Notes: +

+ */ +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. + * + *

Notes: +

  • 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.
+ */ +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. + * + *

Notes: +

  • The value may be sanitized to exclude sensitive information.
+ */ +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. */ static constexpr const char *kHttpRoute = "http.route"; +/** + * Name of the buffer pool. + * + *

Notes: +

+ */ +static constexpr const char *kJvmBufferPoolName = "jvm.buffer.pool.name"; + +/** + * Name of the garbage collector action. + * + *

Notes: +

+ */ +static constexpr const char *kJvmGcAction = "jvm.gc.action"; + +/** + * Name of the garbage collector. + * + *

Notes: +

+ */ +static constexpr const char *kJvmGcName = "jvm.gc.name"; + +/** + * Name of the memory pool. + * + *

Notes: +

+ */ +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. + * + *

Notes: +

  • 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 Universally Unique Lexicographically +Sortable Identifier (ULID), but other identifiers (e.g. UUID) may be used as needed.
+ */ +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 = * *

Notes:

  • 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.
- */ -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 - * - *

Notes: -

  • 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.
- */ -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. - * - *

Notes: -

  • If the key type is not string, it's string representation has to be supplied for the - attribute. If the key has no unambiguous, canonical string form, don't include its value.
  • -
+ 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. */ -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 + * + *

Notes: +

  • 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.
+ */ +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. * *

Notes:

  • If a custom value is used, it MUST be of low cardinality.
*/ -static constexpr const char *kMessagingOperation = "messaging.operation"; +static constexpr const char *kMessagingOperationType = "messaging.operation.type"; + +/** + * The messaging system as identified by the client instrumentation. + * + *

Notes: +

  • 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.
+ */ +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. + * + *

Notes: +

  • If the key type is not string, it's string representation has to be supplied for the + attribute. If the key has no unambiguous, canonical string form, don't include its value.
  • +
+ */ +static constexpr const char *kMessagingKafkaMessageKey = "messaging.kafka.message.key"; + +/** + * The offset of a record in the corresponding Kafka partition. + */ +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. */ static constexpr const char *kOciManifestDigest = "oci.manifest.digest"; +/** + * Parent-child Reference type + * + *

Notes: +

  • The causal relationship between a child Span and a parent Span.
+ */ +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 {@code service.name} of the remote service. + * SHOULD be equal to the actual {@code service.name} resource attribute of the remote service if + * any. + */ +static constexpr const char *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. + * + *

Notes: +

  • 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.
+ */ +static constexpr const char *kProcessVpid = "process.vpid"; + +/** + * The CPU state of the process. + */ +static constexpr const char *kProcessCpuState = "process.cpu.state"; + /** * The error codes 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. + * + *

Notes: +

  • This way we guarantee that the values will be consistent between different + implementations.
+ */ +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"; *

Notes:

  • 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 {@code process.executable.name}, e.g. {@code unknown_service:bash}. - If {@code process.executable.name} is not available, the value MUST be set to {@code - unknown_service}.
+ href="process.md">{@code process.executable.name}, e.g. {@code unknown_service:bash}. If {@code + process.executable.name} is not available, the value MUST be set to {@code unknown_service}. + */ 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"; + +/** + * SignalR + * transport type + */ +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., Linux Process State + * Codes */ -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 absolute path reference. + */ +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 * - *

Notes: -

  • Example 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}
- */ -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 ECS cluster. - */ -static constexpr const char *kAwsEcsClusterArn = "aws.ecs.cluster.arn"; - -/** - * The Amazon Resource Name (ARN) of an ECS - * container instance. - */ -static constexpr const char *kAwsEcsContainerArn = "aws.ecs.container.arn"; - -/** - * The launch - * type for an ECS task. - */ -static constexpr const char *kAwsEcsLaunchtype = "aws.ecs.launchtype"; - -/** - * The ARN of a running ECS - * task. - */ -static constexpr const char *kAwsEcsTaskArn = "aws.ecs.task.arn"; - -/** - * The family name of the ECS task - * definition 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). - * - *

Notes: -

- */ -static constexpr const char *kAwsLogGroupArns = "aws.log.group.arns"; - -/** - * The name(s) of the AWS log group(s) an application is writing to. - * - *

Notes: -

  • Multiple log groups must be supported for cases like multi-container applications, where - a single application has sidecar containers, and each write to their own log group.
- */ -static constexpr const char *kAwsLogGroupNames = "aws.log.group.names"; - -/** - * The ARN(s) of the AWS log stream(s). - * - *

Notes: -

- */ -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 + *

Notes: +

  • Example 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}
+ */ +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 Date: Mon, 3 Jun 2024 22:46:08 +0200 Subject: [PATCH 09/44] [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 tracer_provider; + tracer_provider = opentelemetry::sdk::trace::TracerProviderFactory::Create(...); +``` + +should be adjusted to: + +```cpp + std::shared_ptr 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{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_thistracer().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 provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + std::shared_ptr provider = + opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); +#else + std::shared_ptr 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 api_provider = provider; + trace_api::Provider::SetTracerProvider(api_provider); } void CleanupTracer() @@ -54,11 +62,18 @@ void InitLogger() auto exporter = std::unique_ptr(new logs_exporter::OStreamLogRecordExporter); auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); - std::shared_ptr provider( - logs_sdk::LoggerProviderFactory::Create(std::move(processor))); + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + std::shared_ptr provider( + opentelemetry::sdk::logs::LoggerProviderFactory::Create(std::move(processor))); +#else + std::shared_ptr 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 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(u_provider.get()); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + auto u_provider = opentelemetry::sdk::metrics::MeterProviderFactory::Create(); + auto *provider = static_cast(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 api_provider(std::move(u_provider)); +#else + std::shared_ptr api_provider(std::move(provider)); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - std::shared_ptr 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 #include #include @@ -43,27 +40,40 @@ namespace { opentelemetry::exporter::otlp::OtlpFileExporterOptions opts; opentelemetry::exporter::otlp::OtlpFileLogRecordExporterOptions log_opts; + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY +std::shared_ptr tracer_provider; +std::shared_ptr logger_provider; +#else +std::shared_ptr tracer_provider; +std::shared_ptr 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 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 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 provider = - trace::Provider::GetTracerProvider(); - if (provider) + if (tracer_provider) { - static_cast(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast(tracer_provider.get())->ForceFlush(); +#else + tracer_provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + tracer_provider.reset(); std::shared_ptr 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 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 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 provider = - logs::Provider::GetLoggerProvider(); - if (provider) + if (logger_provider) { - static_cast(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast(logger_provider.get())->ForceFlush(); +#else + logger_provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + logger_provider.reset(); nostd::shared_ptr 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 #include #include @@ -28,27 +25,38 @@ namespace otlp = opentelemetry::exporter::otlp; namespace { opentelemetry::exporter::otlp::OtlpFileExporterOptions opts; + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY +std::shared_ptr provider; +#else +std::shared_ptr 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 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 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 provider = - trace::Provider::GetTracerProvider(); if (provider) { - static_cast(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast(provider.get())->ForceFlush(); +#else + provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + provider.reset(); std::shared_ptr 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 #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 tracer_provider; +std::shared_ptr logger_provider; +#else +std::shared_ptr tracer_provider; +std::shared_ptr 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 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 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 provider = - trace::Provider::GetTracerProvider(); - if (provider) + if (tracer_provider) { - static_cast(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast(tracer_provider.get())->ForceFlush(); +#else + tracer_provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + tracer_provider.reset(); std::shared_ptr 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 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 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 provider = - logs::Provider::GetLoggerProvider(); - if (provider) + if (logger_provider) { - static_cast(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast(logger_provider.get())->ForceFlush(); +#else + logger_provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + logger_provider.reset(); nostd::shared_ptr 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 provider; +#else +std::shared_ptr 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 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 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 provider = - trace::Provider::GetTracerProvider(); if (provider) { - static_cast(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast(provider.get())->ForceFlush(); +#else + provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + provider.reset(); std::shared_ptr 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 #include @@ -40,6 +37,13 @@ namespace { opentelemetry::exporter::otlp::OtlpHttpExporterOptions trace_opts; + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY +std::shared_ptr tracer_provider; +#else +std::shared_ptr 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 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 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 provider = - trace::Provider::GetTracerProvider(); - if (provider) + if (tracer_provider) { - static_cast(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast(tracer_provider.get())->ForceFlush(); +#else + tracer_provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + tracer_provider.reset(); std::shared_ptr none; trace::Provider::SetTracerProvider(none); } opentelemetry::exporter::otlp::OtlpHttpLogRecordExporterOptions logger_opts; + +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY +std::shared_ptr logger_provider; +#else +std::shared_ptr 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 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 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 provider = - logs::Provider::GetLoggerProvider(); - if (provider) + if (logger_provider) { - static_cast(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast(logger_provider.get())->ForceFlush(); +#else + logger_provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + logger_provider.reset(); std::shared_ptr 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 #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 provider; +#else +std::shared_ptr 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 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 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 provider = - trace::Provider::GetTracerProvider(); if (provider) { - static_cast(provider.get())->ForceFlush(); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + static_cast(provider.get())->ForceFlush(); +#else + provider->ForceFlush(); +#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } + provider.reset(); std::shared_ptr 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 provider = - trace_sdk::TracerProviderFactory::Create(std::move(processor)); + opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); +#else + std::shared_ptr 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 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( new sdk::trace::BatchSpanProcessor(std::move(exporter), processor_opts)); - auto provider = nostd::shared_ptr( + auto provider = nostd::shared_ptr( 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(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 trace_stub_interface( trace_mock_stub); +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY auto trace_provider = opentelemetry::nostd::shared_ptr( 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::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( new opentelemetry::trace::NoopTracerProvider())); - trace_provider = opentelemetry::nostd::shared_ptr(); + trace_provider = opentelemetry::nostd::shared_ptr(); } } // 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( new sdk::trace::BatchSpanProcessor(std::move(exporter), processor_opts)); - auto provider = nostd::shared_ptr( + auto provider = nostd::shared_ptr( 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(provider.get())->ForceFlush(); + provider->ForceFlush(); } # ifdef ENABLE_ASYNC_EXPORT @@ -226,7 +226,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto processor = std::unique_ptr( new sdk::trace::BatchSpanProcessor(std::move(exporter), processor_opts)); - auto provider = nostd::shared_ptr( + auto provider = nostd::shared_ptr( 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(provider.get())->ForceFlush(); + provider->ForceFlush(); } # endif @@ -321,7 +321,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto processor = std::unique_ptr( new sdk::trace::BatchSpanProcessor(std::move(exporter), processor_opts)); - auto provider = nostd::shared_ptr( + auto provider = nostd::shared_ptr( 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(provider.get())->ForceFlush(); + provider->ForceFlush(); } # ifdef ENABLE_ASYNC_EXPORT @@ -402,7 +402,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto processor = std::unique_ptr( new sdk::trace::BatchSpanProcessor(std::move(exporter), processor_opts)); - auto provider = nostd::shared_ptr( + auto provider = nostd::shared_ptr( 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(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 + +#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 Create(); +# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ + +#else + static std::unique_ptr 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 #include +#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 Create( + std::unique_ptr &&processor); + + OPENTELEMETRY_DEPRECATED + static std::unique_ptr Create( + std::unique_ptr &&processor, + const opentelemetry::sdk::resource::Resource &resource); + + OPENTELEMETRY_DEPRECATED + static std::unique_ptr Create( + std::vector> &&processors); + + OPENTELEMETRY_DEPRECATED + static std::unique_ptr Create( + std::vector> &&processors, + const opentelemetry::sdk::resource::Resource &resource); + + OPENTELEMETRY_DEPRECATED + static std::unique_ptr Create( + std::unique_ptr context); + +# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ + +#else + /** * Create a LoggerProvider. */ - static std::unique_ptr Create( + static std::unique_ptr Create( std::unique_ptr &&processor); /** * Create a LoggerProvider. */ - static std::unique_ptr Create( + static std::unique_ptr Create( std::unique_ptr &&processor, const opentelemetry::sdk::resource::Resource &resource); /** * Create a LoggerProvider. */ - static std::unique_ptr Create( + static std::unique_ptr Create( std::vector> &&processors); /** * Create a LoggerProvider. */ - static std::unique_ptr Create( + static std::unique_ptr Create( std::vector> &&processors, const opentelemetry::sdk::resource::Resource &resource); /** * Create a LoggerProvider. */ - static std::unique_ptr Create( + static std::unique_ptr Create( std::unique_ptr 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 + +#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 - 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 - 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 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 Create( + std::unique_ptr views); - We need to decide whether to return: - - (1) std::unique_ptr - - (2) std::unique_ptr - from a Create() method. + OPENTELEMETRY_DEPRECATED + static std::unique_ptr Create( + std::unique_ptr 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 to add all readers. + OPENTELEMETRY_DEPRECATED + static std::unique_ptr Create( + std::unique_ptr 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 Create(); + static std::unique_ptr Create(); - static std::unique_ptr Create( + static std::unique_ptr Create( std::unique_ptr views); - static std::unique_ptr Create( + static std::unique_ptr Create( std::unique_ptr views, const opentelemetry::sdk::resource::Resource &resource); - static std::unique_ptr Create( + static std::unique_ptr Create( std::unique_ptr 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 + void ForceFlush(std::chrono::duration timeout) noexcept + { + this->ForceFlushWithMicroseconds(static_cast( + std::chrono::duration_cast(timeout).count())); + } + + void ForceFlushWithMicroseconds(uint64_t timeout) noexcept; + + /** + * ForceFlush any buffered spans and stop reporting spans. + * @param timeout to complete the flush + */ + template + void Close(std::chrono::duration timeout) noexcept + { + this->CloseWithMicroseconds(static_cast( + std::chrono::duration_cast(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 Create( std::unique_ptr processor); + OPENTELEMETRY_DEPRECATED static std::unique_ptr Create( std::unique_ptr processor, const opentelemetry::sdk::resource::Resource &resource); + OPENTELEMETRY_DEPRECATED static std::unique_ptr Create( std::unique_ptr processor, const opentelemetry::sdk::resource::Resource &resource, std::unique_ptr sampler); + OPENTELEMETRY_DEPRECATED static std::unique_ptr Create( std::unique_ptr 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 Create( std::vector> &&processors); + OPENTELEMETRY_DEPRECATED static std::unique_ptr Create( std::vector> &&processors, const opentelemetry::sdk::resource::Resource &resource); + OPENTELEMETRY_DEPRECATED static std::unique_ptr Create( std::vector> &&processors, const opentelemetry::sdk::resource::Resource &resource, std::unique_ptr sampler); + OPENTELEMETRY_DEPRECATED static std::unique_ptr Create( std::vector> &&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 Create( std::unique_ptr context); + +# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ + +#else + + /* Serie of builders with a single processor. */ + + static std::unique_ptr Create( + std::unique_ptr processor); + + static std::unique_ptr Create( + std::unique_ptr processor, + const opentelemetry::sdk::resource::Resource &resource); + + static std::unique_ptr Create( + std::unique_ptr processor, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr sampler); + + static std::unique_ptr Create( + std::unique_ptr processor, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr sampler, + std::unique_ptr id_generator); + + /* Serie of builders with a vector of processor. */ + + static std::unique_ptr Create( + std::vector> &&processors); + + static std::unique_ptr Create( + std::vector> &&processors, + const opentelemetry::sdk::resource::Resource &resource); + + static std::unique_ptr Create( + std::vector> &&processors, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr sampler); + + static std::unique_ptr Create( + std::vector> &&processors, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr sampler, + std::unique_ptr id_generator); + + /* Create with a tracer context. */ + + static std::unique_ptr Create( + std::unique_ptr 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 EventLoggerProviderFactory::Create() { return std::unique_ptr(new EventLoggerProvider()); } +#else + +std::unique_ptr EventLoggerProviderFactory::Create() +{ + return std::unique_ptr(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 + #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 LoggerProviderFactory::Create( std::unique_ptr &&processor) { @@ -52,6 +56,50 @@ std::unique_ptr LoggerProviderFactory::Crea return provider; } +#else + +std::unique_ptr LoggerProviderFactory::Create( + std::unique_ptr &&processor) +{ + auto resource = opentelemetry::sdk::resource::Resource::Create({}); + return Create(std::move(processor), resource); +} + +std::unique_ptr LoggerProviderFactory::Create( + std::unique_ptr &&processor, + const opentelemetry::sdk::resource::Resource &resource) +{ + std::unique_ptr provider( + new LoggerProvider(std::move(processor), resource)); + return provider; +} + +std::unique_ptr LoggerProviderFactory::Create( + std::vector> &&processors) +{ + auto resource = opentelemetry::sdk::resource::Resource::Create({}); + return Create(std::move(processors), resource); +} + +std::unique_ptr LoggerProviderFactory::Create( + std::vector> &&processors, + const opentelemetry::sdk::resource::Resource &resource) +{ + std::unique_ptr provider( + new LoggerProvider(std::move(processors), resource)); + return provider; +} + +std::unique_ptr LoggerProviderFactory::Create( + std::unique_ptr context) +{ + std::unique_ptr 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 #include -#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 MeterProviderFactory::Create() { auto views = ViewRegistryFactory::Create(); @@ -36,7 +38,7 @@ std::unique_ptr MeterProviderFactory::Cre const opentelemetry::sdk::resource::Resource &resource) { std::unique_ptr 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 MeterProviderFactory::Cre std::unique_ptr context) { std::unique_ptr provider( - new metrics_sdk::MeterProvider(std::move(context))); + new opentelemetry::sdk::metrics::MeterProvider(std::move(context))); + return provider; +} + +#else + +std::unique_ptr MeterProviderFactory::Create() +{ + auto views = ViewRegistryFactory::Create(); + return Create(std::move(views)); +} + +std::unique_ptr MeterProviderFactory::Create( + std::unique_ptr views) +{ + auto resource = opentelemetry::sdk::resource::Resource::Create({}); + return Create(std::move(views), resource); +} + +std::unique_ptr MeterProviderFactory::Create( + std::unique_ptr views, + const opentelemetry::sdk::resource::Resource &resource) +{ + std::unique_ptr provider( + new opentelemetry::sdk::metrics::MeterProvider(std::move(views), resource)); return provider; } +std::unique_ptr MeterProviderFactory::Create( + std::unique_ptr context) +{ + std::unique_ptr 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 TracerProviderFactory::Create( +#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY + +std::unique_ptr TracerProviderFactory::Create( std::unique_ptr processor) { auto resource = opentelemetry::sdk::resource::Resource::Create({}); return Create(std::move(processor), resource); } -std::unique_ptr TracerProviderFactory::Create( +std::unique_ptr TracerProviderFactory::Create( std::unique_ptr processor, const opentelemetry::sdk::resource::Resource &resource) { @@ -57,8 +54,9 @@ std::unique_ptr TracerProviderFactory::Cre std::unique_ptr sampler, std::unique_ptr id_generator) { - std::unique_ptr provider(new trace_sdk::TracerProvider( - std::move(processor), resource, std::move(sampler), std::move(id_generator))); + std::unique_ptr 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 TracerProviderFactory::Cre std::unique_ptr sampler, std::unique_ptr id_generator) { - std::unique_ptr provider(new trace_sdk::TracerProvider( - std::move(processors), resource, std::move(sampler), std::move(id_generator))); + std::unique_ptr provider( + new opentelemetry::sdk::trace::TracerProvider(std::move(processors), resource, + std::move(sampler), std::move(id_generator))); + return provider; +} + +std::unique_ptr TracerProviderFactory::Create( + std::unique_ptr context) +{ + std::unique_ptr provider( + new opentelemetry::sdk::trace::TracerProvider(std::move(context))); + return provider; +} + +#else + +std::unique_ptr TracerProviderFactory::Create( + std::unique_ptr processor) +{ + auto resource = opentelemetry::sdk::resource::Resource::Create({}); + return Create(std::move(processor), resource); +} + +std::unique_ptr TracerProviderFactory::Create( + std::unique_ptr processor, + const opentelemetry::sdk::resource::Resource &resource) +{ + auto sampler = AlwaysOnSamplerFactory::Create(); + return Create(std::move(processor), resource, std::move(sampler)); +} + +std::unique_ptr TracerProviderFactory::Create( + std::unique_ptr processor, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr sampler) +{ + auto id_generator = RandomIdGeneratorFactory::Create(); + return Create(std::move(processor), resource, std::move(sampler), std::move(id_generator)); +} + +std::unique_ptr TracerProviderFactory::Create( + std::unique_ptr processor, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr sampler, + std::unique_ptr id_generator) +{ + std::unique_ptr provider( + new opentelemetry::sdk::trace::TracerProvider(std::move(processor), resource, + std::move(sampler), std::move(id_generator))); + return provider; +} + +std::unique_ptr TracerProviderFactory::Create( + std::vector> &&processors) +{ + auto resource = opentelemetry::sdk::resource::Resource::Create({}); + return Create(std::move(processors), resource); +} + +std::unique_ptr TracerProviderFactory::Create( + std::vector> &&processors, + const opentelemetry::sdk::resource::Resource &resource) +{ + auto sampler = AlwaysOnSamplerFactory::Create(); + return Create(std::move(processors), resource, std::move(sampler)); +} + +std::unique_ptr TracerProviderFactory::Create( + std::vector> &&processors, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr sampler) +{ + auto id_generator = RandomIdGeneratorFactory::Create(); + return Create(std::move(processors), resource, std::move(sampler), std::move(id_generator)); +} + +std::unique_ptr TracerProviderFactory::Create( + std::vector> &&processors, + const opentelemetry::sdk::resource::Resource &resource, + std::unique_ptr sampler, + std::unique_ptr id_generator) +{ + std::unique_ptr provider( + new opentelemetry::sdk::trace::TracerProvider(std::move(processors), resource, + std::move(sampler), std::move(id_generator))); return provider; } -std::unique_ptr TracerProviderFactory::Create( +std::unique_ptr TracerProviderFactory::Create( std::unique_ptr context) { - std::unique_ptr provider( - new trace_sdk::TracerProvider(std::move(context))); + std::unique_ptr 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 Date: Wed, 5 Jun 2024 10:52:19 -0700 Subject: [PATCH 10/44] [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>; +using TelemetryProviderOptions = std::map< + std::string, + nostd::variant>>; /** * @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 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 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{ - 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 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 From bf8fa53ac13e513eb50845e5e22fcbce94587094 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Thu, 6 Jun 2024 08:47:45 -0700 Subject: [PATCH 11/44] [BUILD] Remove benchmark overlay for vcpkg (#2695) --- ci/ports/benchmark/portfile.cmake | 36 ----------------------------- ci/ports/benchmark/vcpkg.json | 19 --------------- ci/setup_windows_ci_environment.ps1 | 4 ++-- 3 files changed, 2 insertions(+), 57 deletions(-) delete mode 100644 ci/ports/benchmark/portfile.cmake delete mode 100644 ci/ports/benchmark/vcpkg.json diff --git a/ci/ports/benchmark/portfile.cmake b/ci/ports/benchmark/portfile.cmake deleted file mode 100644 index efb5a2fce7..0000000000 --- a/ci/ports/benchmark/portfile.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") - message(FATAL_ERROR "${PORT} does not currently support UWP") -endif() - -# Make sure vs2019 compiled binaries are compat with vs2017 -vcpkg_check_linkage(ONLY_STATIC_LIBRARY) - -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO google/benchmark - REF v1.7.1 - SHA512 396af1c1d3eaa2b78c6d23b1472f6088db85a294056ae1c2366dc5c0becdc8f141ba8fc3a235033324ab0a41c2298f5d242ef09b9b6f69d9877de6bcb2062efd - HEAD_REF master -) - -vcpkg_cmake_configure( - SOURCE_PATH ${SOURCE_PATH} - OPTIONS - -DBENCHMARK_ENABLE_TESTING=OFF -) - -vcpkg_cmake_install() -vcpkg_copy_pdbs() - -vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/benchmark) - -vcpkg_fixup_pkgconfig() - -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") - -# Handle copyright -file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/ci/ports/benchmark/vcpkg.json b/ci/ports/benchmark/vcpkg.json deleted file mode 100644 index 605f5af9f0..0000000000 --- a/ci/ports/benchmark/vcpkg.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$comment": "https://github.com/google/benchmark/issues/661 describes the missing UWP support upstream", - "name": "benchmark", - "version-semver": "1.7.1", - "description": "A library to support the benchmarking of functions, similar to unit-tests.", - "homepage": "https://github.com/google/benchmark", - "license": "Apache-2.0", - "supports": "!uwp", - "dependencies": [ - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ] - } \ No newline at end of file diff --git a/ci/setup_windows_ci_environment.ps1 b/ci/setup_windows_ci_environment.ps1 index 6d003bd0ef..7ad57c3464 100755 --- a/ci/setup_windows_ci_environment.ps1 +++ b/ci/setup_windows_ci_environment.ps1 @@ -10,8 +10,8 @@ $VCPKG_DIR = (Get-Item -Path ".\").FullName ./bootstrap-vcpkg.bat ./vcpkg integrate install -# Patched Google Benchmark can be shared between vs2017 and vs2019 compilers -./vcpkg "--vcpkg-root=$VCPKG_DIR" install --overlay-ports="$PSScriptRoot\ports" benchmark:x64-windows +# Google Benchmark +./vcpkg "--vcpkg-root=$VCPKG_DIR" install benchmark:x64-windows # Google Test ./vcpkg "--vcpkg-root=$VCPKG_DIR" install gtest:x64-windows From 1d8a7b5b256cfa0010681ab9be1d918a85133c0a Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Thu, 6 Jun 2024 09:24:23 -0700 Subject: [PATCH 12/44] [BUILD] Remove the incorrect set of CMAKE_MSVC_RUNTIME_LIBRARY for vcpkg (#2696) --- CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d01d7054ef..0304beec50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -343,12 +343,6 @@ if(MSVC) # __cplusplus flag is not supported by Visual Studio 2015 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") endif() - # When using vcpkg, all targets build with the same runtime - if(VCPKG_TOOLCHAIN) - set(CMAKE_MSVC_RUNTIME_LIBRARY - "MultiThreaded$<$:Debug>$<$:DLL>" - CACHE STRING "") - endif() endif() # include GNUInstallDirs before include cmake/opentelemetry-proto.cmake because From 436a981d81c1094c66b7e647b5380f23c099efed Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Thu, 6 Jun 2024 19:34:47 +0200 Subject: [PATCH 13/44] CMakeLists.txt: Enable CMAKE_MSVC_RUNTIME_LIBRARY support (#2652) The documentation for CMAKE_MSVC_RUNTIME_LIBRARY states [1]: > This variable has effect only when policy CMP0091 is set to NEW prior to > the first project() or enable_language() command that enables a language > using a compiler targeting the MSVC ABI. so the current usage of CMAKE_MSVC_RUNTIME_LIBRARY for vcpkg does not work at all. Let's fix that by setting policy 91 to new if present. [1]: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html Co-authored-by: Tom Tan --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0304beec50..2e61faed35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,11 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12") cmake_policy(SET CMP0074 NEW) endif() +# Prefer CMAKE_MSVC_RUNTIME_LIBRARY if possible +if(POLICY CMP0091) + cmake_policy(SET CMP0091 NEW) +endif() + project(opentelemetry-cpp) # Mark variables as used so cmake doesn't complain about them From 3efd3ce8f4d9b2753751208c717da47c652ea27e Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Sat, 8 Jun 2024 20:38:00 +0800 Subject: [PATCH 14/44] [EXPORTER] OTLP file: use `fopen`, `fwrite`, `fflush` and `fclose` which are thread-safe. (#2675) * Use `fopen`, `fwrite`, `fflush` and `fclose` which are thread-safety. * Add some macros to help to find problems. Add `OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND` , `OPENTELEMETRY_SANITIZER_NO_MEMORY` , `OPENTELEMETRY_SANITIZER_NO_THREAD`, `OPENTELEMETRY_SANITIZER_NO_ADDRESS`, `OPENTELEMETRY_HAVE_BUILTIN`, `OPENTELEMETRY_HAVE_FEATURE`, `OPENTELEMETRY_HAVE_ATTRIBUTE`, `OPENTELEMETRY_HAVE_CPP_ATTRIBUTE` * Append EOL before call Export of backend --------- Co-authored-by: Marc Alff --- api/include/opentelemetry/common/macros.h | 171 ++++++++++++++++++ api/include/opentelemetry/nostd/string_view.h | 3 +- exporters/otlp/src/otlp_file_client.cc | 73 +++++--- 3 files changed, 218 insertions(+), 29 deletions(-) diff --git a/api/include/opentelemetry/common/macros.h b/api/include/opentelemetry/common/macros.h index db1ca54a86..b4a270084d 100644 --- a/api/include/opentelemetry/common/macros.h +++ b/api/include/opentelemetry/common/macros.h @@ -3,6 +3,73 @@ #pragma once +/* + OPENTELEMETRY_HAVE_BUILTIN&OPENTELEMETRY_HAVE_FEATURE + + Checks whether the compiler supports a Clang Feature Checking Macro, and if + so, checks whether it supports the provided builtin function "x" where x + is one of the functions noted in + https://clang.llvm.org/docs/LanguageExtensions.html + + Note: Use this macro to avoid an extra level of #ifdef __has_builtin check. + http://releases.llvm.org/3.3/tools/clang/docs/LanguageExtensions.html +*/ +#if !defined(OPENTELEMETRY_HAVE_BUILTIN) +# ifdef __has_builtin +# define OPENTELEMETRY_HAVE_BUILTIN(x) __has_builtin(x) +# else +# define OPENTELEMETRY_HAVE_BUILTIN(x) 0 +# endif +#endif + +#if !defined(OPENTELEMETRY_HAVE_FEATURE) +# ifdef __has_feature +# define OPENTELEMETRY_HAVE_FEATURE(f) __has_feature(f) +# else +# define OPENTELEMETRY_HAVE_FEATURE(f) 0 +# endif +#endif + +/* + has feature + + OPENTELEMETRY_HAVE_ATTRIBUTE + + A function-like feature checking macro that is a wrapper around + `__has_attribute`, which is defined by GCC 5+ and Clang and evaluates to a + nonzero constant integer if the attribute is supported or 0 if not. + + It evaluates to zero if `__has_attribute` is not defined by the compiler. + + GCC: https://gcc.gnu.org/gcc-5/changes.html + Clang: https://clang.llvm.org/docs/LanguageExtensions.html +*/ +#if !defined(OPENTELEMETRY_HAVE_ATTRIBUTE) +# ifdef __has_attribute +# define OPENTELEMETRY_HAVE_ATTRIBUTE(x) __has_attribute(x) +# else +# define OPENTELEMETRY_HAVE_ATTRIBUTE(x) 0 +# endif +#endif + +/* + OPENTELEMETRY_HAVE_CPP_ATTRIBUTE + + A function-like feature checking macro that accepts C++11 style attributes. + It's a wrapper around `__has_cpp_attribute`, defined by ISO C++ SD-6 + (https://en.cppreference.com/w/cpp/experimental/feature_test). If we don't + find `__has_cpp_attribute`, will evaluate to 0. +*/ +#if !defined(OPENTELEMETRY_HAVE_CPP_ATTRIBUTE) +# if defined(__cplusplus) && defined(__has_cpp_attribute) +// NOTE: requiring __cplusplus above should not be necessary, but +// works around https://bugs.llvm.org/show_bug.cgi?id=23435. +# define OPENTELEMETRY_HAVE_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) +# else +# define OPENTELEMETRY_HAVE_CPP_ATTRIBUTE(x) 0 +# endif +#endif + /* Expected usage pattern: @@ -319,3 +386,107 @@ point. # define OPENTELEMETRY_EXPORT #endif + +/* + OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND indicates that a resource owned by a function + parameter or implicit object parameter is retained by the return value of the + annotated function (or, for a parameter of a constructor, in the value of the + constructed object). This attribute causes warnings to be produced if a + temporary object does not live long enough. + + When applied to a reference parameter, the referenced object is assumed to be + retained by the return value of the function. When applied to a non-reference + parameter (for example, a pointer or a class type), all temporaries + referenced by the parameter are assumed to be retained by the return value of + the function. + + See also the upstream documentation: + https://clang.llvm.org/docs/AttributeReference.html#lifetimebound +*/ +#ifndef OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND +# if OPENTELEMETRY_HAVE_CPP_ATTRIBUTE(clang::lifetimebound) +# define OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND [[clang::lifetimebound]] +# elif OPENTELEMETRY_HAVE_ATTRIBUTE(lifetimebound) +# define OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND __attribute__((lifetimebound)) +# else +# define OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND +# endif +#endif + +// OPENTELEMETRY_HAVE_MEMORY_SANITIZER +// +// MemorySanitizer (MSan) is a detector of uninitialized reads. It consists of +// a compiler instrumentation module and a run-time library. +#ifndef OPENTELEMETRY_HAVE_MEMORY_SANITIZER +# if !defined(__native_client__) && OPENTELEMETRY_HAVE_FEATURE(memory_sanitizer) +# define OPENTELEMETRY_HAVE_MEMORY_SANITIZER 1 +# else +# define OPENTELEMETRY_HAVE_MEMORY_SANITIZER 0 +# endif +#endif + +#if OPENTELEMETRY_HAVE_MEMORY_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize_memory) +# define OPENTELEMETRY_SANITIZER_NO_MEMORY \ + __attribute__((no_sanitize_memory)) // __attribute__((no_sanitize("memory"))) +#else +# define OPENTELEMETRY_SANITIZER_NO_MEMORY +#endif + +// OPENTELEMETRY_HAVE_THREAD_SANITIZER +// +// ThreadSanitizer (TSan) is a fast data race detector. +#ifndef OPENTELEMETRY_HAVE_THREAD_SANITIZER +# if defined(__SANITIZE_THREAD__) +# define OPENTELEMETRY_HAVE_THREAD_SANITIZER 1 +# elif OPENTELEMETRY_HAVE_FEATURE(thread_sanitizer) +# define OPENTELEMETRY_HAVE_THREAD_SANITIZER 1 +# else +# define OPENTELEMETRY_HAVE_THREAD_SANITIZER 0 +# endif +#endif + +#if OPENTELEMETRY_HAVE_THREAD_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize_thread) +# define OPENTELEMETRY_SANITIZER_NO_THREAD \ + __attribute__((no_sanitize_thread)) // __attribute__((no_sanitize("thread"))) +#else +# define OPENTELEMETRY_SANITIZER_NO_THREAD +#endif + +// OPENTELEMETRY_HAVE_ADDRESS_SANITIZER +// +// AddressSanitizer (ASan) is a fast memory error detector. +#ifndef OPENTELEMETRY_HAVE_ADDRESS_SANITIZER +# if defined(__SANITIZE_ADDRESS__) +# define OPENTELEMETRY_HAVE_ADDRESS_SANITIZER 1 +# elif OPENTELEMETRY_HAVE_FEATURE(address_sanitizer) +# define OPENTELEMETRY_HAVE_ADDRESS_SANITIZER 1 +# else +# define OPENTELEMETRY_HAVE_ADDRESS_SANITIZER 0 +# endif +#endif + +// OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER +// +// Hardware-Assisted AddressSanitizer (or HWASAN) is even faster than asan +// memory error detector which can use CPU features like ARM TBI, Intel LAM or +// AMD UAI. +#ifndef OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER +# if defined(__SANITIZE_HWADDRESS__) +# define OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER 1 +# elif OPENTELEMETRY_HAVE_FEATURE(hwaddress_sanitizer) +# define OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER 1 +# else +# define OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER 0 +# endif +#endif + +#if OPENTELEMETRY_HAVE_ADDRESS_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize_address) +# define OPENTELEMETRY_SANITIZER_NO_ADDRESS \ + __attribute__((no_sanitize_address)) // __attribute__((no_sanitize("address"))) +#elif OPENTELEMETRY_HAVE_ADDRESS_SANITIZER && defined(_MSC_VER) && _MSC_VER >= 1928 +# define OPENTELEMETRY_SANITIZER_NO_ADDRESS __declspec(no_sanitize_address) +#elif OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize) +# define OPENTELEMETRY_SANITIZER_NO_ADDRESS __attribute__((no_sanitize("hwaddress"))) +#else +# define OPENTELEMETRY_SANITIZER_NO_ADDRESS +#endif diff --git a/api/include/opentelemetry/nostd/string_view.h b/api/include/opentelemetry/nostd/string_view.h index 9f9fb42180..5ee86dce23 100644 --- a/api/include/opentelemetry/nostd/string_view.h +++ b/api/include/opentelemetry/nostd/string_view.h @@ -18,6 +18,7 @@ # include # include +# include "opentelemetry/common/macros.h" # include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -43,7 +44,7 @@ class string_view string_view(const char *str) noexcept : length_(std::strlen(str)), data_(str) {} - string_view(const std::basic_string &str) noexcept + string_view(const std::basic_string &str OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND) noexcept : length_(str.length()), data_(str.c_str()) {} diff --git a/exporters/otlp/src/otlp_file_client.cc b/exporters/otlp/src/otlp_file_client.cc index 2549c369d1..9678b22476 100644 --- a/exporters/otlp/src/otlp_file_client.cc +++ b/exporters/otlp/src/otlp_file_client.cc @@ -22,6 +22,7 @@ #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // clang-format on +#include "opentelemetry/common/macros.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/common/base64.h" @@ -30,6 +31,7 @@ #include #include +#include #include #include #include @@ -106,6 +108,14 @@ snprintf(buffer, static_cast(bufsz), fmt, ##args) #endif +#if (defined(_MSC_VER) && _MSC_VER >= 1600) || \ + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) +# define OTLP_FILE_OPEN(f, path, mode) fopen_s(&f, path, mode) +#else +# include +# define OTLP_FILE_OPEN(f, path, mode) f = fopen(path, mode) +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { @@ -978,6 +988,16 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender } } + // Written size is not required to be precise, we can just ignore tsan report here. + OPENTELEMETRY_SANITIZER_NO_THREAD void MaybeRotateLog(std::size_t data_size) + { + if (file_->written_size > 0 && file_->written_size + data_size > options_.file_size) + { + RotateLog(); + } + CheckUpdate(); + } + void Export(nostd::string_view data, std::size_t record_count) override { if (!is_initialized_.load(std::memory_order_acquire)) @@ -985,20 +1005,15 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender Initialize(); } - if (file_->written_size > 0 && file_->written_size + data.size() > options_.file_size) - { - RotateLog(); - } - CheckUpdate(); + MaybeRotateLog(data.size()); - std::shared_ptr out = OpenLogFile(true); + std::shared_ptr out = OpenLogFile(true); if (!out) { return; } - out->write(data.data(), data.size()); - out->write("\n", 1); + fwrite(data.data(), 1, data.size(), out.get()); { std::lock_guard lock_guard{file_->file_lock}; @@ -1006,7 +1021,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender file_->record_count += record_count; // Pipe file size always returns 0, we ignore the size limit of it. - auto written_size = out->tellp(); + auto written_size = ftell(out.get()); if (written_size >= 0) { file_->written_size = static_cast(written_size); @@ -1018,7 +1033,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender { file_->left_flush_record_count = options_.flush_count; - out->flush(); + fflush(out.get()); file_->flushed_record_count.store(file_->record_count.load(std::memory_order_acquire), std::memory_order_release); @@ -1030,7 +1045,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender } } - // Maybe need spawn a background thread to flush ostream + // Maybe need spawn a background thread to flush FILE SpawnBackgroundWorkThread(); } @@ -1180,11 +1195,11 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender OpenLogFile(false); } - std::shared_ptr OpenLogFile(bool destroy_content) + std::shared_ptr OpenLogFile(bool destroy_content) { std::lock_guard lock_guard{file_->file_lock}; - if (file_->current_file && file_->current_file->good()) + if (file_->current_file) { return file_->current_file; } @@ -1198,11 +1213,11 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender { OTEL_INTERNAL_LOG_ERROR("[OTLP FILE Client] Generate file path from pattern " << options_.file_pattern << " failed"); - return std::shared_ptr(); + return nullptr; } file_path[file_path_size] = 0; - std::shared_ptr of = std::make_shared(); + std::shared_ptr of = std::make_shared(); std::string directory_name = FileSystemUtil::DirName(file_path); if (!directory_name.empty()) @@ -1231,20 +1246,21 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender if (destroy_content && FileSystemUtil::IsExist(file_path)) { - std::fstream trunc_file; - trunc_file.open(file_path, std::ios::binary | std::ios::out | std::ios::trunc); - if (!trunc_file.is_open()) + FILE *trunc_file = nullptr; + OTLP_FILE_OPEN(trunc_file, file_path, "wb"); + if (nullptr == trunc_file) { OTEL_INTERNAL_LOG_ERROR("[OTLP FILE Client] Open " << static_cast(file_path) << " failed with pattern: " << options_.file_pattern); - return std::shared_ptr(); + return nullptr; } - trunc_file.close(); + fclose(trunc_file); } - of->open(file_path, std::ios::binary | std::ios::out | std::ios::app); - if (!of->is_open()) + std::FILE *new_file = nullptr; + OTLP_FILE_OPEN(new_file, file_path, "ab"); + if (nullptr == new_file) { std::string hint; if (!directory_name.empty()) @@ -1255,11 +1271,12 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender OTEL_INTERNAL_LOG_ERROR("[OTLP FILE Client] Open " << static_cast(file_path) << " failed with pattern: " << options_.file_pattern << hint); - return std::shared_ptr(); + return nullptr; } + of = std::shared_ptr(new_file, fclose); - of->seekp(0, std::ios_base::end); - file_->written_size = static_cast(of->tellp()); + fseek(of.get(), 0, SEEK_END); + file_->written_size = static_cast(ftell(of.get())); file_->current_file = of; file_->last_checkpoint = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); @@ -1447,7 +1464,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender if (concurrency_file->current_file) { - concurrency_file->current_file->flush(); + fflush(concurrency_file->current_file.get()); } concurrency_file->flushed_record_count.store(current_record_count, @@ -1479,7 +1496,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender std::size_t rotate_index; std::size_t written_size; std::size_t left_flush_record_count; - std::shared_ptr current_file; + std::shared_ptr current_file; std::mutex file_lock; std::time_t last_checkpoint; std::string file_path; @@ -1509,7 +1526,6 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileOstreamBackend : public OtlpFileAppende void Export(nostd::string_view data, std::size_t /*record_count*/) override { os_.get().write(data.data(), data.size()); - os_.get().write("\n", 1); } bool ForceFlush(std::chrono::microseconds /*timeout*/) noexcept override @@ -1577,6 +1593,7 @@ opentelemetry::sdk::common::ExportResult OtlpFileClient::Export( if (backend_) { + post_body_json += '\n'; backend_->Export(post_body_json, record_count); return ::opentelemetry::sdk::common::ExportResult::kSuccess; } From 508910529b394e75c72ece18daf14b07955852c6 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Tue, 11 Jun 2024 12:47:23 -0700 Subject: [PATCH 15/44] [bazel] Bump version and deps (#2679) --------- Co-authored-by: Marc Alff Co-authored-by: Lalit Kumar Bhasin Co-authored-by: Tom Tan --- .bazelrc | 6 ++++ .bazelversion | 2 +- .github/workflows/ci.yml | 21 ------------ api/BUILD | 30 ++++------------- api/test/singleton/BUILD | 72 +++++++++++++++++++++++----------------- bazel/repository.bzl | 63 +++++++++++------------------------ ci/do_ci.ps1 | 4 ++- ci/do_ci.sh | 6 +--- docs/dependencies.md | 6 ++-- 9 files changed, 82 insertions(+), 128 deletions(-) diff --git a/.bazelrc b/.bazelrc index 01a3b4c7bb..fc170b0e8b 100644 --- a/.bazelrc +++ b/.bazelrc @@ -4,12 +4,18 @@ # bazel configurations for running tests under sanitizers. # Based on https://github.com/bazelment/trunk/blob/master/tools/bazel.rc +# TODO: Remove once support is added, avoid MODULE.bazel creation for now +common --enable_bzlmod=false + # Enable automatic configs based on platform common --enable_platform_specific_config # Needed by gRPC to build on some platforms. build --copt -DGRPC_BAZEL_BUILD +# Workaround abseil libraries missing symbols +build:windows --dynamic_mode=off + # Set minimum supported C++ version build:macos --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 build:linux --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 diff --git a/.bazelversion b/.bazelversion index ade65226e0..21c8c7b46b 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -5.4.1 +7.1.1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcdf4f0ed8..5834ca2fd4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -558,27 +558,6 @@ jobs: - name: run tests run: ./ci/do_ci.sh bazel.with_async_export.test - bazel_with_abseil: - name: Bazel with external abseil - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - name: Mount Bazel Cache - uses: actions/cache@v4 - env: - cache-name: bazel_cache - with: - path: /home/runner/.cache/bazel - key: bazel_test - - name: setup - run: | - sudo ./ci/setup_ci_environment.sh - sudo ./ci/install_bazelisk.sh - - name: run tests - run: ./ci/do_ci.sh bazel.with_abseil - bazel_valgrind: name: Bazel valgrind runs-on: ubuntu-latest diff --git a/api/BUILD b/api/BUILD index fa4da45a66..2eca1de986 100644 --- a/api/BUILD +++ b/api/BUILD @@ -1,15 +1,10 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag") +load("@bazel_skylib//rules:common_settings.bzl", "string_flag") package(default_visibility = ["//visibility:public"]) -bool_flag( - name = "with_abseil", - build_setting_default = False, -) - CPP_STDLIBS = [ "none", "best", @@ -28,10 +23,7 @@ string_flag( cc_library( name = "api", hdrs = glob(["include/**/*.h"]), - defines = select({ - ":with_external_abseil": ["HAVE_ABSEIL"], - "//conditions:default": [], - }) + select({ + defines = ["HAVE_ABSEIL"] + select({ ":set_cxx_stdlib_none": [], ### automatic selection ":set_cxx_stdlib_best": ["OPENTELEMETRY_STL_VERSION=(__cplusplus/100)"], @@ -46,19 +38,11 @@ cc_library( }), strip_include_prefix = "include", tags = ["api"], - deps = select({ - ":with_external_abseil": [ - "@com_google_absl//absl/base", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/types:variant", - ], - "//conditions:default": [], - }), -) - -config_setting( - name = "with_external_abseil", - flag_values = {":with_abseil": "true"}, + deps = [ + "@com_google_absl//absl/base", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/types:variant", + ], ) [config_setting( diff --git a/api/test/singleton/BUILD b/api/test/singleton/BUILD index cdd1ed7cf4..eae9f6b8c0 100644 --- a/api/test/singleton/BUILD +++ b/api/test/singleton/BUILD @@ -1,17 +1,11 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -DEFAULT_WIN_COPTS = [ -] - # gcc and clang, assumed to be used on this platform DEFAULT_NOWIN_COPTS = [ "-fvisibility=default", ] -HIDDEN_WIN_COPTS = [ -] - # gcc and clang, assumed to be used on this platform HIDDEN_NOWIN_COPTS = [ "-fvisibility=hidden", @@ -26,6 +20,10 @@ cc_library( "component_a.h", ], linkstatic = True, + target_compatible_with = select({ + "//bazel:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), deps = [ "//api", ], @@ -40,6 +38,10 @@ cc_library( "component_b.h", ], linkstatic = True, + target_compatible_with = select({ + "//bazel:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), deps = [ "//api", ], @@ -53,11 +55,12 @@ cc_library( hdrs = [ "component_c.h", ], - copts = select({ - "//bazel:windows": DEFAULT_WIN_COPTS, - "//conditions:default": DEFAULT_NOWIN_COPTS, - }), + copts = DEFAULT_NOWIN_COPTS, linkstatic = False, + target_compatible_with = select({ + "//bazel:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), deps = [ "//api", ], @@ -71,11 +74,12 @@ cc_library( hdrs = [ "component_d.h", ], - copts = select({ - "//bazel:windows": HIDDEN_WIN_COPTS, - "//conditions:default": HIDDEN_NOWIN_COPTS, - }), + copts = HIDDEN_NOWIN_COPTS, linkstatic = False, + target_compatible_with = select({ + "//bazel:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), deps = [ "//api", ], @@ -89,11 +93,12 @@ cc_library( hdrs = [ "component_e.h", ], - copts = select({ - "//bazel:windows": DEFAULT_WIN_COPTS, - "//conditions:default": DEFAULT_NOWIN_COPTS, - }), + copts = DEFAULT_NOWIN_COPTS, linkstatic = False, + target_compatible_with = select({ + "//bazel:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), deps = [ "//api", ], @@ -107,11 +112,12 @@ cc_library( hdrs = [ "component_f.h", ], - copts = select({ - "//bazel:windows": HIDDEN_WIN_COPTS, - "//conditions:default": HIDDEN_NOWIN_COPTS, - }), + copts = HIDDEN_NOWIN_COPTS, linkstatic = False, + target_compatible_with = select({ + "//bazel:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), deps = [ "//api", ], @@ -123,11 +129,12 @@ cc_binary( srcs = [ "component_g.cc", ], - copts = select({ - "//bazel:windows": DEFAULT_WIN_COPTS, - "//conditions:default": DEFAULT_NOWIN_COPTS, - }), + copts = DEFAULT_NOWIN_COPTS, linkshared = True, + target_compatible_with = select({ + "//bazel:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), deps = [ "//api", ], @@ -139,11 +146,12 @@ cc_binary( srcs = [ "component_h.cc", ], - copts = select({ - "//bazel:windows": HIDDEN_WIN_COPTS, - "//conditions:default": HIDDEN_NOWIN_COPTS, - }), + copts = HIDDEN_NOWIN_COPTS, linkshared = True, + target_compatible_with = select({ + "//bazel:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), deps = [ "//api", ], @@ -176,6 +184,10 @@ cc_test( "api", "test", ], + target_compatible_with = select({ + "//bazel:windows": ["@platforms//:incompatible"], + "//conditions:default": [], + }), deps = [ "component_a", "component_b", diff --git a/bazel/repository.bzl b/bazel/repository.bzl index 9ba8ad5388..bac1e45b34 100644 --- a/bazel/repository.bzl +++ b/bazel/repository.bzl @@ -1,17 +1,8 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") - -_ALL_CONTENT = """ -filegroup( - name = "all_srcs", - srcs = glob(["**"]), - visibility = ["//visibility:public"], -) -""" +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # # MAINTAINER @@ -55,54 +46,40 @@ def opentelemetry_cpp_deps(): # Load abseil dependency(optional) maybe( - # - # Important note: - # - # The bazel build uses abseil-cpp-20230802.2 here, - # while CMake uses more recent versions. - # - # bazel with abseil-cpp-20240116.2 : build failures in CI - # bazel with abseil-cpp-20240116.1 : build failures in CI - # - # TODO: Fix issue #2619 - # http_archive, name = "com_google_absl", - sha256 = "7c11539617af1f332f0854a6fb21e296a1b29c27d03f23c7b49d4adefcd102cc", - strip_prefix = "abseil-cpp-20230802.2", + sha256 = "733726b8c3a6d39a4120d7e45ea8b41a434cdacde401cba500f14236c49b39dc", + strip_prefix = "abseil-cpp-20240116.2", urls = [ - "https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.2.tar.gz", + "https://github.com/abseil/abseil-cpp/archive/refs/tags/20240116.2.tar.gz", ], ) - # Load gRPC dependency + # gRPC transitively depends on apple_support and rules_apple at older + # versions. Bazel 7.x requires newer versions of these rules. By loading + # them before grpc, these newer versions are preferrred. maybe( http_archive, - name = "com_github_grpc_grpc_legacy", - sha256 = "024118069912358e60722a2b7e507e9c3b51eeaeee06e2dd9d95d9c16f6639ec", - strip_prefix = "grpc-1.39.1", - urls = [ - "https://github.com/grpc/grpc/archive/v1.39.1.tar.gz", - ], + name = "build_bazel_apple_support", + sha256 = "c4bb2b7367c484382300aee75be598b92f847896fb31bbd22f3a2346adf66a80", + url = "https://github.com/bazelbuild/apple_support/releases/download/1.15.1/apple_support.1.15.1.tar.gz", ) maybe( http_archive, - name = "com_github_grpc_grpc_latest11", - sha256 = "e266aa0d9d9cddb876484a370b94f468248594a96ca0b6f87c21f969db2b8c5b", - strip_prefix = "grpc-1.46.4", - urls = [ - "https://github.com/grpc/grpc/archive/v1.46.4.tar.gz", - ], + name = "build_bazel_rules_apple", + sha256 = "b4df908ec14868369021182ab191dbd1f40830c9b300650d5dc389e0b9266c8d", + url = "https://github.com/bazelbuild/rules_apple/releases/download/3.5.1/rules_apple.3.5.1.tar.gz", ) + # Load gRPC dependency maybe( http_archive, name = "com_github_grpc_grpc", - sha256 = "cdeb805385fba23242bf87073e68d590c446751e09089f26e5e0b3f655b0f089", - strip_prefix = "grpc-1.49.2", + sha256 = "f40bde4ce2f31760f65dc49a2f50876f59077026494e67dccf23992548b1b04f", + strip_prefix = "grpc-1.62.0", urls = [ - "https://github.com/grpc/grpc/archive/v1.49.2.tar.gz", + "https://github.com/grpc/grpc/archive/refs/tags/v1.62.0.tar.gz", ], ) @@ -144,10 +121,10 @@ def opentelemetry_cpp_deps(): maybe( http_archive, name = "platforms", - sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca", + sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", ], ) diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index f6a12e3877..62e174854e 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -10,6 +10,8 @@ $nproc = (Get-ComputerInfo).CsNumberOfLogicalProcessors $SRC_DIR = (Get-Item -Path ".\").FullName +# Workaround https://github.com/bazelbuild/bazel/issues/18683 +$BAZEL_STARTUP_OPTIONS = "--output_base=C:\Out" $BAZEL_OPTIONS = "--copt=-DENABLE_ASYNC_EXPORT" $BAZEL_TEST_OPTIONS = "$BAZEL_OPTIONS --test_output=errors" @@ -27,7 +29,7 @@ $VCPKG_DIR = Join-Path "$SRC_DIR" "tools" "vcpkg" switch ($action) { "bazel.build" { - bazel build $BAZEL_OPTIONS --action_env=VCPKG_DIR=$VCPKG_DIR --deleted_packages=opentracing-shim -- //... + bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS --action_env=VCPKG_DIR=$VCPKG_DIR --deleted_packages=opentracing-shim -- //... $exit = $LASTEXITCODE if ($exit -ne 0) { exit $exit diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 2d089ef21e..7855ed4175 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -425,10 +425,6 @@ elif [[ "$1" == "cmake.install.test" ]]; then make -j $(nproc) sudo make install exit 0 -elif [[ "$1" == "bazel.with_abseil" ]]; then - bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS_ASYNC --//api:with_abseil=true //... - bazel $BAZEL_STARTUP_OPTIONS test $BAZEL_TEST_OPTIONS_ASYNC --//api:with_abseil=true //... - exit 0 elif [[ "$1" == "cmake.test_example_plugin" ]]; then # Build the plugin cd "${BUILD_DIR}" @@ -507,7 +503,7 @@ elif [[ "$1" == "bazel.tsan" ]]; then exit 0 elif [[ "$1" == "bazel.valgrind" ]]; then bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS_ASYNC //... - bazel $BAZEL_STARTUP_OPTIONS test --run_under="/usr/bin/valgrind --leak-check=full --error-exitcode=1 --suppressions=\"${SRC_DIR}/ci/valgrind-suppressions\"" $BAZEL_TEST_OPTIONS_ASYNC //... + bazel $BAZEL_STARTUP_OPTIONS test --run_under="/usr/bin/valgrind --leak-check=full --error-exitcode=1 --errors-for-leak-kinds=definite --suppressions=\"${SRC_DIR}/ci/valgrind-suppressions\"" $BAZEL_TEST_OPTIONS_ASYNC //... exit 0 elif [[ "$1" == "bazel.e2e" ]]; then cd examples/e2e diff --git a/docs/dependencies.md b/docs/dependencies.md index dd495f4888..6375ec79e2 100644 --- a/docs/dependencies.md +++ b/docs/dependencies.md @@ -35,10 +35,8 @@ Both these dependencies are listed here: `OPENTELEMETRY_OPTION_USE_STD_SPAN=0` to indicate nostd:span will always not be a alias for std::span. - Uses Abseil C++ Library for `absl::variant` as default `nostd::variant` if - `WITH_ABSEIL` cmake option or - `--@io_opentelemetry_cpp//api:with_abseil=true` (aka - `--//api:with_abseil=true`) bazel option is enabled. License: `Apache - License 2.0` + `WITH_ABSEIL` cmake option (always enabled with bazel) + License: `Apache License 2.0` - [OTLP/HTTP+JSON](/exporters/otlp) exporter: From 025f42f1eacc3b656cedb8465ec2f2574fcc9e51 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Fri, 14 Jun 2024 13:43:37 -0700 Subject: [PATCH 16/44] [BUILD] Add support for bzlmod (#2608) * Add support for bzlmod This adds support for bzlmod, which is bazel's new dependency resolution system. Theoretically we could now remove the previous dependency management configuration which required flattening all the dependencies, but I left it here for now for users using old versions of bazel. --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ .gitignore | 1 + MODULE.bazel | 25 +++++++++++++++++++++++++ WORKSPACE.bzlmod | 4 ++++ ci/do_ci.sh | 4 ++++ 5 files changed, 55 insertions(+) create mode 100644 MODULE.bazel create mode 100644 WORKSPACE.bzlmod diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5834ca2fd4..26c692953c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -537,6 +537,27 @@ jobs: - name: run tests run: ./ci/do_ci.sh bazel.test + bazel_no_bzlmod_test: + name: Bazel without bzlmod + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - name: Mount Bazel Cache + uses: actions/cache@v4 + env: + cache-name: bazel_cache + with: + path: /home/runner/.cache/bazel + key: bazel_test + - name: setup + run: | + sudo ./ci/setup_ci_environment.sh + sudo ./ci/install_bazelisk.sh + - name: run tests + run: ./ci/do_ci.sh bazel.no_bzlmod.test + bazel_test_async: name: Bazel with async export runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index dc26aa2f82..cafefd636d 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ *.app # Bazel files +MODULE.bazel.lock /bazel-* # Mac diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000000..7b84c2b719 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,25 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +module( + name = "opentelemetry-cpp", + version = "0", + compatibility_level = 0, + repo_name = "io_opentelemetry_cpp", +) + +bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "com_google_absl") +bazel_dep(name = "bazel_skylib", version = "1.5.0") +bazel_dep(name = "curl", version = "8.4.0") +bazel_dep(name = "grpc", version = "1.62.1", repo_name = "com_github_grpc_grpc") +bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "github_nlohmann_json") +bazel_dep(name = "opentelemetry-proto", version = "1.3.1", repo_name = "com_github_opentelemetry_proto") +bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing") +bazel_dep(name = "platforms", version = "0.0.8") +bazel_dep(name = "prometheus-cpp", version = "1.2.4", repo_name = "com_github_jupp0r_prometheus_cpp") +bazel_dep(name = "protobuf", version = "26.0", repo_name = "com_google_protobuf") +bazel_dep(name = "rules_proto", version = "5.3.0-21.7") +bazel_dep(name = "zlib", version = "1.3.1.bcr.1") + +bazel_dep(name = "google_benchmark", version = "1.8.3", dev_dependency = True, repo_name = "com_github_google_benchmark") +bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True, repo_name = "com_google_googletest") diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod new file mode 100644 index 0000000000..0db1b04622 --- /dev/null +++ b/WORKSPACE.bzlmod @@ -0,0 +1,4 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +# Disables the default WORKSPACE when using bzlmod diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 7855ed4175..efdac9e87e 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -459,6 +459,10 @@ EOF make load_plugin_example examples/plugin/load/load_plugin_example ${PLUGIN_DIR}/libexample_plugin.so /dev/null exit 0 +elif [[ "$1" == "bazel.no_bzlmod.test" ]]; then + bazel $BAZEL_STARTUP_OPTIONS build --enable_bzlmod=false $BAZEL_OPTIONS //... + bazel $BAZEL_STARTUP_OPTIONS test --enable_bzlmod=false $BAZEL_TEST_OPTIONS //... + exit 0 elif [[ "$1" == "bazel.test" ]]; then bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS //... bazel $BAZEL_STARTUP_OPTIONS test $BAZEL_TEST_OPTIONS //... From fad93f0727a44df5d2f88be2ab11e4e533ce349c Mon Sep 17 00:00:00 2001 From: zhanglei <357733652@qq.com> Date: Sat, 15 Jun 2024 19:50:04 +0800 Subject: [PATCH 17/44] [BUILD] Fix Import Abseil-cpp (#2701) --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e61faed35..3d7831b2a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -377,7 +377,9 @@ if(WITH_PROMETHEUS) endif() if(WITH_ABSEIL) - find_package(absl CONFIG REQUIRED) + if(NOT TARGET absl::strings) + find_package(absl CONFIG REQUIRED) + endif() endif() if(WITH_OTLP_GRPC From f97dc061bc96cd090f8af8493db4467494147da9 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Sat, 15 Jun 2024 17:10:05 +0200 Subject: [PATCH 18/44] [Code health] include-what-you-use cleanup (#2692) --- .github/workflows/iwyu.yml | 1 + CHANGELOG.md | 3 + api/include/opentelemetry/nostd/type_traits.h | 2 +- api/include/opentelemetry/nostd/utility.h | 4 +- .../plugin/detail/dynamic_load_unix.h | 3 +- .../opentelemetry/plugin/dynamic_load.h | 4 +- api/include/opentelemetry/plugin/factory.h | 2 +- api/include/opentelemetry/plugin/tracer.h | 2 +- examples/batch/main.cc | 20 +- examples/common/foo_library/foo_library.cc | 6 + .../common/logs_foo_library/foo_library.cc | 11 +- .../common/metrics_foo_library/foo_library.cc | 14 +- examples/logs_simple/main.cc | 11 +- examples/metrics_simple/metrics_ostream.cc | 17 +- examples/multi_processor/main.cc | 18 +- examples/multithreaded/main.cc | 18 +- examples/plugin/load/main.cc | 8 +- examples/plugin/plugin/factory_impl.cc | 7 + examples/plugin/plugin/tracer.cc | 14 +- examples/plugin/plugin/tracer.h | 7 + examples/simple/main.cc | 7 +- .../memory/in_memory_span_exporter_factory.h | 4 + .../exporters/ostream/log_record_exporter.h | 14 +- .../ostream/log_record_exporter_factory.h | 11 +- .../exporters/ostream/metric_exporter.h | 13 +- .../ostream/metric_exporter_factory.h | 9 +- .../exporters/ostream/span_exporter.h | 19 +- .../exporters/ostream/span_exporter_factory.h | 11 +- exporters/ostream/src/log_record_exporter.cc | 34 +++- .../src/log_record_exporter_factory.cc | 2 + exporters/ostream/src/metric_exporter.cc | 32 +++- exporters/ostream/src/span_exporter.cc | 36 +++- .../ostream/src/span_exporter_factory.cc | 2 + .../sdk/logs/batch_log_record_processor.h | 16 +- .../logs/batch_log_record_processor_factory.h | 7 +- .../opentelemetry/sdk/logs/event_logger.h | 5 +- .../sdk/logs/event_logger_provider.h | 5 +- sdk/include/opentelemetry/sdk/logs/exporter.h | 3 +- sdk/include/opentelemetry/sdk/logs/logger.h | 3 +- .../sdk/logs/logger_context_factory.h | 10 +- .../opentelemetry/sdk/logs/logger_provider.h | 10 +- .../sdk/logs/multi_log_record_processor.h | 3 +- .../logs/multi_log_record_processor_factory.h | 2 +- .../opentelemetry/sdk/logs/multi_recordable.h | 8 +- .../sdk/logs/readable_log_record.h | 4 + .../sdk/logs/simple_log_record_processor.h | 5 +- .../simple_log_record_processor_factory.h | 2 +- .../aggregation/histogram_aggregation.h | 6 + .../aggregation/lastvalue_aggregation.h | 2 + .../sdk/metrics/aggregation/sum_aggregation.h | 2 + .../sdk/metrics/data/circular_buffer.h | 6 +- .../export/periodic_exporting_metric_reader.h | 4 +- ...periodic_exporting_metric_reader_factory.h | 6 +- .../metrics/instrument_metadata_validator.h | 3 - .../opentelemetry/sdk/metrics/meter_context.h | 13 +- .../opentelemetry/sdk/metrics/metric_reader.h | 6 +- .../state/filtered_ordered_attribute_map.h | 13 +- .../sdk/metrics/state/metric_collector.h | 2 + .../sdk/metrics/state/sync_metric_storage.h | 24 ++- .../metrics/state/temporal_metric_storage.h | 7 +- .../sdk/metrics/sync_instruments.h | 7 +- .../view/instrument_selector_factory.h | 5 +- .../sdk/metrics/view/meter_selector_factory.h | 3 +- .../sdk/metrics/view/view_factory.h | 10 +- .../sdk/metrics/view/view_registry_factory.h | 4 +- .../opentelemetry/sdk/version/version.h | 2 - sdk/src/logs/batch_log_record_processor.cc | 25 ++- .../batch_log_record_processor_factory.cc | 9 +- sdk/src/logs/event_logger.cc | 27 ++- sdk/src/logs/event_logger_provider.cc | 18 +- sdk/src/logs/logger.cc | 51 +++-- sdk/src/logs/logger_context.cc | 11 +- sdk/src/logs/logger_context_factory.cc | 10 +- sdk/src/logs/logger_provider.cc | 33 ++-- sdk/src/logs/logger_provider_factory.cc | 4 + sdk/src/logs/multi_log_record_processor.cc | 9 + .../multi_log_record_processor_factory.cc | 10 +- sdk/src/logs/multi_recordable.cc | 14 +- sdk/src/logs/read_write_log_record.cc | 19 +- sdk/src/logs/readable_log_record.cc | 13 +- sdk/src/logs/simple_log_record_processor.cc | 13 +- .../simple_log_record_processor_factory.cc | 8 +- .../aggregation/histogram_aggregation.cc | 18 +- .../aggregation/lastvalue_aggregation.cc | 15 +- .../metrics/aggregation/sum_aggregation.cc | 14 +- sdk/src/metrics/async_instruments.cc | 3 + sdk/src/metrics/data/circular_buffer.cc | 8 + sdk/src/metrics/exemplar/reservoir.cc | 4 +- .../periodic_exporting_metric_reader.cc | 21 ++- ...eriodic_exporting_metric_reader_factory.cc | 7 +- .../metrics/instrument_metadata_validator.cc | 12 +- sdk/src/metrics/meter.cc | 174 ++++++++++-------- sdk/src/metrics/meter_context.cc | 27 ++- sdk/src/metrics/meter_context_factory.cc | 8 +- sdk/src/metrics/meter_provider.cc | 11 ++ sdk/src/metrics/metric_reader.cc | 3 +- sdk/src/metrics/state/metric_collector.cc | 14 +- sdk/src/metrics/state/observable_registry.cc | 22 ++- sdk/src/metrics/state/sync_metric_storage.cc | 13 ++ .../metrics/state/temporal_metric_storage.cc | 26 ++- sdk/src/metrics/sync_instruments.cc | 14 +- sdk/src/metrics/view/view_factory.cc | 9 +- sdk/src/trace/batch_span_processor.cc | 2 +- 103 files changed, 879 insertions(+), 394 deletions(-) diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index de60502794..29b8274fbd 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -38,6 +38,7 @@ jobs: 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 \ + -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DBUILD_W3CTRACECONTEXT_TEST=OFF \ .. diff --git a/CHANGELOG.md b/CHANGELOG.md index cd92d15ba4..f2c08c6065 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,9 @@ Increment the: * [API/SDK] Provider cleanup [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) +* [Code health] include-what-you-use cleanup + [#2692](https://github.com/open-telemetry/opentelemetry-cpp/pull/2692) + Important changes: * [API/SDK] Provider cleanup diff --git a/api/include/opentelemetry/nostd/type_traits.h b/api/include/opentelemetry/nostd/type_traits.h index 46d11c89cb..5a087075bf 100644 --- a/api/include/opentelemetry/nostd/type_traits.h +++ b/api/include/opentelemetry/nostd/type_traits.h @@ -15,7 +15,7 @@ # include # include "opentelemetry/config.h" -# include "opentelemetry/nostd/detail/void.h" +# include "opentelemetry/nostd/detail/void.h" // IWYU pragma: export # include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/api/include/opentelemetry/nostd/utility.h b/api/include/opentelemetry/nostd/utility.h index 3238b0328d..de4f47e4cf 100644 --- a/api/include/opentelemetry/nostd/utility.h +++ b/api/include/opentelemetry/nostd/utility.h @@ -15,8 +15,8 @@ # include # include -# include "opentelemetry/nostd/detail/decay.h" -# include "opentelemetry/nostd/detail/invoke.h" +# include "opentelemetry/nostd/detail/decay.h" // IWYU pragma: export +# include "opentelemetry/nostd/detail/invoke.h" // IWYU pragma: export # include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/api/include/opentelemetry/plugin/detail/dynamic_load_unix.h b/api/include/opentelemetry/plugin/detail/dynamic_load_unix.h index 1d249317a0..83522c56eb 100644 --- a/api/include/opentelemetry/plugin/detail/dynamic_load_unix.h +++ b/api/include/opentelemetry/plugin/detail/dynamic_load_unix.h @@ -3,11 +3,10 @@ #pragma once +#include #include #include -#include - #include "opentelemetry/plugin/detail/dynamic_library_handle.h" #include "opentelemetry/plugin/detail/loader_info.h" #include "opentelemetry/plugin/detail/utility.h" diff --git a/api/include/opentelemetry/plugin/dynamic_load.h b/api/include/opentelemetry/plugin/dynamic_load.h index 58a69ad5c8..10b4a34af4 100644 --- a/api/include/opentelemetry/plugin/dynamic_load.h +++ b/api/include/opentelemetry/plugin/dynamic_load.h @@ -7,9 +7,9 @@ #include #ifdef _WIN32 -# include "opentelemetry/plugin/detail/dynamic_load_windows.h" +# include "opentelemetry/plugin/detail/dynamic_load_windows.h" // IWYU pragma: export #else -# include "opentelemetry/plugin/detail/dynamic_load_unix.h" +# include "opentelemetry/plugin/detail/dynamic_load_unix.h" // IWYU pragma: export #endif #include "opentelemetry/version.h" diff --git a/api/include/opentelemetry/plugin/factory.h b/api/include/opentelemetry/plugin/factory.h index 6b484d8f2f..d9df30e480 100644 --- a/api/include/opentelemetry/plugin/factory.h +++ b/api/include/opentelemetry/plugin/factory.h @@ -6,7 +6,7 @@ #include #include -#include "opentelemetry/plugin/detail/utility.h" +#include "opentelemetry/plugin/detail/utility.h" // IWYU pragma: export #include "opentelemetry/plugin/tracer.h" #include "opentelemetry/version.h" diff --git a/api/include/opentelemetry/plugin/tracer.h b/api/include/opentelemetry/plugin/tracer.h index 9f3c7c76d1..ae78109dab 100644 --- a/api/include/opentelemetry/plugin/tracer.h +++ b/api/include/opentelemetry/plugin/tracer.h @@ -6,7 +6,7 @@ #include #include "opentelemetry/common/key_value_iterable.h" -#include "opentelemetry/plugin/detail/tracer_handle.h" +#include "opentelemetry/plugin/detail/tracer_handle.h" // IWYU pragma: export #include "opentelemetry/trace/span_context_kv_iterable.h" #include "opentelemetry/trace/tracer.h" #include "opentelemetry/version.h" diff --git a/examples/batch/main.cc b/examples/batch/main.cc index ece864001a..2a7fba4630 100644 --- a/examples/batch/main.cc +++ b/examples/batch/main.cc @@ -1,17 +1,29 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include + #include "opentelemetry/exporters/ostream/span_exporter_factory.h" +#include "opentelemetry/nostd/detail/decay.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/resource/resource.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/sdk/trace/recordable.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/provider.h" - -#include -#include +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" constexpr int kNumSpans = 10; namespace trace_api = opentelemetry::trace; diff --git a/examples/common/foo_library/foo_library.cc b/examples/common/foo_library/foo_library.cc index a0dec3c766..e336bc5e4c 100644 --- a/examples/common/foo_library/foo_library.cc +++ b/examples/common/foo_library/foo_library.cc @@ -1,8 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include "opentelemetry/context/context_value.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/sdk/version/version.h" #include "opentelemetry/trace/provider.h" +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" namespace trace = opentelemetry::trace; namespace nostd = opentelemetry::nostd; diff --git a/examples/common/logs_foo_library/foo_library.cc b/examples/common/logs_foo_library/foo_library.cc index d77cd058dc..23402563c6 100644 --- a/examples/common/logs_foo_library/foo_library.cc +++ b/examples/common/logs_foo_library/foo_library.cc @@ -1,11 +1,18 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include -#include +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/logs/logger.h" +#include "opentelemetry/logs/logger_provider.h" #include "opentelemetry/logs/provider.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/version/version.h" #include "opentelemetry/trace/provider.h" +#include "opentelemetry/trace/scope.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" namespace logs = opentelemetry::logs; namespace trace = opentelemetry::trace; diff --git a/examples/common/metrics_foo_library/foo_library.cc b/examples/common/metrics_foo_library/foo_library.cc index 79427d195b..dd5f23297b 100644 --- a/examples/common/metrics_foo_library/foo_library.cc +++ b/examples/common/metrics_foo_library/foo_library.cc @@ -1,15 +1,25 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "foo_library.h" +#include +#include #include #include -#include #include +#include #include + +#include "foo_library.h" +#include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/context/context.h" +#include "opentelemetry/metrics/async_instruments.h" +#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/metrics/meter_provider.h" +#include "opentelemetry/metrics/observer_result.h" #include "opentelemetry/metrics/provider.h" #include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/unique_ptr.h" +#include "opentelemetry/nostd/variant.h" namespace nostd = opentelemetry::nostd; namespace metrics_api = opentelemetry::metrics; diff --git a/examples/logs_simple/main.cc b/examples/logs_simple/main.cc index e104724e2a..35827b6502 100644 --- a/examples/logs_simple/main.cc +++ b/examples/logs_simple/main.cc @@ -1,19 +1,26 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include + #include "opentelemetry/exporters/ostream/log_record_exporter.h" #include "opentelemetry/exporters/ostream/span_exporter_factory.h" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/logs/logger_provider.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/recordable.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/recordable.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/trace/tracer_provider.h" #ifdef BAZEL_BUILD # include "examples/common/logs_foo_library/foo_library.h" diff --git a/examples/metrics_simple/metrics_ostream.cc b/examples/metrics_simple/metrics_ostream.cc index 770b2db81a..5871b5e6a3 100644 --- a/examples/metrics_simple/metrics_ostream.cc +++ b/examples/metrics_simple/metrics_ostream.cc @@ -1,20 +1,31 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include #include +#include #include +#include +#include +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/exporters/ostream/metric_exporter_factory.h" +#include "opentelemetry/metrics/meter_provider.h" #include "opentelemetry/metrics/provider.h" -#include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" -#include "opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" #include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h" -#include "opentelemetry/sdk/metrics/meter.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/meter_provider_factory.h" +#include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" +#include "opentelemetry/sdk/metrics/view/instrument_selector.h" #include "opentelemetry/sdk/metrics/view/instrument_selector_factory.h" +#include "opentelemetry/sdk/metrics/view/meter_selector.h" #include "opentelemetry/sdk/metrics/view/meter_selector_factory.h" +#include "opentelemetry/sdk/metrics/view/view.h" #include "opentelemetry/sdk/metrics/view/view_factory.h" #ifdef BAZEL_BUILD diff --git a/examples/multi_processor/main.cc b/examples/multi_processor/main.cc index 10fe606b30..ceb7cdfcf9 100644 --- a/examples/multi_processor/main.cc +++ b/examples/multi_processor/main.cc @@ -1,13 +1,29 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include + #include "opentelemetry/exporters/memory/in_memory_span_data.h" #include "opentelemetry/exporters/memory/in_memory_span_exporter_factory.h" #include "opentelemetry/exporters/ostream/span_exporter_factory.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/simple_processor_factory.h" -#include "opentelemetry/sdk/trace/tracer_context.h" +#include "opentelemetry/sdk/trace/span_data.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" #include "opentelemetry/sdk/trace/tracer_provider_factory.h" #include "opentelemetry/trace/provider.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/tracer_provider.h" #ifdef BAZEL_BUILD # include "examples/common/foo_library/foo_library.h" diff --git a/examples/multithreaded/main.cc b/examples/multithreaded/main.cc index 6071e2597a..9dd76647c5 100644 --- a/examples/multithreaded/main.cc +++ b/examples/multithreaded/main.cc @@ -1,17 +1,27 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include + #include "opentelemetry/exporters/ostream/span_exporter_factory.h" +#include "opentelemetry/nostd/detail/decay.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.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/trace/scope.h" - -#include -#include +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" namespace trace_api = opentelemetry::trace; namespace trace_sdk = opentelemetry::sdk::trace; diff --git a/examples/plugin/load/main.cc b/examples/plugin/load/main.cc index 41a04baa48..589f70c2af 100644 --- a/examples/plugin/load/main.cc +++ b/examples/plugin/load/main.cc @@ -1,15 +1,17 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/plugin/dynamic_load.h" - -#include +#include #include #include #include #include #include +#include "opentelemetry/plugin/dynamic_load.h" +#include "opentelemetry/plugin/factory.h" +#include "opentelemetry/trace/tracer.h" + int main(int argc, char *argv[]) { if (argc != 3) diff --git a/examples/plugin/plugin/factory_impl.cc b/examples/plugin/plugin/factory_impl.cc index b262facfb8..4d74bd6062 100644 --- a/examples/plugin/plugin/factory_impl.cc +++ b/examples/plugin/plugin/factory_impl.cc @@ -1,8 +1,15 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include + +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/plugin/factory.h" #include "opentelemetry/plugin/hook.h" +#include "opentelemetry/plugin/tracer.h" #include "tracer.h" namespace nostd = opentelemetry::nostd; diff --git a/examples/plugin/plugin/tracer.cc b/examples/plugin/plugin/tracer.cc index 14d1a746df..faf3f036e5 100644 --- a/examples/plugin/plugin/tracer.cc +++ b/examples/plugin/plugin/tracer.cc @@ -1,11 +1,19 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "tracer.h" -#include "opentelemetry/nostd/unique_ptr.h" - #include #include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/context/context_value.h" +#include "opentelemetry/nostd/unique_ptr.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_metadata.h" +#include "tracer.h" namespace nostd = opentelemetry::nostd; namespace common = opentelemetry::common; diff --git a/examples/plugin/plugin/tracer.h b/examples/plugin/plugin/tracer.h index 1480b44541..bb933d3d9b 100644 --- a/examples/plugin/plugin/tracer.h +++ b/examples/plugin/plugin/tracer.h @@ -3,8 +3,15 @@ #pragma once +#include #include +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.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" class Tracer final : public opentelemetry::trace::Tracer, diff --git a/examples/simple/main.cc b/examples/simple/main.cc index 284ec2f693..a872816ba1 100644 --- a/examples/simple/main.cc +++ b/examples/simple/main.cc @@ -1,13 +1,18 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include + #include "opentelemetry/exporters/ostream/span_exporter_factory.h" -#include "opentelemetry/sdk/trace/exporter.h" #include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.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/trace/span_id.h" +#include "opentelemetry/trace/tracer_provider.h" #ifdef BAZEL_BUILD # include "examples/common/foo_library/foo_library.h" diff --git a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter_factory.h b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter_factory.h index c55f6a0802..549ff13c71 100644 --- a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter_factory.h +++ b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter_factory.h @@ -3,8 +3,12 @@ #pragma once +#include +#include + #include "opentelemetry/exporters/memory/in_memory_span_data.h" #include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE 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 3c11c53aee..24bc8e5be7 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h @@ -3,17 +3,21 @@ #pragma once +#include +#include +#include +#include +#include +#include + #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/recordable.h" #include "opentelemetry/version.h" -#include -#include -#include -#include - OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter_factory.h b/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter_factory.h index 143a481801..36c09a9f74 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter_factory.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter_factory.h @@ -6,17 +6,10 @@ #include #include -#include "opentelemetry/sdk/version/version.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace sdk -{ -namespace logs -{ -class LogRecordExporter; -} // namespace logs -} // namespace sdk - namespace exporter { namespace logs diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h index 0dd22203e5..1ad124a9ab 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h @@ -4,25 +4,22 @@ #pragma once #include +#include #include +#include #include #include +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace sdk -{ -namespace resource -{ -class Resource; -} // namespace resource -} // namespace sdk - namespace exporter { namespace metrics diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter_factory.h b/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter_factory.h index 0526165026..3451769747 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter_factory.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter_factory.h @@ -7,17 +7,10 @@ #include #include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace sdk -{ -namespace metrics -{ -class PushMetricExporter; -} // namespace metrics -} // namespace sdk - namespace exporter { namespace metrics diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h index 153aa4701e..a7de9a5eb4 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h @@ -3,16 +3,25 @@ #pragma once +#include +#include +#include +#include +#include +#include +#include +#include + #include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/span_data.h" #include "opentelemetry/version.h" -#include -#include -#include -#include - OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter_factory.h b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter_factory.h index 79ba3b06d4..4797473bbb 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter_factory.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter_factory.h @@ -6,17 +6,10 @@ #include #include -#include "opentelemetry/sdk/version/version.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace sdk -{ -namespace trace -{ -class SpanExporter; -} // namespace trace -} // namespace sdk - namespace exporter { namespace trace diff --git a/exporters/ostream/src/log_record_exporter.cc b/exporters/ostream/src/log_record_exporter.cc index 88b8ba5ba2..7f661276c8 100644 --- a/exporters/ostream/src/log_record_exporter.cc +++ b/exporters/ostream/src/log_record_exporter.cc @@ -1,20 +1,38 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/ostream/log_record_exporter.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/ostream/common_utils.h" +#include "opentelemetry/exporters/ostream/log_record_exporter.h" +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/read_write_log_record.h" +#include "opentelemetry/sdk/logs/recordable.h" #include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/sdk_config.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/version.h" -#include -#include -#include - -namespace nostd = opentelemetry::nostd; namespace sdklogs = opentelemetry::sdk::logs; namespace sdkcommon = opentelemetry::sdk::common; + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { @@ -33,7 +51,7 @@ std::unique_ptr OStreamLogRecordExporter::MakeRecordable() } sdk::common::ExportResult OStreamLogRecordExporter::Export( - const nostd::span> &records) noexcept + const opentelemetry::nostd::span> &records) noexcept { if (isShutdown()) { diff --git a/exporters/ostream/src/log_record_exporter_factory.cc b/exporters/ostream/src/log_record_exporter_factory.cc index 66ea1a0232..31539c5182 100644 --- a/exporters/ostream/src/log_record_exporter_factory.cc +++ b/exporters/ostream/src/log_record_exporter_factory.cc @@ -3,6 +3,8 @@ #include "opentelemetry/exporters/ostream/log_record_exporter_factory.h" #include "opentelemetry/exporters/ostream/log_record_exporter.h" +#include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/version.h" namespace logs_sdk = opentelemetry::sdk::logs; diff --git a/exporters/ostream/src/metric_exporter.cc b/exporters/ostream/src/metric_exporter.cc index 4871a28b3d..08bfe340c7 100644 --- a/exporters/ostream/src/metric_exporter.cc +++ b/exporters/ostream/src/metric_exporter.cc @@ -1,19 +1,35 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/ostream/metric_exporter.h" -#include "opentelemetry/exporters/ostream/common_utils.h" -#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" -#include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" -#include "opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h" -#include "opentelemetry/sdk/resource/resource.h" -#include "opentelemetry/sdk_config.h" - +#include #include +#include #include #include +#include #include #include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/exporters/ostream/common_utils.h" +#include "opentelemetry/exporters/ostream/metric_exporter.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/version.h" namespace { diff --git a/exporters/ostream/src/span_exporter.cc b/exporters/ostream/src/span_exporter.cc index 4faa6854be..d3f5093b40 100644 --- a/exporters/ostream/src/span_exporter.cc +++ b/exporters/ostream/src/span_exporter.cc @@ -1,14 +1,36 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/ostream/span_exporter.h" -#include "opentelemetry/exporters/ostream/common_utils.h" - +#include +#include #include -#include -#include "opentelemetry/sdk_config.h" +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/exporters/ostream/common_utils.h" +#include "opentelemetry/exporters/ostream/span_exporter.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/common/exporter_utils.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/recordable.h" +#include "opentelemetry/sdk/trace/span_data.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" +#include "opentelemetry/version.h" -namespace nostd = opentelemetry::nostd; namespace trace_sdk = opentelemetry::sdk::trace; namespace trace_api = opentelemetry::trace; namespace sdkcommon = opentelemetry::sdk::common; @@ -45,7 +67,7 @@ std::unique_ptr OStreamSpanExporter::MakeRecordable() noe } sdk::common::ExportResult OStreamSpanExporter::Export( - const nostd::span> &spans) noexcept + const opentelemetry::nostd::span> &spans) noexcept { if (isShutdown()) { diff --git a/exporters/ostream/src/span_exporter_factory.cc b/exporters/ostream/src/span_exporter_factory.cc index 5b3061ac3c..fdb08f150f 100644 --- a/exporters/ostream/src/span_exporter_factory.cc +++ b/exporters/ostream/src/span_exporter_factory.cc @@ -3,6 +3,8 @@ #include "opentelemetry/exporters/ostream/span_exporter_factory.h" #include "opentelemetry/exporters/ostream/span_exporter.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/version.h" namespace trace_sdk = opentelemetry::sdk::trace; 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 01a39348e2..b52476071a 100644 --- a/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h @@ -3,18 +3,22 @@ #pragma once -#include "opentelemetry/sdk/common/circular_buffer.h" -#include "opentelemetry/sdk/logs/batch_log_record_processor_options.h" -#include "opentelemetry/sdk/logs/exporter.h" -#include "opentelemetry/sdk/logs/processor.h" -#include "opentelemetry/version.h" - +#include #include +#include #include #include #include +#include #include +#include "opentelemetry/sdk/common/circular_buffer.h" +#include "opentelemetry/sdk/logs/batch_log_record_processor_options.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/version.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { diff --git a/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_factory.h b/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_factory.h index 74e0efbb59..983f2e7508 100644 --- a/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_factory.h @@ -5,6 +5,9 @@ #include +#include "opentelemetry/sdk/logs/batch_log_record_processor_options.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -14,10 +17,6 @@ namespace sdk namespace logs { -struct BatchLogRecordProcessorOptions; -class LogRecordExporter; -class LogRecordProcessor; - /** * Factory class for BatchLogRecordProcessor. */ diff --git a/sdk/include/opentelemetry/sdk/logs/event_logger.h b/sdk/include/opentelemetry/sdk/logs/event_logger.h index 8230beeb32..d9e83b9998 100644 --- a/sdk/include/opentelemetry/sdk/logs/event_logger.h +++ b/sdk/include/opentelemetry/sdk/logs/event_logger.h @@ -6,6 +6,8 @@ #include #include "opentelemetry/logs/event_logger.h" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/logs/logger.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" @@ -16,9 +18,6 @@ namespace sdk { namespace logs { -class Logger; -class LogRecord; - class EventLogger final : public opentelemetry::logs::EventLogger { public: diff --git a/sdk/include/opentelemetry/sdk/logs/event_logger_provider.h b/sdk/include/opentelemetry/sdk/logs/event_logger_provider.h index 4572647356..9e7ff4d866 100644 --- a/sdk/include/opentelemetry/sdk/logs/event_logger_provider.h +++ b/sdk/include/opentelemetry/sdk/logs/event_logger_provider.h @@ -3,7 +3,9 @@ #pragma once +#include "opentelemetry/logs/event_logger.h" #include "opentelemetry/logs/event_logger_provider.h" +#include "opentelemetry/logs/logger.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" @@ -17,9 +19,6 @@ namespace sdk { namespace logs { -class EventLogger; -class Logger; - class OPENTELEMETRY_EXPORT EventLoggerProvider final : public opentelemetry::logs::EventLoggerProvider { diff --git a/sdk/include/opentelemetry/sdk/logs/exporter.h b/sdk/include/opentelemetry/sdk/logs/exporter.h index 68c61603fa..15e848f351 100644 --- a/sdk/include/opentelemetry/sdk/logs/exporter.h +++ b/sdk/include/opentelemetry/sdk/logs/exporter.h @@ -8,6 +8,7 @@ #include "opentelemetry/nostd/span.h" #include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/logs/recordable.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -15,8 +16,6 @@ namespace sdk { namespace logs { -class Recordable; - /** * LogRecordExporter defines the interface that log exporters must implement. */ diff --git a/sdk/include/opentelemetry/sdk/logs/logger.h b/sdk/include/opentelemetry/sdk/logs/logger.h index fbbf4f28a5..ed43d1ce55 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger.h +++ b/sdk/include/opentelemetry/sdk/logs/logger.h @@ -6,7 +6,7 @@ #include #include -#include "opentelemetry/common/macros.h" +#include "opentelemetry/logs/log_record.h" #include "opentelemetry/logs/logger.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" @@ -19,7 +19,6 @@ namespace sdk { namespace logs { -class LoggerProvider; class Logger final : public opentelemetry::logs::Logger { diff --git a/sdk/include/opentelemetry/sdk/logs/logger_context_factory.h b/sdk/include/opentelemetry/sdk/logs/logger_context_factory.h index 9f8a8a54ba..5565be8a62 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_context_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_context_factory.h @@ -6,20 +6,16 @@ #include #include +#include "opentelemetry/sdk/logs/logger_context.h" +#include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { -namespace resource -{ -class Resource; -} // namespace resource - namespace logs { -class LoggerContext; -class LogRecordProcessor; /** * Factory class for LoggerContext. diff --git a/sdk/include/opentelemetry/sdk/logs/logger_provider.h b/sdk/include/opentelemetry/sdk/logs/logger_provider.h index bced6061f5..bf116b4272 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_provider.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_provider.h @@ -3,13 +3,19 @@ #pragma once +#include #include #include #include +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/logs/logger.h" #include "opentelemetry/logs/logger_provider.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/logs/logger.h" +#include "opentelemetry/sdk/logs/logger_context.h" +#include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" @@ -22,10 +28,6 @@ namespace sdk { namespace logs { -class Logger; -class LoggerContext; -class LogRecordProcessor; - class OPENTELEMETRY_EXPORT LoggerProvider final : public opentelemetry::logs::LoggerProvider { public: diff --git a/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor.h b/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor.h index 8ca5cffcca..46432ef22e 100644 --- a/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor.h @@ -8,6 +8,7 @@ #include #include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/sdk/logs/recordable.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -15,8 +16,6 @@ namespace sdk { namespace logs { -class Recordable; - /** * Log processor allow hooks for receive method invocations. * diff --git a/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor_factory.h b/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor_factory.h index 26bd9152ce..351b9c0f7f 100644 --- a/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor_factory.h @@ -6,6 +6,7 @@ #include #include +#include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -13,7 +14,6 @@ namespace sdk { namespace logs { -class LogRecordProcessor; /** * Factory class for MultiLogRecordProcessor. diff --git a/sdk/include/opentelemetry/sdk/logs/multi_recordable.h b/sdk/include/opentelemetry/sdk/logs/multi_recordable.h index 1eb4b1a221..40a9c92e3b 100644 --- a/sdk/include/opentelemetry/sdk/logs/multi_recordable.h +++ b/sdk/include/opentelemetry/sdk/logs/multi_recordable.h @@ -3,11 +3,17 @@ #pragma once +#include #include #include #include +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/macros.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/recordable.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" @@ -17,8 +23,6 @@ namespace sdk { namespace logs { -class LogRecordProcessor; - class MultiRecordable final : public Recordable { public: diff --git a/sdk/include/opentelemetry/sdk/logs/readable_log_record.h b/sdk/include/opentelemetry/sdk/logs/readable_log_record.h index a8f366b5b7..2222def9d2 100644 --- a/sdk/include/opentelemetry/sdk/logs/readable_log_record.h +++ b/sdk/include/opentelemetry/sdk/logs/readable_log_record.h @@ -3,14 +3,18 @@ #pragma once +#include #include #include #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/timestamp.h" +#include "opentelemetry/logs/log_record.h" #include "opentelemetry/logs/severity.h" #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor.h b/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor.h index a65c0eb7a9..23b6efa46f 100644 --- a/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor.h @@ -8,7 +8,9 @@ #include #include "opentelemetry/common/spin_lock_mutex.h" +#include "opentelemetry/sdk/logs/exporter.h" #include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/sdk/logs/recordable.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -16,9 +18,6 @@ namespace sdk { namespace logs { -class LogRecordExporter; -class Recordable; - /** * The simple log processor passes all log records * in a batch of 1 to the configured diff --git a/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor_factory.h b/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor_factory.h index 295addce11..0b9df81c1e 100644 --- a/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor_factory.h @@ -5,6 +5,7 @@ #include +#include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -13,7 +14,6 @@ namespace sdk namespace logs { class LogRecordExporter; -class LogRecordProcessor; /** * Factory class for SimpleLogRecordProcessor. diff --git a/sdk/include/opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h b/sdk/include/opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h index 04293e696f..c5cfcfd897 100644 --- a/sdk/include/opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h +++ b/sdk/include/opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h @@ -3,11 +3,17 @@ #pragma once +#include +#include #include #include +#include #include "opentelemetry/common/spin_lock_mutex.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/metrics/aggregation/aggregation.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/version.h" diff --git a/sdk/include/opentelemetry/sdk/metrics/aggregation/lastvalue_aggregation.h b/sdk/include/opentelemetry/sdk/metrics/aggregation/lastvalue_aggregation.h index 859fe26d6b..e8e6c40a30 100644 --- a/sdk/include/opentelemetry/sdk/metrics/aggregation/lastvalue_aggregation.h +++ b/sdk/include/opentelemetry/sdk/metrics/aggregation/lastvalue_aggregation.h @@ -3,10 +3,12 @@ #pragma once +#include #include #include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/sdk/metrics/aggregation/aggregation.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/version.h" diff --git a/sdk/include/opentelemetry/sdk/metrics/aggregation/sum_aggregation.h b/sdk/include/opentelemetry/sdk/metrics/aggregation/sum_aggregation.h index a098d86b72..035a8df84d 100644 --- a/sdk/include/opentelemetry/sdk/metrics/aggregation/sum_aggregation.h +++ b/sdk/include/opentelemetry/sdk/metrics/aggregation/sum_aggregation.h @@ -3,10 +3,12 @@ #pragma once +#include #include #include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/sdk/metrics/aggregation/aggregation.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/version.h" diff --git a/sdk/include/opentelemetry/sdk/metrics/data/circular_buffer.h b/sdk/include/opentelemetry/sdk/metrics/data/circular_buffer.h index 32605dfd68..db4de054f4 100644 --- a/sdk/include/opentelemetry/sdk/metrics/data/circular_buffer.h +++ b/sdk/include/opentelemetry/sdk/metrics/data/circular_buffer.h @@ -3,12 +3,14 @@ #pragma once -#include "opentelemetry/nostd/variant.h" - +#include #include #include #include +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/version.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { 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 9fb0fbf5a0..d72ec08839 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 @@ -12,7 +12,9 @@ #include #include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/metric_reader.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -21,8 +23,6 @@ namespace sdk namespace metrics { -class PushMetricExporter; - class PeriodicExportingMetricReader : public MetricReader { diff --git a/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h b/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h index 1c5c1a0d7b..8cb439599e 100644 --- a/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h @@ -3,8 +3,11 @@ #pragma once +#include + #include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h" #include "opentelemetry/sdk/metrics/metric_reader.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -13,9 +16,6 @@ namespace sdk namespace metrics { -class MetricReader; -class PushMetricExporter; - class OPENTELEMETRY_EXPORT PeriodicExportingMetricReaderFactory { public: diff --git a/sdk/include/opentelemetry/sdk/metrics/instrument_metadata_validator.h b/sdk/include/opentelemetry/sdk/metrics/instrument_metadata_validator.h index fec1027746..a24d6db734 100644 --- a/sdk/include/opentelemetry/sdk/metrics/instrument_metadata_validator.h +++ b/sdk/include/opentelemetry/sdk/metrics/instrument_metadata_validator.h @@ -3,9 +3,6 @@ #pragma once -#include - -#include "opentelemetry/common/macros.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_context.h b/sdk/include/opentelemetry/sdk/metrics/meter_context.h index 2dfa2db56e..40a57a6f88 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_context.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_context.h @@ -12,15 +12,20 @@ #include "opentelemetry/common/timestamp.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/metrics/metric_reader.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.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 sdk { diff --git a/sdk/include/opentelemetry/sdk/metrics/metric_reader.h b/sdk/include/opentelemetry/sdk/metrics/metric_reader.h index 126ad92282..30d5e60823 100644 --- a/sdk/include/opentelemetry/sdk/metrics/metric_reader.h +++ b/sdk/include/opentelemetry/sdk/metrics/metric_reader.h @@ -5,10 +5,9 @@ #include #include -#include #include "opentelemetry/nostd/function_ref.h" -#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/version.h" @@ -17,9 +16,6 @@ namespace sdk { namespace metrics { -class MetricProducer; -struct ResourceMetrics; - /** * MetricReader defines the interface to collect metrics from SDK */ diff --git a/sdk/include/opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h b/sdk/include/opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h index f9880b5073..329e75bfa7 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h @@ -3,9 +3,13 @@ #pragma once -#include -#include -#include "opentelemetry/sdk/common/attributemap_hash.h" +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -13,7 +17,8 @@ namespace sdk { namespace metrics { -class AttributesProcessor; +class AttributesProcessor; // IWYU pragma: keep + class FilteredOrderedAttributeMap : public opentelemetry::sdk::common::OrderedAttributeMap { public: diff --git a/sdk/include/opentelemetry/sdk/metrics/state/metric_collector.h b/sdk/include/opentelemetry/sdk/metrics/state/metric_collector.h index bf0a9ba86b..e652ba12a9 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/metric_collector.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/metric_collector.h @@ -6,8 +6,10 @@ #include #include +#include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" #include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h b/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h index 031bab2f61..0e4d288d6e 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h @@ -3,26 +3,25 @@ #pragma once +#include +#include #include -#include #include #include -#include -#include +#include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/common/spin_lock_mutex.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/context/context.h" #include "opentelemetry/nostd/function_ref.h" -#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/attributemap_hash.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" #include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" - -#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" -# include "opentelemetry/sdk/metrics/exemplar/reservoir.h" -#endif - +#include "opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" #include "opentelemetry/sdk/metrics/state/metric_collector.h" #include "opentelemetry/sdk/metrics/state/metric_storage.h" @@ -30,6 +29,11 @@ #include "opentelemetry/sdk/metrics/view/attributes_processor.h" #include "opentelemetry/version.h" +#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW +# include "opentelemetry/sdk/metrics/exemplar/filter_type.h" +# include "opentelemetry/sdk/metrics/exemplar/reservoir.h" +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { diff --git a/sdk/include/opentelemetry/sdk/metrics/state/temporal_metric_storage.h b/sdk/include/opentelemetry/sdk/metrics/state/temporal_metric_storage.h index 0a08e7d100..2d01710e47 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/temporal_metric_storage.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/temporal_metric_storage.h @@ -11,7 +11,10 @@ #include "opentelemetry/common/timestamp.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -19,10 +22,6 @@ namespace sdk { namespace metrics { -class AggregationConfig; -class AttributesHashMap; -class CollectorHandle; -class MetricData; struct LastReportedMetrics { diff --git a/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h b/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h index f08b629fe2..1d2c5bf25f 100644 --- a/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h +++ b/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h @@ -3,8 +3,12 @@ #pragma once +#include #include +#include +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/context/context.h" #include "opentelemetry/metrics/sync_instruments.h" #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/state/metric_storage.h" @@ -17,9 +21,6 @@ namespace sdk namespace metrics { -// forward declaration -class SyncWritableMetricStorage; - class Synchronous { public: diff --git a/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h b/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h index 3c221f123b..a2db241e98 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h @@ -3,9 +3,12 @@ #pragma once +#include #include #include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/view/instrument_selector.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -13,8 +16,6 @@ namespace sdk namespace metrics { -class InstrumentSelector; - class OPENTELEMETRY_EXPORT InstrumentSelectorFactory { public: diff --git a/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h b/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h index 47aa77b772..19cee41629 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h @@ -6,6 +6,7 @@ #include #include +#include "opentelemetry/sdk/metrics/view/meter_selector.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -14,8 +15,6 @@ namespace sdk namespace metrics { -class MeterSelector; - class OPENTELEMETRY_EXPORT MeterSelectorFactory { public: diff --git a/sdk/include/opentelemetry/sdk/metrics/view/view_factory.h b/sdk/include/opentelemetry/sdk/metrics/view/view_factory.h index 22d34bf506..2fa1733f92 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/view_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/view_factory.h @@ -3,12 +3,14 @@ #pragma once -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/string_view.h" +#include +#include + #include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" -#include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/view/attributes_processor.h" +#include "opentelemetry/sdk/metrics/view/view.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -16,8 +18,6 @@ namespace sdk namespace metrics { -class View; - /** * Factory class for View. */ diff --git a/sdk/include/opentelemetry/sdk/metrics/view/view_registry_factory.h b/sdk/include/opentelemetry/sdk/metrics/view/view_registry_factory.h index f8f83c21ad..3592e95512 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/view_registry_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/view_registry_factory.h @@ -5,6 +5,7 @@ #include +#include "opentelemetry/sdk/metrics/view/view_registry.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,9 +13,6 @@ namespace sdk { namespace metrics { - -class ViewRegistry; - class ViewRegistryFactory { public: diff --git a/sdk/include/opentelemetry/sdk/version/version.h b/sdk/include/opentelemetry/sdk/version/version.h index f7f6f4f0fd..f98c5c433f 100644 --- a/sdk/include/opentelemetry/sdk/version/version.h +++ b/sdk/include/opentelemetry/sdk/version/version.h @@ -3,8 +3,6 @@ #pragma once -#include "opentelemetry/detail/preprocessor.h" - #define OPENTELEMETRY_SDK_VERSION "1.15.0" #include "opentelemetry/version.h" diff --git a/sdk/src/logs/batch_log_record_processor.cc b/sdk/src/logs/batch_log_record_processor.cc index c29e27bdd3..c85d56739e 100644 --- a/sdk/src/logs/batch_log_record_processor.cc +++ b/sdk/src/logs/batch_log_record_processor.cc @@ -1,12 +1,29 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/batch_log_record_processor.h" -#include "opentelemetry/common/spin_lock_mutex.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #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/logs/batch_log_record_processor.h" +#include "opentelemetry/sdk/logs/batch_log_record_processor_options.h" +#include "opentelemetry/sdk/logs/exporter.h" #include "opentelemetry/sdk/logs/recordable.h" - -#include +#include "opentelemetry/version.h" using opentelemetry::sdk::common::AtomicUniquePtr; using opentelemetry::sdk::common::CircularBufferRange; diff --git a/sdk/src/logs/batch_log_record_processor_factory.cc b/sdk/src/logs/batch_log_record_processor_factory.cc index dabd0f4ff8..a6e29e4967 100644 --- a/sdk/src/logs/batch_log_record_processor_factory.cc +++ b/sdk/src/logs/batch_log_record_processor_factory.cc @@ -1,8 +1,15 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/batch_log_record_processor_factory.h" +#include +#include + #include "opentelemetry/sdk/logs/batch_log_record_processor.h" +#include "opentelemetry/sdk/logs/batch_log_record_processor_factory.h" +#include "opentelemetry/sdk/logs/batch_log_record_processor_options.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/logs/event_logger.cc b/sdk/src/logs/event_logger.cc index c9dd5c35b5..6b0afacfaf 100644 --- a/sdk/src/logs/event_logger.cc +++ b/sdk/src/logs/event_logger.cc @@ -1,23 +1,30 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include + +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/logs/logger.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/sdk/logs/event_logger.h" -#include "opentelemetry/sdk_config.h" -#include "opentelemetry/trace/provider.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { namespace logs { -namespace nostd = opentelemetry::nostd; -EventLogger::EventLogger(nostd::shared_ptr delegate_logger, - nostd::string_view event_domain) noexcept +EventLogger::EventLogger( + opentelemetry::nostd::shared_ptr delegate_logger, + opentelemetry::nostd::string_view event_domain) noexcept : delegate_logger_(delegate_logger), event_domain_(event_domain) {} -const nostd::string_view EventLogger::GetName() noexcept +const opentelemetry::nostd::string_view EventLogger::GetName() noexcept { if (delegate_logger_) { @@ -27,13 +34,15 @@ const nostd::string_view EventLogger::GetName() noexcept return {}; } -nostd::shared_ptr EventLogger::GetDelegateLogger() noexcept +opentelemetry::nostd::shared_ptr +EventLogger::GetDelegateLogger() noexcept { return delegate_logger_; } -void EventLogger::EmitEvent(nostd::string_view event_name, - nostd::unique_ptr &&log_record) noexcept +void EventLogger::EmitEvent( + opentelemetry::nostd::string_view event_name, + opentelemetry::nostd::unique_ptr &&log_record) noexcept { if (!delegate_logger_ || !log_record) { diff --git a/sdk/src/logs/event_logger_provider.cc b/sdk/src/logs/event_logger_provider.cc index 28a88d82e2..570a64f82d 100644 --- a/sdk/src/logs/event_logger_provider.cc +++ b/sdk/src/logs/event_logger_provider.cc @@ -2,21 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/sdk/logs/event_logger_provider.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/logs/event_logger.h" - -#include -#include -#include -#include -#include +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { namespace logs { -namespace nostd = opentelemetry::nostd; EventLoggerProvider::EventLoggerProvider() noexcept { @@ -25,11 +20,12 @@ EventLoggerProvider::EventLoggerProvider() noexcept EventLoggerProvider::~EventLoggerProvider() {} -nostd::shared_ptr EventLoggerProvider::CreateEventLogger( - nostd::shared_ptr delegate_logger, - nostd::string_view event_domain) noexcept +opentelemetry::nostd::shared_ptr +EventLoggerProvider::CreateEventLogger( + opentelemetry::nostd::shared_ptr delegate_logger, + opentelemetry::nostd::string_view event_domain) noexcept { - return nostd::shared_ptr{ + return opentelemetry::nostd::shared_ptr{ new EventLogger(delegate_logger, event_domain)}; } diff --git a/sdk/src/logs/logger.cc b/sdk/src/logs/logger.cc index 972b380efc..d3555ba4ec 100644 --- a/sdk/src/logs/logger.cc +++ b/sdk/src/logs/logger.cc @@ -1,12 +1,29 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/logger.h" +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/context/context_value.h" #include "opentelemetry/context/runtime_context.h" +#include "opentelemetry/logs/log_record.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/logs/logger.h" +#include "opentelemetry/sdk/logs/logger_context.h" #include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/recordable.h" -#include "opentelemetry/sdk_config.h" -#include "opentelemetry/trace/provider.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -14,11 +31,10 @@ namespace sdk namespace logs { namespace trace_api = opentelemetry::trace; -namespace nostd = opentelemetry::nostd; namespace common = opentelemetry::common; Logger::Logger( - nostd::string_view name, + opentelemetry::nostd::string_view name, std::shared_ptr context, std::unique_ptr instrumentation_scope) noexcept : logger_name_(std::string(name)), @@ -26,12 +42,12 @@ Logger::Logger( context_(context) {} -const nostd::string_view Logger::GetName() noexcept +const opentelemetry::nostd::string_view Logger::GetName() noexcept { return logger_name_; } -nostd::unique_ptr Logger::CreateLogRecord() noexcept +opentelemetry::nostd::unique_ptr Logger::CreateLogRecord() noexcept { auto recordable = context_->GetProcessor().MakeRecordable(); @@ -42,10 +58,12 @@ nostd::unique_ptr Logger::CreateLogRecord() noex opentelemetry::context::ContextValue context_value = opentelemetry::context::RuntimeContext::GetCurrent().GetValue( opentelemetry::trace::kSpanKey); - if (nostd::holds_alternative>(context_value)) + if (opentelemetry::nostd::holds_alternative< + opentelemetry::nostd::shared_ptr>(context_value)) { - nostd::shared_ptr &data = - nostd::get>(context_value); + opentelemetry::nostd::shared_ptr &data = + opentelemetry::nostd::get>( + context_value); if (data) { recordable->SetTraceId(data->GetContext().trace_id()); @@ -53,10 +71,12 @@ nostd::unique_ptr Logger::CreateLogRecord() noex recordable->SetSpanId(data->GetContext().span_id()); } } - else if (nostd::holds_alternative>(context_value)) + else if (opentelemetry::nostd::holds_alternative< + opentelemetry::nostd::shared_ptr>(context_value)) { - nostd::shared_ptr &data = - nostd::get>(context_value); + opentelemetry::nostd::shared_ptr &data = + opentelemetry::nostd::get>( + context_value); if (data) { recordable->SetTraceId(data->trace_id()); @@ -66,10 +86,11 @@ nostd::unique_ptr Logger::CreateLogRecord() noex } } - return nostd::unique_ptr(recordable.release()); + return opentelemetry::nostd::unique_ptr(recordable.release()); } -void Logger::EmitLogRecord(nostd::unique_ptr &&log_record) noexcept +void Logger::EmitLogRecord( + opentelemetry::nostd::unique_ptr &&log_record) noexcept { if (!log_record) { diff --git a/sdk/src/logs/logger_context.cc b/sdk/src/logs/logger_context.cc index 357d13193d..2bfb89161e 100644 --- a/sdk/src/logs/logger_context.cc +++ b/sdk/src/logs/logger_context.cc @@ -1,12 +1,17 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/logger_context.h" -#include "opentelemetry/sdk/logs/multi_log_record_processor.h" - +#include #include +#include #include +#include "opentelemetry/sdk/logs/logger_context.h" +#include "opentelemetry/sdk/logs/multi_log_record_processor.h" +#include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/version.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { diff --git a/sdk/src/logs/logger_context_factory.cc b/sdk/src/logs/logger_context_factory.cc index ff57747f80..f11852be7f 100644 --- a/sdk/src/logs/logger_context_factory.cc +++ b/sdk/src/logs/logger_context_factory.cc @@ -1,13 +1,15 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/logger_context_factory.h" +#include +#include +#include + #include "opentelemetry/sdk/logs/logger_context.h" +#include "opentelemetry/sdk/logs/logger_context_factory.h" #include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/resource/resource.h" - -#include -#include +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/logs/logger_provider.cc b/sdk/src/logs/logger_provider.cc index 46eaa01054..c3b1fb7dd4 100644 --- a/sdk/src/logs/logger_provider.cc +++ b/sdk/src/logs/logger_provider.cc @@ -1,12 +1,26 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/logger_provider.h" +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/logs/logger.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/logger.h" #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 sdk @@ -14,9 +28,6 @@ namespace sdk namespace logs { -namespace nostd = opentelemetry::nostd; -namespace logs_api = opentelemetry::logs; - LoggerProvider::LoggerProvider(std::unique_ptr &&processor, opentelemetry::sdk::resource::Resource resource) noexcept { @@ -50,11 +61,11 @@ LoggerProvider::~LoggerProvider() } } -nostd::shared_ptr LoggerProvider::GetLogger( - nostd::string_view logger_name, - nostd::string_view library_name, - nostd::string_view library_version, - nostd::string_view schema_url, +opentelemetry::nostd::shared_ptr LoggerProvider::GetLogger( + opentelemetry::nostd::string_view logger_name, + opentelemetry::nostd::string_view library_name, + opentelemetry::nostd::string_view library_version, + opentelemetry::nostd::string_view schema_url, const opentelemetry::common::KeyValueIterable &attributes) noexcept { // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-instrumentationscope @@ -73,7 +84,7 @@ nostd::shared_ptr LoggerProvider::GetLogger( if (logger->GetName() == logger_name && logger_lib.equal(library_name, library_version, schema_url)) { - return nostd::shared_ptr{logger}; + return opentelemetry::nostd::shared_ptr{logger}; } } @@ -96,7 +107,7 @@ nostd::shared_ptr LoggerProvider::GetLogger( loggers_.push_back(std::shared_ptr( new Logger(logger_name, context_, std::move(lib)))); - return nostd::shared_ptr{loggers_.back()}; + return opentelemetry::nostd::shared_ptr{loggers_.back()}; } void LoggerProvider::AddProcessor(std::unique_ptr processor) noexcept diff --git a/sdk/src/logs/logger_provider_factory.cc b/sdk/src/logs/logger_provider_factory.cc index 8c169866ff..08567c65d9 100644 --- a/sdk/src/logs/logger_provider_factory.cc +++ b/sdk/src/logs/logger_provider_factory.cc @@ -1,12 +1,16 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include #include +#include #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/logs/processor.h" #include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/logs/multi_log_record_processor.cc b/sdk/src/logs/multi_log_record_processor.cc index c0b3eb1ec6..efc1cbd1b4 100644 --- a/sdk/src/logs/multi_log_record_processor.cc +++ b/sdk/src/logs/multi_log_record_processor.cc @@ -1,9 +1,18 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include + #include "opentelemetry/sdk/logs/multi_log_record_processor.h" #include "opentelemetry/sdk/logs/multi_recordable.h" +#include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/logs/multi_log_record_processor_factory.cc b/sdk/src/logs/multi_log_record_processor_factory.cc index ab49689ca0..f51c851a28 100644 --- a/sdk/src/logs/multi_log_record_processor_factory.cc +++ b/sdk/src/logs/multi_log_record_processor_factory.cc @@ -1,13 +1,15 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/multi_log_record_processor_factory.h" -#include "opentelemetry/sdk/logs/multi_log_record_processor.h" - -#include #include +#include #include +#include "opentelemetry/sdk/logs/multi_log_record_processor.h" +#include "opentelemetry/sdk/logs/multi_log_record_processor_factory.h" +#include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/version.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { diff --git a/sdk/src/logs/multi_recordable.cc b/sdk/src/logs/multi_recordable.cc index 7d80259f27..53c2b25e33 100644 --- a/sdk/src/logs/multi_recordable.cc +++ b/sdk/src/logs/multi_recordable.cc @@ -1,11 +1,21 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/multi_recordable.h" - +#include #include #include #include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/logs/multi_recordable.h" +#include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/logs/read_write_log_record.cc b/sdk/src/logs/read_write_log_record.cc index 27dd8f7d5f..48c9a2699d 100644 --- a/sdk/src/logs/read_write_log_record.cc +++ b/sdk/src/logs/read_write_log_record.cc @@ -1,10 +1,23 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include -#include - +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/read_write_log_record.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/logs/readable_log_record.cc b/sdk/src/logs/readable_log_record.cc index 80493354e3..4c8d119347 100644 --- a/sdk/src/logs/readable_log_record.cc +++ b/sdk/src/logs/readable_log_record.cc @@ -1,13 +1,18 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/readable_log_record.h" +#include +#include +#include + +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/logs/readable_log_record.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/version/version.h" - -#include -#include +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/logs/simple_log_record_processor.cc b/sdk/src/logs/simple_log_record_processor.cc index 68f90e83ab..7e65f31ca4 100644 --- a/sdk/src/logs/simple_log_record_processor.cc +++ b/sdk/src/logs/simple_log_record_processor.cc @@ -1,12 +1,19 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/simple_log_record_processor.h" +#include +#include +#include +#include +#include + +#include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/logs/exporter.h" #include "opentelemetry/sdk/logs/recordable.h" - -#include +#include "opentelemetry/sdk/logs/simple_log_record_processor.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/logs/simple_log_record_processor_factory.cc b/sdk/src/logs/simple_log_record_processor_factory.cc index 6146efc174..88e1b4b1ee 100644 --- a/sdk/src/logs/simple_log_record_processor_factory.cc +++ b/sdk/src/logs/simple_log_record_processor_factory.cc @@ -1,8 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h" +#include +#include + +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/processor.h" #include "opentelemetry/sdk/logs/simple_log_record_processor.h" +#include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/metrics/aggregation/histogram_aggregation.cc b/sdk/src/metrics/aggregation/histogram_aggregation.cc index 8e14ddec7a..da725cf09c 100644 --- a/sdk/src/metrics/aggregation/histogram_aggregation.cc +++ b/sdk/src/metrics/aggregation/histogram_aggregation.cc @@ -1,15 +1,23 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h" -#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" -#include "opentelemetry/version.h" - +#include #include -#include +#include #include #include #include +#include +#include + +#include "opentelemetry/common/spin_lock_mutex.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" +#include "opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/metrics/aggregation/lastvalue_aggregation.cc b/sdk/src/metrics/aggregation/lastvalue_aggregation.cc index 50904f8184..0380015234 100644 --- a/sdk/src/metrics/aggregation/lastvalue_aggregation.cc +++ b/sdk/src/metrics/aggregation/lastvalue_aggregation.cc @@ -1,12 +1,21 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/aggregation/lastvalue_aggregation.h" +#include +#include +#include +#include +#include + +#include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/common/timestamp.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" +#include "opentelemetry/sdk/metrics/aggregation/lastvalue_aggregation.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/version.h" -#include - OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { diff --git a/sdk/src/metrics/aggregation/sum_aggregation.cc b/sdk/src/metrics/aggregation/sum_aggregation.cc index 0901a7bbdd..1e0442e92c 100644 --- a/sdk/src/metrics/aggregation/sum_aggregation.cc +++ b/sdk/src/metrics/aggregation/sum_aggregation.cc @@ -1,14 +1,20 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/aggregation/sum_aggregation.h" +#include +#include +#include +#include + +#include "opentelemetry/common/spin_lock_mutex.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" +#include "opentelemetry/sdk/metrics/aggregation/sum_aggregation.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" #include "opentelemetry/sdk/metrics/data/point_data.h" #include "opentelemetry/version.h" -#include -#include - OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { diff --git a/sdk/src/metrics/async_instruments.cc b/sdk/src/metrics/async_instruments.cc index 88f818dad9..311efc1e7e 100644 --- a/sdk/src/metrics/async_instruments.cc +++ b/sdk/src/metrics/async_instruments.cc @@ -1,9 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include #include +#include "opentelemetry/metrics/async_instruments.h" #include "opentelemetry/sdk/metrics/async_instruments.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" diff --git a/sdk/src/metrics/data/circular_buffer.cc b/sdk/src/metrics/data/circular_buffer.cc index e2bd6e8ec0..007bedef6d 100644 --- a/sdk/src/metrics/data/circular_buffer.cc +++ b/sdk/src/metrics/data/circular_buffer.cc @@ -1,7 +1,15 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include + +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/metrics/data/circular_buffer.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/metrics/exemplar/reservoir.cc b/sdk/src/metrics/exemplar/reservoir.cc index d695587a91..4e7501799e 100644 --- a/sdk/src/metrics/exemplar/reservoir.cc +++ b/sdk/src/metrics/exemplar/reservoir.cc @@ -1,13 +1,11 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include - #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW +# include "opentelemetry/sdk/metrics/exemplar/reservoir.h" # include "opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.h" # include "opentelemetry/sdk/metrics/exemplar/no_exemplar_reservoir.h" -# include "opentelemetry/sdk/metrics/exemplar/reservoir.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir_cell.h" # include "opentelemetry/sdk/metrics/exemplar/simple_fixed_size_exemplar_reservoir.h" diff --git a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc index 1de1ea71c8..f6ae47977d 100644 --- a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc +++ b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc @@ -1,12 +1,27 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h" -#include "opentelemetry/common/spin_lock_mutex.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" -#include #if defined(_MSC_VER) # pragma warning(suppress : 5204) # include diff --git a/sdk/src/metrics/export/periodic_exporting_metric_reader_factory.cc b/sdk/src/metrics/export/periodic_exporting_metric_reader_factory.cc index c4f0b8348a..6c85caaa2a 100644 --- a/sdk/src/metrics/export/periodic_exporting_metric_reader_factory.cc +++ b/sdk/src/metrics/export/periodic_exporting_metric_reader_factory.cc @@ -1,8 +1,13 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h" +#include +#include + #include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h" +#include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include "opentelemetry/version.h" diff --git a/sdk/src/metrics/instrument_metadata_validator.cc b/sdk/src/metrics/instrument_metadata_validator.cc index 0b00404447..a63050985e 100644 --- a/sdk/src/metrics/instrument_metadata_validator.cc +++ b/sdk/src/metrics/instrument_metadata_validator.cc @@ -1,12 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/instrument_metadata_validator.h" -#include "opentelemetry/common/macros.h" -#include "opentelemetry/nostd/string_view.h" +#include +#include +#include +#include -#include -#include +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/metrics/instrument_metadata_validator.h" +#include "opentelemetry/version.h" #if OPENTELEMETRY_HAVE_WORKING_REGEX # include diff --git a/sdk/src/metrics/meter.cc b/sdk/src/metrics/meter.cc index 763cdcbe02..f472ac726e 100644 --- a/sdk/src/metrics/meter.cc +++ b/sdk/src/metrics/meter.cc @@ -1,27 +1,46 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include #include - +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/spin_lock_mutex.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/metrics/async_instruments.h" #include "opentelemetry/metrics/noop.h" +#include "opentelemetry/metrics/observer_result.h" +#include "opentelemetry/metrics/sync_instruments.h" #include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/sdk/common/attributemap_hash.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/unique_ptr.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/metrics/async_instruments.h" - -#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/reservoir_utils.h" -#endif - +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter.h" +#include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/state/async_metric_storage.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" +#include "opentelemetry/sdk/metrics/state/metric_storage.h" #include "opentelemetry/sdk/metrics/state/multi_metric_storage.h" #include "opentelemetry/sdk/metrics/state/observable_registry.h" #include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" - -#include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/metrics/sync_instruments.h" -#include "opentelemetry/sdk_config.h" +#include "opentelemetry/sdk/metrics/view/view.h" +#include "opentelemetry/sdk/metrics/view/view_registry.h" +#include "opentelemetry/version.h" -#include +#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW +# include "opentelemetry/sdk/metrics/exemplar/reservoir_utils.h" +#endif OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -30,7 +49,6 @@ namespace metrics { namespace metrics = opentelemetry::metrics; -namespace nostd = opentelemetry::nostd; Meter::Meter( std::weak_ptr meter_context, @@ -40,38 +58,38 @@ Meter::Meter( observable_registry_(new ObservableRegistry()) {} -nostd::unique_ptr> Meter::CreateUInt64Counter( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit) noexcept +opentelemetry::nostd::unique_ptr> Meter::CreateUInt64Counter( + opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept { if (!ValidateInstrument(name, description, unit)) { OTEL_INTERNAL_LOG_ERROR("Meter::CreateUInt64Counter - failed. Invalid parameters." << name << " " << description << " " << unit << ". Measurements won't be recorded."); - return nostd::unique_ptr>( + return opentelemetry::nostd::unique_ptr>( new metrics::NoopCounter(name, description, unit)); } InstrumentDescriptor instrument_descriptor = { std::string{name.data(), name.size()}, std::string{description.data(), description.size()}, std::string{unit.data(), unit.size()}, InstrumentType::kCounter, InstrumentValueType::kLong}; auto storage = RegisterSyncMetricStorage(instrument_descriptor); - return nostd::unique_ptr>( + return opentelemetry::nostd::unique_ptr>( new LongCounter(instrument_descriptor, std::move(storage))); } -nostd::unique_ptr> Meter::CreateDoubleCounter( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit) noexcept +opentelemetry::nostd::unique_ptr> Meter::CreateDoubleCounter( + opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept { if (!ValidateInstrument(name, description, unit)) { OTEL_INTERNAL_LOG_ERROR("Meter::CreateDoubleCounter - failed. Invalid parameters." << name << " " << description << " " << unit << ". Measurements won't be recorded."); - return nostd::unique_ptr>( + return opentelemetry::nostd::unique_ptr>( new metrics::NoopCounter(name, description, unit)); } InstrumentDescriptor instrument_descriptor = { @@ -79,14 +97,14 @@ nostd::unique_ptr> Meter::CreateDoubleCounter( std::string{unit.data(), unit.size()}, InstrumentType::kCounter, InstrumentValueType::kDouble}; auto storage = RegisterSyncMetricStorage(instrument_descriptor); - return nostd::unique_ptr>{ + return opentelemetry::nostd::unique_ptr>{ new DoubleCounter(instrument_descriptor, std::move(storage))}; } -nostd::shared_ptr Meter::CreateInt64ObservableCounter( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit) noexcept +opentelemetry::nostd::shared_ptr +Meter::CreateInt64ObservableCounter(opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept { if (!ValidateInstrument(name, description, unit)) { @@ -100,14 +118,14 @@ nostd::shared_ptr Meter::CreateInt std::string{unit.data(), unit.size()}, InstrumentType::kObservableCounter, InstrumentValueType::kLong}; auto storage = RegisterAsyncMetricStorage(instrument_descriptor); - return nostd::shared_ptr{ + return opentelemetry::nostd::shared_ptr{ new ObservableInstrument(instrument_descriptor, std::move(storage), observable_registry_)}; } -nostd::shared_ptr -Meter::CreateDoubleObservableCounter(nostd::string_view name, - nostd::string_view description, - nostd::string_view unit) noexcept +opentelemetry::nostd::shared_ptr +Meter::CreateDoubleObservableCounter(opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept { if (!ValidateInstrument(name, description, unit)) { @@ -121,21 +139,21 @@ Meter::CreateDoubleObservableCounter(nostd::string_view name, std::string{unit.data(), unit.size()}, InstrumentType::kObservableCounter, InstrumentValueType::kDouble}; auto storage = RegisterAsyncMetricStorage(instrument_descriptor); - return nostd::shared_ptr{ + return opentelemetry::nostd::shared_ptr{ new ObservableInstrument(instrument_descriptor, std::move(storage), observable_registry_)}; } -nostd::unique_ptr> Meter::CreateUInt64Histogram( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit) noexcept +opentelemetry::nostd::unique_ptr> Meter::CreateUInt64Histogram( + opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept { if (!ValidateInstrument(name, description, unit)) { OTEL_INTERNAL_LOG_ERROR("Meter::CreateUInt64Histogram - failed. Invalid parameters." << name << " " << description << " " << unit << ". Measurements won't be recorded."); - return nostd::unique_ptr>( + return opentelemetry::nostd::unique_ptr>( new metrics::NoopHistogram(name, description, unit)); } InstrumentDescriptor instrument_descriptor = { @@ -143,21 +161,21 @@ nostd::unique_ptr> Meter::CreateUInt64Histogram( std::string{unit.data(), unit.size()}, InstrumentType::kHistogram, InstrumentValueType::kLong}; auto storage = RegisterSyncMetricStorage(instrument_descriptor); - return nostd::unique_ptr>{ + return opentelemetry::nostd::unique_ptr>{ new LongHistogram(instrument_descriptor, std::move(storage))}; } -nostd::unique_ptr> Meter::CreateDoubleHistogram( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit) noexcept +opentelemetry::nostd::unique_ptr> Meter::CreateDoubleHistogram( + opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept { if (!ValidateInstrument(name, description, unit)) { OTEL_INTERNAL_LOG_ERROR("Meter::CreateDoubleHistogram - failed. Invalid parameters." << name << " " << description << " " << unit << ". Measurements won't be recorded."); - return nostd::unique_ptr>( + return opentelemetry::nostd::unique_ptr>( new metrics::NoopHistogram(name, description, unit)); } InstrumentDescriptor instrument_descriptor = { @@ -165,14 +183,14 @@ nostd::unique_ptr> Meter::CreateDoubleHistogram( std::string{unit.data(), unit.size()}, InstrumentType::kHistogram, InstrumentValueType::kDouble}; auto storage = RegisterSyncMetricStorage(instrument_descriptor); - return nostd::unique_ptr>{ + return opentelemetry::nostd::unique_ptr>{ new DoubleHistogram(instrument_descriptor, std::move(storage))}; } -nostd::shared_ptr Meter::CreateInt64ObservableGauge( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit) noexcept +opentelemetry::nostd::shared_ptr +Meter::CreateInt64ObservableGauge(opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept { if (!ValidateInstrument(name, description, unit)) { @@ -186,14 +204,14 @@ nostd::shared_ptr Meter::CreateInt std::string{unit.data(), unit.size()}, InstrumentType::kObservableGauge, InstrumentValueType::kLong}; auto storage = RegisterAsyncMetricStorage(instrument_descriptor); - return nostd::shared_ptr{ + return opentelemetry::nostd::shared_ptr{ new ObservableInstrument(instrument_descriptor, std::move(storage), observable_registry_)}; } -nostd::shared_ptr Meter::CreateDoubleObservableGauge( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit) noexcept +opentelemetry::nostd::shared_ptr +Meter::CreateDoubleObservableGauge(opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept { if (!ValidateInstrument(name, description, unit)) { @@ -207,21 +225,21 @@ nostd::shared_ptr Meter::CreateDou std::string{unit.data(), unit.size()}, InstrumentType::kObservableGauge, InstrumentValueType::kDouble}; auto storage = RegisterAsyncMetricStorage(instrument_descriptor); - return nostd::shared_ptr{ + return opentelemetry::nostd::shared_ptr{ new ObservableInstrument(instrument_descriptor, std::move(storage), observable_registry_)}; } -nostd::unique_ptr> Meter::CreateInt64UpDownCounter( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit) noexcept +opentelemetry::nostd::unique_ptr> Meter::CreateInt64UpDownCounter( + opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept { if (!ValidateInstrument(name, description, unit)) { OTEL_INTERNAL_LOG_ERROR("Meter::CreateInt64UpDownCounter - failed. Invalid parameters." << name << " " << description << " " << unit << ". Measurements won't be recorded."); - return nostd::unique_ptr>( + return opentelemetry::nostd::unique_ptr>( new metrics::NoopUpDownCounter(name, description, unit)); } InstrumentDescriptor instrument_descriptor = { @@ -229,21 +247,21 @@ nostd::unique_ptr> Meter::CreateInt64UpDownCount std::string{unit.data(), unit.size()}, InstrumentType::kUpDownCounter, InstrumentValueType::kLong}; auto storage = RegisterSyncMetricStorage(instrument_descriptor); - return nostd::unique_ptr>{ + return opentelemetry::nostd::unique_ptr>{ new LongUpDownCounter(instrument_descriptor, std::move(storage))}; } -nostd::unique_ptr> Meter::CreateDoubleUpDownCounter( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit) noexcept +opentelemetry::nostd::unique_ptr> Meter::CreateDoubleUpDownCounter( + opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept { if (!ValidateInstrument(name, description, unit)) { OTEL_INTERNAL_LOG_ERROR("Meter::CreateDoubleUpDownCounter - failed. Invalid parameters." << name << " " << description << " " << unit << ". Measurements won't be recorded."); - return nostd::unique_ptr>( + return opentelemetry::nostd::unique_ptr>( new metrics::NoopUpDownCounter(name, description, unit)); } InstrumentDescriptor instrument_descriptor = { @@ -251,14 +269,14 @@ nostd::unique_ptr> Meter::CreateDoubleUpDownCount std::string{unit.data(), unit.size()}, InstrumentType::kUpDownCounter, InstrumentValueType::kDouble}; auto storage = RegisterSyncMetricStorage(instrument_descriptor); - return nostd::unique_ptr>{ + return opentelemetry::nostd::unique_ptr>{ new DoubleUpDownCounter(instrument_descriptor, std::move(storage))}; } -nostd::shared_ptr -Meter::CreateInt64ObservableUpDownCounter(nostd::string_view name, - nostd::string_view description, - nostd::string_view unit) noexcept +opentelemetry::nostd::shared_ptr +Meter::CreateInt64ObservableUpDownCounter(opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept { if (!ValidateInstrument(name, description, unit)) { @@ -272,14 +290,14 @@ Meter::CreateInt64ObservableUpDownCounter(nostd::string_view name, std::string{unit.data(), unit.size()}, InstrumentType::kObservableUpDownCounter, InstrumentValueType::kLong}; auto storage = RegisterAsyncMetricStorage(instrument_descriptor); - return nostd::shared_ptr{ + return opentelemetry::nostd::shared_ptr{ new ObservableInstrument(instrument_descriptor, std::move(storage), observable_registry_)}; } -nostd::shared_ptr -Meter::CreateDoubleObservableUpDownCounter(nostd::string_view name, - nostd::string_view description, - nostd::string_view unit) noexcept +opentelemetry::nostd::shared_ptr +Meter::CreateDoubleObservableUpDownCounter(opentelemetry::nostd::string_view name, + opentelemetry::nostd::string_view description, + opentelemetry::nostd::string_view unit) noexcept { if (!ValidateInstrument(name, description, unit)) { @@ -293,7 +311,7 @@ Meter::CreateDoubleObservableUpDownCounter(nostd::string_view name, std::string{unit.data(), unit.size()}, InstrumentType::kObservableUpDownCounter, InstrumentValueType::kDouble}; auto storage = RegisterAsyncMetricStorage(instrument_descriptor); - return nostd::shared_ptr{ + return opentelemetry::nostd::shared_ptr{ new ObservableInstrument(instrument_descriptor, std::move(storage), observable_registry_)}; } diff --git a/sdk/src/metrics/meter_context.cc b/sdk/src/metrics/meter_context.cc index 2b5ef3148c..de32c469d8 100644 --- a/sdk/src/metrics/meter_context.cc +++ b/sdk/src/metrics/meter_context.cc @@ -1,14 +1,33 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/meter_context.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/spin_lock_mutex.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/span.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/metrics/meter.h" +#include "opentelemetry/sdk/metrics/meter_context.h" #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/metrics/state/metric_collector.h" -#include "opentelemetry/sdk_config.h" - -#include +#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" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/metrics/meter_context_factory.cc b/sdk/src/metrics/meter_context_factory.cc index d41bb6a193..59e97ce264 100644 --- a/sdk/src/metrics/meter_context_factory.cc +++ b/sdk/src/metrics/meter_context_factory.cc @@ -1,10 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/meter_context_factory.h" +#include +#include + #include "opentelemetry/sdk/metrics/meter_context.h" +#include "opentelemetry/sdk/metrics/meter_context_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" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/sdk/src/metrics/meter_provider.cc b/sdk/src/metrics/meter_provider.cc index 84a0f56bf4..959ff32800 100644 --- a/sdk/src/metrics/meter_provider.cc +++ b/sdk/src/metrics/meter_provider.cc @@ -1,18 +1,29 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include #include #include #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/metrics/meter.h" +#include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/span.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/metrics/export/metric_producer.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/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" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/sdk/src/metrics/metric_reader.cc b/sdk/src/metrics/metric_reader.cc index 8046b1c148..e2f5bc1f1c 100644 --- a/sdk/src/metrics/metric_reader.cc +++ b/sdk/src/metrics/metric_reader.cc @@ -4,8 +4,7 @@ #include "opentelemetry/sdk/metrics/metric_reader.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" - -#include +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/metrics/state/metric_collector.cc b/sdk/src/metrics/state/metric_collector.cc index f0535a905d..5ecf41cecf 100644 --- a/sdk/src/metrics/state/metric_collector.cc +++ b/sdk/src/metrics/state/metric_collector.cc @@ -1,12 +1,22 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/state/metric_collector.h" +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/meter.h" #include "opentelemetry/sdk/metrics/meter_context.h" #include "opentelemetry/sdk/metrics/metric_reader.h" -#include "opentelemetry/sdk_config.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/sdk/src/metrics/state/observable_registry.cc b/sdk/src/metrics/state/observable_registry.cc index 86a6d17abd..4da46ddfe3 100644 --- a/sdk/src/metrics/state/observable_registry.cc +++ b/sdk/src/metrics/state/observable_registry.cc @@ -1,11 +1,29 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/state/observable_registry.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/metrics/async_instruments.h" +#include "opentelemetry/metrics/observer_result.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/metrics/async_instruments.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/observer_result.h" #include "opentelemetry/sdk/metrics/state/metric_storage.h" -#include "opentelemetry/sdk_config.h" +#include "opentelemetry/sdk/metrics/state/observable_registry.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/metrics/state/sync_metric_storage.cc b/sdk/src/metrics/state/sync_metric_storage.cc index 72bee72ea5..fe736e64f3 100644 --- a/sdk/src/metrics/state/sync_metric_storage.cc +++ b/sdk/src/metrics/state/sync_metric_storage.cc @@ -1,7 +1,20 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include + +#include "opentelemetry/common/spin_lock_mutex.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" +#include "opentelemetry/sdk/metrics/state/metric_collector.h" #include "opentelemetry/sdk/metrics/state/sync_metric_storage.h" +#include "opentelemetry/sdk/metrics/state/temporal_metric_storage.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/metrics/state/temporal_metric_storage.cc b/sdk/src/metrics/state/temporal_metric_storage.cc index f988551108..2ba74d9213 100644 --- a/sdk/src/metrics/state/temporal_metric_storage.cc +++ b/sdk/src/metrics/state/temporal_metric_storage.cc @@ -1,16 +1,30 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/state/temporal_metric_storage.h" +#include +#include +#include +#include +#include +#include +#include +#include + #include "opentelemetry/common/spin_lock_mutex.h" -#include "opentelemetry/metrics/meter.h" +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/attributemap_hash.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" +#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" #include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/metrics/state/attributes_hashmap.h" #include "opentelemetry/sdk/metrics/state/metric_collector.h" - -#include -#include -#include +#include "opentelemetry/sdk/metrics/state/temporal_metric_storage.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/metrics/sync_instruments.cc b/sdk/src/metrics/sync_instruments.cc index bdeff150ae..a99fa80868 100644 --- a/sdk/src/metrics/sync_instruments.cc +++ b/sdk/src/metrics/sync_instruments.cc @@ -1,9 +1,19 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include + +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/state/metric_storage.h" #include "opentelemetry/sdk/metrics/sync_instruments.h" - -#include +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/src/metrics/view/view_factory.cc b/sdk/src/metrics/view/view_factory.cc index 24d87769f9..36496f62d6 100644 --- a/sdk/src/metrics/view/view_factory.cc +++ b/sdk/src/metrics/view/view_factory.cc @@ -1,8 +1,15 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/metrics/view/view_factory.h" +#include +#include +#include + +#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/view/attributes_processor.h" #include "opentelemetry/sdk/metrics/view/view.h" +#include "opentelemetry/sdk/metrics/view/view_factory.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/sdk/src/trace/batch_span_processor.cc b/sdk/src/trace/batch_span_processor.cc index 7759949490..c5e72f8176 100644 --- a/sdk/src/trace/batch_span_processor.cc +++ b/sdk/src/trace/batch_span_processor.cc @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include #include #include #include @@ -13,7 +14,6 @@ #include #include -#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" From 9af3c99cf03765b64279d2df654772fd53d79490 Mon Sep 17 00:00:00 2001 From: Darren Bolduc Date: Sat, 15 Jun 2024 12:20:57 -0400 Subject: [PATCH 19/44] [BUILD] Restore Bazel flag removed from public API (#2702) --- api/BUILD | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/BUILD b/api/BUILD index 2eca1de986..fdfe3ca146 100644 --- a/api/BUILD +++ b/api/BUILD @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -load("@bazel_skylib//rules:common_settings.bzl", "string_flag") +load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag") package(default_visibility = ["//visibility:public"]) @@ -55,3 +55,9 @@ config_setting( constraint_values = ["@bazel_tools//tools/cpp:msvc"], flag_values = {":with_cxx_stdlib": "best"}, ) + +bool_flag( + name = "with_abseil", + build_setting_default = False, + deprecation = "The value of this flag is ignored. Bazel builds always depend on Abseil for its pre-adopted `std::` types. You should remove this flag from your build command.", +) From 05bfb8a2578aa7af8145b0bb0e3fd9e87b60dd71 Mon Sep 17 00:00:00 2001 From: Yijie Ma Date: Sun, 16 Jun 2024 23:51:42 -0700 Subject: [PATCH 20/44] [DOC] Fix typo tace_id -> trace_id in logger.h (#2703) --- api/include/opentelemetry/logs/logger.h | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/api/include/opentelemetry/logs/logger.h b/api/include/opentelemetry/logs/logger.h index 46fd8bca72..dc09a0c2b4 100644 --- a/api/include/opentelemetry/logs/logger.h +++ b/api/include/opentelemetry/logs/logger.h @@ -54,9 +54,9 @@ class Logger * Severity -> severity, severity_text * string_view -> body * AttributeValue -> body - * SpanContext -> span_id,tace_id and trace_flags + * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id - * TraceId -> tace_id + * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp @@ -86,9 +86,9 @@ class Logger * Severity -> severity, severity_text * string_view -> body * AttributeValue -> body - * SpanContext -> span_id,tace_id and trace_flags + * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id - * TraceId -> tace_id + * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp @@ -109,9 +109,9 @@ class Logger * @tparam args Arguments which can be used to set data of log record by type. * string_view -> body * AttributeValue -> body - * SpanContext -> span_id,tace_id and trace_flags + * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id - * TraceId -> tace_id + * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp @@ -133,9 +133,9 @@ class Logger * @tparam args Arguments which can be used to set data of log record by type. * string_view -> body * AttributeValue -> body - * SpanContext -> span_id,tace_id and trace_flags + * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id - * TraceId -> tace_id + * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp @@ -157,9 +157,9 @@ class Logger * @tparam args Arguments which can be used to set data of log record by type. * string_view -> body * AttributeValue -> body - * SpanContext -> span_id,tace_id and trace_flags + * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id - * TraceId -> tace_id + * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp @@ -181,9 +181,9 @@ class Logger * @tparam args Arguments which can be used to set data of log record by type. * string_view -> body * AttributeValue -> body - * SpanContext -> span_id,tace_id and trace_flags + * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id - * TraceId -> tace_id + * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp @@ -205,9 +205,9 @@ class Logger * @tparam args Arguments which can be used to set data of log record by type. * string_view -> body * AttributeValue -> body - * SpanContext -> span_id,tace_id and trace_flags + * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id - * TraceId -> tace_id + * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp @@ -229,9 +229,9 @@ class Logger * @tparam args Arguments which can be used to set data of log record by type. * string_view -> body * AttributeValue -> body - * SpanContext -> span_id,tace_id and trace_flags + * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id - * TraceId -> tace_id + * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp From 595801bab9ace8b0930b97183a2d9a28adb5d1fe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Jun 2024 13:11:37 +0200 Subject: [PATCH 21/44] Bump docker/build-push-action from 5 to 6 (#2705) Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v5...v6) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dependencies_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependencies_image.yml b/.github/workflows/dependencies_image.yml index 723fd1256b..0c7bad843f 100644 --- a/.github/workflows/dependencies_image.yml +++ b/.github/workflows/dependencies_image.yml @@ -21,7 +21,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build Image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: builder: ${{ steps.buildx.outputs.name }} context: ci/ From aff26ac503b1cd7e0b038cd9bb627c332fdd7036 Mon Sep 17 00:00:00 2001 From: Ehsan Saei <71217171+esigo@users.noreply.github.com> Date: Wed, 19 Jun 2024 09:25:08 +0200 Subject: [PATCH 22/44] [CI] Enable ARM64 build in CI (#2699) --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++++ ci/setup_cmake.sh | 9 +++++++++ ci/setup_gcc10.sh | 10 ++++++++++ 3 files changed, 50 insertions(+) create mode 100755 ci/setup_cmake.sh create mode 100755 ci/setup_gcc10.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26c692953c..8c17bbece0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,37 @@ on: branches: [ main ] jobs: + arm64_test: + name: CMake test arm64 (with modern protobuf,grpc and abseil) + runs-on: actuated-arm64-4cpu-16gb + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - name: setup + env: + PROTOBUF_VERSION: '23.3' + ABSEIL_CPP_VERSION: '20230125.3' + CXX_STANDARD: '14' + CC: /usr/bin/gcc-10 + CXX: /usr/bin/g++-10 + run: | + sudo -E ./ci/setup_gcc10.sh + sudo -E ./ci/setup_cmake.sh + sudo -E ./ci/setup_ci_environment.sh + sudo -E ./ci/setup_googletest.sh + sudo -E ./ci/install_abseil.sh + sudo -E ./ci/install_protobuf.sh + - name: run otlp exporter tests + env: + CC: /usr/bin/gcc-10 + CXX: /usr/bin/g++-10 + WITH_ABSEIL: 'ON' + CXX_STANDARD: '14' + run: | + sudo -E ./ci/setup_grpc.sh -m -p protobuf -p abseil-cpp + ./ci/do_ci.sh cmake.exporter.otprotocol.test + cmake_test: name: CMake test (without otlp-exporter) runs-on: ubuntu-latest diff --git a/ci/setup_cmake.sh b/ci/setup_cmake.sh new file mode 100755 index 0000000000..0cb5d7eb79 --- /dev/null +++ b/ci/setup_cmake.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +set -e +apt-get update +apt-get install --no-install-recommends --no-install-suggests -y \ + cmake diff --git a/ci/setup_gcc10.sh b/ci/setup_gcc10.sh new file mode 100755 index 0000000000..119d361cbf --- /dev/null +++ b/ci/setup_gcc10.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +set -e +apt-get update +apt-get install --no-install-recommends --no-install-suggests -y \ + g++-10 \ + gcc-10 From e1d96901fc9f41d79244e35c4209649d22b9fe9d Mon Sep 17 00:00:00 2001 From: Harish <140232061+perhapsmaple@users.noreply.github.com> Date: Thu, 20 Jun 2024 12:50:57 +0530 Subject: [PATCH 23/44] [Code health] Remove Unicode Text from Source files (#2707) Signed-off-by: perhapsmaple <140232061+perhapsmaple@users.noreply.github.com> --- api/include/opentelemetry/baggage/baggage.h | 2 +- api/include/opentelemetry/context/context.h | 2 +- api/include/opentelemetry/context/runtime_context.h | 2 +- ext/test/http/url_parser_test.cc | 3 ++- opentracing-shim/src/span_shim.cc | 2 +- sdk/test/metrics/instrument_metadata_validator_test.cc | 10 +++++----- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/api/include/opentelemetry/baggage/baggage.h b/api/include/opentelemetry/baggage/baggage.h index 66eb9d9833..6c799cda27 100644 --- a/api/include/opentelemetry/baggage/baggage.h +++ b/api/include/opentelemetry/baggage/baggage.h @@ -1,4 +1,4 @@ -// Copyright The OpenTelemetry Authors +// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once diff --git a/api/include/opentelemetry/context/context.h b/api/include/opentelemetry/context/context.h index d0b53c3ea8..cf5c9cd319 100644 --- a/api/include/opentelemetry/context/context.h +++ b/api/include/opentelemetry/context/context.h @@ -1,4 +1,4 @@ -// Copyright The OpenTelemetry Authors +// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once diff --git a/api/include/opentelemetry/context/runtime_context.h b/api/include/opentelemetry/context/runtime_context.h index 2cd5b0ff90..cccc71e32f 100644 --- a/api/include/opentelemetry/context/runtime_context.h +++ b/api/include/opentelemetry/context/runtime_context.h @@ -1,4 +1,4 @@ -// Copyright The OpenTelemetry Authors +// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once diff --git a/ext/test/http/url_parser_test.cc b/ext/test/http/url_parser_test.cc index 212c5655a7..7b28d763e6 100644 --- a/ext/test/http/url_parser_test.cc +++ b/ext/test/http/url_parser_test.cc @@ -140,7 +140,8 @@ TEST(UrlDecoderTests, BasicTests) std::map testdata{ {"Authentication=Basic xxx", "Authentication=Basic xxx"}, {"Authentication=Basic%20xxx", "Authentication=Basic xxx"}, - {"%C3%B6%C3%A0%C2%A7%C3%96abcd%C3%84", "öà§ÖabcdÄ"}, + {"%C3%B6%C3%A0%C2%A7%C3%96abcd%C3%84", + "\xc3\xb6\xc3\xa0\xc2\xa7\xc3\x96\x61\x62\x63\x64\xc3\x84"}, {"%2x", "%2x"}, {"%20", " "}, {"text%2", "text%2"}, diff --git a/opentracing-shim/src/span_shim.cc b/opentracing-shim/src/span_shim.cc index 808b6b9e74..7911277f78 100644 --- a/opentracing-shim/src/span_shim.cc +++ b/opentracing-shim/src/span_shim.cc @@ -111,7 +111,7 @@ void SpanShim::Log(opentracing::SystemTime timestamp, void SpanShim::logImpl(nostd::span fields, const opentracing::SystemTime *const timestamp) noexcept { - // The Add Event’s name parameter MUST be the value with the event key + // The Add Event's name parameter MUST be the value with the event key // in the pair set, or else fallback to use the log literal string. const auto &event = std::find_if(fields.begin(), fields.end(), [](const EventEntry &item) { return item.first == "event"; }); diff --git a/sdk/test/metrics/instrument_metadata_validator_test.cc b/sdk/test/metrics/instrument_metadata_validator_test.cc index 17b76a9419..172df1af3c 100644 --- a/sdk/test/metrics/instrument_metadata_validator_test.cc +++ b/sdk/test/metrics/instrument_metadata_validator_test.cc @@ -19,14 +19,14 @@ TEST(InstrumentMetadataValidator, TestName) { opentelemetry::sdk::metrics::InstrumentMetaDataValidator validator; std::vector invalid_names = { - "", // empty string - "1sdf", // string starting with number - "123€AAA€BBB", // unicode characters + "", // empty string + "1sdf", // string starting with number + "\x31\x32\x33\xe2\x82\xac\x41\x41\x41\xe2\x82\xac\x42\x42\x42" // unicode characters "/\\sdsd", // string starting with special character "***sSSs", // string starting with special character "a\\broken\\path", // contains backward slash CreateVeryLargeString(25) + "X", // total 256 characters - CreateVeryLargeString(26), // string much bigger than 255 characters + CreateVeryLargeString(26), // string much bigger than 255 character }; for (auto const &str : invalid_names) { @@ -56,7 +56,7 @@ TEST(InstrumentMetadataValidator, TestUnit) std::vector invalid_units = { CreateVeryLargeString(5) + "ABCERTYGJ", // total 64 charactes CreateVeryLargeString(7), // string bigger than 63 chars - "123€AAA€BBB", // unicode string + "\x31\x32\x33\xe2\x82\xac\x41\x41\x41\xe2\x82\xac\x42\x42\x42", // unicode string }; for (auto const &str : invalid_units) { From 086e94cdbd10c742b07ca3b351157e253c9152eb Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Fri, 21 Jun 2024 15:35:34 +0800 Subject: [PATCH 24/44] [BUILD] Add option `WITH_OTLP_GRPC_SSL_MTLS_PREVIEW` (#2714) --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d7831b2a4..711ac14c4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -211,6 +211,9 @@ if(DEFINED WITH_OTLP) ) endif() +option(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW + "Whether to enable mTLS support fro gRPC" OFF) + option(WITH_OTLP_GRPC "Whether to include the OTLP gRPC exporter in the SDK" OFF) From 4e86a86a5fbb5b72c0adb4ded18c49400fc8685f Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Fri, 21 Jun 2024 17:14:09 +0800 Subject: [PATCH 25/44] [EXPORTER] All 2xx return codes should be considered successful. (#2712) --- exporters/elasticsearch/src/es_log_record_exporter.cc | 2 +- exporters/otlp/src/otlp_http_client.cc | 2 +- exporters/zipkin/src/zipkin_exporter.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/exporters/elasticsearch/src/es_log_record_exporter.cc b/exporters/elasticsearch/src/es_log_record_exporter.cc index e58fb1dda4..3b3e8c4aeb 100644 --- a/exporters/elasticsearch/src/es_log_record_exporter.cc +++ b/exporters/elasticsearch/src/es_log_record_exporter.cc @@ -59,7 +59,7 @@ class ResponseHandler : public http_client::EventHandler // Store the body of the request body_ = std::string(response.GetBody().begin(), response.GetBody().end()); - if (response.GetStatusCode() != 200 && response.GetStatusCode() != 202) + if (!(response.GetStatusCode() >= 200 && response.GetStatusCode() <= 299)) { log_message = BuildResponseLogMessage(response, body_); diff --git a/exporters/otlp/src/otlp_http_client.cc b/exporters/otlp/src/otlp_http_client.cc index 6a1b89164e..8bada1e0e0 100644 --- a/exporters/otlp/src/otlp_http_client.cc +++ b/exporters/otlp/src/otlp_http_client.cc @@ -100,7 +100,7 @@ class ResponseHandler : public http_client::EventHandler // Store the body of the request body_ = std::string(response.GetBody().begin(), response.GetBody().end()); - if (response.GetStatusCode() != 200 && response.GetStatusCode() != 202) + if (!(response.GetStatusCode() >= 200 && response.GetStatusCode() <= 299)) { log_message = BuildResponseLogMessage(response, body_); diff --git a/exporters/zipkin/src/zipkin_exporter.cc b/exporters/zipkin/src/zipkin_exporter.cc index 97fdf4e63a..a8a97b58af 100644 --- a/exporters/zipkin/src/zipkin_exporter.cc +++ b/exporters/zipkin/src/zipkin_exporter.cc @@ -78,7 +78,7 @@ sdk::common::ExportResult ZipkinExporter::Export( http_client::Body body_v(body_s.begin(), body_s.end()); auto result = http_client_->PostNoSsl(url_parser_.url_, body_v, options_.headers); if (result && - (result.GetResponse().GetStatusCode() == 200 || result.GetResponse().GetStatusCode() == 202)) + (result.GetResponse().GetStatusCode() >= 200 && result.GetResponse().GetStatusCode() <= 299)) { return sdk::common::ExportResult::kSuccess; } From fd57e7aa23ffc352f62e504f34fd1c6b7b2ecac3 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Fri, 21 Jun 2024 19:13:20 +0200 Subject: [PATCH 26/44] [RELEASE] Release opentelemetry-cpp version 1.16.0 (#2711) --- CHANGELOG.md | 69 +++++++++++++++++-- api/include/opentelemetry/version.h | 4 +- docs/public/conf.py | 2 +- .../opentelemetry/sdk/version/version.h | 2 +- sdk/src/version/version.cc | 8 +-- 5 files changed, 73 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2c08c6065..6edb724131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,17 +15,78 @@ Increment the: ## [Unreleased] -* [SDK] Update ExemplarFilter and ExemplarReservoir for spec - [#2372](https://github.com/open-telemetry/opentelemetry-cpp/pull/2372) +## [1.16.0] 2024-06-21 +* [BUILD] Upgrade bazel abseil from 20220623.1 to 20230802.2 + [#2650](https://github.com/open-telemetry/opentelemetry-cpp/pull/2650) +* [BUILD] Use nostd::enable_if_t instead of std::enable_if_t + [#2648](https://github.com/open-telemetry/opentelemetry-cpp/pull/2648) +* [EXEMPLAR] Update ExemplarFilter and ExemplarReservoir for spec + [#2372](https://github.com/open-telemetry/opentelemetry-cpp/pull/2372) +* [BUILD] Link CoreFoundation on apple systems + [#2655](https://github.com/open-telemetry/opentelemetry-cpp/pull/2655) +* [SDK] Avoid missing conditional variable update and simplify atomic bool + [#2553](https://github.com/open-telemetry/opentelemetry-cpp/pull/2553) +* [BUILD] Build break in OLTP_FILE tests + [#2659](https://github.com/open-telemetry/opentelemetry-cpp/pull/2659) +* [EXPORTER] General cleanup for is_shutdown flags in exporters. + [#2663](https://github.com/open-telemetry/opentelemetry-cpp/pull/2663) +* [CI] Upgrade Maintainers CI to ubuntu-24.04 + [#2670](https://github.com/open-telemetry/opentelemetry-cpp/pull/2670) +* [BUILD] Upgrade to opentelemetry-proto 1.3.1 + [#2669](https://github.com/open-telemetry/opentelemetry-cpp/pull/2669) +* [API] Return NoopLogRecord from NoopLogger + [#2668](https://github.com/open-telemetry/opentelemetry-cpp/pull/2668) +* [BUILD] Remove the hard-coded separator in tracestate + [#2672](https://github.com/open-telemetry/opentelemetry-cpp/pull/2672) +* [SDK] Fix forceflush may wait for ever + [#2584](https://github.com/open-telemetry/opentelemetry-cpp/pull/2584) +* [API] DO not allow unsafe Logger::EmitLogRecord + [#2673](https://github.com/open-telemetry/opentelemetry-cpp/pull/2673) +* [BUILD] Read default proto version from third_party_release + [#2677](https://github.com/open-telemetry/opentelemetry-cpp/pull/2677) +* [CI] include-what-you-use + [#2629](https://github.com/open-telemetry/opentelemetry-cpp/pull/2629) * [CI] Upgrade to clang-format 18 [#2684](https://github.com/open-telemetry/opentelemetry-cpp/pull/2684) - +* [CI] Fix CI failures on Ubuntu 24.04 + [#2686](https://github.com/open-telemetry/opentelemetry-cpp/pull/2686) +* [SEMANTIC CONVENTIONS] Upgrade to version 1.26.0 + [#2687](https://github.com/open-telemetry/opentelemetry-cpp/pull/2687) * [API/SDK] Provider cleanup [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) - +* [ETW] Add table name mapping for Logs other than the default Log table + [#2691](https://github.com/open-telemetry/opentelemetry-cpp/pull/2691) +* [CI] Remove benchmark overlay for vcpkg + [#2695](https://github.com/open-telemetry/opentelemetry-cpp/pull/2695) +* [BUILD] Remove the incorrect set of CMAKE_MSVC_RUNTIME_LIBRARY for vcpkg + [#2696](https://github.com/open-telemetry/opentelemetry-cpp/pull/2696) +* [BUILD] CMakeLists.txt: Enable CMAKE_MSVC_RUNTIME_LIBRARY support + [#2652](https://github.com/open-telemetry/opentelemetry-cpp/pull/2652) +* [EXPORTER] OTLP file: use thread-safe file/io + [#2675](https://github.com/open-telemetry/opentelemetry-cpp/pull/2675) +* [bazel] Bump version and deps + [#2679](https://github.com/open-telemetry/opentelemetry-cpp/pull/2679) +* [BUILD] Add support for bzlmod + [#2608](https://github.com/open-telemetry/opentelemetry-cpp/pull/2608) +* [BUILD] Fix Import Abseil-cpp + [#2701](https://github.com/open-telemetry/opentelemetry-cpp/pull/2701) * [Code health] include-what-you-use cleanup [#2692](https://github.com/open-telemetry/opentelemetry-cpp/pull/2692) +* [BUILD] Restore Bazel flag removed from public API + [#2702](https://github.com/open-telemetry/opentelemetry-cpp/pull/2702) +* [DOC] Fix typo tace_id -> trace_id in logger.h + [#2703](https://github.com/open-telemetry/opentelemetry-cpp/pull/2703) +* Bump docker/build-push-action from 5 to 6 + [#2705](https://github.com/open-telemetry/opentelemetry-cpp/pull/2705) +* [CI] Enable ARM64 build in CI + [#2699](https://github.com/open-telemetry/opentelemetry-cpp/pull/2699) +* [Code health] Remove Unicode Text from Source files + [#2707](https://github.com/open-telemetry/opentelemetry-cpp/pull/2707) +* [BUILD] Add option WITH_OTLP_GRPC_SSL_MTLS_PREVIEW + [#2714](https://github.com/open-telemetry/opentelemetry-cpp/pull/2714) +* [EXPORTER] All 2xx return codes should be considered successful. + [#2712](https://github.com/open-telemetry/opentelemetry-cpp/pull/2712) Important changes: diff --git a/api/include/opentelemetry/version.h b/api/include/opentelemetry/version.h index 6e8a24a2d4..e09c193659 100644 --- a/api/include/opentelemetry/version.h +++ b/api/include/opentelemetry/version.h @@ -10,9 +10,9 @@ # define OPENTELEMETRY_ABI_VERSION_NO 1 #endif -#define OPENTELEMETRY_VERSION "1.15.0" +#define OPENTELEMETRY_VERSION "1.16.0" #define OPENTELEMETRY_VERSION_MAJOR 1 -#define OPENTELEMETRY_VERSION_MINOR 15 +#define OPENTELEMETRY_VERSION_MINOR 16 #define OPENTELEMETRY_VERSION_PATCH 0 #define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO) diff --git a/docs/public/conf.py b/docs/public/conf.py index 1747696a30..927e07751a 100644 --- a/docs/public/conf.py +++ b/docs/public/conf.py @@ -24,7 +24,7 @@ author = 'OpenTelemetry authors' # The full version, including alpha/beta/rc tags -release = "1.15.0" +release = "1.16.0" # Run sphinx on subprojects and copy output # ----------------------------------------- diff --git a/sdk/include/opentelemetry/sdk/version/version.h b/sdk/include/opentelemetry/sdk/version/version.h index f98c5c433f..bfc93238b4 100644 --- a/sdk/include/opentelemetry/sdk/version/version.h +++ b/sdk/include/opentelemetry/sdk/version/version.h @@ -3,7 +3,7 @@ #pragma once -#define OPENTELEMETRY_SDK_VERSION "1.15.0" +#define OPENTELEMETRY_SDK_VERSION "1.16.0" #include "opentelemetry/version.h" diff --git a/sdk/src/version/version.cc b/sdk/src/version/version.cc index 71d8db16e2..e5fdbda99d 100644 --- a/sdk/src/version/version.cc +++ b/sdk/src/version/version.cc @@ -12,13 +12,13 @@ namespace sdk namespace version { const int major_version = 1; -const int minor_version = 15; +const int minor_version = 16; const int patch_version = 0; const char *pre_release = "NONE"; const char *build_metadata = "NONE"; -const char *short_version = "1.15.0"; -const char *full_version = "1.15.0-NONE-NONE"; -const char *build_date = "Sun Apr 21 19:31:02 UTC 2024"; +const char *short_version = "1.16.0"; +const char *full_version = "1.16.0-NONE-NONE"; +const char *build_date = "Fri Jun 21 16:41:17 UTC 2024"; } // namespace version } // namespace sdk OPENTELEMETRY_END_NAMESPACE From 77012391b272c016b15611092626dec4c21c54bb Mon Sep 17 00:00:00 2001 From: Dat Le <4686348+tdat00@users.noreply.github.com> Date: Thu, 27 Jun 2024 14:01:41 +0700 Subject: [PATCH 27/44] [BUILD] Add bazel missing BUILD file (#2720) --- examples/etw_threads/BUILD | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/etw_threads/BUILD diff --git a/examples/etw_threads/BUILD b/examples/etw_threads/BUILD new file mode 100644 index 0000000000..edb60080eb --- /dev/null +++ b/examples/etw_threads/BUILD @@ -0,0 +1,18 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +cc_binary( + name = "example_etw_threads", + srcs = [ + "main.cc", + ], + tags = [ + "etw", + "examples", + ], + target_compatible_with = ["@platforms//os:windows"], + deps = [ + "//api", + "//exporters/etw:etw_exporter", + ], +) From f0e0ef0bf3e769b609de3fd1d79a5b615b8bc881 Mon Sep 17 00:00:00 2001 From: Siddhartha Malladi Date: Thu, 27 Jun 2024 18:14:31 -0400 Subject: [PATCH 28/44] [SDK] Added reserve for spans array in BatchSpanProcessor. (#2724) * Added reserve for spans array in BatchSpanProcessor. Added reserve for spans array in BatchSpanProcessor. Helps to allocate the amount of memory needed for number of records so that dynamic memory allocation doesn't happen in the consume method. .push_back() reallocates memory each time the method is called. Using .reserve() would avoid memory reallocation as already the memory is allocated. References: https://cplusplus.com/reference/vector/vector/push_back/ https://cplusplus.com/reference/vector/vector/reserve/ * Added reserve for spans array in BatchLogProcessor. Added reserve for spans array in BatchLogProcessor. Same as previously done for BatchSpanProcessor * Update batch_log_record_processor.cc * Update batch_span_processor.cc * Update sdk/src/logs/batch_log_record_processor.cc --- sdk/src/logs/batch_log_record_processor.cc | 2 ++ sdk/src/trace/batch_span_processor.cc | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/sdk/src/logs/batch_log_record_processor.cc b/sdk/src/logs/batch_log_record_processor.cc index c85d56739e..f5c35ad339 100644 --- a/sdk/src/logs/batch_log_record_processor.cc +++ b/sdk/src/logs/batch_log_record_processor.cc @@ -208,6 +208,8 @@ void BatchLogRecordProcessor::Export() break; } + // Reserve space for the number of records + records_arr.reserve(num_records_to_export); buffer_.Consume(num_records_to_export, [&](CircularBufferRange> range) noexcept { range.ForEach([&](AtomicUniquePtr &ptr) { diff --git a/sdk/src/trace/batch_span_processor.cc b/sdk/src/trace/batch_span_processor.cc index c5e72f8176..03b79f6ebb 100644 --- a/sdk/src/trace/batch_span_processor.cc +++ b/sdk/src/trace/batch_span_processor.cc @@ -206,6 +206,10 @@ void BatchSpanProcessor::Export() NotifyCompletion(notify_force_flush, exporter_, synchronization_data_); break; } + + // Reserve space for the number of records + spans_arr.reserve(num_records_to_export); + buffer_.Consume(num_records_to_export, [&](CircularBufferRange> range) noexcept { range.ForEach([&](AtomicUniquePtr &ptr) { From ead2d1b6062473c354a9ca91f65e322170acb001 Mon Sep 17 00:00:00 2001 From: Pravila Date: Sun, 30 Jun 2024 13:47:06 +0100 Subject: [PATCH 29/44] [DOC] Update "Using triplets" section in building-with-vcpkg documentation. (#2726) * Update triplet links in building-with-vcpkg documentation. * Update docs/building-with-vcpkg.md Co-authored-by: Tom Tan --------- Co-authored-by: Marc Alff Co-authored-by: Tom Tan --- docs/building-with-vcpkg.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/building-with-vcpkg.md b/docs/building-with-vcpkg.md index aace95460c..70d794d5cf 100644 --- a/docs/building-with-vcpkg.md +++ b/docs/building-with-vcpkg.md @@ -67,12 +67,12 @@ logs in case if you encounter package installation failures. In order to enable custom build flags - vcpkg triplets and custom environment variables may be used. Please see [triplets instruction -here](https://vcpkg.readthedocs.io/en/latest/users/triplets/). Response file for +here](https://learn.microsoft.com/en-us/vcpkg/users/triplets). Response file for a custom build, e.g. `response_file_linux_PRODUCTNAME.txt` may specify a custom triplet. For example, custom triplet controls if the library is built as static -or dynamic. Default triplets may also be overridden with [custom -triplets](https://vcpkg.readthedocs.io/en/latest/examples/overlay-triplets-linux-dynamic/#overlay-triplets-example). -Custom triplets specific to various products must be maintained by product +or dynamic. Default triplets may also be overridden with [overlay +triplets](https://learn.microsoft.com/en-us/vcpkg/users/examples/overlay-triplets-linux-dynamic). +Overlay triplets specific to various products must be maintained by product teams. Product teams may optionally decide to integrate their triplets in the mainline OpenTelemetry C++ SDK repo as-needed. From 5e21b8ac2dec059d89f515e67600a0c11d15d19f Mon Sep 17 00:00:00 2001 From: Dylan Herman Date: Sun, 30 Jun 2024 14:42:19 -0700 Subject: [PATCH 30/44] [DOC] Remove comment for unused LoggerProvider initialization params (#2972) --- sdk/include/opentelemetry/sdk/logs/logger_provider.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/logs/logger_provider.h b/sdk/include/opentelemetry/sdk/logs/logger_provider.h index bf116b4272..6c035ad5e9 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_provider.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_provider.h @@ -36,10 +36,6 @@ class OPENTELEMETRY_EXPORT LoggerProvider final : public opentelemetry::logs::Lo * @param processor The span processor for this logger provider. This must * not be a nullptr. * @param resource The resources for this logger provider. - * @param sampler The sampler for this logger provider. This must - * not be a nullptr. - * @param id_generator The custom id generator for this logger provider. This must - * not be a nullptr */ explicit LoggerProvider(std::unique_ptr &&processor, opentelemetry::sdk::resource::Resource resource = From 42563e41602bd29fba7ea00082a4df4a4f8c7676 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Tue, 2 Jul 2024 20:42:54 +0200 Subject: [PATCH 31/44] [SECURITY] Remove OTLP HTTP support for TLS 1.0 and TLS 1.1, require TLS 1.2 (#2722) --- CHANGELOG.md | 19 ++++++ .../exporters/otlp/otlp_environment.h | 2 +- .../ext/http/client/http_client.h | 8 +-- .../http/client/curl/http_operation_curl.cc | 40 +++++------- functional/otlp/func_http_main.cc | 62 +++++++++++++++---- 5 files changed, 86 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6edb724131..92e234a77b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,25 @@ Increment the: ## [Unreleased] +* [SECURITY] Remove OTLP HTTP support for TLS 1.0 and TLS 1.1, + require TLS 1.2 or better + [#2721](https://github.com/open-telemetry/opentelemetry-cpp/pull/2721) + +Breaking changes: + +* [SECURITY] Remove OTLP HTTP support for TLS 1.0 and TLS 1.1, + require TLS 1.2 or better + [#2721](https://github.com/open-telemetry/opentelemetry-cpp/pull/2721) + * The OTLP HTTP exporter no longer accept options like: + * min_TLS = 1.0 + * min_TLS = 1.1 + * max_TLS = 1.0 + * max_TLS = 1.1 + * When connecting to an OTLP HTTP endpoint, using `https`, + the connection will require TLS 1.2 by default, + unless min_TLS is set to 1.3 + * Plain `http` connections (insecure) are not affected. + ## [1.16.0] 2024-06-21 * [BUILD] Upgrade bazel abseil from 20220623.1 to 20230802.2 diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_environment.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_environment.h index c2e0afb7bc..8b486a548f 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_environment.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_environment.h @@ -111,7 +111,7 @@ std::string GetOtlpDefaultTracesSslTlsMaxVersion(); std::string GetOtlpDefaultMetricsSslTlsMaxVersion(); std::string GetOtlpDefaultLogsSslTlsMaxVersion(); -// For TLS 1.0, 1.1, 1.2 +// For TLS 1.2 std::string GetOtlpDefaultTracesSslTlsCipher(); std::string GetOtlpDefaultMetricsSslTlsCipher(); std::string GetOtlpDefaultLogsSslTlsCipher(); diff --git a/ext/include/opentelemetry/ext/http/client/http_client.h b/ext/include/opentelemetry/ext/http/client/http_client.h index b3cf7365eb..1089402e28 100644 --- a/ext/include/opentelemetry/ext/http/client/http_client.h +++ b/ext/include/opentelemetry/ext/http/client/http_client.h @@ -192,9 +192,7 @@ struct HttpSslOptions /** Minimum SSL version to use. Valid values are: - - empty (no minimum version required) - - "1.0" (TLSv1.0) - - "1.1" (TLSv1.1) + - empty (defaults to TLSv1.2) - "1.2" (TLSv1.2) - "1.3" (TLSv1.3) */ @@ -204,8 +202,6 @@ struct HttpSslOptions Maximum SSL version to use. Valid values are: - empty (no maximum version required) - - "1.0" (TLSv1.0) - - "1.1" (TLSv1.1) - "1.2" (TLSv1.2) - "1.3" (TLSv1.3) */ @@ -213,7 +209,7 @@ struct HttpSslOptions /** TLS Cipher. - This is for TLS 1.0, 1.1 and 1.2. + This is for TLS 1.2. The list is delimited by colons (":"). Cipher names depends on the underlying CURL implementation. */ diff --git a/ext/src/http/client/curl/http_operation_curl.cc b/ext/src/http/client/curl/http_operation_curl.cc index 25f43fcb2f..fe06384414 100644 --- a/ext/src/http/client/curl/http_operation_curl.cc +++ b/ext/src/http/client/curl/http_operation_curl.cc @@ -414,16 +414,16 @@ void HttpOperation::Cleanup() To represent versions, the following symbols are needed: Added in CURL 7.34.0: - - CURL_SSLVERSION_TLSv1_0 - - CURL_SSLVERSION_TLSv1_1 + - CURL_SSLVERSION_TLSv1_0 (do not use) + - CURL_SSLVERSION_TLSv1_1 (do not use) - CURL_SSLVERSION_TLSv1_2 Added in CURL 7.52.0: - CURL_SSLVERSION_TLSv1_3 Added in CURL 7.54.0: - - CURL_SSLVERSION_MAX_TLSv1_0 - - CURL_SSLVERSION_MAX_TLSv1_1 + - CURL_SSLVERSION_MAX_TLSv1_0 (do not use) + - CURL_SSLVERSION_MAX_TLSv1_1 (do not use) - CURL_SSLVERSION_MAX_TLSv1_2 - CURL_SSLVERSION_MAX_TLSv1_3 @@ -439,16 +439,6 @@ void HttpOperation::Cleanup() static long parse_min_ssl_version(std::string version) { #ifdef HAVE_TLS_VERSION - if (version == "1.0") - { - return CURL_SSLVERSION_TLSv1_0; - } - - if (version == "1.1") - { - return CURL_SSLVERSION_TLSv1_1; - } - if (version == "1.2") { return CURL_SSLVERSION_TLSv1_2; @@ -466,16 +456,6 @@ static long parse_min_ssl_version(std::string version) static long parse_max_ssl_version(std::string version) { #ifdef HAVE_TLS_VERSION - if (version == "1.0") - { - return CURL_SSLVERSION_MAX_TLSv1_0; - } - - if (version == "1.1") - { - return CURL_SSLVERSION_MAX_TLSv1_1; - } - if (version == "1.2") { return CURL_SSLVERSION_MAX_TLSv1_2; @@ -730,7 +710,12 @@ CURLcode HttpOperation::Setup() /* 4 - TLS */ +#ifdef HAVE_TLS_VERSION + /* By default, TLSv1.2 or better is required (if we have TLS). */ + long min_ssl_version = CURL_SSLVERSION_TLSv1_2; +#else long min_ssl_version = 0; +#endif if (!ssl_options_.ssl_min_tls.empty()) { @@ -748,6 +733,11 @@ CURLcode HttpOperation::Setup() #endif } + /* + * Do not set a max TLS version by default. + * The CURL + openssl library may be more recent than this code, + * and support a version we do not know about. + */ long max_ssl_version = 0; if (!ssl_options_.ssl_max_tls.empty()) @@ -780,7 +770,7 @@ CURLcode HttpOperation::Setup() if (!ssl_options_.ssl_cipher.empty()) { - /* TLS 1.0, 1.1, 1.2 */ + /* TLS 1.2 */ const char *cipher_list = ssl_options_.ssl_cipher.c_str(); rc = SetCurlStrOption(CURLOPT_SSL_CIPHER_LIST, cipher_list); diff --git a/functional/otlp/func_http_main.cc b/functional/otlp/func_http_main.cc index 9cd3585668..08b7807998 100644 --- a/functional/otlp/func_http_main.cc +++ b/functional/otlp/func_http_main.cc @@ -54,6 +54,8 @@ struct TestResult bool found_request_send_failure = false; bool found_export_error = false; bool found_export_success = false; + bool found_unknown_min_tls = false; + bool found_unknown_max_tls = false; void reset() { @@ -62,6 +64,8 @@ struct TestResult found_request_send_failure = false; found_export_error = false; found_export_success = false; + found_unknown_min_tls = false; + found_unknown_max_tls = false; } }; @@ -96,6 +100,20 @@ void parse_error_msg(TestResult *result, std::string msg) { result->found_export_error = true; } + + static std::string unknown_min_tls("Unknown min TLS version"); + + if (msg.find(unknown_min_tls) != std::string::npos) + { + result->found_unknown_min_tls = true; + } + + static std::string unknown_max_tls("Unknown max TLS version"); + + if (msg.find(unknown_max_tls) != std::string::npos) + { + result->found_unknown_max_tls = true; + } } void parse_warning_msg(TestResult * /* result */, std::string /* msg */) {} @@ -507,6 +525,24 @@ int expect_request_send_failed() return TEST_FAILED; } +int expect_unknown_min_tls() +{ + if (g_test_result.found_export_error && g_test_result.found_unknown_min_tls) + { + return TEST_PASSED; + } + return TEST_FAILED; +} + +int expect_unknown_max_tls() +{ + if (g_test_result.found_export_error && g_test_result.found_unknown_max_tls) + { + return TEST_PASSED; + } + return TEST_FAILED; +} + int expect_export_failed() { /* @@ -928,7 +964,7 @@ int test_min_tls_unknown() return expect_export_failed(); } - return expect_connection_failed(); + return expect_unknown_min_tls(); } int test_min_tls_10() @@ -963,7 +999,7 @@ int test_min_tls_10() return expect_connection_failed(); } - return expect_success(); + return expect_unknown_min_tls(); } int test_min_tls_11() @@ -998,7 +1034,7 @@ int test_min_tls_11() return expect_connection_failed(); } - return expect_success(); + return expect_unknown_min_tls(); } int test_min_tls_12() @@ -1098,7 +1134,7 @@ int test_max_tls_unknown() return expect_export_failed(); } - return expect_connection_failed(); + return expect_unknown_max_tls(); } int test_max_tls_10() @@ -1134,7 +1170,7 @@ int test_max_tls_10() } // No support for TLS 1.0 - return expect_connection_failed(); + return expect_unknown_max_tls(); } int test_max_tls_11() @@ -1170,7 +1206,7 @@ int test_max_tls_11() } // No support for TLS 1.1 - return expect_connection_failed(); + return expect_unknown_max_tls(); } int test_max_tls_12() @@ -1277,7 +1313,7 @@ int test_range_tls_10() } // No support for TLS 1.0 - return expect_connection_failed(); + return expect_unknown_min_tls(); } int test_range_tls_11() @@ -1314,7 +1350,7 @@ int test_range_tls_11() } // No support for TLS 1.0 - return expect_connection_failed(); + return expect_unknown_min_tls(); } int test_range_tls_12() @@ -1423,7 +1459,7 @@ int test_range_tls_10_11() } // No support for TLS 1.0, TLS 1.1 - return expect_connection_failed(); + return expect_unknown_min_tls(); } int test_range_tls_10_12() @@ -1459,7 +1495,7 @@ int test_range_tls_10_12() return expect_connection_failed(); } - return expect_success(); + return expect_unknown_min_tls(); } int test_range_tls_10_13() @@ -1495,7 +1531,7 @@ int test_range_tls_10_13() return expect_connection_failed(); } - return expect_success(); + return expect_unknown_min_tls(); } int test_range_tls_11_10() @@ -1563,7 +1599,7 @@ int test_range_tls_11_12() return expect_connection_failed(); } - return expect_success(); + return expect_unknown_min_tls(); } int test_range_tls_11_13() @@ -1599,7 +1635,7 @@ int test_range_tls_11_13() return expect_connection_failed(); } - return expect_success(); + return expect_unknown_min_tls(); } int test_range_tls_12_10() From f6dca999b5ec011af07fb2e86cc7e9c1eaa6e80a Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 3 Jul 2024 18:04:05 +0200 Subject: [PATCH 32/44] [TEST] Fix opentelemetry-collector bind address (#2989) --- functional/otlp/otel-config-http.yaml | 1 + functional/otlp/otel-config-https.yaml | 1 + functional/otlp/otel-docker-config-http.yaml | 1 + functional/otlp/otel-docker-config-https.yaml | 1 + 4 files changed, 4 insertions(+) diff --git a/functional/otlp/otel-config-http.yaml b/functional/otlp/otel-config-http.yaml index 39c264c747..da68e6f96c 100644 --- a/functional/otlp/otel-config-http.yaml +++ b/functional/otlp/otel-config-http.yaml @@ -10,6 +10,7 @@ receivers: otlp: protocols: http: + endpoint: 0.0.0.0:4318 processors: batch: diff --git a/functional/otlp/otel-config-https.yaml b/functional/otlp/otel-config-https.yaml index 611bba828f..f106baf8b6 100644 --- a/functional/otlp/otel-config-https.yaml +++ b/functional/otlp/otel-config-https.yaml @@ -10,6 +10,7 @@ receivers: otlp: protocols: http: + endpoint: 0.0.0.0:4318 tls: ca_file: ../cert/ca.pem cert_file: ../cert/server_cert.pem diff --git a/functional/otlp/otel-docker-config-http.yaml b/functional/otlp/otel-docker-config-http.yaml index f8e5ad45d3..c18f0e54a4 100644 --- a/functional/otlp/otel-docker-config-http.yaml +++ b/functional/otlp/otel-docker-config-http.yaml @@ -9,6 +9,7 @@ receivers: otlp: protocols: http: + endpoint: 0.0.0.0:4318 processors: batch: diff --git a/functional/otlp/otel-docker-config-https.yaml b/functional/otlp/otel-docker-config-https.yaml index 9b3422bf5e..db8f2b3756 100644 --- a/functional/otlp/otel-docker-config-https.yaml +++ b/functional/otlp/otel-docker-config-https.yaml @@ -9,6 +9,7 @@ receivers: otlp: protocols: http: + endpoint: 0.0.0.0:4318 tls: ca_file: /otel-cpp/ca.pem cert_file: /otel-cpp/server_cert.pem From 0ff58e8334dc9c5b7cbf0f8088f174dd5ddbd538 Mon Sep 17 00:00:00 2001 From: Mats Taraldsvik Date: Fri, 5 Jul 2024 19:16:32 +0200 Subject: [PATCH 33/44] [EXPORTER] Fix references in AttributeValueVisitor (#2985) --- .../include/opentelemetry/exporters/ostream/common_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/common_utils.h b/exporters/ostream/include/opentelemetry/exporters/ostream/common_utils.h index ec1ee2d367..ec860794f0 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/common_utils.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/common_utils.h @@ -87,7 +87,7 @@ class AttributeValueVisitor print_value(arg, sout_); } - void operator()(const nostd::string_view &&arg) { sout_.write(arg.data(), arg.size()); } + void operator()(nostd::string_view &&arg) { sout_.write(arg.data(), arg.size()); } private: std::ostream &sout_; From 6dbfdb52ebca82d8705392fe88dadd9c133374e4 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Sat, 6 Jul 2024 17:16:02 +0200 Subject: [PATCH 34/44] [Code health] include-what-you-use cleanup, part 2 (#2704) --- .github/workflows/iwyu.yml | 8 +++ api/include/opentelemetry/std/shared_ptr.h | 4 +- api/include/opentelemetry/std/span.h | 2 + api/include/opentelemetry/std/string_view.h | 2 + api/include/opentelemetry/std/type_traits.h | 2 + api/include/opentelemetry/std/unique_ptr.h | 4 +- api/include/opentelemetry/std/utility.h | 2 + api/include/opentelemetry/std/variant.h | 2 + cmake/opentelemetry-proto.cmake | 6 ++ examples/batch/main.cc | 5 +- examples/common/foo_library/foo_library.cc | 1 - .../common/logs_foo_library/foo_library.cc | 5 +- .../common/metrics_foo_library/foo_library.cc | 36 ++++++------ examples/multithreaded/main.cc | 5 +- examples/otlp/file_log_main.cc | 19 +++--- examples/otlp/file_main.cc | 13 +++-- examples/otlp/file_metric_main.cc | 25 ++++---- examples/otlp/http_log_main.cc | 18 ++++-- examples/otlp/http_main.cc | 11 +++- examples/otlp/http_metric_main.cc | 22 ++++--- examples/plugin/load/main.cc | 2 +- examples/plugin/plugin/factory_impl.cc | 1 - examples/plugin/plugin/tracer.cc | 2 - examples/plugin/plugin/tracer.h | 1 - examples/zipkin/main.cc | 9 +++ exporters/ostream/src/span_exporter.cc | 1 - .../exporters/otlp/otlp_environment.h | 12 ++-- .../exporters/otlp/otlp_file_client.h | 9 +-- .../exporters/otlp/otlp_file_exporter.h | 13 +++-- .../otlp/otlp_file_exporter_factory.h | 1 + .../otlp/otlp_file_log_record_exporter.h | 14 ++--- .../otlp_file_log_record_exporter_factory.h | 1 + .../otlp/otlp_file_metric_exporter.h | 14 ++--- .../otlp/otlp_file_metric_exporter_factory.h | 1 + .../opentelemetry/exporters/otlp/otlp_http.h | 3 +- .../exporters/otlp/otlp_http_client.h | 16 ++--- .../exporters/otlp/otlp_http_exporter.h | 17 +++--- .../otlp/otlp_http_exporter_factory.h | 1 + .../otlp/otlp_http_exporter_options.h | 8 +-- .../otlp/otlp_http_log_record_exporter.h | 15 +++-- .../otlp_http_log_record_exporter_factory.h | 5 +- .../otlp_http_log_record_exporter_options.h | 8 +-- .../otlp/otlp_http_metric_exporter.h | 14 ++--- .../otlp/otlp_http_metric_exporter_factory.h | 5 +- .../otlp/otlp_http_metric_exporter_options.h | 8 +-- .../exporters/otlp/otlp_metric_utils.h | 32 +++++++--- .../otlp/otlp_populate_attribute_utils.h | 31 ++++++++-- .../exporters/otlp/otlp_recordable.h | 22 +++++-- .../exporters/otlp/otlp_recordable_utils.h | 36 +++++++++--- exporters/otlp/src/otlp_environment.cc | 17 ++++-- exporters/otlp/src/otlp_file_client.cc | 7 +-- exporters/otlp/src/otlp_file_exporter.cc | 25 +++++--- .../otlp/src/otlp_file_log_record_exporter.cc | 24 ++++++-- .../otlp/src/otlp_file_metric_exporter.cc | 25 ++++++-- exporters/otlp/src/otlp_http_client.cc | 58 ++++++++++--------- exporters/otlp/src/otlp_http_exporter.cc | 32 +++++++--- .../otlp/src/otlp_http_exporter_options.cc | 9 +-- .../otlp/src/otlp_http_log_record_exporter.cc | 32 +++++++--- .../otlp_http_log_record_exporter_options.cc | 9 +-- .../otlp/src/otlp_http_metric_exporter.cc | 30 +++++++--- .../src/otlp_http_metric_exporter_options.cc | 10 ++-- exporters/otlp/src/otlp_log_recordable.cc | 19 ++++-- exporters/otlp/src/otlp_metric_utils.cc | 23 ++++++++ .../otlp/src/otlp_populate_attribute_utils.cc | 22 +++++++ exporters/otlp/src/otlp_recordable.cc | 30 +++++++++- exporters/otlp/src/otlp_recordable_utils.cc | 43 +++++++++----- exporters/otlp/test/otlp_recordable_test.cc | 6 ++ .../exporters/zipkin/recordable.h | 14 +++++ .../exporters/zipkin/zipkin_exporter.h | 18 +++--- .../zipkin/zipkin_exporter_factory.h | 1 + exporters/zipkin/src/recordable.cc | 27 ++++++++- exporters/zipkin/src/zipkin_exporter.cc | 21 ++++++- .../zipkin/src/zipkin_exporter_factory.cc | 2 + .../ext/http/client/curl/http_client_curl.h | 21 ++++--- ext/src/http/client/curl/http_client_curl.cc | 26 ++++++++- .../client/curl/http_client_factory_curl.cc | 2 + .../http/client/curl/http_operation_curl.cc | 21 ++++++- functional/otlp/func_http_main.cc | 19 +++++- sdk/src/logs/logger.cc | 1 - sdk/src/logs/logger_provider.cc | 2 - sdk/src/logs/readable_log_record.cc | 1 - sdk/src/metrics/meter.cc | 1 - sdk/src/metrics/meter_provider.cc | 2 - sdk/src/metrics/state/observable_registry.cc | 1 - sdk/src/trace/tracer.cc | 2 - sdk/src/trace/tracer_provider.cc | 2 - 86 files changed, 761 insertions(+), 338 deletions(-) diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 29b8274fbd..598f57e97e 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -36,10 +36,18 @@ jobs: TOPDIR=`pwd` mkdir build && cd build CC="clang" CXX="clang++" cmake \ + -DCMAKE_CXX_STANDARD=14 \ + -DWITH_STL=CXX14 \ -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;" \ -DBUILD_TESTING=OFF \ -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DBUILD_W3CTRACECONTEXT_TEST=OFF \ + -DWITH_OTLP_GRPC=OFF \ + -DWITH_OTLP_HTTP=ON \ + -DWITH_OTLP_FILE=ON \ + -DWITH_OTLP_HTTP_COMPRESSION=ON \ + -DWITH_ZIPKIN=ON \ + -DWITH_PROMETHEUS=OFF \ .. - name: iwyu_tool diff --git a/api/include/opentelemetry/std/shared_ptr.h b/api/include/opentelemetry/std/shared_ptr.h index b1b99bd36c..8b855b08c6 100644 --- a/api/include/opentelemetry/std/shared_ptr.h +++ b/api/include/opentelemetry/std/shared_ptr.h @@ -3,7 +3,9 @@ #pragma once -#include +// IWYU pragma: private, include "opentelemetry/nostd/shared_ptr.h" + +#include // IWYU pragma: export #include "opentelemetry/version.h" diff --git a/api/include/opentelemetry/std/span.h b/api/include/opentelemetry/std/span.h index 1160d54fbe..5d20e0227f 100644 --- a/api/include/opentelemetry/std/span.h +++ b/api/include/opentelemetry/std/span.h @@ -3,6 +3,8 @@ #pragma once +// IWYU pragma: private, include "opentelemetry/nostd/span.h" + #include "opentelemetry/version.h" // Standard library implementation requires at least C++17 compiler. diff --git a/api/include/opentelemetry/std/string_view.h b/api/include/opentelemetry/std/string_view.h index 5295eb4544..d0f0c08125 100644 --- a/api/include/opentelemetry/std/string_view.h +++ b/api/include/opentelemetry/std/string_view.h @@ -3,6 +3,8 @@ #pragma once +// IWYU pragma: private, include "opentelemetry/nostd/string_view.h" + #include #include "opentelemetry/version.h" diff --git a/api/include/opentelemetry/std/type_traits.h b/api/include/opentelemetry/std/type_traits.h index f26af95b94..074f796798 100644 --- a/api/include/opentelemetry/std/type_traits.h +++ b/api/include/opentelemetry/std/type_traits.h @@ -3,6 +3,8 @@ #pragma once +// IWYU pragma: private, include "opentelemetry/nostd/type_traits.h" + #include #include "opentelemetry/version.h" diff --git a/api/include/opentelemetry/std/unique_ptr.h b/api/include/opentelemetry/std/unique_ptr.h index 1d7d9b1fc7..4b25b7c381 100644 --- a/api/include/opentelemetry/std/unique_ptr.h +++ b/api/include/opentelemetry/std/unique_ptr.h @@ -3,7 +3,9 @@ #pragma once -#include +// IWYU pragma: private, include "opentelemetry/nostd/unique_ptr.h" + +#include // IWYU pragma: export #include "opentelemetry/version.h" diff --git a/api/include/opentelemetry/std/utility.h b/api/include/opentelemetry/std/utility.h index be0f1e5f46..d1f5614d7c 100644 --- a/api/include/opentelemetry/std/utility.h +++ b/api/include/opentelemetry/std/utility.h @@ -3,6 +3,8 @@ #pragma once +// IWYU pragma: private, include "opentelemetry/nostd/utility.h" + #include #include diff --git a/api/include/opentelemetry/std/variant.h b/api/include/opentelemetry/std/variant.h index 6acdb81e9a..58bc510c5f 100644 --- a/api/include/opentelemetry/std/variant.h +++ b/api/include/opentelemetry/std/variant.h @@ -3,6 +3,8 @@ #pragma once +// IWYU pragma: private, include "opentelemetry/nostd/variant.h" + #include "opentelemetry/version.h" #include diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake index 19516c3b71..62197068e2 100644 --- a/cmake/opentelemetry-proto.cmake +++ b/cmake/opentelemetry-proto.cmake @@ -326,6 +326,12 @@ add_library( ${LOGS_SERVICE_PB_CPP_FILE} ${METRICS_SERVICE_PB_CPP_FILE}) +# Disable include-what-you-use on generated code. +set_target_properties( + opentelemetry_proto + PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "" +) + if(WITH_ABSEIL) target_link_libraries(opentelemetry_proto PUBLIC absl::bad_variant_access) endif() diff --git a/examples/batch/main.cc b/examples/batch/main.cc index 2a7fba4630..677feca424 100644 --- a/examples/batch/main.cc +++ b/examples/batch/main.cc @@ -5,13 +5,11 @@ #include #include #include -#include #include #include #include #include "opentelemetry/exporters/ostream/span_exporter_factory.h" -#include "opentelemetry/nostd/detail/decay.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/batch_span_processor_factory.h" @@ -30,7 +28,6 @@ namespace trace_api = opentelemetry::trace; namespace resource = opentelemetry::sdk::resource; namespace trace_sdk = opentelemetry::sdk::trace; namespace trace_exporter = opentelemetry::exporter::trace; -namespace nostd = opentelemetry::nostd; namespace { @@ -69,7 +66,7 @@ void CleanupTracer() trace_api::Provider::SetTracerProvider(none); } -nostd::shared_ptr get_tracer() +opentelemetry::nostd::shared_ptr get_tracer() { auto provider = trace_api::Provider::GetTracerProvider(); return provider->GetTracer("foo_library"); diff --git a/examples/common/foo_library/foo_library.cc b/examples/common/foo_library/foo_library.cc index e336bc5e4c..6dd7792e48 100644 --- a/examples/common/foo_library/foo_library.cc +++ b/examples/common/foo_library/foo_library.cc @@ -3,7 +3,6 @@ #include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/sdk/version/version.h" #include "opentelemetry/trace/provider.h" #include "opentelemetry/trace/scope.h" diff --git a/examples/common/logs_foo_library/foo_library.cc b/examples/common/logs_foo_library/foo_library.cc index 23402563c6..510c3956d4 100644 --- a/examples/common/logs_foo_library/foo_library.cc +++ b/examples/common/logs_foo_library/foo_library.cc @@ -16,17 +16,16 @@ namespace logs = opentelemetry::logs; namespace trace = opentelemetry::trace; -namespace nostd = opentelemetry::nostd; namespace { -nostd::shared_ptr get_tracer() +opentelemetry::nostd::shared_ptr get_tracer() { auto provider = trace::Provider::GetTracerProvider(); return provider->GetTracer("foo_library", OPENTELEMETRY_SDK_VERSION); } -nostd::shared_ptr get_logger() +opentelemetry::nostd::shared_ptr get_logger() { auto provider = logs::Provider::GetLoggerProvider(); return provider->GetLogger("foo_library_logger", "foo_library"); diff --git a/examples/common/metrics_foo_library/foo_library.cc b/examples/common/metrics_foo_library/foo_library.cc index dd5f23297b..c4be2b530f 100644 --- a/examples/common/metrics_foo_library/foo_library.cc +++ b/examples/common/metrics_foo_library/foo_library.cc @@ -17,17 +17,17 @@ #include "opentelemetry/metrics/meter_provider.h" #include "opentelemetry/metrics/observer_result.h" #include "opentelemetry/metrics/provider.h" +#include "opentelemetry/metrics/sync_instruments.h" #include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/nostd/variant.h" -namespace nostd = opentelemetry::nostd; namespace metrics_api = opentelemetry::metrics; namespace { -static nostd::shared_ptr double_observable_counter; +static opentelemetry::nostd::shared_ptr + double_observable_counter; std::map get_random_attr() { @@ -45,13 +45,15 @@ class MeasurementFetcher public: static void Fetcher(opentelemetry::metrics::ObserverResult observer_result, void * /* state */) { - if (nostd::holds_alternative< - nostd::shared_ptr>>(observer_result)) + if (opentelemetry::nostd::holds_alternative< + opentelemetry::nostd::shared_ptr>>( + observer_result)) { double random_incr = (rand() % 5) + 1.1; value_ += random_incr; std::map labels = get_random_attr(); - nostd::get>>( + opentelemetry::nostd::get< + opentelemetry::nostd::shared_ptr>>( observer_result) ->Observe(value_, labels); } @@ -63,10 +65,10 @@ double MeasurementFetcher::value_ = 0.0; void foo_library::counter_example(const std::string &name) { - std::string counter_name = name + "_counter"; - auto provider = metrics_api::Provider::GetMeterProvider(); - nostd::shared_ptr meter = provider->GetMeter(name, "1.2.0"); - auto double_counter = meter->CreateDoubleCounter(counter_name); + std::string counter_name = name + "_counter"; + auto provider = metrics_api::Provider::GetMeterProvider(); + opentelemetry::nostd::shared_ptr meter = provider->GetMeter(name, "1.2.0"); + auto double_counter = meter->CreateDoubleCounter(counter_name); for (uint32_t i = 0; i < 20; ++i) { @@ -78,10 +80,10 @@ void foo_library::counter_example(const std::string &name) void foo_library::observable_counter_example(const std::string &name) { - std::string counter_name = name + "_observable_counter"; - auto provider = metrics_api::Provider::GetMeterProvider(); - nostd::shared_ptr meter = provider->GetMeter(name, "1.2.0"); - double_observable_counter = meter->CreateDoubleObservableCounter(counter_name); + std::string counter_name = name + "_observable_counter"; + auto provider = metrics_api::Provider::GetMeterProvider(); + opentelemetry::nostd::shared_ptr meter = provider->GetMeter(name, "1.2.0"); + double_observable_counter = meter->CreateDoubleObservableCounter(counter_name); double_observable_counter->AddCallback(MeasurementFetcher::Fetcher, nullptr); for (uint32_t i = 0; i < 20; ++i) { @@ -91,9 +93,9 @@ void foo_library::observable_counter_example(const std::string &name) void foo_library::histogram_example(const std::string &name) { - std::string histogram_name = name + "_histogram"; - auto provider = metrics_api::Provider::GetMeterProvider(); - nostd::shared_ptr meter = provider->GetMeter(name, "1.2.0"); + std::string histogram_name = name + "_histogram"; + auto provider = metrics_api::Provider::GetMeterProvider(); + opentelemetry::nostd::shared_ptr meter = provider->GetMeter(name, "1.2.0"); auto histogram_counter = meter->CreateDoubleHistogram(histogram_name, "des", "unit"); auto context = opentelemetry::context::Context{}; for (uint32_t i = 0; i < 20; ++i) diff --git a/examples/multithreaded/main.cc b/examples/multithreaded/main.cc index 9dd76647c5..d92a4ab2ac 100644 --- a/examples/multithreaded/main.cc +++ b/examples/multithreaded/main.cc @@ -2,14 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include #include #include #include #include #include "opentelemetry/exporters/ostream/span_exporter_factory.h" -#include "opentelemetry/nostd/detail/decay.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/processor.h" @@ -25,7 +23,6 @@ namespace trace_api = opentelemetry::trace; namespace trace_sdk = opentelemetry::sdk::trace; -namespace nostd = opentelemetry::nostd; namespace { @@ -46,7 +43,7 @@ void CleanupTracer() trace_api::Provider::SetTracerProvider(none); } -nostd::shared_ptr get_tracer() +opentelemetry::nostd::shared_ptr get_tracer() { auto provider = trace_api::Provider::GetTracerProvider(); return provider->GetTracer("foo_library"); diff --git a/examples/otlp/file_log_main.cc b/examples/otlp/file_log_main.cc index 9254c9947f..30eb71cc2b 100644 --- a/examples/otlp/file_log_main.cc +++ b/examples/otlp/file_log_main.cc @@ -1,27 +1,32 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include + #include "opentelemetry/exporters/otlp/otlp_file_client_options.h" #include "opentelemetry/exporters/otlp/otlp_file_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_file_exporter_options.h" #include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter_options.h" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/logs/logger_provider.h" #include "opentelemetry/logs/provider.h" -#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/nostd/shared_ptr.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/recordable.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/recordable.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 -#include -#include +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/tracer_provider.h" #ifdef BAZEL_BUILD # include "examples/common/logs_foo_library/foo_library.h" diff --git a/examples/otlp/file_main.cc b/examples/otlp/file_main.cc index 13db0e4ad1..243ad44428 100644 --- a/examples/otlp/file_main.cc +++ b/examples/otlp/file_main.cc @@ -1,16 +1,21 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_file_client_options.h" #include "opentelemetry/exporters/otlp/otlp_file_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_file_exporter_options.h" #include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.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 -#include -#include +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/tracer_provider.h" #ifdef BAZEL_BUILD # include "examples/common/foo_library/foo_library.h" diff --git a/examples/otlp/file_metric_main.cc b/examples/otlp/file_metric_main.cc index b99d77a609..ce259005be 100644 --- a/examples/otlp/file_metric_main.cc +++ b/examples/otlp/file_metric_main.cc @@ -1,21 +1,26 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/exporters/otlp/otlp_file_client_options.h" #include "opentelemetry/exporters/otlp/otlp_file_metric_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_file_metric_exporter_options.h" +#include "opentelemetry/metrics/meter_provider.h" #include "opentelemetry/metrics/provider.h" -#include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" -#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h" #include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h" -#include "opentelemetry/sdk/metrics/meter.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h" +#include "opentelemetry/sdk/metrics/meter_context.h" #include "opentelemetry/sdk/metrics/meter_context_factory.h" -#include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/meter_provider_factory.h" - -#include -#include -#include -#include -#include +#include "opentelemetry/sdk/metrics/metric_reader.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" #ifdef BAZEL_BUILD # include "examples/common/metrics_foo_library/foo_library.h" diff --git a/examples/otlp/http_log_main.cc b/examples/otlp/http_log_main.cc index e2b219de1c..38aa009d04 100644 --- a/examples/otlp/http_log_main.cc +++ b/examples/otlp/http_log_main.cc @@ -1,23 +1,33 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" #include "opentelemetry/exporters/otlp/otlp_http_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" #include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" +#include "opentelemetry/logs/log_record.h" +#include "opentelemetry/logs/logger_provider.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/recordable.h" #include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h" #include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.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 -#include +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/tracer_provider.h" #ifdef BAZEL_BUILD # include "examples/common/logs_foo_library/foo_library.h" diff --git a/examples/otlp/http_main.cc b/examples/otlp/http_main.cc index 9ad476bd47..6217bdcb34 100644 --- a/examples/otlp/http_main.cc +++ b/examples/otlp/http_main.cc @@ -1,16 +1,23 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" #include "opentelemetry/exporters/otlp/otlp_http_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.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 +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/tracer_provider.h" #ifdef BAZEL_BUILD # include "examples/common/foo_library/foo_library.h" diff --git a/examples/otlp/http_metric_main.cc b/examples/otlp/http_metric_main.cc index f33d57772f..53f5fe38bc 100644 --- a/examples/otlp/http_metric_main.cc +++ b/examples/otlp/http_metric_main.cc @@ -1,20 +1,28 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" #include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h" +#include "opentelemetry/metrics/meter_provider.h" #include "opentelemetry/metrics/provider.h" #include "opentelemetry/sdk/common/global_log_handler.h" -#include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" -#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h" #include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h" -#include "opentelemetry/sdk/metrics/meter.h" +#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h" +#include "opentelemetry/sdk/metrics/meter_context.h" #include "opentelemetry/sdk/metrics/meter_context_factory.h" -#include "opentelemetry/sdk/metrics/meter_provider.h" #include "opentelemetry/sdk/metrics/meter_provider_factory.h" - -#include -#include +#include "opentelemetry/sdk/metrics/metric_reader.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h" #ifdef BAZEL_BUILD # include "examples/common/metrics_foo_library/foo_library.h" diff --git a/examples/plugin/load/main.cc b/examples/plugin/load/main.cc index 589f70c2af..81d5221372 100644 --- a/examples/plugin/load/main.cc +++ b/examples/plugin/load/main.cc @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include +#include // IWYU pragma: keep #include #include #include diff --git a/examples/plugin/plugin/factory_impl.cc b/examples/plugin/plugin/factory_impl.cc index 4d74bd6062..6eaa4aa4f1 100644 --- a/examples/plugin/plugin/factory_impl.cc +++ b/examples/plugin/plugin/factory_impl.cc @@ -1,7 +1,6 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include #include #include diff --git a/examples/plugin/plugin/tracer.cc b/examples/plugin/plugin/tracer.cc index faf3f036e5..5361197584 100644 --- a/examples/plugin/plugin/tracer.cc +++ b/examples/plugin/plugin/tracer.cc @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include #include #include #include @@ -10,7 +9,6 @@ #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/timestamp.h" #include "opentelemetry/context/context_value.h" -#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_metadata.h" #include "tracer.h" diff --git a/examples/plugin/plugin/tracer.h b/examples/plugin/plugin/tracer.h index bb933d3d9b..92012fa4a5 100644 --- a/examples/plugin/plugin/tracer.h +++ b/examples/plugin/plugin/tracer.h @@ -4,7 +4,6 @@ #pragma once #include -#include #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/shared_ptr.h" diff --git a/examples/zipkin/main.cc b/examples/zipkin/main.cc index 0052cd430e..ac9e454580 100644 --- a/examples/zipkin/main.cc +++ b/examples/zipkin/main.cc @@ -1,12 +1,21 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include + #include "opentelemetry/exporters/zipkin/zipkin_exporter_factory.h" +#include "opentelemetry/exporters/zipkin/zipkin_exporter_options.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.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/trace/span_id.h" +#include "opentelemetry/trace/tracer_provider.h" #ifdef BAZEL_BUILD # include "examples/common/foo_library/foo_library.h" diff --git a/exporters/ostream/src/span_exporter.cc b/exporters/ostream/src/span_exporter.cc index d3f5093b40..9437ae561a 100644 --- a/exporters/ostream/src/span_exporter.cc +++ b/exporters/ostream/src/span_exporter.cc @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_environment.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_environment.h index 8b486a548f..74a222a9d0 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_environment.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_environment.h @@ -3,18 +3,14 @@ #pragma once -#include "opentelemetry/common/kv_properties.h" -#include "opentelemetry/nostd/string_view.h" - -#include "opentelemetry/sdk/common/attribute_utils.h" -#include "opentelemetry/sdk/common/env_variables.h" -#include "opentelemetry/sdk/version/version.h" - +#include #include #include #include #include -#include + +#include "opentelemetry/sdk/version/version.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_client.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_client.h index bedbe77e52..e377b140b6 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_client.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_client.h @@ -3,12 +3,13 @@ #pragma once -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/sdk/common/exporter_utils.h" +#include +#include #include "opentelemetry/exporters/otlp/otlp_file_client_options.h" - -#include +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/version.h" // forward declare google::protobuf::Message namespace google diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter.h index b5b87f9f88..b49dcef77f 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter.h @@ -3,15 +3,16 @@ #pragma once -// We need include exporter.h first, which will include Windows.h with NOMINMAX on Windows -#include "opentelemetry/sdk/trace/exporter.h" +#include +#include #include "opentelemetry/exporters/otlp/otlp_file_client.h" - #include "opentelemetry/exporters/otlp/otlp_file_exporter_options.h" - -#include -#include +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter_factory.h index dc68609729..bf4ba3288f 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter_factory.h @@ -7,6 +7,7 @@ #include "opentelemetry/exporters/otlp/otlp_file_exporter_options.h" #include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter.h index 79d816ae53..6fb9f6d844 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter.h @@ -3,16 +3,16 @@ #pragma once -#include "opentelemetry/sdk/logs/exporter.h" +#include +#include #include "opentelemetry/exporters/otlp/otlp_file_client.h" - #include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter_options.h" - -#include -#include -#include -#include +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter_factory.h index 0e6c0143b9..663eeb189a 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter_factory.h @@ -7,6 +7,7 @@ #include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter_options.h" #include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter.h index 165c7de99a..e03e544de9 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter.h @@ -3,16 +3,16 @@ #pragma once -#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include +#include #include "opentelemetry/exporters/otlp/otlp_file_client.h" - #include "opentelemetry/exporters/otlp/otlp_file_metric_exporter_options.h" - -#include -#include -#include -#include +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter_factory.h index 483e4aa5aa..a34c057fad 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter_factory.h @@ -7,6 +7,7 @@ #include "opentelemetry/exporters/otlp/otlp_file_metric_exporter_options.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http.h index 7d1e7bac55..6899c6f544 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http.h @@ -3,9 +3,8 @@ #pragma once -#include "opentelemetry/common/macros.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/sdk/version/version.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter 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 9d79b5d99b..6806f1cdf9 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h @@ -3,14 +3,6 @@ #pragma once -#include "opentelemetry/ext/http/client/http_client.h" -#include "opentelemetry/nostd/variant.h" -#include "opentelemetry/sdk/common/exporter_utils.h" - -#include "opentelemetry/exporters/otlp/otlp_environment.h" -#include "opentelemetry/exporters/otlp/otlp_http.h" - -#include #include #include #include @@ -21,6 +13,14 @@ #include #include +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/version.h" + // forward declare google::protobuf::Message namespace google { diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter.h index b5faf1a9b8..38f1d9e306 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter.h @@ -3,19 +3,16 @@ #pragma once -// We need include exporter.h first, which will include Windows.h with NOMINMAX on Windows -#include "opentelemetry/sdk/trace/exporter.h" +#include +#include #include "opentelemetry/exporters/otlp/otlp_http_client.h" - -#include "opentelemetry/exporters/otlp/otlp_environment.h" - #include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" - -#include -#include -#include -#include +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_factory.h index 5316528365..9e072a0534 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_factory.h @@ -7,6 +7,7 @@ #include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" #include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h index 1be4bd8d95..7f6d5a1b35 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h @@ -3,15 +3,13 @@ #pragma once +#include +#include + #include "opentelemetry/exporters/otlp/otlp_environment.h" #include "opentelemetry/exporters/otlp/otlp_http.h" #include "opentelemetry/version.h" -#include -#include -#include -#include - OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter.h index f481fdab0b..9439e5725b 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter.h @@ -3,17 +3,16 @@ #pragma once -#include "opentelemetry/sdk/logs/exporter.h" +#include +#include #include "opentelemetry/exporters/otlp/otlp_http_client.h" - -#include "opentelemetry/exporters/otlp/otlp_environment.h" #include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" - -#include -#include -#include -#include +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h index f4c90d5b0c..c1e9de9ae1 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h @@ -3,10 +3,11 @@ #pragma once +#include + #include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" #include "opentelemetry/sdk/logs/exporter.h" - -#include +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h index 7d60a28cf0..60f674a3a7 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h @@ -3,15 +3,13 @@ #pragma once +#include +#include + #include "opentelemetry/exporters/otlp/otlp_environment.h" #include "opentelemetry/exporters/otlp/otlp_http.h" #include "opentelemetry/version.h" -#include -#include -#include -#include - OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter.h index 0aebf79760..d74177e5c9 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter.h @@ -3,16 +3,16 @@ #pragma once -#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include +#include -#include "opentelemetry/exporters/otlp/otlp_environment.h" #include "opentelemetry/exporters/otlp/otlp_http_client.h" #include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h" - -#include -#include -#include -#include +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h index 7fa7980470..a290d91fd0 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h @@ -3,10 +3,11 @@ #pragma once +#include + #include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h" #include "opentelemetry/sdk/metrics/push_metric_exporter.h" - -#include +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h index d5cf3072f8..82c91aa51f 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h @@ -3,16 +3,14 @@ #pragma once +#include +#include + #include "opentelemetry/exporters/otlp/otlp_environment.h" #include "opentelemetry/exporters/otlp/otlp_http.h" #include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h" #include "opentelemetry/version.h" -#include -#include -#include -#include - OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_metric_utils.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_metric_utils.h index c6e11aeff3..4f92b8e665 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_metric_utils.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_metric_utils.h @@ -3,16 +3,34 @@ #pragma once -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +#include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/version.h" -#include "opentelemetry/proto/collector/metrics/v1/metrics_service.pb.h" +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep #include "opentelemetry/proto/metrics/v1/metrics.pb.h" -#include "opentelemetry/proto/resource/v1/resource.pb.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on -#include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h" -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -#include "opentelemetry/sdk/metrics/export/metric_producer.h" +namespace opentelemetry +{ +namespace proto +{ +namespace collector +{ +namespace metrics +{ +namespace v1 +{ +class ExportMetricsServiceRequest; +} +} // namespace metrics +} // namespace collector +} // namespace proto +} // namespace opentelemetry OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h index dc43827641..499aa3685f 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h @@ -3,18 +3,37 @@ #pragma once -// clang-format off -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" -#include "opentelemetry/proto/resource/v1/resource.pb.h" -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" -// clang-format on - #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/version.h" +namespace opentelemetry +{ +namespace proto +{ + +namespace common +{ +namespace v1 +{ +class AnyValue; +class KeyValue; +} // namespace v1 +} // namespace common + +namespace resource +{ +namespace v1 +{ +class Resource; +} +} // namespace resource + +} // namespace proto +} // namespace opentelemetry + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable.h index 88e7cd91cf..103357d11f 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable.h @@ -3,14 +3,28 @@ #pragma once -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +#include +#include +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include "opentelemetry/proto/common/v1/common.pb.h" #include "opentelemetry/proto/resource/v1/resource.pb.h" #include "opentelemetry/proto/trace/v1/trace.pb.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on + +#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/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable_utils.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable_utils.h index 74a4cd9aeb..0651abc2b9 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable_utils.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable_utils.h @@ -5,18 +5,36 @@ #include -#include "opentelemetry/nostd/unique_ptr.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - -#include "opentelemetry/proto/collector/logs/v1/logs_service.pb.h" -#include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/version.h" -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" +namespace opentelemetry +{ +namespace proto +{ +namespace collector +{ -#include "opentelemetry/sdk/trace/recordable.h" +namespace logs +{ +namespace v1 +{ +class ExportLogsServiceRequest; +} +} // namespace logs +namespace trace +{ +namespace v1 +{ +class ExportTraceServiceRequest; +} +} // namespace trace -#include "opentelemetry/sdk/logs/recordable.h" +} // namespace collector +} // namespace proto +} // namespace opentelemetry OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/src/otlp_environment.cc b/exporters/otlp/src/otlp_environment.cc index a7af30bb73..276d9fc709 100644 --- a/exporters/otlp/src/otlp_environment.cc +++ b/exporters/otlp/src/otlp_environment.cc @@ -1,15 +1,20 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/kv_properties.h" #include "opentelemetry/exporters/otlp/otlp_environment.h" - +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/common/env_variables.h" -#include "opentelemetry/sdk/version/version.h" - -#include "opentelemetry/sdk/common/global_log_handler.h" -#include "opentelemetry/sdk_config.h" +#include "opentelemetry/version.h" -namespace nostd = opentelemetry::nostd; namespace sdk_common = opentelemetry::sdk::common; /* diff --git a/exporters/otlp/src/otlp_file_client.cc b/exporters/otlp/src/otlp_file_client.cc index 9678b22476..bd36a602c4 100644 --- a/exporters/otlp/src/otlp_file_client.cc +++ b/exporters/otlp/src/otlp_file_client.cc @@ -10,7 +10,7 @@ #endif // clang-format off -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep // clang-format on #include "google/protobuf/message.h" @@ -19,15 +19,14 @@ #include "nlohmann/json.hpp" // clang-format off -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep // clang-format on -#include "opentelemetry/common/macros.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/common/base64.h" #include "opentelemetry/sdk/common/global_log_handler.h" -#include "opentelemetry/sdk_config.h" +#include "opentelemetry/version.h" #include #include diff --git a/exporters/otlp/src/otlp_file_exporter.cc b/exporters/otlp/src/otlp_file_exporter.cc index 816151719a..b98a6b2007 100644 --- a/exporters/otlp/src/otlp_file_exporter.cc +++ b/exporters/otlp/src/otlp_file_exporter.cc @@ -1,19 +1,30 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/otlp/otlp_file_exporter.h" +#include +#include +#include +#include +#include + #include "opentelemetry/exporters/otlp/otlp_file_client.h" +#include "opentelemetry/exporters/otlp/otlp_file_client_options.h" +#include "opentelemetry/exporters/otlp/otlp_file_exporter.h" +#include "opentelemetry/exporters/otlp/otlp_file_exporter_options.h" #include "opentelemetry/exporters/otlp/otlp_recordable.h" #include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/version.h" -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep #include "google/protobuf/arena.h" #include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/src/otlp_file_log_record_exporter.cc b/exporters/otlp/src/otlp_file_log_record_exporter.cc index 49cbfd3ab2..7df1c70b29 100644 --- a/exporters/otlp/src/otlp_file_log_record_exporter.cc +++ b/exporters/otlp/src/otlp_file_log_record_exporter.cc @@ -1,18 +1,30 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_file_client.h" +#include "opentelemetry/exporters/otlp/otlp_file_client_options.h" #include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter.h" +#include "opentelemetry/exporters/otlp/otlp_file_log_record_exporter_options.h" #include "opentelemetry/exporters/otlp/otlp_log_recordable.h" #include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/version.h" -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep #include "google/protobuf/arena.h" #include "opentelemetry/proto/collector/logs/v1/logs_service.pb.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/src/otlp_file_metric_exporter.cc b/exporters/otlp/src/otlp_file_metric_exporter.cc index 2c414c31b4..78aea66956 100644 --- a/exporters/otlp/src/otlp_file_metric_exporter.cc +++ b/exporters/otlp/src/otlp_file_metric_exporter.cc @@ -1,17 +1,30 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_file_client.h" +#include "opentelemetry/exporters/otlp/otlp_file_client_options.h" #include "opentelemetry/exporters/otlp/otlp_file_metric_exporter.h" +#include "opentelemetry/exporters/otlp/otlp_file_metric_exporter_options.h" #include "opentelemetry/exporters/otlp/otlp_metric_utils.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/version.h" -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep #include "google/protobuf/arena.h" #include "opentelemetry/proto/collector/metrics/v1/metrics_service.pb.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/src/otlp_http_client.cc b/exporters/otlp/src/otlp_http_client.cc index 8bada1e0e0..03eb5fb434 100644 --- a/exporters/otlp/src/otlp_http_client.cc +++ b/exporters/otlp/src/otlp_http_client.cc @@ -1,7 +1,22 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/otlp/otlp_http_client.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #if defined(HAVE_GSL) # include @@ -9,42 +24,33 @@ # include #endif -#include "opentelemetry/ext/http/client/http_client_factory.h" -#include "opentelemetry/ext/http/common/url_parser.h" - -// clang-format off -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" -// clang-format on - -#include "google/protobuf/message.h" -#include "google/protobuf/reflection.h" -#include "google/protobuf/stubs/common.h" #include "nlohmann/json.hpp" - -// clang-format off -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" -// clang-format on - #include "opentelemetry/common/timestamp.h" +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/exporters/otlp/otlp_http_client.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/ext/http/client/http_client_factory.h" +#include "opentelemetry/ext/http/common/url_parser.h" #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" #include "opentelemetry/sdk/common/base64.h" +#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/common/global_log_handler.h" -#include "opentelemetry/sdk_config.h" +#include "opentelemetry/version.h" -#include -#include -#include -#include -#include -#include -#include -#include +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include +#include +#include +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on #ifdef GetMessage # undef GetMessage #endif -namespace nostd = opentelemetry::nostd; namespace http_client = opentelemetry::ext::http::client; OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/exporters/otlp/src/otlp_http_exporter.cc b/exporters/otlp/src/otlp_http_exporter.cc index aa00c3f79a..f740a0babf 100644 --- a/exporters/otlp/src/otlp_http_exporter.cc +++ b/exporters/otlp/src/otlp_http_exporter.cc @@ -1,20 +1,33 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http_client.h" #include "opentelemetry/exporters/otlp/otlp_http_exporter.h" +#include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" #include "opentelemetry/exporters/otlp/otlp_recordable.h" #include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/version.h" -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep #include "google/protobuf/arena.h" #include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -#include "opentelemetry/sdk/common/global_log_handler.h" - -namespace nostd = opentelemetry::nostd; +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter @@ -78,7 +91,8 @@ std::unique_ptr OtlpHttpExporter::MakeRec } opentelemetry::sdk::common::ExportResult OtlpHttpExporter::Export( - const nostd::span> &spans) noexcept + const opentelemetry::nostd::span> + &spans) noexcept { if (http_client_->IsShutdown()) { diff --git a/exporters/otlp/src/otlp_http_exporter_options.cc b/exporters/otlp/src/otlp_http_exporter_options.cc index d88b8d2e3d..753efcb481 100644 --- a/exporters/otlp/src/otlp_http_exporter_options.cc +++ b/exporters/otlp/src/otlp_http_exporter_options.cc @@ -1,13 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" - #include -#include -#include #include +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" +#include "opentelemetry/version.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { diff --git a/exporters/otlp/src/otlp_http_log_record_exporter.cc b/exporters/otlp/src/otlp_http_log_record_exporter.cc index 0d08c66a79..bd76bd10bd 100644 --- a/exporters/otlp/src/otlp_http_log_record_exporter.cc +++ b/exporters/otlp/src/otlp_http_log_record_exporter.cc @@ -1,20 +1,33 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http_client.h" #include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter.h" +#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" #include "opentelemetry/exporters/otlp/otlp_log_recordable.h" #include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/version.h" -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep #include "google/protobuf/arena.h" #include "opentelemetry/proto/collector/logs/v1/logs_service.pb.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -#include "opentelemetry/sdk/common/global_log_handler.h" - -namespace nostd = opentelemetry::nostd; +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter @@ -82,7 +95,8 @@ OtlpHttpLogRecordExporter::MakeRecordable() noexcept } opentelemetry::sdk::common::ExportResult OtlpHttpLogRecordExporter::Export( - const nostd::span> &logs) noexcept + const opentelemetry::nostd::span> + &logs) noexcept { if (http_client_->IsShutdown()) { diff --git a/exporters/otlp/src/otlp_http_log_record_exporter_options.cc b/exporters/otlp/src/otlp_http_log_record_exporter_options.cc index cf2227a8d5..08a04cfa80 100644 --- a/exporters/otlp/src/otlp_http_log_record_exporter_options.cc +++ b/exporters/otlp/src/otlp_http_log_record_exporter_options.cc @@ -1,13 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" - #include -#include -#include #include +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" +#include "opentelemetry/version.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { diff --git a/exporters/otlp/src/otlp_http_metric_exporter.cc b/exporters/otlp/src/otlp_http_metric_exporter.cc index 1782bb6acb..18b4ed0712 100644 --- a/exporters/otlp/src/otlp_http_metric_exporter.cc +++ b/exporters/otlp/src/otlp_http_metric_exporter.cc @@ -1,19 +1,33 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http_client.h" #include "opentelemetry/exporters/otlp/otlp_http_metric_exporter.h" +#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h" #include "opentelemetry/exporters/otlp/otlp_metric_utils.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/version.h" -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep #include "google/protobuf/arena.h" #include "opentelemetry/proto/collector/metrics/v1/metrics_service.pb.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -#include "opentelemetry/sdk/common/global_log_handler.h" - -namespace nostd = opentelemetry::nostd; +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/src/otlp_http_metric_exporter_options.cc b/exporters/otlp/src/otlp_http_metric_exporter_options.cc index 7e2c145639..66d65fa54b 100644 --- a/exporters/otlp/src/otlp_http_metric_exporter_options.cc +++ b/exporters/otlp/src/otlp_http_metric_exporter_options.cc @@ -1,13 +1,15 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h" - #include -#include -#include #include +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h" +#include "opentelemetry/version.h" + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { diff --git a/exporters/otlp/src/otlp_log_recordable.cc b/exporters/otlp/src/otlp_log_recordable.cc index 8acb4073d2..03c89626f2 100644 --- a/exporters/otlp/src/otlp_log_recordable.cc +++ b/exporters/otlp/src/otlp_log_recordable.cc @@ -1,14 +1,23 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/common/macros.h" +#include +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/otlp/otlp_log_recordable.h" #include "opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h" -#include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/proto/logs/v1/logs.pb.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/readable_log_record.h" - -namespace nostd = opentelemetry::nostd; +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter @@ -216,7 +225,7 @@ void OtlpLogRecordable::SetTraceFlags(const opentelemetry::trace::TraceFlags &tr proto_record_.set_flags(trace_flags.flags()); } -void OtlpLogRecordable::SetAttribute(nostd::string_view key, +void OtlpLogRecordable::SetAttribute(opentelemetry::nostd::string_view key, const opentelemetry::common::AttributeValue &value) noexcept { OtlpPopulateAttributeUtils::PopulateAttribute(proto_record_.add_attributes(), key, value); diff --git a/exporters/otlp/src/otlp_metric_utils.cc b/exporters/otlp/src/otlp_metric_utils.cc index e75b17ddd7..da162d117e 100644 --- a/exporters/otlp/src/otlp_metric_utils.cc +++ b/exporters/otlp/src/otlp_metric_utils.cc @@ -1,9 +1,32 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include + +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/otlp/otlp_metric_utils.h" #include "opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h" +#include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/metrics/data/metric_data.h" +#include "opentelemetry/sdk/metrics/data/point_data.h" +#include "opentelemetry/sdk/metrics/export/metric_producer.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/version.h" + +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include "opentelemetry/proto/collector/metrics/v1/metrics_service.pb.h" +#include "opentelemetry/proto/common/v1/common.pb.h" +#include "opentelemetry/proto/metrics/v1/metrics.pb.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/exporters/otlp/src/otlp_populate_attribute_utils.cc b/exporters/otlp/src/otlp_populate_attribute_utils.cc index 69a284835a..a2ef2edafa 100644 --- a/exporters/otlp/src/otlp_populate_attribute_utils.cc +++ b/exporters/otlp/src/otlp_populate_attribute_utils.cc @@ -1,7 +1,29 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/common/attribute_value.h" #include "opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/version.h" + +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include "opentelemetry/proto/common/v1/common.pb.h" +#include "opentelemetry/proto/resource/v1/resource.pb.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on namespace nostd = opentelemetry::nostd; diff --git a/exporters/otlp/src/otlp_recordable.cc b/exporters/otlp/src/otlp_recordable.cc index f9cee24677..356472fb48 100644 --- a/exporters/otlp/src/otlp_recordable.cc +++ b/exporters/otlp/src/otlp_recordable.cc @@ -1,10 +1,36 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/otlp/otlp_recordable.h" +#include +#include +#include +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h" -#include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" +#include "opentelemetry/exporters/otlp/otlp_recordable.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/utility.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/trace_state.h" +#include "opentelemetry/version.h" + +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include "opentelemetry/proto/common/v1/common.pb.h" +#include "opentelemetry/proto/resource/v1/resource.pb.h" +#include "opentelemetry/proto/trace/v1/trace.pb.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on namespace nostd = opentelemetry::nostd; diff --git a/exporters/otlp/src/otlp_recordable_utils.cc b/exporters/otlp/src/otlp_recordable_utils.cc index 59e4aadf4e..df29cca838 100644 --- a/exporters/otlp/src/otlp_recordable_utils.cc +++ b/exporters/otlp/src/otlp_recordable_utils.cc @@ -1,23 +1,36 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - -#include "opentelemetry/proto/logs/v1/logs.pb.h" -#include "opentelemetry/proto/trace/v1/trace.pb.h" - -#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" +#include +#include +#include +#include +#include +#include +#include #include "opentelemetry/exporters/otlp/otlp_log_recordable.h" #include "opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h" #include "opentelemetry/exporters/otlp/otlp_recordable.h" - -#include -#include - -namespace nostd = opentelemetry::nostd; +#include "opentelemetry/exporters/otlp/otlp_recordable_utils.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/version.h" + +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include "opentelemetry/proto/collector/logs/v1/logs_service.pb.h" +#include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h" +#include "opentelemetry/proto/common/v1/common.pb.h" +#include "opentelemetry/proto/logs/v1/logs.pb.h" +#include "opentelemetry/proto/resource/v1/resource.pb.h" +#include "opentelemetry/proto/trace/v1/trace.pb.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter @@ -48,7 +61,7 @@ struct InstrumentationScopePointerEqual } // namespace void OtlpRecordableUtils::PopulateRequest( - const nostd::span> &spans, + const opentelemetry::nostd::span> &spans, proto::collector::trace::v1::ExportTraceServiceRequest *request) noexcept { if (nullptr == request) @@ -108,7 +121,7 @@ void OtlpRecordableUtils::PopulateRequest( } void OtlpRecordableUtils::PopulateRequest( - const nostd::span> &logs, + const opentelemetry::nostd::span> &logs, proto::collector::logs::v1::ExportLogsServiceRequest *request) noexcept { if (nullptr == request) diff --git a/exporters/otlp/test/otlp_recordable_test.cc b/exporters/otlp/test/otlp_recordable_test.cc index 9f3ba62b16..caa17c8a46 100644 --- a/exporters/otlp/test/otlp_recordable_test.cc +++ b/exporters/otlp/test/otlp_recordable_test.cc @@ -13,6 +13,12 @@ #include +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +#include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on + OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter { diff --git a/exporters/zipkin/include/opentelemetry/exporters/zipkin/recordable.h b/exporters/zipkin/include/opentelemetry/exporters/zipkin/recordable.h index 09955711e3..0331178f2a 100644 --- a/exporters/zipkin/include/opentelemetry/exporters/zipkin/recordable.h +++ b/exporters/zipkin/include/opentelemetry/exporters/zipkin/recordable.h @@ -3,8 +3,22 @@ #pragma once +#include +#include + #include "nlohmann/json.hpp" + +#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/instrumentationscope/instrumentation_scope.h" +#include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h b/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h index effa2dfe75..19e7af9cf6 100644 --- a/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h +++ b/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h @@ -3,16 +3,20 @@ #pragma once -#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" -#include "opentelemetry/sdk/common/env_variables.h" -#include "opentelemetry/sdk/trace/exporter.h" -#include "opentelemetry/sdk/trace/span_data.h" +#include +#include +#include #include "nlohmann/json.hpp" -#include +#include "opentelemetry/exporters/zipkin/zipkin_exporter_options.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/ext/http/common/url_parser.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter_factory.h b/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter_factory.h index 3f84c6041b..b1564a7977 100644 --- a/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter_factory.h +++ b/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter_factory.h @@ -7,6 +7,7 @@ #include "opentelemetry/exporters/zipkin/zipkin_exporter_options.h" #include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/zipkin/src/recordable.cc b/exporters/zipkin/src/recordable.cc index ed43cb8a2d..69899e7fad 100644 --- a/exporters/zipkin/src/recordable.cc +++ b/exporters/zipkin/src/recordable.cc @@ -1,12 +1,33 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include + +#include "nlohmann/json.hpp" + +#include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/zipkin/recordable.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/attribute_utils.h" +#include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/sdk/resource/semantic_conventions.h" - -#include -#include +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/span_metadata.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/zipkin/src/zipkin_exporter.cc b/exporters/zipkin/src/zipkin_exporter.cc index a8a97b58af..e6d3ce8b26 100644 --- a/exporters/zipkin/src/zipkin_exporter.cc +++ b/exporters/zipkin/src/zipkin_exporter.cc @@ -2,12 +2,27 @@ // SPDX-License-Identifier: Apache-2.0 #define _WINSOCKAPI_ // stops including winsock.h -#include "opentelemetry/exporters/zipkin/zipkin_exporter.h" -#include + +#include +#include +#include +#include +#include +#include + +#include "nlohmann/json.hpp" + #include "opentelemetry/exporters/zipkin/recordable.h" +#include "opentelemetry/exporters/zipkin/zipkin_exporter.h" +#include "opentelemetry/exporters/zipkin/zipkin_exporter_options.h" +#include "opentelemetry/ext/http/client/http_client.h" #include "opentelemetry/ext/http/client/http_client_factory.h" #include "opentelemetry/ext/http/common/url_parser.h" -#include "opentelemetry/sdk_config.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/version.h" namespace http_client = opentelemetry::ext::http::client; diff --git a/exporters/zipkin/src/zipkin_exporter_factory.cc b/exporters/zipkin/src/zipkin_exporter_factory.cc index 5003dbb0a0..edacb79842 100644 --- a/exporters/zipkin/src/zipkin_exporter_factory.cc +++ b/exporters/zipkin/src/zipkin_exporter_factory.cc @@ -4,6 +4,8 @@ #include "opentelemetry/exporters/zipkin/zipkin_exporter_factory.h" #include "opentelemetry/exporters/zipkin/zipkin_exporter.h" #include "opentelemetry/exporters/zipkin/zipkin_exporter_options.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/version.h" namespace http_client = opentelemetry::ext::http::client; diff --git a/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h b/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h index 63702be09a..902981f392 100644 --- a/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h +++ b/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h @@ -3,20 +3,27 @@ #pragma once -#include "opentelemetry/ext/http/client/curl/http_operation_curl.h" -#include "opentelemetry/ext/http/client/http_client.h" -#include "opentelemetry/ext/http/common/url_parser.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/version.h" - +#include #include +#include +#include +#include #include +#include +#include #include #include #include #include #include -#include +#include + +#include "opentelemetry/ext/http/client/curl/http_operation_curl.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/nostd/function_ref.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace ext diff --git a/ext/src/http/client/curl/http_client_curl.cc b/ext/src/http/client/curl/http_client_curl.cc index 11c1435b1f..38ca2e7348 100644 --- a/ext/src/http/client/curl/http_client_curl.cc +++ b/ext/src/http/client/curl/http_client_curl.cc @@ -1,15 +1,35 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "opentelemetry/ext/http/client/curl/http_client_curl.h" -#include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/ext/http/client/curl/http_operation_curl.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/ext/http/common/url_parser.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/version.h" #ifdef ENABLE_OTLP_COMPRESSION_PREVIEW # include +#else +# include "opentelemetry/sdk/common/global_log_handler.h" #endif -#include - OPENTELEMETRY_BEGIN_NAMESPACE namespace ext { diff --git a/ext/src/http/client/curl/http_client_factory_curl.cc b/ext/src/http/client/curl/http_client_factory_curl.cc index f6266c2931..fd0a7d6a81 100644 --- a/ext/src/http/client/curl/http_client_factory_curl.cc +++ b/ext/src/http/client/curl/http_client_factory_curl.cc @@ -1,6 +1,8 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include + #include "opentelemetry/ext/http/client/curl/http_client_curl.h" #include "opentelemetry/ext/http/client/http_client.h" #include "opentelemetry/ext/http/client/http_client_factory.h" diff --git a/ext/src/http/client/curl/http_operation_curl.cc b/ext/src/http/client/curl/http_operation_curl.cc index fe06384414..f82c17ccc5 100644 --- a/ext/src/http/client/curl/http_operation_curl.cc +++ b/ext/src/http/client/curl/http_operation_curl.cc @@ -1,12 +1,29 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include +#include +#include #include - -#include "opentelemetry/ext/http/client/curl/http_operation_curl.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "opentelemetry/ext/http/client/curl/http_client_curl.h" +#include "opentelemetry/ext/http/client/curl/http_operation_curl.h" +#include "opentelemetry/ext/http/client/http_client.h" #include "opentelemetry/sdk/common/global_log_handler.h" +#include "opentelemetry/version.h" // CURL_VERSION_BITS was added in CURL 7.43.0 #ifndef CURL_VERSION_BITS diff --git a/functional/otlp/func_http_main.cc b/functional/otlp/func_http_main.cc index 08b7807998..4f6c144a43 100644 --- a/functional/otlp/func_http_main.cc +++ b/functional/otlp/func_http_main.cc @@ -1,16 +1,29 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include +#include +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_environment.h" #include "opentelemetry/exporters/otlp/otlp_http_exporter_factory.h" #include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.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 -#include +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" namespace trace = opentelemetry::trace; namespace trace_sdk = opentelemetry::sdk::trace; diff --git a/sdk/src/logs/logger.cc b/sdk/src/logs/logger.cc index d3555ba4ec..e9935c5107 100644 --- a/sdk/src/logs/logger.cc +++ b/sdk/src/logs/logger.cc @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include #include #include diff --git a/sdk/src/logs/logger_provider.cc b/sdk/src/logs/logger_provider.cc index c3b1fb7dd4..1eaa0d186e 100644 --- a/sdk/src/logs/logger_provider.cc +++ b/sdk/src/logs/logger_provider.cc @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -12,7 +11,6 @@ #include "opentelemetry/logs/logger.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/logger.h" diff --git a/sdk/src/logs/readable_log_record.cc b/sdk/src/logs/readable_log_record.cc index 4c8d119347..8d35c1eb2e 100644 --- a/sdk/src/logs/readable_log_record.cc +++ b/sdk/src/logs/readable_log_record.cc @@ -7,7 +7,6 @@ #include "opentelemetry/logs/severity.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h" #include "opentelemetry/sdk/logs/readable_log_record.h" #include "opentelemetry/sdk/resource/resource.h" diff --git a/sdk/src/metrics/meter.cc b/sdk/src/metrics/meter.cc index f472ac726e..8b4413113b 100644 --- a/sdk/src/metrics/meter.cc +++ b/sdk/src/metrics/meter.cc @@ -3,7 +3,6 @@ #include #include -#include #include #include #include diff --git a/sdk/src/metrics/meter_provider.cc b/sdk/src/metrics/meter_provider.cc index 959ff32800..6ddba6aa7c 100644 --- a/sdk/src/metrics/meter_provider.cc +++ b/sdk/src/metrics/meter_provider.cc @@ -2,9 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include #include -#include #include #include "opentelemetry/common/key_value_iterable.h" diff --git a/sdk/src/metrics/state/observable_registry.cc b/sdk/src/metrics/state/observable_registry.cc index 4da46ddfe3..8db11d4605 100644 --- a/sdk/src/metrics/state/observable_registry.cc +++ b/sdk/src/metrics/state/observable_registry.cc @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include diff --git a/sdk/src/trace/tracer.cc b/sdk/src/trace/tracer.cc index f23ce5f628..fd02548c7b 100644 --- a/sdk/src/trace/tracer.cc +++ b/sdk/src/trace/tracer.cc @@ -4,7 +4,6 @@ #include #include #include -#include #include #include @@ -12,7 +11,6 @@ #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" diff --git a/sdk/src/trace/tracer_provider.cc b/sdk/src/trace/tracer_provider.cc index 7421e07de4..9440e3d469 100644 --- a/sdk/src/trace/tracer_provider.cc +++ b/sdk/src/trace/tracer_provider.cc @@ -3,9 +3,7 @@ #include #include -#include #include -#include #include #include From eb2b9753ea2df64079e07d40489388ea1b323108 Mon Sep 17 00:00:00 2001 From: Siddhartha Malladi Date: Thu, 11 Jul 2024 05:45:17 -0400 Subject: [PATCH 35/44] [Code Health] clang-tidy cleanup, part 1 (#2990) --- .clang-tidy | 69 ++++ api/test/baggage/baggage_benchmark.cc | 2 +- api/test/baggage/baggage_test.cc | 2 +- .../propagation/baggage_propagator_test.cc | 2 +- api/test/common/kv_properties_test.cc | 2 +- api/test/context/context_test.cc | 6 +- api/test/context/runtime_context_test.cc | 2 + api/test/logs/logger_benchmark.cc | 10 +- api/test/logs/logger_test.cc | 1 - api/test/metrics/meter_provider_test.cc | 1 - api/test/nostd/shared_ptr_test.cc | 10 +- api/test/nostd/unique_ptr_test.cc | 12 +- api/test/trace/trace_state_test.cc | 4 +- examples/etw_threads/main.cc | 2 +- examples/grpc/client.cc | 7 +- examples/grpc/server.cc | 9 +- examples/logs_simple/main.cc | 4 +- examples/multi_processor/main.cc | 18 +- examples/multithreaded/main.cc | 1 + examples/otlp/http_log_main.cc | 4 +- examples/simple/main.cc | 2 +- .../elasticsearch/es_log_recordable.h | 6 +- .../elasticsearch/src/es_log_recordable.cc | 6 +- .../memory/test/in_memory_span_data_test.cc | 1 - .../exporters/ostream/log_record_exporter.h | 4 +- .../exporters/ostream/metric_exporter.h | 2 +- .../exporters/ostream/span_exporter.h | 2 +- exporters/ostream/src/log_record_exporter.cc | 10 +- exporters/ostream/src/metric_exporter.cc | 2 +- exporters/ostream/src/span_exporter.cc | 8 +- exporters/ostream/test/ostream_log_test.cc | 60 ++- exporters/ostream/test/ostream_span_test.cc | 2 +- exporters/otlp/src/otlp_file_client.cc | 9 +- exporters/otlp/src/otlp_grpc_client.cc | 6 +- exporters/otlp/src/otlp_http_client.cc | 10 +- .../otlp/test/otlp_http_exporter_test.cc | 215 ++++++----- .../otlp_http_log_record_exporter_test.cc | 363 +++++++++--------- .../test/otlp_http_metric_exporter_test.cc | 265 ++++++------- .../test/otlp_metrics_serialization_test.cc | 6 +- exporters/otlp/test/otlp_recordable_test.cc | 6 +- exporters/prometheus/src/exporter_utils.cc | 4 +- exporters/prometheus/test/exporter_test.cc | 1 - .../prometheus/test/exporter_utils_test.cc | 7 +- exporters/zipkin/src/zipkin_exporter.cc | 2 +- exporters/zipkin/test/zipkin_exporter_test.cc | 3 +- .../http/client/curl/http_operation_curl.h | 3 +- ext/src/dll/dllmain.cc | 2 +- ext/src/http/client/curl/http_client_curl.cc | 2 +- .../http/client/curl/http_operation_curl.cc | 8 +- ext/test/http/curl_http_test.cc | 5 +- ext/test/w3c_tracecontext_test/main.cc | 6 +- functional/otlp/func_http_main.cc | 24 +- .../opentelemetry/sdk/logs/logger_context.h | 2 +- .../opentelemetry/sdk/logs/logger_provider.h | 4 +- .../opentelemetry/sdk/metrics/meter_context.h | 4 +- .../sdk/metrics/meter_provider.h | 4 +- .../metrics/state/temporal_metric_storage.h | 2 +- .../sdk/metrics/sync_instruments.h | 12 +- .../opentelemetry/sdk/trace/samplers/parent.h | 2 +- .../sdk/trace/samplers/parent_factory.h | 2 +- .../opentelemetry/sdk/trace/tracer_context.h | 2 +- .../opentelemetry/sdk/trace/tracer_provider.h | 4 +- sdk/src/common/global_log_handler.cc | 2 +- sdk/src/logs/event_logger.cc | 2 +- sdk/src/logs/logger.cc | 2 +- sdk/src/logs/logger_context.cc | 2 +- sdk/src/logs/logger_provider.cc | 4 +- sdk/src/metrics/async_instruments.cc | 4 +- sdk/src/metrics/exemplar/reservoir.cc | 10 +- sdk/src/metrics/meter.cc | 4 +- sdk/src/metrics/meter_context.cc | 6 +- sdk/src/metrics/meter_provider.cc | 4 +- sdk/src/metrics/state/metric_collector.cc | 4 +- .../metrics/state/temporal_metric_storage.cc | 4 +- sdk/src/metrics/sync_instruments.cc | 12 +- sdk/src/metrics/view/view_factory.cc | 5 +- sdk/src/trace/batch_span_processor.cc | 1 - sdk/src/trace/samplers/parent.cc | 2 +- sdk/src/trace/samplers/parent_factory.cc | 8 +- sdk/src/trace/span.cc | 2 +- sdk/src/trace/tracer.cc | 2 +- sdk/src/trace/tracer_context.cc | 2 +- sdk/src/trace/tracer_provider.cc | 4 +- sdk/test/common/empty_attributes_test.cc | 2 +- .../logs/batch_log_record_processor_test.cc | 12 +- sdk/test/logs/logger_sdk_test.cc | 3 +- .../logs/simple_log_record_processor_test.cc | 3 +- sdk/test/metrics/async_instruments_test.cc | 1 + sdk/test/metrics/async_metric_storage_test.cc | 4 +- sdk/test/metrics/cardinality_limit_test.cc | 4 +- .../instrument_metadata_validator_test.cc | 6 +- sdk/test/metrics/meter_test.cc | 2 +- ...ync_metric_storage_up_down_counter_test.cc | 12 +- sdk/test/resource/resource_test.cc | 11 +- sdk/test/trace/batch_span_processor_test.cc | 11 +- sdk/test/trace/span_data_test.cc | 4 +- sdk/test/trace/tracer_test.cc | 1 - 97 files changed, 759 insertions(+), 661 deletions(-) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..5abedb62fd --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,69 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +Checks: > + -*, + abseil-*, + -abseil-string-find-str-contains, + bugprone-*, + -bugprone-easily-swappable-parameters, + -bugprone-implicit-widening-of-multiplication-result, + -bugprone-inc-dec-in-conditions, + -bugprone-narrowing-conversions, + -bugprone-unchecked-optional-access, + -bugprone-unhandled-exception-at-new, + -bugprone-unused-local-non-trivial-variable, + -bugprone-unused-return-value, + google-*, + -google-build-using-namespace, + -google-default-arguments, + -google-explicit-constructor, + -google-readability-avoid-underscore-in-googletest-name, + -google-readability-braces-around-statements, + -google-readability-namespace-comments, + -google-readability-todo, + -google-runtime-references, + misc-*, + -misc-const-correctness, + -misc-include-cleaner, + -misc-non-private-member-variables-in-classes, + -misc-unused-alias-decls, + -misc-use-anonymous-namespace, + performance-*, + -performance-move-const-arg, + portability-* +# readability-*, +# -readability-convert-member-functions-to-static, +# -readability-else-after-return, +# -readability-function-cognitive-complexity, +# -readability-identifier-length, +# -readability-implicit-bool-conversion, +# -readability-isolate-declaration, +# -readability-magic-numbers, +# -readability-named-parameter, +# -readability-redundant-*, +# -readability-string-compare, +# cppcoreguidelines-*, +# -cppcoreguidelines-avoid-c-arrays, +# -cppcoreguidelines-avoid-magic-numbers, +# -cppcoreguidelines-init-variables, +# -cppcoreguidelines-macro-usage, +# -cppcoreguidelines-non-private-member-variables-in-classes, +# -cppcoreguidelines-pro-*, +# modernize-*, +# -modernize-use-default-member-init, +# -modernize-use-nodiscard, +# -modernize-use-trailing-return-type, +# -modernize-avoid-c-arrays, +# -modernize-use-using + +# Use existing clang-format for formatting the code +# FormatStyle: 'file' + +# TODO: include checks: readability, cppcoreguidelines, modernize , google-readability-namespace-comments, google-readability-avoid-underscore-in-googletest-name, performance-move-const-arg + + + + + + diff --git a/api/test/baggage/baggage_benchmark.cc b/api/test/baggage/baggage_benchmark.cc index 0f2efa9939..4ced142327 100644 --- a/api/test/baggage/baggage_benchmark.cc +++ b/api/test/baggage/baggage_benchmark.cc @@ -22,7 +22,7 @@ std::string header_with_custom_entries(size_t num_entries) { std::string key = "ADecentlyLargekey" + std::to_string(i); std::string value = "ADecentlyLargeValue" + std::to_string(i); - header += key + "=" + value; + header.append(key).append("=").append(value); if (i != num_entries - 1) { header += ","; diff --git a/api/test/baggage/baggage_test.cc b/api/test/baggage/baggage_test.cc index 9c14fc892f..f29615c983 100644 --- a/api/test/baggage/baggage_test.cc +++ b/api/test/baggage/baggage_test.cc @@ -19,7 +19,7 @@ std::string header_with_custom_entries(size_t num_entries) { std::string key = "key" + std::to_string(i); std::string value = "value" + std::to_string(i); - header += key + "=" + value; + header.append(key).append("=").append(value); if (i != num_entries - 1) { header += ","; diff --git a/api/test/baggage/propagation/baggage_propagator_test.cc b/api/test/baggage/propagation/baggage_propagator_test.cc index 94fe8b005b..83de75757b 100644 --- a/api/test/baggage/propagation/baggage_propagator_test.cc +++ b/api/test/baggage/propagation/baggage_propagator_test.cc @@ -62,7 +62,7 @@ TEST(BaggagePropagatorTest, ExtractAndInjectBaggage) {"invalid_header", ""}, // invalid header {very_large_baggage_header, ""}}; // baggage header larger than allowed size. - for (auto baggage : baggages) + for (const auto &baggage : baggages) { BaggageCarrierTest carrier1; carrier1.headers_[baggage::kBaggageHeader.data()] = baggage.first; diff --git a/api/test/common/kv_properties_test.cc b/api/test/common/kv_properties_test.cc index e5d9a2439e..f616664265 100644 --- a/api/test/common/kv_properties_test.cc +++ b/api/test/common/kv_properties_test.cc @@ -31,7 +31,7 @@ TEST(EntryTest, KeyValueConstruction) TEST(EntryTest, Copy) { KeyValueProperties::Entry e("test_key", "test_value"); - KeyValueProperties::Entry copy(e); + const KeyValueProperties::Entry ©(e); EXPECT_EQ(copy.GetKey(), e.GetKey()); EXPECT_EQ(copy.GetValue(), e.GetValue()); } diff --git a/api/test/context/context_test.cc b/api/test/context/context_test.cc index 764dac6477..294f1cd180 100644 --- a/api/test/context/context_test.cc +++ b/api/test/context/context_test.cc @@ -105,8 +105,8 @@ TEST(ContextTest, ContextCopyOperator) {"foo_key", static_cast(456)}, {"other_key", static_cast(789)}}; - context::Context test_context = context::Context(test_map); - context::Context copied_context = test_context; + context::Context test_context = context::Context(test_map); + const context::Context &copied_context = test_context; EXPECT_EQ(nostd::get(copied_context.GetValue("test_key")), 123); EXPECT_EQ(nostd::get(copied_context.GetValue("foo_key")), 456); @@ -135,7 +135,7 @@ TEST(ContextTest, ContextCopyCompare) { std::map map_test = {{"test_key", static_cast(123)}}; context::Context context_test = context::Context(map_test); - context::Context copied_test = context_test; + const context::Context &copied_test = context_test; EXPECT_TRUE(context_test == copied_test); } diff --git a/api/test/context/runtime_context_test.cc b/api/test/context/runtime_context_test.cc index c2ec732fe0..cd551c599c 100644 --- a/api/test/context/runtime_context_test.cc +++ b/api/test/context/runtime_context_test.cc @@ -113,6 +113,7 @@ TEST(RuntimeContextTest, DetachOutOfOrder) indices.push_back(3); std::vector contexts; + contexts.reserve(indices.size()); for (auto i : indices) { contexts.push_back(context::Context("index", static_cast(i))); @@ -122,6 +123,7 @@ TEST(RuntimeContextTest, DetachOutOfOrder) { std::vector> tokens; + tokens.reserve(contexts.size()); for (auto &c : contexts) { tokens.push_back(context::RuntimeContext::Attach(c)); diff --git a/api/test/logs/logger_benchmark.cc b/api/test/logs/logger_benchmark.cc index 098b9c7df8..db225d496a 100644 --- a/api/test/logs/logger_benchmark.cc +++ b/api/test/logs/logger_benchmark.cc @@ -16,13 +16,8 @@ #include using opentelemetry::logs::EventId; -using opentelemetry::logs::Logger; -using opentelemetry::logs::LoggerProvider; using opentelemetry::logs::Provider; using opentelemetry::logs::Severity; -using opentelemetry::nostd::shared_ptr; -using opentelemetry::nostd::span; -using opentelemetry::nostd::string_view; namespace common = opentelemetry::common; namespace nostd = opentelemetry::nostd; @@ -66,7 +61,7 @@ class Barrier static void ThreadRoutine(Barrier &barrier, benchmark::State &state, int thread_id, - std::function func) + const std::function &func) { barrier.Wait(); @@ -87,7 +82,7 @@ static void ThreadRoutine(Barrier &barrier, barrier.Wait(); } -void MultiThreadRunner(benchmark::State &state, std::function func) +void MultiThreadRunner(benchmark::State &state, const std::function &func) { int num_threads = std::thread::hardware_concurrency(); @@ -95,6 +90,7 @@ void MultiThreadRunner(benchmark::State &state, std::function func) std::vector threads; + threads.reserve(num_threads); for (int i = 0; i < num_threads; i++) { threads.emplace_back(ThreadRoutine, std::ref(barrier), std::ref(state), i, func); diff --git a/api/test/logs/logger_test.cc b/api/test/logs/logger_test.cc index 43d7afc685..848f053453 100644 --- a/api/test/logs/logger_test.cc +++ b/api/test/logs/logger_test.cc @@ -16,7 +16,6 @@ using opentelemetry::logs::LoggerProvider; using opentelemetry::logs::Provider; using opentelemetry::logs::Severity; using opentelemetry::nostd::shared_ptr; -using opentelemetry::nostd::span; using opentelemetry::nostd::string_view; namespace common = opentelemetry::common; namespace nostd = opentelemetry::nostd; diff --git a/api/test/metrics/meter_provider_test.cc b/api/test/metrics/meter_provider_test.cc index 878c5e9a3b..b8fb083799 100644 --- a/api/test/metrics/meter_provider_test.cc +++ b/api/test/metrics/meter_provider_test.cc @@ -6,7 +6,6 @@ #include "opentelemetry/metrics/provider.h" #include "opentelemetry/nostd/shared_ptr.h" -using opentelemetry::metrics::Meter; using opentelemetry::metrics::MeterProvider; using opentelemetry::metrics::NoopMeterProvider; using opentelemetry::metrics::Provider; diff --git a/api/test/nostd/shared_ptr_test.cc b/api/test/nostd/shared_ptr_test.cc index 0c79c7efd2..5c290c6284 100644 --- a/api/test/nostd/shared_ptr_test.cc +++ b/api/test/nostd/shared_ptr_test.cc @@ -63,7 +63,7 @@ TEST(SharedPtrTest, MoveConstruction) auto value = new int{123}; shared_ptr ptr1{value}; shared_ptr ptr2{std::move(ptr1)}; - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); } @@ -72,7 +72,7 @@ TEST(SharedPtrTest, MoveConstructionFromDifferentType) auto value = new int{123}; shared_ptr ptr1{value}; shared_ptr ptr2{std::move(ptr1)}; - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); } @@ -81,14 +81,14 @@ TEST(SharedPtrTest, MoveConstructionFromStdSharedPtr) auto value = new int{123}; std::shared_ptr ptr1{value}; shared_ptr ptr2{std::move(ptr1)}; - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); } TEST(SharedPtrTest, Destruction) { bool was_destructed; - shared_ptr{new A{was_destructed}}; + shared_ptr{new A{was_destructed}}; // NOLINT EXPECT_TRUE(was_destructed); } @@ -173,7 +173,7 @@ static void SharedPtrTest_Sort(size_t size = 10) auto nums2 = nums; std::sort(nums.begin(), nums.end(), - [](shared_ptr a, shared_ptr b) { return *a < *b; }); + [](const shared_ptr &a, const shared_ptr &b) { return *a < *b; }); EXPECT_NE(nums, nums2); diff --git a/api/test/nostd/unique_ptr_test.cc b/api/test/nostd/unique_ptr_test.cc index f3684be0b8..893525c266 100644 --- a/api/test/nostd/unique_ptr_test.cc +++ b/api/test/nostd/unique_ptr_test.cc @@ -49,7 +49,7 @@ TEST(UniquePtrTest, MoveConstruction) auto value = new int{123}; unique_ptr ptr1{value}; unique_ptr ptr2{std::move(ptr1)}; - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); } @@ -58,7 +58,7 @@ TEST(UniquePtrTest, MoveConstructionFromDifferentType) auto value = new int{123}; unique_ptr ptr1{value}; unique_ptr ptr2{std::move(ptr1)}; - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); } @@ -67,14 +67,14 @@ TEST(UniquePtrTest, MoveConstructionFromStdUniquePtr) auto value = new int{123}; std::unique_ptr ptr1{value}; unique_ptr ptr2{std::move(ptr1)}; - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); } TEST(UniquePtrTest, Destruction) { bool was_destructed; - unique_ptr{new A{was_destructed}}; + unique_ptr{new A{was_destructed}}; // NOLINT EXPECT_TRUE(was_destructed); } @@ -83,13 +83,13 @@ TEST(UniquePtrTest, StdUniquePtrConversionOperator) auto value = new int{123}; unique_ptr ptr1{value}; std::unique_ptr ptr2{std::move(ptr1)}; - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); value = new int{456}; ptr1 = unique_ptr{value}; ptr2 = std::move(ptr1); - EXPECT_EQ(ptr1.get(), nullptr); + EXPECT_EQ(ptr1.get(), nullptr); // NOLINT EXPECT_EQ(ptr2.get(), value); ptr2 = nullptr; diff --git a/api/test/trace/trace_state_test.cc b/api/test/trace/trace_state_test.cc index 7f5a05cfe6..e6ed73c1f4 100644 --- a/api/test/trace/trace_state_test.cc +++ b/api/test/trace/trace_state_test.cc @@ -20,7 +20,7 @@ const char *kLongString = // -------------------------- TraceState class tests --------------------------- -std::string create_ts_return_header(std::string header) +std::string create_ts_return_header(const std::string &header) { auto ts = TraceState::FromHeader(header); return ts->ToHeader(); @@ -34,7 +34,7 @@ std::string header_with_max_members() { std::string key = "key" + std::to_string(i); std::string value = "value" + std::to_string(i); - header += key + "=" + value; + header.append(key).append("=").append(value); if (i != max_members - 1) { header += ","; diff --git a/examples/etw_threads/main.cc b/examples/etw_threads/main.cc index d25883d1d1..e5b8dbac9f 100644 --- a/examples/etw_threads/main.cc +++ b/examples/etw_threads/main.cc @@ -113,7 +113,7 @@ void beep() // Max number of threads to spawn constexpr int kMaxThreads = 10; -int main(int arc, char **argv) +int main(int /*arc*/, char ** /*argv*/) { std::thread pool[kMaxThreads]; diff --git a/examples/grpc/client.cc b/examples/grpc/client.cc index b8f233dcc7..9ca41c6958 100644 --- a/examples/grpc/client.cc +++ b/examples/grpc/client.cc @@ -20,7 +20,6 @@ using grpc::Channel; using grpc::ClientContext; -using grpc::ClientReader; using grpc::Status; using grpc_example::Greeter; @@ -34,7 +33,7 @@ using namespace opentelemetry::trace; class GreeterClient { public: - GreeterClient(std::shared_ptr channel) : stub_(Greeter::NewStub(channel)) {} + GreeterClient(const std::shared_ptr &channel) : stub_(Greeter::NewStub(channel)) {} std::string Greet(std::string ip, uint16_t port) { @@ -77,7 +76,7 @@ class GreeterClient } else { - std::cout << status.error_code() << ": " << status.error_message() << std::endl; + std::cout << status.error_code() << ": " << status.error_message() << '\n'; span->SetStatus(StatusCode::kError); span->SetAttribute(SemanticConventions::kRpcGrpcStatusCode, status.error_code()); // Make sure to end your spans! @@ -95,7 +94,7 @@ void RunClient(uint16_t port) GreeterClient greeter( grpc::CreateChannel("0.0.0.0:" + std::to_string(port), grpc::InsecureChannelCredentials())); std::string response = greeter.Greet("0.0.0.0", port); - std::cout << "grpc_server says: " << response << std::endl; + std::cout << "grpc_server says: " << response << '\n'; } } // namespace diff --git a/examples/grpc/server.cc b/examples/grpc/server.cc index a8fac8b5f0..3c3fcede4f 100644 --- a/examples/grpc/server.cc +++ b/examples/grpc/server.cc @@ -27,7 +27,6 @@ using grpc::Server; using grpc::ServerBuilder; using grpc::ServerContext; -using grpc::ServerWriter; using grpc::Status; using grpc_example::Greeter; @@ -49,7 +48,7 @@ class GreeterServer final : public Greeter::Service const GreetRequest *request, GreetResponse *response) override { - for (auto elem : context->client_metadata()) + for (const auto &elem : context->client_metadata()) { std::cout << "ELEM: " << elem.first << " " << elem.second << "\n"; } @@ -78,8 +77,8 @@ class GreeterServer final : public Greeter::Service // Fetch and parse whatever HTTP headers we can from the gRPC request. span->AddEvent("Processing client attributes"); - std::string req = request->request(); - std::cout << std::endl << "grpc_client says: " << req << std::endl; + const std::string &req = request->request(); + std::cout << '\n' << "grpc_client says: " << req << '\n'; std::string message = "The pleasure is mine."; // Send response to client response->set_response(message); @@ -102,7 +101,7 @@ void RunServer(uint16_t port) builder.AddListeningPort(address, grpc::InsecureServerCredentials()); std::unique_ptr server(builder.BuildAndStart()); - std::cout << "Server listening on port: " << address << std::endl; + std::cout << "Server listening on port: " << address << '\n'; server->Wait(); server->Shutdown(); } diff --git a/examples/logs_simple/main.cc b/examples/logs_simple/main.cc index 35827b6502..444775dc59 100644 --- a/examples/logs_simple/main.cc +++ b/examples/logs_simple/main.cc @@ -53,7 +53,7 @@ void InitTracer() #endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global trace provider - std::shared_ptr api_provider = provider; + const std::shared_ptr &api_provider = provider; trace_api::Provider::SetTracerProvider(api_provider); } @@ -79,7 +79,7 @@ void InitLogger() #endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global logger provider - std::shared_ptr api_provider = provider; + const std::shared_ptr &api_provider = provider; logs_api::Provider::SetLoggerProvider(api_provider); } diff --git a/examples/multi_processor/main.cc b/examples/multi_processor/main.cc index ceb7cdfcf9..d99d77de7d 100644 --- a/examples/multi_processor/main.cc +++ b/examples/multi_processor/main.cc @@ -70,29 +70,29 @@ void dumpSpans(std::vector> &spans) char span_buf[trace_api::SpanId::kSize * 2]; char trace_buf[trace_api::TraceId::kSize * 2]; char parent_span_buf[trace_api::SpanId::kSize * 2]; - std::cout << "\nSpans from memory :" << std::endl; + std::cout << "\nSpans from memory :" << '\n'; for (auto &span : spans) { - std::cout << "\n\tSpan: " << std::endl; - std::cout << "\t\tName: " << span->GetName() << std::endl; + std::cout << "\n\tSpan: " << '\n'; + std::cout << "\t\tName: " << span->GetName() << '\n'; span->GetSpanId().ToLowerBase16(span_buf); span->GetTraceId().ToLowerBase16(trace_buf); span->GetParentSpanId().ToLowerBase16(parent_span_buf); - std::cout << "\t\tTraceId: " << std::string(trace_buf, sizeof(trace_buf)) << std::endl; - std::cout << "\t\tSpanId: " << std::string(span_buf, sizeof(span_buf)) << std::endl; + std::cout << "\t\tTraceId: " << std::string(trace_buf, sizeof(trace_buf)) << '\n'; + std::cout << "\t\tSpanId: " << std::string(span_buf, sizeof(span_buf)) << '\n'; std::cout << "\t\tParentSpanId: " << std::string(parent_span_buf, sizeof(parent_span_buf)) - << std::endl; + << '\n'; - std::cout << "\t\tDescription: " << span->GetDescription() << std::endl; + std::cout << "\t\tDescription: " << span->GetDescription() << '\n'; std::cout << "\t\tSpan kind:" << static_cast::type>( span->GetSpanKind()) - << std::endl; + << '\n'; std::cout << "\t\tSpan Status: " << static_cast::type>( span->GetStatus()) - << std::endl; + << '\n'; } } } // namespace diff --git a/examples/multithreaded/main.cc b/examples/multithreaded/main.cc index d92a4ab2ac..675a6053ec 100644 --- a/examples/multithreaded/main.cc +++ b/examples/multithreaded/main.cc @@ -55,6 +55,7 @@ void run_threads() auto thread_span = get_tracer()->StartSpan(__func__); std::vector threads; + threads.reserve(5); for (int thread_num = 0; thread_num < 5; ++thread_num) { // This shows how one can effectively use Scope objects to correctly diff --git a/examples/otlp/http_log_main.cc b/examples/otlp/http_log_main.cc index 38aa009d04..37bace2b0f 100644 --- a/examples/otlp/http_log_main.cc +++ b/examples/otlp/http_log_main.cc @@ -71,7 +71,7 @@ void InitTracer() trace_opts.url = opentelemetry::exporter::otlp::GetOtlpDefaultHttpTracesEndpoint(); } } - std::cout << "Using " << trace_opts.url << " to export trace spans." << std::endl; + std::cout << "Using " << trace_opts.url << " to export trace spans." << '\n'; // Create OTLP exporter instance auto exporter = otlp::OtlpHttpExporterFactory::Create(trace_opts); @@ -110,7 +110,7 @@ std::shared_ptr logger_provider; void InitLogger() { - std::cout << "Using " << logger_opts.url << " to export log records." << std::endl; + std::cout << "Using " << logger_opts.url << " to export log records." << '\n'; logger_opts.console_debug = true; // Create OTLP exporter instance auto exporter = otlp::OtlpHttpLogRecordExporterFactory::Create(logger_opts); diff --git a/examples/simple/main.cc b/examples/simple/main.cc index a872816ba1..349aec500a 100644 --- a/examples/simple/main.cc +++ b/examples/simple/main.cc @@ -40,7 +40,7 @@ void InitTracer() #endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global trace provider - std::shared_ptr api_provider = provider; + const std::shared_ptr &api_provider = provider; trace_api::Provider::SetTracerProvider(api_provider); } diff --git a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h index feb68f7f9c..af4ccb16ef 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h @@ -33,13 +33,13 @@ class ElasticSearchRecordable final : public sdk::logs::Recordable */ void WriteKeyValue(nostd::string_view key, const opentelemetry::common::AttributeValue &value, - std::string name); + const std::string &name); void WriteKeyValue(nostd::string_view key, const opentelemetry::sdk::common::OwnedAttributeValue &value, - std::string name); + const std::string &name); - void WriteValue(const opentelemetry::common::AttributeValue &value, std::string name); + void WriteValue(const opentelemetry::common::AttributeValue &value, const std::string &name); public: /** diff --git a/exporters/elasticsearch/src/es_log_recordable.cc b/exporters/elasticsearch/src/es_log_recordable.cc index 139d22e863..663691273b 100644 --- a/exporters/elasticsearch/src/es_log_recordable.cc +++ b/exporters/elasticsearch/src/es_log_recordable.cc @@ -16,7 +16,7 @@ namespace logs { void ElasticSearchRecordable::WriteKeyValue(nostd::string_view key, const opentelemetry::common::AttributeValue &value, - std::string name) + const std::string &name) { switch (value.index()) { @@ -53,7 +53,7 @@ void ElasticSearchRecordable::WriteKeyValue(nostd::string_view key, void ElasticSearchRecordable::WriteKeyValue( nostd::string_view key, const opentelemetry::sdk::common::OwnedAttributeValue &value, - std::string name) + const std::string &name) { namespace common = opentelemetry::sdk::common; switch (value.index()) @@ -85,7 +85,7 @@ void ElasticSearchRecordable::WriteKeyValue( } void ElasticSearchRecordable::WriteValue(const opentelemetry::common::AttributeValue &value, - std::string name) + const std::string &name) { // Assert size of variant to ensure that this method gets updated if the variant diff --git a/exporters/memory/test/in_memory_span_data_test.cc b/exporters/memory/test/in_memory_span_data_test.cc index bc19550264..be013734ef 100644 --- a/exporters/memory/test/in_memory_span_data_test.cc +++ b/exporters/memory/test/in_memory_span_data_test.cc @@ -8,7 +8,6 @@ #include using opentelemetry::exporter::memory::InMemorySpanData; -using opentelemetry::sdk::trace::Recordable; using opentelemetry::sdk::trace::SpanData; TEST(InMemorySpanData, AddRecordable) 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 24bc8e5be7..840d7d5b8a 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h @@ -66,10 +66,10 @@ class OStreamLogRecordExporter final : public opentelemetry::sdk::logs::LogRecor bool isShutdown() const noexcept; void printAttributes( const std::unordered_map &map, - const std::string prefix = "\n\t"); + const std::string &prefix = "\n\t"); void printAttributes( const std::unordered_map &map, - const std::string prefix = "\n\t"); + const std::string &prefix = "\n\t"); }; } // namespace logs } // namespace exporter diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h index 1ad124a9ab..f1b2cd6ef9 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h @@ -79,7 +79,7 @@ class OStreamMetricExporter final : public opentelemetry::sdk::metrics::PushMetr void printPointData(const opentelemetry::sdk::metrics::PointType &point_data); void printPointAttributes(const opentelemetry::sdk::metrics::PointAttributes &point_attributes); void printAttributes(const std::map &map, - const std::string prefix); + const std::string &prefix); void printResources(const opentelemetry::sdk::resource::Resource &resources); }; } // namespace metrics diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h index a7de9a5eb4..e22eb77f3e 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h @@ -69,7 +69,7 @@ class OStreamSpanExporter final : public opentelemetry::sdk::trace::SpanExporter // various print helpers void printAttributes( const std::unordered_map &map, - const std::string prefix = "\n\t"); + const std::string &prefix = "\n\t"); void printEvents(const std::vector &events); diff --git a/exporters/ostream/src/log_record_exporter.cc b/exporters/ostream/src/log_record_exporter.cc index 7f661276c8..26266161c3 100644 --- a/exporters/ostream/src/log_record_exporter.cc +++ b/exporters/ostream/src/log_record_exporter.cc @@ -75,11 +75,11 @@ sdk::common::ExportResult OStreamLogRecordExporter::Export( // Convert trace, spanid, traceflags into exportable representation constexpr int trace_id_len = 32; - constexpr int span_id__len = 16; + constexpr int span_id_len = 16; constexpr int trace_flags_len = 2; char trace_id[trace_id_len] = {0}; - char span_id[span_id__len] = {0}; + char span_id[span_id_len] = {0}; char trace_flags[trace_flags_len] = {0}; log_record->GetTraceId().ToLowerBase16(trace_id); @@ -120,7 +120,7 @@ sdk::common::ExportResult OStreamLogRecordExporter::Export( << " event_id : " << event_id << "\n" << " event_name : " << log_record->GetEventName() << "\n" << " trace_id : " << std::string(trace_id, trace_id_len) << "\n" - << " span_id : " << std::string(span_id, span_id__len) << "\n" + << " span_id : " << std::string(span_id, span_id_len) << "\n" << " trace_flags : " << std::string(trace_flags, trace_flags_len) << "\n" << " scope : \n" << " name : " << log_record->GetInstrumentationScope().GetName() << "\n" @@ -155,7 +155,7 @@ bool OStreamLogRecordExporter::isShutdown() const noexcept void OStreamLogRecordExporter::printAttributes( const std::unordered_map &map, - const std::string prefix) + const std::string &prefix) { for (const auto &kv : map) { @@ -166,7 +166,7 @@ void OStreamLogRecordExporter::printAttributes( void OStreamLogRecordExporter::printAttributes( const std::unordered_map &map, - const std::string prefix) + const std::string &prefix) { for (const auto &kv : map) { diff --git a/exporters/ostream/src/metric_exporter.cc b/exporters/ostream/src/metric_exporter.cc index 08bfe340c7..4bdd122492 100644 --- a/exporters/ostream/src/metric_exporter.cc +++ b/exporters/ostream/src/metric_exporter.cc @@ -117,7 +117,7 @@ sdk::common::ExportResult OStreamMetricExporter::Export( void OStreamMetricExporter::printAttributes( const std::map &map, - const std::string prefix) + const std::string &prefix) { for (const auto &kv : map) { diff --git a/exporters/ostream/src/span_exporter.cc b/exporters/ostream/src/span_exporter.cc index 9437ae561a..f41d33ae6c 100644 --- a/exporters/ostream/src/span_exporter.cc +++ b/exporters/ostream/src/span_exporter.cc @@ -100,7 +100,7 @@ sdk::common::ExportResult OStreamSpanExporter::Export( << "\n duration : " << span->GetDuration().count() << "\n description : " << span->GetDescription() << "\n span kind : " << span->GetSpanKind() - << "\n status : " << statusMap[int(span->GetStatus())] + << "\n status : " << statusMap[static_cast(span->GetStatus())] << "\n attributes : "; printAttributes(span->GetAttributes()); sout_ << "\n events : "; @@ -137,7 +137,7 @@ bool OStreamSpanExporter::isShutdown() const noexcept void OStreamSpanExporter::printAttributes( const std::unordered_map &map, - const std::string prefix) + const std::string &prefix) { for (const auto &kv : map) { @@ -177,7 +177,7 @@ void OStreamSpanExporter::printLinks(const std::vector void OStreamSpanExporter::printResources(const opentelemetry::sdk::resource::Resource &resources) { - auto attributes = resources.GetAttributes(); + const auto &attributes = resources.GetAttributes(); if (attributes.size()) { printAttributes(attributes, "\n\t"); @@ -188,7 +188,7 @@ void OStreamSpanExporter::printInstrumentationScope( const opentelemetry::sdk::instrumentationscope::InstrumentationScope &instrumentation_scope) { sout_ << instrumentation_scope.GetName(); - auto version = instrumentation_scope.GetVersion(); + const auto &version = instrumentation_scope.GetVersion(); if (version.size()) { sout_ << "-" << version; diff --git a/exporters/ostream/test/ostream_log_test.cc b/exporters/ostream/test/ostream_log_test.cc index 7b22d9b3fd..b7708f3153 100644 --- a/exporters/ostream/test/ostream_log_test.cc +++ b/exporters/ostream/test/ostream_log_test.cc @@ -97,17 +97,17 @@ TEST(OstreamLogExporter, DefaultLogRecordToCout) std::cout.rdbuf(original); std::vector expected_output{ - "{\n" + "{\n", " timestamp : 0\n", - " severity_num : 0\n" - " severity_text : INVALID\n" + " severity_num : 0\n", + " severity_text : INVALID\n", " body : \n", " resource : \n", " telemetry.sdk.version: " OPENTELEMETRY_VERSION "\n", " telemetry.sdk.name: opentelemetry\n", " telemetry.sdk.language: cpp\n", " attributes : \n", - " event_id : 0\n" + " event_id : 0\n", " event_name : \n", " trace_id : 00000000000000000000000000000000\n", " span_id : 0000000000000000\n", @@ -126,7 +126,7 @@ TEST(OstreamLogExporter, DefaultLogRecordToCout) std::string::size_type result = ostream_output.find(expected); if (result == std::string::npos) { - std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << std::endl; + std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << '\n'; } ASSERT_NE(result, std::string::npos); } @@ -167,9 +167,8 @@ TEST(OStreamLogRecordExporter, SimpleLogToCout) std::cout.rdbuf(original); std::vector expected_output{ - "{\n" - " timestamp : " + - std::to_string(now.time_since_epoch().count()) + + "{\n", + " timestamp : " + std::to_string(now.time_since_epoch().count()) + "\n" " observed_timestamp : " + std::to_string(now.time_since_epoch().count()) + @@ -182,7 +181,7 @@ TEST(OStreamLogRecordExporter, SimpleLogToCout) " telemetry.sdk.name: opentelemetry\n", " telemetry.sdk.language: cpp\n", " attributes : \n", - " event_id : 0\n" + " event_id : 0\n", " event_name : \n", " trace_id : 00000000000000000000000000000000\n", " span_id : 0000000000000000\n", @@ -201,7 +200,7 @@ TEST(OStreamLogRecordExporter, SimpleLogToCout) std::string::size_type result = ostream_output.find(expected); if (result == std::string::npos) { - std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << std::endl; + std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << '\n'; } ASSERT_NE(result, std::string::npos); } @@ -243,10 +242,10 @@ TEST(OStreamLogRecordExporter, LogWithStringAttributesToCerr) std::cerr.rdbuf(original); std::vector expected_output{ - "{\n" + "{\n", " timestamp : 0\n", - " severity_num : 0\n" - " severity_text : INVALID\n" + " severity_num : 0\n", + " severity_text : INVALID\n", " body : \n", " resource : \n", " telemetry.sdk.version: " OPENTELEMETRY_VERSION "\n", @@ -256,7 +255,7 @@ TEST(OStreamLogRecordExporter, LogWithStringAttributesToCerr) " key1: val1\n", " attributes : \n", " a: 1\n", - " event_id : 0\n" + " event_id : 0\n", " event_name : \n", " trace_id : 00000000000000000000000000000000\n", " span_id : 0000000000000000\n", @@ -275,7 +274,7 @@ TEST(OStreamLogRecordExporter, LogWithStringAttributesToCerr) std::string::size_type result = ostream_output.find(expected); if (result == std::string::npos) { - std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << std::endl; + std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << '\n'; } ASSERT_NE(result, std::string::npos); } @@ -324,10 +323,10 @@ TEST(OStreamLogRecordExporter, LogWithVariantTypesToClog) std::clog.rdbuf(original); std::vector expected_output{ - "{\n" + "{\n", " timestamp : 0\n", - " severity_num : 0\n" - " severity_text : INVALID\n" + " severity_num : 0\n", + " severity_text : INVALID\n", " body : \n", " resource : \n", " service.name: unknown_service\n", @@ -337,7 +336,7 @@ TEST(OStreamLogRecordExporter, LogWithVariantTypesToClog) " res1: [1,2,3]\n", " attributes : \n", " attr1: [0,1,0]\n", - " event_id : 0\n" + " event_id : 0\n", " event_name : \n", " trace_id : 00000000000000000000000000000000\n", " span_id : 0000000000000000\n", @@ -356,7 +355,7 @@ TEST(OStreamLogRecordExporter, LogWithVariantTypesToClog) std::string::size_type result = ostream_output.find(expected); if (result == std::string::npos) { - std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << std::endl; + std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << '\n'; } ASSERT_NE(result, std::string::npos); } @@ -398,11 +397,10 @@ TEST(OStreamLogRecordExporter, IntegrationTest) // Compare actual vs expected outputs std::vector expected_output{ - "{\n" - " timestamp : " + - std::to_string(now.time_since_epoch().count()) + "\n", - " severity_num : 5\n" - " severity_text : DEBUG\n" + "{\n", + " timestamp : " + std::to_string(now.time_since_epoch().count()) + "\n", + " severity_num : 5\n", + " severity_text : DEBUG\n", " body : Hello\n", " resource : \n", " telemetry.sdk.version: " OPENTELEMETRY_VERSION "\n", @@ -410,7 +408,7 @@ TEST(OStreamLogRecordExporter, IntegrationTest) " telemetry.sdk.name: opentelemetry\n", " telemetry.sdk.language: cpp\n", " attributes : \n", - " event_id : 0\n" + " event_id : 0\n", " event_name : \n", " trace_id : 00000000000000000000000000000000\n", " span_id : 0000000000000000\n", @@ -429,7 +427,7 @@ TEST(OStreamLogRecordExporter, IntegrationTest) std::string::size_type result = ostream_output.find(expected); if (result == std::string::npos) { - std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << std::endl; + std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << '\n'; } ASSERT_NE(result, std::string::npos); } @@ -472,8 +470,8 @@ TEST(OStreamLogRecordExporter, IntegrationTestWithEventId) // Compare actual vs expected outputs std::vector expected_output{ - " severity_num : 5\n" - " severity_text : DEBUG\n" + " severity_num : 5\n", + " severity_text : DEBUG\n", " body : Hello {key1} {key2}\n", " resource : \n", " telemetry.sdk.version: " OPENTELEMETRY_VERSION "\n", @@ -481,7 +479,7 @@ TEST(OStreamLogRecordExporter, IntegrationTestWithEventId) " telemetry.sdk.name: opentelemetry\n", " telemetry.sdk.language: cpp\n", " attributes : \n", - " event_id : 12345678\n" + " event_id : 12345678\n", " event_name : test_event_id\n", " trace_id : 00000000000000000000000000000000\n", " span_id : 0000000000000000\n", @@ -500,7 +498,7 @@ TEST(OStreamLogRecordExporter, IntegrationTestWithEventId) std::string::size_type result = ostream_output.find(expected); if (result == std::string::npos) { - std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << std::endl; + std::cout << "Can not find: \"" << expected << "\" in\n" << ostream_output << '\n'; } ASSERT_NE(result, std::string::npos); } diff --git a/exporters/ostream/test/ostream_span_test.cc b/exporters/ostream/test/ostream_span_test.cc index f92f1bbffd..cadc1b9d38 100644 --- a/exporters/ostream/test/ostream_span_test.cc +++ b/exporters/ostream/test/ostream_span_test.cc @@ -31,7 +31,7 @@ using Attributes = std::initializer_listEXPRESS; \ + (VAR) = tm_obj_ptr->EXPRESS; \ } \ else \ { \ - VAR = tm_obj_ptr->EXPRESS; \ + (VAR) = tm_obj_ptr->EXPRESS; \ } for (size_t i = 0; i < fmt.size() && ret < bufz && running; ++i) @@ -619,7 +619,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL FileSystemUtil } #if !defined(UTIL_FS_DISABLE_LINK) - enum class LinkOption : int32_t + enum class LinkOption : uint8_t { kDefault = 0x00, // hard link for default kSymbolicLink = 0x01, // or soft link @@ -749,6 +749,7 @@ static void ConvertListFieldToJson(nlohmann::json &value, const google::protobuf::Message &message, const google::protobuf::FieldDescriptor *field_descriptor); +// NOLINTBEGIN(misc-no-recursion) static void ConvertGenericMessageToJson(nlohmann::json &value, const google::protobuf::Message &message) { @@ -952,6 +953,8 @@ void ConvertListFieldToJson(nlohmann::json &value, } } +// NOLINTEND(misc-no-recursion) suppressing for performance as if implemented with stack needs +// Dynamic memory allocation } // namespace class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender diff --git a/exporters/otlp/src/otlp_grpc_client.cc b/exporters/otlp/src/otlp_grpc_client.cc index 3410726cf8..a5760bdd81 100644 --- a/exporters/otlp/src/otlp_grpc_client.cc +++ b/exporters/otlp/src/otlp_grpc_client.cc @@ -132,7 +132,7 @@ static std::string GetFileContentsOrInMemoryContents(const std::string &file_pat #ifdef ENABLE_ASYNC_EXPORT template static sdk::common::ExportResult InternalDelegateAsyncExport( - std::shared_ptr async_data, + const std::shared_ptr &async_data, StubType *stub, std::unique_ptr &&context, std::unique_ptr &&arena, @@ -163,8 +163,8 @@ static sdk::common::ExportResult InternalDelegateAsyncExport( call_data->arena.swap(arena); call_data->result_callback.swap(result_callback); - call_data->request = - google::protobuf::Arena::Create(call_data->arena.get(), std::move(request)); + call_data->request = google::protobuf::Arena::Create( + call_data->arena.get(), std::forward(request)); call_data->response = google::protobuf::Arena::Create(call_data->arena.get()); if (call_data->request == nullptr || call_data->response == nullptr) diff --git a/exporters/otlp/src/otlp_http_client.cc b/exporters/otlp/src/otlp_http_client.cc index 03eb5fb434..94f02a9967 100644 --- a/exporters/otlp/src/otlp_http_client.cc +++ b/exporters/otlp/src/otlp_http_client.cc @@ -434,6 +434,7 @@ static void ConvertListFieldToJson(nlohmann::json &value, const google::protobuf::FieldDescriptor *field_descriptor, const OtlpHttpClientOptions &options); +// NOLINTBEGIN(misc-no-recursion) static void ConvertGenericMessageToJson(nlohmann::json &value, const google::protobuf::Message &message, const OtlpHttpClientOptions &options) @@ -654,6 +655,9 @@ void ConvertListFieldToJson(nlohmann::json &value, } } +// NOLINTEND(misc-no-recursion) suppressing for performance, if implemented iterative process needs +// Dynamic memory allocation + } // namespace OtlpHttpClient::OtlpHttpClient(OtlpHttpClientOptions &&options) @@ -696,7 +700,7 @@ OtlpHttpClient::~OtlpHttpClient() OtlpHttpClient::OtlpHttpClient(OtlpHttpClientOptions &&options, std::shared_ptr http_client) - : is_shutdown_(false), options_(options), http_client_(http_client) + : is_shutdown_(false), options_(options), http_client_(std::move(http_client)) { http_client_->SetMaxSessionsPerConnection(options_.max_requests_per_connection); } @@ -881,7 +885,7 @@ OtlpHttpClient::createSession( std::string error_message = "[OTLP HTTP Client] Export failed, invalid url: " + options_.url; if (options_.console_debug) { - std::cerr << error_message << std::endl; + std::cerr << error_message << '\n'; } OTEL_INTERNAL_LOG_ERROR(error_message.c_str()); @@ -946,7 +950,7 @@ OtlpHttpClient::createSession( const char *error_message = "[OTLP HTTP Client] Export failed, exporter is shutdown"; if (options_.console_debug) { - std::cerr << error_message << std::endl; + std::cerr << error_message << '\n'; } OTEL_INTERNAL_LOG_ERROR(error_message); diff --git a/exporters/otlp/test/otlp_http_exporter_test.cc b/exporters/otlp/test/otlp_http_exporter_test.cc index e4f69f502b..4c4a6dbeb2 100644 --- a/exporters/otlp/test/otlp_http_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_exporter_test.cc @@ -58,8 +58,7 @@ OtlpHttpClientOptions MakeOtlpHttpClientOptions(HttpRequestContentType content_t options.content_type = content_type; options.console_debug = true; options.timeout = std::chrono::system_clock::duration::zero(); - options.http_headers.insert( - std::make_pair("Custom-Header-Key", "Custom-Header-Value")); + options.http_headers.insert(std::make_pair("Custom-Header-Key", "Custom-Header-Value")); OtlpHttpClientOptions otlp_http_client_options( options.url, false, /* ssl_insecure_skip_verify */ "", /* ssl_ca_cert_path */ "", /* ssl_ca_cert_string */ @@ -158,34 +157,35 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id]( - std::shared_ptr callback) { - auto check_json = - nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_span = *check_json["resourceSpans"].begin(); - auto scope_span = *resource_span["scopeSpans"].begin(); - auto span = *scope_span["spans"].begin(); - auto received_trace_id = span["traceId"].get(); - EXPECT_EQ(received_trace_id, report_trace_id); - - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - auto user_agent_header = mock_session->GetRequest()->headers_.find("User-Agent"); - ASSERT_TRUE(user_agent_header != mock_session->GetRequest()->headers_.end()); - if (user_agent_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ(GetOtlpDefaultUserAgent(), user_agent_header->second); - } - - // let the otlp_http_client to continue - http_client::nosend::Response response; - response.Finish(*callback.get()); - }); + .WillOnce( + [&mock_session, report_trace_id]( + const std::shared_ptr &callback) { + auto check_json = + nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); + auto resource_span = *check_json["resourceSpans"].begin(); + auto scope_span = *resource_span["scopeSpans"].begin(); + auto span = *scope_span["spans"].begin(); + auto received_trace_id = span["traceId"].get(); + EXPECT_EQ(received_trace_id, report_trace_id); + + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + auto user_agent_header = mock_session->GetRequest()->headers_.find("User-Agent"); + ASSERT_TRUE(user_agent_header != mock_session->GetRequest()->headers_.end()); + if (user_agent_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ(GetOtlpDefaultUserAgent(), user_agent_header->second); + } + + // let the otlp_http_client to continue + http_client::nosend::Response response; + response.Finish(*callback.get()); + }); child_span->End(); parent_span->End(); @@ -249,38 +249,39 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id]( - std::shared_ptr callback) { - auto check_json = - nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_span = *check_json["resourceSpans"].begin(); - auto scope_span = *resource_span["scopeSpans"].begin(); - auto span = *scope_span["spans"].begin(); - auto received_trace_id = span["traceId"].get(); - EXPECT_EQ(received_trace_id, report_trace_id); - - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - auto user_agent_header = mock_session->GetRequest()->headers_.find("User-Agent"); - ASSERT_TRUE(user_agent_header != mock_session->GetRequest()->headers_.end()); - if (user_agent_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ(GetOtlpDefaultUserAgent(), user_agent_header->second); - } - - // let the otlp_http_client to continue - std::thread async_finish{[callback]() { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - http_client::nosend::Response response; - response.Finish(*callback.get()); - }}; - async_finish.detach(); - }); + .WillOnce( + [&mock_session, report_trace_id]( + const std::shared_ptr &callback) { + auto check_json = + nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); + auto resource_span = *check_json["resourceSpans"].begin(); + auto scope_span = *resource_span["scopeSpans"].begin(); + auto span = *scope_span["spans"].begin(); + auto received_trace_id = span["traceId"].get(); + EXPECT_EQ(received_trace_id, report_trace_id); + + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + auto user_agent_header = mock_session->GetRequest()->headers_.find("User-Agent"); + ASSERT_TRUE(user_agent_header != mock_session->GetRequest()->headers_.end()); + if (user_agent_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ(GetOtlpDefaultUserAgent(), user_agent_header->second); + } + + // let the otlp_http_client to continue + std::thread async_finish{[callback]() { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + http_client::nosend::Response response; + response.Finish(*callback.get()); + }}; + async_finish.detach(); + }); child_span->End(); parent_span->End(); @@ -343,25 +344,27 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id]( - std::shared_ptr callback) { - opentelemetry::proto::collector::trace::v1::ExportTraceServiceRequest request_body; - request_body.ParseFromArray(&mock_session->GetRequest()->body_[0], - static_cast(mock_session->GetRequest()->body_.size())); - auto received_trace_id = - request_body.resource_spans(0).scope_spans(0).spans(0).trace_id(); - EXPECT_EQ(received_trace_id, report_trace_id); - - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - http_client::nosend::Response response; - response.Finish(*callback.get()); - }); + .WillOnce( + [&mock_session, report_trace_id]( + const std::shared_ptr &callback) { + opentelemetry::proto::collector::trace::v1::ExportTraceServiceRequest request_body; + request_body.ParseFromArray( + &mock_session->GetRequest()->body_[0], + static_cast(mock_session->GetRequest()->body_.size())); + auto received_trace_id = + request_body.resource_spans(0).scope_spans(0).spans(0).trace_id(); + EXPECT_EQ(received_trace_id, report_trace_id); + + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + http_client::nosend::Response response; + response.Finish(*callback.get()); + }); child_span->End(); parent_span->End(); @@ -424,30 +427,32 @@ class OtlpHttpExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id]( - std::shared_ptr callback) { - opentelemetry::proto::collector::trace::v1::ExportTraceServiceRequest request_body; - request_body.ParseFromArray(&mock_session->GetRequest()->body_[0], - static_cast(mock_session->GetRequest()->body_.size())); - auto received_trace_id = - request_body.resource_spans(0).scope_spans(0).spans(0).trace_id(); - EXPECT_EQ(received_trace_id, report_trace_id); - - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - // let the otlp_http_client to continue - std::thread async_finish{[callback]() { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - http_client::nosend::Response response; - response.Finish(*callback.get()); - }}; - async_finish.detach(); - }); + .WillOnce( + [&mock_session, report_trace_id]( + const std::shared_ptr &callback) { + opentelemetry::proto::collector::trace::v1::ExportTraceServiceRequest request_body; + request_body.ParseFromArray( + &mock_session->GetRequest()->body_[0], + static_cast(mock_session->GetRequest()->body_.size())); + auto received_trace_id = + request_body.resource_spans(0).scope_spans(0).spans(0).trace_id(); + EXPECT_EQ(received_trace_id, report_trace_id); + + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + // let the otlp_http_client to continue + std::thread async_finish{[callback]() { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + http_client::nosend::Response response; + response.Finish(*callback.get()); + }}; + async_finish.detach(); + }); child_span->End(); parent_span->End(); 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 5fbf95798f..35a0bb62e2 100644 --- a/exporters/otlp/test/otlp_http_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_log_record_exporter_test.cc @@ -57,8 +57,7 @@ OtlpHttpClientOptions MakeOtlpHttpClientOptions(HttpRequestContentType content_t OtlpHttpLogRecordExporterOptions options; options.content_type = content_type; options.console_debug = true; - options.http_headers.insert( - std::make_pair("Custom-Header-Key", "Custom-Header-Value")); + options.http_headers.insert(std::make_pair("Custom-Header-Key", "Custom-Header-Value")); OtlpHttpClientOptions otlp_http_client_options( options.url, false, /* ssl_insecure_skip_verify */ "", /* ssl_ca_cert_path */ "", /* ssl_ca_cert_string */ @@ -151,46 +150,47 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id, report_span_id]( - std::shared_ptr callback) { - auto check_json = - nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_logs = *check_json["resourceLogs"].begin(); - auto scope_logs = *resource_logs["scopeLogs"].begin(); - auto scope = scope_logs["scope"]; - auto log = *scope_logs["logRecords"].begin(); - auto received_trace_id = log["traceId"].get(); - auto received_span_id = log["spanId"].get(); - EXPECT_EQ(received_trace_id, report_trace_id); - EXPECT_EQ(received_span_id, report_span_id); - EXPECT_EQ("Log message", log["body"]["stringValue"].get()); - EXPECT_LE(15, log["attributes"].size()); - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - bool check_scope_attribute = false; - auto scope_attributes = scope["attributes"]; - for (auto &attribute : scope_attributes) - { - if (!attribute.is_object()) - { - continue; - } - if ("scope_key1" == attribute["key"]) - { - check_scope_attribute = true; - EXPECT_EQ("scope_value", attribute["value"]["stringValue"].get()); - } - } - ASSERT_TRUE(check_scope_attribute); - - http_client::nosend::Response response; - response.Finish(*callback.get()); - }); + .WillOnce( + [&mock_session, report_trace_id, report_span_id]( + const std::shared_ptr &callback) { + auto check_json = + nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); + auto resource_logs = *check_json["resourceLogs"].begin(); + auto scope_logs = *resource_logs["scopeLogs"].begin(); + auto scope = scope_logs["scope"]; + auto log = *scope_logs["logRecords"].begin(); + auto received_trace_id = log["traceId"].get(); + auto received_span_id = log["spanId"].get(); + EXPECT_EQ(received_trace_id, report_trace_id); + EXPECT_EQ(received_span_id, report_span_id); + EXPECT_EQ("Log message", log["body"]["stringValue"].get()); + EXPECT_LE(15, log["attributes"].size()); + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + bool check_scope_attribute = false; + auto scope_attributes = scope["attributes"]; + for (auto &attribute : scope_attributes) + { + if (!attribute.is_object()) + { + continue; + } + if ("scope_key1" == attribute["key"]) + { + check_scope_attribute = true; + EXPECT_EQ("scope_value", attribute["value"]["stringValue"].get()); + } + } + ASSERT_TRUE(check_scope_attribute); + + http_client::nosend::Response response; + response.Finish(*callback.get()); + }); logger->EmitLogRecord( opentelemetry::logs::Severity::kInfo, "Log message", @@ -268,57 +268,58 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id, report_span_id]( - std::shared_ptr callback) { - auto check_json = - nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_logs = *check_json["resourceLogs"].begin(); - auto scope_logs = *resource_logs["scopeLogs"].begin(); - auto schema_url = scope_logs["schemaUrl"].get(); - auto scope = scope_logs["scope"]; - auto scope_name = scope["name"]; - auto scope_version = scope["version"]; - auto log = *scope_logs["logRecords"].begin(); - auto received_trace_id = log["traceId"].get(); - auto received_span_id = log["spanId"].get(); - EXPECT_EQ(schema_url, "https://opentelemetry.io/schemas/1.2.0"); - EXPECT_EQ(scope_name, "opentelelemtry_library"); - EXPECT_EQ(scope_version, "1.2.0"); - EXPECT_EQ(received_trace_id, report_trace_id); - EXPECT_EQ(received_span_id, report_span_id); - EXPECT_EQ("Log message", log["body"]["stringValue"].get()); - EXPECT_LE(15, log["attributes"].size()); - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - bool check_scope_attribute = false; - auto scope_attributes = scope["attributes"]; - for (auto &attribute : scope_attributes) - { - if (!attribute.is_object()) - { - continue; - } - if ("scope_key1" == attribute["key"]) - { - check_scope_attribute = true; - EXPECT_EQ("scope_value", attribute["value"]["stringValue"].get()); - } - } - ASSERT_TRUE(check_scope_attribute); - - // let the otlp_http_client to continue - std::thread async_finish{[callback]() { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - http_client::nosend::Response response; - response.Finish(*callback.get()); - }}; - async_finish.detach(); - }); + .WillOnce( + [&mock_session, report_trace_id, report_span_id]( + const std::shared_ptr &callback) { + auto check_json = + nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); + auto resource_logs = *check_json["resourceLogs"].begin(); + auto scope_logs = *resource_logs["scopeLogs"].begin(); + auto schema_url = scope_logs["schemaUrl"].get(); + auto scope = scope_logs["scope"]; + auto scope_name = scope["name"]; + auto scope_version = scope["version"]; + auto log = *scope_logs["logRecords"].begin(); + auto received_trace_id = log["traceId"].get(); + auto received_span_id = log["spanId"].get(); + EXPECT_EQ(schema_url, "https://opentelemetry.io/schemas/1.2.0"); + EXPECT_EQ(scope_name, "opentelelemtry_library"); + EXPECT_EQ(scope_version, "1.2.0"); + EXPECT_EQ(received_trace_id, report_trace_id); + EXPECT_EQ(received_span_id, report_span_id); + EXPECT_EQ("Log message", log["body"]["stringValue"].get()); + EXPECT_LE(15, log["attributes"].size()); + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + bool check_scope_attribute = false; + auto scope_attributes = scope["attributes"]; + for (auto &attribute : scope_attributes) + { + if (!attribute.is_object()) + { + continue; + } + if ("scope_key1" == attribute["key"]) + { + check_scope_attribute = true; + EXPECT_EQ("scope_value", attribute["value"]["stringValue"].get()); + } + } + ASSERT_TRUE(check_scope_attribute); + + // let the otlp_http_client to continue + std::thread async_finish{[callback]() { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + http_client::nosend::Response response; + response.Finish(*callback.get()); + }}; + async_finish.detach(); + }); logger->EmitLogRecord( opentelemetry::logs::Severity::kInfo, "Log message", @@ -390,47 +391,49 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id, report_span_id]( - std::shared_ptr callback) { - opentelemetry::proto::collector::logs::v1::ExportLogsServiceRequest request_body; - request_body.ParseFromArray(&mock_session->GetRequest()->body_[0], - static_cast(mock_session->GetRequest()->body_.size())); - auto scope_log = request_body.resource_logs(0).scope_logs(0); - EXPECT_EQ(scope_log.schema_url(), "https://opentelemetry.io/schemas/1.2.0"); - EXPECT_EQ(scope_log.scope().name(), "opentelelemtry_library"); - EXPECT_EQ(scope_log.scope().version(), "1.2.0"); - auto received_log = scope_log.log_records(0); - EXPECT_EQ(received_log.trace_id(), report_trace_id); - EXPECT_EQ(received_log.span_id(), report_span_id); - EXPECT_EQ("Log message", received_log.body().string_value()); - EXPECT_LE(15, received_log.attributes_size()); - bool check_service_name = false; - for (auto &attribute : received_log.attributes()) - { - if ("service.name" == attribute.key()) - { - check_service_name = true; - EXPECT_EQ("unit_test_service", attribute.value().string_value()); - } - } - ASSERT_TRUE(check_service_name); - - bool check_scope_attribute = false; - for (auto &attribute : scope_log.scope().attributes()) - { - if ("scope_key1" == attribute.key()) - { - check_scope_attribute = true; - EXPECT_EQ("scope_value", attribute.value().string_value()); - } - } - ASSERT_TRUE(check_scope_attribute); - - // let the otlp_http_client to continue - - http_client::nosend::Response response; - response.Finish(*callback.get()); - }); + .WillOnce( + [&mock_session, report_trace_id, report_span_id]( + const std::shared_ptr &callback) { + opentelemetry::proto::collector::logs::v1::ExportLogsServiceRequest request_body; + request_body.ParseFromArray( + &mock_session->GetRequest()->body_[0], + static_cast(mock_session->GetRequest()->body_.size())); + auto scope_log = request_body.resource_logs(0).scope_logs(0); + EXPECT_EQ(scope_log.schema_url(), "https://opentelemetry.io/schemas/1.2.0"); + EXPECT_EQ(scope_log.scope().name(), "opentelelemtry_library"); + EXPECT_EQ(scope_log.scope().version(), "1.2.0"); + const auto &received_log = scope_log.log_records(0); + EXPECT_EQ(received_log.trace_id(), report_trace_id); + EXPECT_EQ(received_log.span_id(), report_span_id); + EXPECT_EQ("Log message", received_log.body().string_value()); + EXPECT_LE(15, received_log.attributes_size()); + bool check_service_name = false; + for (auto &attribute : received_log.attributes()) + { + if ("service.name" == attribute.key()) + { + check_service_name = true; + EXPECT_EQ("unit_test_service", attribute.value().string_value()); + } + } + ASSERT_TRUE(check_service_name); + + bool check_scope_attribute = false; + for (auto &attribute : scope_log.scope().attributes()) + { + if ("scope_key1" == attribute.key()) + { + check_scope_attribute = true; + EXPECT_EQ("scope_value", attribute.value().string_value()); + } + } + ASSERT_TRUE(check_scope_attribute); + + // let the otlp_http_client to continue + + http_client::nosend::Response response; + response.Finish(*callback.get()); + }); logger->EmitLogRecord( opentelemetry::logs::Severity::kInfo, "Log message", @@ -503,51 +506,53 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session, report_trace_id, report_span_id, schema_url]( - std::shared_ptr callback) { - opentelemetry::proto::collector::logs::v1::ExportLogsServiceRequest request_body; - request_body.ParseFromArray(&mock_session->GetRequest()->body_[0], - static_cast(mock_session->GetRequest()->body_.size())); - auto &scope_log = request_body.resource_logs(0).scope_logs(0); - auto received_log = scope_log.log_records(0); - EXPECT_EQ(received_log.trace_id(), report_trace_id); - EXPECT_EQ(received_log.span_id(), report_span_id); - EXPECT_EQ("Log message", received_log.body().string_value()); - EXPECT_LE(15, received_log.attributes_size()); - bool check_service_name = false; - for (auto &attribute : received_log.attributes()) - { - if ("service.name" == attribute.key()) - { - check_service_name = true; - EXPECT_EQ("unit_test_service", attribute.value().string_value()); - } - } - ASSERT_TRUE(check_service_name); - - auto &scope = scope_log.scope(); - EXPECT_EQ(scope.name(), "opentelelemtry_library"); - EXPECT_EQ(scope_log.schema_url(), schema_url); - bool check_scope_attribute = false; - for (auto &attribute : scope.attributes()) - { - if ("scope_key1" == attribute.key()) - { - check_scope_attribute = true; - EXPECT_EQ("scope_value", attribute.value().string_value()); - } - } - ASSERT_TRUE(check_scope_attribute); - - // let the otlp_http_client to continue - - std::thread async_finish{[callback]() { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - http_client::nosend::Response response; - response.Finish(*callback.get()); - }}; - async_finish.detach(); - }); + .WillOnce( + [&mock_session, report_trace_id, report_span_id, schema_url]( + const std::shared_ptr &callback) { + opentelemetry::proto::collector::logs::v1::ExportLogsServiceRequest request_body; + request_body.ParseFromArray( + &mock_session->GetRequest()->body_[0], + static_cast(mock_session->GetRequest()->body_.size())); + auto &scope_log = request_body.resource_logs(0).scope_logs(0); + auto received_log = scope_log.log_records(0); + EXPECT_EQ(received_log.trace_id(), report_trace_id); + EXPECT_EQ(received_log.span_id(), report_span_id); + EXPECT_EQ("Log message", received_log.body().string_value()); + EXPECT_LE(15, received_log.attributes_size()); + bool check_service_name = false; + for (auto &attribute : received_log.attributes()) + { + if ("service.name" == attribute.key()) + { + check_service_name = true; + EXPECT_EQ("unit_test_service", attribute.value().string_value()); + } + } + ASSERT_TRUE(check_service_name); + + auto &scope = scope_log.scope(); + EXPECT_EQ(scope.name(), "opentelelemtry_library"); + EXPECT_EQ(scope_log.schema_url(), schema_url); + bool check_scope_attribute = false; + for (auto &attribute : scope.attributes()) + { + if ("scope_key1" == attribute.key()) + { + check_scope_attribute = true; + EXPECT_EQ("scope_value", attribute.value().string_value()); + } + } + ASSERT_TRUE(check_scope_attribute); + + // let the otlp_http_client to continue + + std::thread async_finish{[callback]() { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + http_client::nosend::Response response; + response.Finish(*callback.get()); + }}; + async_finish.detach(); + }); logger->EmitLogRecord( opentelemetry::logs::Severity::kInfo, "Log message", diff --git a/exporters/otlp/test/otlp_http_metric_exporter_test.cc b/exporters/otlp/test/otlp_http_metric_exporter_test.cc index 1e5fe6469f..174597248b 100644 --- a/exporters/otlp/test/otlp_http_metric_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_metric_exporter_test.cc @@ -64,8 +64,7 @@ OtlpHttpClientOptions MakeOtlpHttpClientOptions(HttpRequestContentType content_t OtlpHttpMetricExporterOptions options; options.content_type = content_type; options.console_debug = true; - options.http_headers.insert( - std::make_pair("Custom-Header-Key", "Custom-Header-Value")); + options.http_headers.insert(std::make_pair("Custom-Header-Key", "Custom-Header-Value")); OtlpHttpClientOptions otlp_http_client_options( options.url, false, /* ssl_insecure_skip_verify */ "", /* ssl_ca_cert_path */ "", /* ssl_ca_cert_string */ @@ -154,36 +153,37 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session]( - std::shared_ptr callback) { - auto check_json = - nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - - auto resource_metrics = *check_json["resourceMetrics"].begin(); - auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); - auto scope = scope_metrics["scope"]; - EXPECT_EQ("library_name", scope["name"].get()); - EXPECT_EQ("1.5.0", scope["version"].get()); - - auto metric = *scope_metrics["metrics"].begin(); - EXPECT_EQ("metrics_library_name", metric["name"].get()); - EXPECT_EQ("metrics_description", metric["description"].get()); - EXPECT_EQ("metrics_unit", metric["unit"].get()); - - auto data_points = metric["sum"]["dataPoints"]; - EXPECT_EQ(10.0, data_points[0]["asDouble"].get()); - EXPECT_EQ(20.0, data_points[1]["asDouble"].get()); - - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - http_client::nosend::Response response; - response.Finish(*callback.get()); - }); + .WillOnce( + [&mock_session]( + const std::shared_ptr &callback) { + auto check_json = + nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); + + auto resource_metrics = *check_json["resourceMetrics"].begin(); + auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); + auto scope = scope_metrics["scope"]; + EXPECT_EQ("library_name", scope["name"].get()); + EXPECT_EQ("1.5.0", scope["version"].get()); + + auto metric = *scope_metrics["metrics"].begin(); + EXPECT_EQ("metrics_library_name", metric["name"].get()); + EXPECT_EQ("metrics_description", metric["description"].get()); + EXPECT_EQ("metrics_unit", metric["unit"].get()); + + auto data_points = metric["sum"]["dataPoints"]; + EXPECT_EQ(10.0, data_points[0]["asDouble"].get()); + EXPECT_EQ(20.0, data_points[1]["asDouble"].get()); + + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + http_client::nosend::Response response; + response.Finish(*callback.get()); + }); auto result = exporter->Export(data); EXPECT_EQ(result, opentelemetry::sdk::common::ExportResult::kSuccess); @@ -237,7 +237,8 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test EXPECT_CALL(*mock_session, SendRequest) .WillOnce([&mock_session]( - std::shared_ptr callback) { + const std::shared_ptr + &callback) { opentelemetry::proto::collector::metrics::v1::ExportMetricsServiceRequest request_body; request_body.ParseFromArray(&mock_session->GetRequest()->body_[0], static_cast(mock_session->GetRequest()->body_.size())); @@ -335,36 +336,37 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session]( - std::shared_ptr callback) { - auto check_json = - nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - - auto resource_metrics = *check_json["resourceMetrics"].begin(); - auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); - auto scope = scope_metrics["scope"]; - EXPECT_EQ("library_name", scope["name"].get()); - EXPECT_EQ("1.5.0", scope["version"].get()); - - auto metric = *scope_metrics["metrics"].begin(); - EXPECT_EQ("metrics_library_name", metric["name"].get()); - EXPECT_EQ("metrics_description", metric["description"].get()); - EXPECT_EQ("metrics_unit", metric["unit"].get()); - - auto data_points = metric["gauge"]["dataPoints"]; - EXPECT_EQ(10.0, data_points[0]["asDouble"].get()); - EXPECT_EQ(20l, JsonToInteger(data_points[1]["asInt"])); - - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - http_client::nosend::Response response; - response.Finish(*callback.get()); - }); + .WillOnce( + [&mock_session]( + const std::shared_ptr &callback) { + auto check_json = + nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); + + auto resource_metrics = *check_json["resourceMetrics"].begin(); + auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); + auto scope = scope_metrics["scope"]; + EXPECT_EQ("library_name", scope["name"].get()); + EXPECT_EQ("1.5.0", scope["version"].get()); + + auto metric = *scope_metrics["metrics"].begin(); + EXPECT_EQ("metrics_library_name", metric["name"].get()); + EXPECT_EQ("metrics_description", metric["description"].get()); + EXPECT_EQ("metrics_unit", metric["unit"].get()); + + auto data_points = metric["gauge"]["dataPoints"]; + EXPECT_EQ(10.0, data_points[0]["asDouble"].get()); + EXPECT_EQ(20l, JsonToInteger(data_points[1]["asInt"])); + + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + http_client::nosend::Response response; + response.Finish(*callback.get()); + }); auto result = exporter->Export(data); EXPECT_EQ(result, opentelemetry::sdk::common::ExportResult::kSuccess); @@ -427,7 +429,8 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test EXPECT_CALL(*mock_session, SendRequest) .WillOnce([&mock_session]( - std::shared_ptr callback) { + const std::shared_ptr + &callback) { opentelemetry::proto::collector::metrics::v1::ExportMetricsServiceRequest request_body; request_body.ParseFromArray(&mock_session->GetRequest()->body_[0], static_cast(mock_session->GetRequest()->body_.size())); @@ -530,71 +533,72 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test auto mock_session = std::static_pointer_cast(no_send_client->session_); EXPECT_CALL(*mock_session, SendRequest) - .WillOnce([&mock_session]( - std::shared_ptr callback) { - auto check_json = - nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - - auto resource_metrics = *check_json["resourceMetrics"].begin(); - auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); - auto scope = scope_metrics["scope"]; - EXPECT_EQ("library_name", scope["name"].get()); - EXPECT_EQ("1.5.0", scope["version"].get()); - - auto metric = *scope_metrics["metrics"].begin(); - EXPECT_EQ("metrics_library_name", metric["name"].get()); - EXPECT_EQ("metrics_description", metric["description"].get()); - EXPECT_EQ("metrics_unit", metric["unit"].get()); - - auto data_points = metric["histogram"]["dataPoints"]; - EXPECT_EQ(3, JsonToInteger(data_points[0]["count"])); - EXPECT_EQ(900.5, data_points[0]["sum"].get()); - EXPECT_EQ(1.8, data_points[0]["min"].get()); - EXPECT_EQ(19, data_points[0]["max"].get()); - EXPECT_EQ(4, data_points[0]["bucketCounts"].size()); - if (4 == data_points[0]["bucketCounts"].size()) - { - EXPECT_EQ(200, JsonToInteger(data_points[0]["bucketCounts"][0])); - EXPECT_EQ(300, JsonToInteger(data_points[0]["bucketCounts"][1])); - EXPECT_EQ(400, JsonToInteger(data_points[0]["bucketCounts"][2])); - EXPECT_EQ(500, JsonToInteger(data_points[0]["bucketCounts"][3])); - } - EXPECT_EQ(3, data_points[0]["explicitBounds"].size()); - if (3 == data_points[0]["explicitBounds"].size()) - { - EXPECT_EQ(10.1, data_points[0]["explicitBounds"][0].get()); - EXPECT_EQ(20.2, data_points[0]["explicitBounds"][1].get()); - EXPECT_EQ(30.2, data_points[0]["explicitBounds"][2].get()); - } - - EXPECT_EQ(3, JsonToInteger(data_points[1]["count"])); - EXPECT_EQ(900.0, data_points[1]["sum"].get()); - EXPECT_EQ(4, data_points[1]["bucketCounts"].size()); - if (4 == data_points[1]["bucketCounts"].size()) - { - EXPECT_EQ(200, JsonToInteger(data_points[1]["bucketCounts"][0])); - EXPECT_EQ(300, JsonToInteger(data_points[1]["bucketCounts"][1])); - EXPECT_EQ(400, JsonToInteger(data_points[1]["bucketCounts"][2])); - EXPECT_EQ(500, JsonToInteger(data_points[1]["bucketCounts"][3])); - } - EXPECT_EQ(3, data_points[1]["explicitBounds"].size()); - if (3 == data_points[1]["explicitBounds"].size()) - { - EXPECT_EQ(10.0, data_points[1]["explicitBounds"][0].get()); - EXPECT_EQ(20.0, data_points[1]["explicitBounds"][1].get()); - EXPECT_EQ(30.0, data_points[1]["explicitBounds"][2].get()); - } - - auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); - ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); - if (custom_header != mock_session->GetRequest()->headers_.end()) - { - EXPECT_EQ("Custom-Header-Value", custom_header->second); - } - - http_client::nosend::Response response; - response.Finish(*callback.get()); - }); + .WillOnce( + [&mock_session]( + const std::shared_ptr &callback) { + auto check_json = + nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); + + auto resource_metrics = *check_json["resourceMetrics"].begin(); + auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); + auto scope = scope_metrics["scope"]; + EXPECT_EQ("library_name", scope["name"].get()); + EXPECT_EQ("1.5.0", scope["version"].get()); + + auto metric = *scope_metrics["metrics"].begin(); + EXPECT_EQ("metrics_library_name", metric["name"].get()); + EXPECT_EQ("metrics_description", metric["description"].get()); + EXPECT_EQ("metrics_unit", metric["unit"].get()); + + auto data_points = metric["histogram"]["dataPoints"]; + EXPECT_EQ(3, JsonToInteger(data_points[0]["count"])); + EXPECT_EQ(900.5, data_points[0]["sum"].get()); + EXPECT_EQ(1.8, data_points[0]["min"].get()); + EXPECT_EQ(19, data_points[0]["max"].get()); + EXPECT_EQ(4, data_points[0]["bucketCounts"].size()); + if (4 == data_points[0]["bucketCounts"].size()) + { + EXPECT_EQ(200, JsonToInteger(data_points[0]["bucketCounts"][0])); + EXPECT_EQ(300, JsonToInteger(data_points[0]["bucketCounts"][1])); + EXPECT_EQ(400, JsonToInteger(data_points[0]["bucketCounts"][2])); + EXPECT_EQ(500, JsonToInteger(data_points[0]["bucketCounts"][3])); + } + EXPECT_EQ(3, data_points[0]["explicitBounds"].size()); + if (3 == data_points[0]["explicitBounds"].size()) + { + EXPECT_EQ(10.1, data_points[0]["explicitBounds"][0].get()); + EXPECT_EQ(20.2, data_points[0]["explicitBounds"][1].get()); + EXPECT_EQ(30.2, data_points[0]["explicitBounds"][2].get()); + } + + EXPECT_EQ(3, JsonToInteger(data_points[1]["count"])); + EXPECT_EQ(900.0, data_points[1]["sum"].get()); + EXPECT_EQ(4, data_points[1]["bucketCounts"].size()); + if (4 == data_points[1]["bucketCounts"].size()) + { + EXPECT_EQ(200, JsonToInteger(data_points[1]["bucketCounts"][0])); + EXPECT_EQ(300, JsonToInteger(data_points[1]["bucketCounts"][1])); + EXPECT_EQ(400, JsonToInteger(data_points[1]["bucketCounts"][2])); + EXPECT_EQ(500, JsonToInteger(data_points[1]["bucketCounts"][3])); + } + EXPECT_EQ(3, data_points[1]["explicitBounds"].size()); + if (3 == data_points[1]["explicitBounds"].size()) + { + EXPECT_EQ(10.0, data_points[1]["explicitBounds"][0].get()); + EXPECT_EQ(20.0, data_points[1]["explicitBounds"][1].get()); + EXPECT_EQ(30.0, data_points[1]["explicitBounds"][2].get()); + } + + auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); + ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); + if (custom_header != mock_session->GetRequest()->headers_.end()) + { + EXPECT_EQ("Custom-Header-Value", custom_header->second); + } + + http_client::nosend::Response response; + response.Finish(*callback.get()); + }); auto result = exporter->Export(data); EXPECT_EQ(result, opentelemetry::sdk::common::ExportResult::kSuccess); @@ -661,7 +665,8 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test EXPECT_CALL(*mock_session, SendRequest) .WillOnce([&mock_session]( - std::shared_ptr callback) { + const std::shared_ptr + &callback) { opentelemetry::proto::collector::metrics::v1::ExportMetricsServiceRequest request_body; request_body.ParseFromArray(&mock_session->GetRequest()->body_[0], static_cast(mock_session->GetRequest()->body_.size())); diff --git a/exporters/otlp/test/otlp_metrics_serialization_test.cc b/exporters/otlp/test/otlp_metrics_serialization_test.cc index b945cb28fe..2ad76dfd1d 100644 --- a/exporters/otlp/test/otlp_metrics_serialization_test.cc +++ b/exporters/otlp/test/otlp_metrics_serialization_test.cc @@ -200,7 +200,7 @@ TEST(OtlpMetricSerializationTest, Counter) EXPECT_EQ(sum.is_monotonic(), true); for (size_t i = 0; i < 1; i++) { - auto proto_number_point = sum.data_points(i); + const auto &proto_number_point = sum.data_points(i); EXPECT_EQ(proto_number_point.as_double(), i == 0 ? 10.2 : 20.2); } @@ -230,7 +230,7 @@ TEST(OtlpMetricSerializationTest, Histogram) proto::metrics::v1::AggregationTemporality::AGGREGATION_TEMPORALITY_CUMULATIVE); for (size_t i = 0; i < 1; i++) { - auto proto_number_point = histogram.data_points(i); + const auto &proto_number_point = histogram.data_points(i); EXPECT_EQ(proto_number_point.sum(), i == 0 ? 100.2 : 200.2); } @@ -244,7 +244,7 @@ TEST(OtlpMetricSerializationTest, ObservableGauge) otlp_exporter::OtlpMetricUtils::ConvertGaugeMetric(data, &gauge); for (size_t i = 0; i < 1; i++) { - auto proto_number_point = gauge.data_points(i); + const auto &proto_number_point = gauge.data_points(i); EXPECT_EQ(proto_number_point.as_double(), i == 0 ? 30.2 : 50.2); } diff --git a/exporters/otlp/test/otlp_recordable_test.cc b/exporters/otlp/test/otlp_recordable_test.cc index caa17c8a46..537f10340d 100644 --- a/exporters/otlp/test/otlp_recordable_test.cc +++ b/exporters/otlp/test/otlp_recordable_test.cc @@ -216,7 +216,7 @@ TEST(OtlpRecordable, SetResource) bool found_service_name = false; for (int i = 0; i < proto_resource.attributes_size(); i++) { - auto attr = proto_resource.attributes(static_cast(i)); + const auto &attr = proto_resource.attributes(static_cast(i)); if (attr.key() == service_name_key && attr.value().string_value() == service_name) { found_service_name = true; @@ -322,7 +322,7 @@ TEST(OtlpRecordable, PopulateRequest) OtlpRecordableUtils::PopulateRequest(spans_span, &req); EXPECT_EQ(req.resource_spans().size(), 2); - for (auto resource_spans : req.resource_spans()) + for (const auto &resource_spans : req.resource_spans()) { auto service_name = resource_spans.resource().attributes(0).value().string_value(); auto scope_spans_size = resource_spans.scope_spans().size(); @@ -359,7 +359,7 @@ TEST(OtlpRecordable, PopulateRequestMissing) OtlpRecordableUtils::PopulateRequest(spans_span, &req); EXPECT_EQ(req.resource_spans().size(), 2); - for (auto resource_spans : req.resource_spans()) + for (const auto &resource_spans : req.resource_spans()) { // Both should have scope spans EXPECT_EQ(resource_spans.scope_spans().size(), 1); diff --git a/exporters/prometheus/src/exporter_utils.cc b/exporters/prometheus/src/exporter_utils.cc index 68d8586bcc..35ee748273 100644 --- a/exporters/prometheus/src/exporter_utils.cc +++ b/exporters/prometheus/src/exporter_utils.cc @@ -88,7 +88,7 @@ inline std::string Sanitize(std::string name, const T &valid) */ std::string SanitizeLabel(std::string label_key) { - return Sanitize(label_key, [](int i, char c) { + return Sanitize(std::move(label_key), [](int i, char c) { return (c >= 'a' && c <= 'z') || // (c >= 'A' && c <= 'Z') || // c == '_' || // @@ -396,7 +396,7 @@ std::string PrometheusExporterUtils::RemoveUnitPortionInBraces(const std::string std::string PrometheusExporterUtils::ConvertRateExpressedToPrometheusUnit( const std::string &rate_expressed_unit) { - size_t pos = rate_expressed_unit.find("/"); + size_t pos = rate_expressed_unit.find('/'); if (pos == std::string::npos) { return rate_expressed_unit; diff --git a/exporters/prometheus/test/exporter_test.cc b/exporters/prometheus/test/exporter_test.cc index 3bda4c3d7b..b268ac8514 100644 --- a/exporters/prometheus/test/exporter_test.cc +++ b/exporters/prometheus/test/exporter_test.cc @@ -16,7 +16,6 @@ * private constructor is only to be used here for testing */ -using opentelemetry::exporter::metrics::PrometheusCollector; using opentelemetry::exporter::metrics::PrometheusExporter; using opentelemetry::exporter::metrics::PrometheusExporterOptions; using opentelemetry::sdk::metrics::AggregationTemporality; diff --git a/exporters/prometheus/test/exporter_utils_test.cc b/exporters/prometheus/test/exporter_utils_test.cc index b876e7369c..7ad5eee1fd 100644 --- a/exporters/prometheus/test/exporter_utils_test.cc +++ b/exporters/prometheus/test/exporter_utils_test.cc @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 #include + +#include #include "prometheus/metric_family.h" #include "prometheus/metric_type.h" @@ -24,7 +26,7 @@ class SanitizeNameTester public: static std::string sanitize(std::string name) { - return PrometheusExporterUtils::SanitizeNames(name); + return PrometheusExporterUtils::SanitizeNames(std::move(name)); } static std::string getPrometheusUnit(const std::string &unit_abbreviation) { @@ -104,14 +106,13 @@ void assert_basic(prometheus_client::MetricFamily &metric, ASSERT_TRUE(false); break; case prometheus::MetricType::Untyped: - break; default: break; } } void assert_histogram(prometheus_client::MetricFamily &metric, - std::list boundaries, + const std::list &boundaries, std::vector correct) { int cumulative_count = 0; diff --git a/exporters/zipkin/src/zipkin_exporter.cc b/exporters/zipkin/src/zipkin_exporter.cc index e6d3ce8b26..a554cbf4cc 100644 --- a/exporters/zipkin/src/zipkin_exporter.cc +++ b/exporters/zipkin/src/zipkin_exporter.cc @@ -1,6 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +// NOLINTNEXTLINE #define _WINSOCKAPI_ // stops including winsock.h #include @@ -105,7 +106,6 @@ sdk::common::ExportResult ZipkinExporter::Export( } return sdk::common::ExportResult::kFailure; } - return sdk::common::ExportResult::kSuccess; } void ZipkinExporter::InitializeLocalEndpoint() diff --git a/exporters/zipkin/test/zipkin_exporter_test.cc b/exporters/zipkin/test/zipkin_exporter_test.cc index 18c47bcab5..8e58f83d2e 100644 --- a/exporters/zipkin/test/zipkin_exporter_test.cc +++ b/exporters/zipkin/test/zipkin_exporter_test.cc @@ -17,6 +17,7 @@ # include "nlohmann/json.hpp" # include +# include # if defined(_MSC_VER) # include "opentelemetry/sdk/common/env_variables.h" @@ -47,7 +48,7 @@ class ZipkinExporterTestPeer : public ::testing::Test std::unique_ptr GetExporter( std::shared_ptr http_client) { - return std::unique_ptr(new ZipkinExporter(http_client)); + return std::unique_ptr(new ZipkinExporter(std::move(http_client))); } // Get the options associated with the given exporter. 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 58dd154bb7..b6654ce3ad 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 @@ -124,7 +124,8 @@ class HttpOperation double ulnow); #endif public: - void DispatchEvent(opentelemetry::ext::http::client::SessionState type, std::string reason = ""); + void DispatchEvent(opentelemetry::ext::http::client::SessionState type, + const std::string &reason = ""); /** * Create local CURL instance for url and body diff --git a/ext/src/dll/dllmain.cc b/ext/src/dll/dllmain.cc index 1812377374..df1d2bc70d 100644 --- a/ext/src/dll/dllmain.cc +++ b/ext/src/dll/dllmain.cc @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include +#include // NOLINT // Include API header files here for exporting #include diff --git a/ext/src/http/client/curl/http_client_curl.cc b/ext/src/http/client/curl/http_client_curl.cc index 38ca2e7348..67b0b93a54 100644 --- a/ext/src/http/client/curl/http_client_curl.cc +++ b/ext/src/http/client/curl/http_client_curl.cc @@ -562,7 +562,7 @@ bool HttpClient::doAbortSessions() } bool has_data = false; - for (auto session : pending_to_abort_sessions) + for (const auto &session : pending_to_abort_sessions) { if (!session.second) { diff --git a/ext/src/http/client/curl/http_operation_curl.cc b/ext/src/http/client/curl/http_operation_curl.cc index f82c17ccc5..4de014fd82 100644 --- a/ext/src/http/client/curl/http_operation_curl.cc +++ b/ext/src/http/client/curl/http_operation_curl.cc @@ -240,7 +240,7 @@ int HttpOperation::OnProgressCallback(void *clientp, #endif void HttpOperation::DispatchEvent(opentelemetry::ext::http::client::SessionState type, - std::string reason) + const std::string &reason) { if (event_handle_ != nullptr) { @@ -273,7 +273,7 @@ HttpOperation::HttpOperation(opentelemetry::ext::http::client::Method method, last_curl_result_(CURLE_OK), event_handle_(event_handle), method_(method), - url_(url), + url_(std::move(url)), ssl_options_(ssl_options), // Local vars request_headers_(request_headers), @@ -453,7 +453,7 @@ void HttpOperation::Cleanup() # define HAVE_TLS_VERSION #endif -static long parse_min_ssl_version(std::string version) +static long parse_min_ssl_version(const std::string &version) { #ifdef HAVE_TLS_VERSION if (version == "1.2") @@ -470,7 +470,7 @@ static long parse_min_ssl_version(std::string version) return 0; } -static long parse_max_ssl_version(std::string version) +static long parse_max_ssl_version(const std::string &version) { #ifdef HAVE_TLS_VERSION if (version == "1.2") diff --git a/ext/test/http/curl_http_test.cc b/ext/test/http/curl_http_test.cc index 6e30323eeb..0dc6e5d5e8 100644 --- a/ext/test/http/curl_http_test.cc +++ b/ext/test/http/curl_http_test.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include #define HTTP_PORT 19000 @@ -74,7 +75,9 @@ class PostEventHandler : public CustomEventHandler class FinishInCallbackHandler : public CustomEventHandler { public: - FinishInCallbackHandler(std::shared_ptr session) : session_(session) {} + FinishInCallbackHandler(std::shared_ptr session) + : session_(std::move(session)) + {} void OnResponse(http_client::Response &response) noexcept override { diff --git a/ext/test/w3c_tracecontext_test/main.cc b/ext/test/w3c_tracecontext_test/main.cc index 349626e219..d9819cde0d 100644 --- a/ext/test/w3c_tracecontext_test/main.cc +++ b/ext/test/w3c_tracecontext_test/main.cc @@ -75,10 +75,10 @@ struct Uri uint16_t port; std::string path; - Uri(std::string uri) + Uri(const std::string &uri) { - size_t host_end = uri.substr(7, std::string::npos).find(":"); - size_t port_end = uri.substr(host_end + 1, std::string::npos).find("/"); + size_t host_end = uri.substr(7, std::string::npos).find(':'); + size_t port_end = uri.substr(host_end + 1, std::string::npos).find('/'); host = uri.substr(0, host_end + 7); port = std::stoi(uri.substr(7 + host_end + 1, port_end)); diff --git a/functional/otlp/func_http_main.cc b/functional/otlp/func_http_main.cc index 4f6c144a43..ece1588425 100644 --- a/functional/otlp/func_http_main.cc +++ b/functional/otlp/func_http_main.cc @@ -39,7 +39,7 @@ const int TEST_FAILED = 1; Command line parameters. */ -enum test_mode +enum test_mode : std::uint8_t { MODE_NONE, MODE_HTTP, @@ -84,7 +84,7 @@ struct TestResult struct TestResult g_test_result; -void parse_error_msg(TestResult *result, std::string msg) +void parse_error_msg(TestResult *result, const std::string &msg) { static std::string connection_failed("Session state: connection failed."); @@ -129,11 +129,11 @@ void parse_error_msg(TestResult *result, std::string msg) } } -void parse_warning_msg(TestResult * /* result */, std::string /* msg */) {} +void parse_warning_msg(TestResult * /* result */, const std::string & /* msg */) {} -void parse_info_msg(TestResult * /* result */, std::string /* msg */) {} +void parse_info_msg(TestResult * /* result */, const std::string & /* msg */) {} -void parse_debug_msg(TestResult *result, std::string msg) +void parse_debug_msg(TestResult *result, const std::string &msg) { static std::string export_success("Export 1 trace span(s) success"); @@ -162,19 +162,19 @@ class TestLogHandler : public opentelemetry::sdk::common::internal_log::LogHandl case opentelemetry::sdk::common::internal_log::LogLevel::None: break; case opentelemetry::sdk::common::internal_log::LogLevel::Error: - std::cout << " - [E] " << msg << std::endl; + std::cout << " - [E] " << msg << '\n'; parse_error_msg(&g_test_result, msg); break; case opentelemetry::sdk::common::internal_log::LogLevel::Warning: - std::cout << " - [W] " << msg << std::endl; + std::cout << " - [W] " << msg << '\n'; parse_warning_msg(&g_test_result, msg); break; case opentelemetry::sdk::common::internal_log::LogLevel::Info: - std::cout << " - [I] " << msg << std::endl; + std::cout << " - [I] " << msg << '\n'; parse_info_msg(&g_test_result, msg); break; case opentelemetry::sdk::common::internal_log::LogLevel::Debug: - std::cout << " - [D] " << msg << std::endl; + std::cout << " - [D] " << msg << '\n'; parse_debug_msg(&g_test_result, msg); break; } @@ -429,12 +429,12 @@ void list_test_cases() while (current->m_func != nullptr) { - std::cout << current->m_name << std::endl; + std::cout << current->m_name << '\n'; current++; } } -int run_test_case(std::string name) +int run_test_case(const std::string &name) { const test_case *current = all_tests; @@ -448,7 +448,7 @@ int run_test_case(std::string name) current++; } - std::cerr << "Unknown test <" << name << ">" << std::endl; + std::cerr << "Unknown test <" << name << ">" << '\n'; return 1; } diff --git a/sdk/include/opentelemetry/sdk/logs/logger_context.h b/sdk/include/opentelemetry/sdk/logs/logger_context.h index bab002b231..11eca41d16 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_context.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_context.h @@ -34,7 +34,7 @@ class LoggerContext { public: explicit LoggerContext(std::vector> &&processors, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({})) noexcept; /** diff --git a/sdk/include/opentelemetry/sdk/logs/logger_provider.h b/sdk/include/opentelemetry/sdk/logs/logger_provider.h index 6c035ad5e9..dd2a52789d 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_provider.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_provider.h @@ -38,11 +38,11 @@ class OPENTELEMETRY_EXPORT LoggerProvider final : public opentelemetry::logs::Lo * @param resource The resources for this logger provider. */ explicit LoggerProvider(std::unique_ptr &&processor, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({})) noexcept; explicit LoggerProvider(std::vector> &&processors, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({})) noexcept; /** diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_context.h b/sdk/include/opentelemetry/sdk/metrics/meter_context.h index 40a57a6f88..fe85fe04cc 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_context.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_context.h @@ -54,7 +54,7 @@ class MeterContext : public std::enable_shared_from_this */ MeterContext( std::unique_ptr views = std::unique_ptr(new ViewRegistry()), - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({})) noexcept; /** @@ -131,7 +131,7 @@ class MeterContext : public std::enable_shared_from_this * * @param meter */ - void AddMeter(std::shared_ptr meter); + void AddMeter(const std::shared_ptr &meter); void RemoveMeter(nostd::string_view name, nostd::string_view version, diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h index a838f2a96a..c34f16e0a1 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h @@ -39,8 +39,8 @@ class OPENTELEMETRY_EXPORT MeterProvider final : public opentelemetry::metrics:: * @param resource The resources for this meter provider. */ MeterProvider( - std::unique_ptr views = std::unique_ptr(new ViewRegistry()), - sdk::resource::Resource resource = sdk::resource::Resource::Create({})) noexcept; + std::unique_ptr views = std::unique_ptr(new ViewRegistry()), + const sdk::resource::Resource &resource = sdk::resource::Resource::Create({})) noexcept; /** * Initialize a new meter provider with a specified context diff --git a/sdk/include/opentelemetry/sdk/metrics/state/temporal_metric_storage.h b/sdk/include/opentelemetry/sdk/metrics/state/temporal_metric_storage.h index 2d01710e47..007b3c74cd 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/temporal_metric_storage.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/temporal_metric_storage.h @@ -40,7 +40,7 @@ class TemporalMetricStorage nostd::span> collectors, opentelemetry::common::SystemTimestamp sdk_start_ts, opentelemetry::common::SystemTimestamp collection_ts, - std::shared_ptr delta_metrics, + const std::shared_ptr &delta_metrics, nostd::function_ref callback) noexcept; private: diff --git a/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h b/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h index 1d2c5bf25f..1d5f8dbc55 100644 --- a/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h +++ b/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h @@ -37,7 +37,7 @@ class Synchronous class LongCounter : public Synchronous, public opentelemetry::metrics::Counter { public: - LongCounter(InstrumentDescriptor instrument_descriptor, + LongCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage); void Add(uint64_t value, @@ -56,7 +56,7 @@ class DoubleCounter : public Synchronous, public opentelemetry::metrics::Counter { public: - DoubleCounter(InstrumentDescriptor instrument_descriptor, + DoubleCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage); void Add(double value, @@ -72,7 +72,7 @@ class DoubleCounter : public Synchronous, public opentelemetry::metrics::Counter class LongUpDownCounter : public Synchronous, public opentelemetry::metrics::UpDownCounter { public: - LongUpDownCounter(InstrumentDescriptor instrument_descriptor, + LongUpDownCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage); void Add(int64_t value, @@ -88,7 +88,7 @@ class LongUpDownCounter : public Synchronous, public opentelemetry::metrics::UpD class DoubleUpDownCounter : public Synchronous, public opentelemetry::metrics::UpDownCounter { public: - DoubleUpDownCounter(InstrumentDescriptor instrument_descriptor, + DoubleUpDownCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage); void Add(double value, @@ -104,7 +104,7 @@ class DoubleUpDownCounter : public Synchronous, public opentelemetry::metrics::U class LongHistogram : public Synchronous, public opentelemetry::metrics::Histogram { public: - LongHistogram(InstrumentDescriptor instrument_descriptor, + LongHistogram(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage); #if OPENTELEMETRY_ABI_VERSION_NO >= 2 @@ -124,7 +124,7 @@ class LongHistogram : public Synchronous, public opentelemetry::metrics::Histogr class DoubleHistogram : public Synchronous, public opentelemetry::metrics::Histogram { public: - DoubleHistogram(InstrumentDescriptor instrument_descriptor, + DoubleHistogram(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage); #if OPENTELEMETRY_ABI_VERSION_NO >= 2 diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/parent.h b/sdk/include/opentelemetry/sdk/trace/samplers/parent.h index d5054d9218..e44e9fa320 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/parent.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/parent.h @@ -27,7 +27,7 @@ namespace trace class ParentBasedSampler : public Sampler { public: - explicit ParentBasedSampler(std::shared_ptr delegate_sampler) noexcept; + explicit ParentBasedSampler(const std::shared_ptr &delegate_sampler) noexcept; /** The decision either respects the parent span's sampling decision or delegates to * delegateSampler for root spans * @return Returns DROP always diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h b/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h index 68557ace79..d5cf598311 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h @@ -23,7 +23,7 @@ class ParentBasedSamplerFactory /** * Create a ParentBasedSampler. */ - static std::unique_ptr Create(std::shared_ptr delegate_sampler); + static std::unique_ptr Create(const std::shared_ptr &delegate_sampler); }; } // namespace trace diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_context.h b/sdk/include/opentelemetry/sdk/trace/tracer_context.h index 73bbe4f84b..e1b2cb25d2 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_context.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_context.h @@ -39,7 +39,7 @@ class TracerContext public: explicit TracerContext( std::vector> &&processor, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({}), std::unique_ptr sampler = std::unique_ptr(new AlwaysOnSampler), std::unique_ptr id_generator = diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h index 0d05a94043..13a65a2d87 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_provider.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_provider.h @@ -43,7 +43,7 @@ class OPENTELEMETRY_EXPORT TracerProvider final : public opentelemetry::trace::T */ explicit TracerProvider( std::unique_ptr processor, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({}), std::unique_ptr sampler = std::unique_ptr(new AlwaysOnSampler), std::unique_ptr id_generator = @@ -51,7 +51,7 @@ class OPENTELEMETRY_EXPORT TracerProvider final : public opentelemetry::trace::T explicit TracerProvider( std::vector> &&processors, - opentelemetry::sdk::resource::Resource resource = + const opentelemetry::sdk::resource::Resource &resource = opentelemetry::sdk::resource::Resource::Create({}), std::unique_ptr sampler = std::unique_ptr(new AlwaysOnSampler), std::unique_ptr id_generator = diff --git a/sdk/src/common/global_log_handler.cc b/sdk/src/common/global_log_handler.cc index 40968f2b7e..f60527eee8 100644 --- a/sdk/src/common/global_log_handler.cc +++ b/sdk/src/common/global_log_handler.cc @@ -31,7 +31,7 @@ void DefaultLogHandler::Handle(LogLevel level, { output_s << msg; } - output_s << std::endl; + output_s << '\n'; // TBD - print attributes switch (level) diff --git a/sdk/src/logs/event_logger.cc b/sdk/src/logs/event_logger.cc index 6b0afacfaf..df9ba44c31 100644 --- a/sdk/src/logs/event_logger.cc +++ b/sdk/src/logs/event_logger.cc @@ -21,7 +21,7 @@ namespace logs EventLogger::EventLogger( opentelemetry::nostd::shared_ptr delegate_logger, opentelemetry::nostd::string_view event_domain) noexcept - : delegate_logger_(delegate_logger), event_domain_(event_domain) + : delegate_logger_(std::move(delegate_logger)), event_domain_(event_domain) {} const opentelemetry::nostd::string_view EventLogger::GetName() noexcept diff --git a/sdk/src/logs/logger.cc b/sdk/src/logs/logger.cc index e9935c5107..2d57ab9faa 100644 --- a/sdk/src/logs/logger.cc +++ b/sdk/src/logs/logger.cc @@ -38,7 +38,7 @@ Logger::Logger( std::unique_ptr instrumentation_scope) noexcept : logger_name_(std::string(name)), instrumentation_scope_(std::move(instrumentation_scope)), - context_(context) + context_(std::move(context)) {} const opentelemetry::nostd::string_view Logger::GetName() noexcept diff --git a/sdk/src/logs/logger_context.cc b/sdk/src/logs/logger_context.cc index 2bfb89161e..a6eb063661 100644 --- a/sdk/src/logs/logger_context.cc +++ b/sdk/src/logs/logger_context.cc @@ -19,7 +19,7 @@ namespace logs { LoggerContext::LoggerContext(std::vector> &&processors, - opentelemetry::sdk::resource::Resource resource) noexcept + const opentelemetry::sdk::resource::Resource &resource) noexcept : resource_(resource), processor_( std::unique_ptr(new MultiLogRecordProcessor(std::move(processors)))) diff --git a/sdk/src/logs/logger_provider.cc b/sdk/src/logs/logger_provider.cc index 1eaa0d186e..fdea3eb51a 100644 --- a/sdk/src/logs/logger_provider.cc +++ b/sdk/src/logs/logger_provider.cc @@ -27,7 +27,7 @@ namespace logs { LoggerProvider::LoggerProvider(std::unique_ptr &&processor, - opentelemetry::sdk::resource::Resource resource) noexcept + const opentelemetry::sdk::resource::Resource &resource) noexcept { std::vector> processors; processors.emplace_back(std::move(processor)); @@ -36,7 +36,7 @@ LoggerProvider::LoggerProvider(std::unique_ptr &&processor, } LoggerProvider::LoggerProvider(std::vector> &&processors, - opentelemetry::sdk::resource::Resource resource) noexcept + const opentelemetry::sdk::resource::Resource &resource) noexcept : context_{std::make_shared(std::move(processors), std::move(resource))} {} diff --git a/sdk/src/metrics/async_instruments.cc b/sdk/src/metrics/async_instruments.cc index 311efc1e7e..709957d68e 100644 --- a/sdk/src/metrics/async_instruments.cc +++ b/sdk/src/metrics/async_instruments.cc @@ -20,9 +20,9 @@ namespace metrics ObservableInstrument::ObservableInstrument(InstrumentDescriptor instrument_descriptor, std::unique_ptr storage, std::shared_ptr observable_registry) - : instrument_descriptor_(instrument_descriptor), + : instrument_descriptor_(std::move(instrument_descriptor)), storage_(std::move(storage)), - observable_registry_{observable_registry} + observable_registry_{std::move(observable_registry)} {} diff --git a/sdk/src/metrics/exemplar/reservoir.cc b/sdk/src/metrics/exemplar/reservoir.cc index 4e7501799e..264a000828 100644 --- a/sdk/src/metrics/exemplar/reservoir.cc +++ b/sdk/src/metrics/exemplar/reservoir.cc @@ -3,9 +3,11 @@ #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW -# include "opentelemetry/sdk/metrics/exemplar/reservoir.h" +# include + # include "opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.h" # include "opentelemetry/sdk/metrics/exemplar/no_exemplar_reservoir.h" +# include "opentelemetry/sdk/metrics/exemplar/reservoir.h" # include "opentelemetry/sdk/metrics/exemplar/reservoir_cell.h" # include "opentelemetry/sdk/metrics/exemplar/simple_fixed_size_exemplar_reservoir.h" @@ -20,8 +22,8 @@ nostd::shared_ptr ExemplarReservoir::GetSimpleFixedSizeExempl std::shared_ptr reservoir_cell_selector, MapAndResetCellType map_and_reset_cell) { - return nostd::shared_ptr{ - new SimpleFixedSizeExemplarReservoir{size, reservoir_cell_selector, map_and_reset_cell}}; + return nostd::shared_ptr{new SimpleFixedSizeExemplarReservoir{ + size, std::move(reservoir_cell_selector), map_and_reset_cell}}; } nostd::shared_ptr ExemplarReservoir::GetAlignedHistogramBucketExemplarReservoir( @@ -30,7 +32,7 @@ nostd::shared_ptr ExemplarReservoir::GetAlignedHistogramBucke MapAndResetCellType map_and_reset_cell) { return nostd::shared_ptr{new AlignedHistogramBucketExemplarReservoir{ - size, reservoir_cell_selector, map_and_reset_cell}}; + size, std::move(reservoir_cell_selector), map_and_reset_cell}}; } nostd::shared_ptr ExemplarReservoir::GetNoExemplarReservoir() diff --git a/sdk/src/metrics/meter.cc b/sdk/src/metrics/meter.cc index 8b4413113b..c61f3a8d31 100644 --- a/sdk/src/metrics/meter.cc +++ b/sdk/src/metrics/meter.cc @@ -53,7 +53,7 @@ Meter::Meter( std::weak_ptr meter_context, std::unique_ptr instrumentation_scope) noexcept : scope_{std::move(instrumentation_scope)}, - meter_context_{meter_context}, + meter_context_{std::move(meter_context)}, observable_registry_(new ObservableRegistry()) {} @@ -455,7 +455,7 @@ std::vector Meter::Collect(CollectorHandle *collector, for (auto &metric_storage : storage_registry_) { metric_storage.second->Collect(collector, ctx->GetCollectors(), ctx->GetSDKStartTime(), - collect_ts, [&metric_data_list](MetricData metric_data) { + collect_ts, [&metric_data_list](const MetricData &metric_data) { metric_data_list.push_back(metric_data); return true; }); diff --git a/sdk/src/metrics/meter_context.cc b/sdk/src/metrics/meter_context.cc index de32c469d8..40b9da42b2 100644 --- a/sdk/src/metrics/meter_context.cc +++ b/sdk/src/metrics/meter_context.cc @@ -36,7 +36,7 @@ namespace metrics { MeterContext::MeterContext(std::unique_ptr views, - opentelemetry::sdk::resource::Resource resource) noexcept + const opentelemetry::sdk::resource::Resource &resource) noexcept : resource_{resource}, views_(std::move(views)), sdk_start_ts_{std::chrono::system_clock::now()} {} @@ -82,7 +82,7 @@ opentelemetry::common::SystemTimestamp MeterContext::GetSDKStartTime() noexcept void MeterContext::AddMetricReader(std::shared_ptr reader) noexcept { - auto collector = std::shared_ptr{new MetricCollector(this, reader)}; + auto collector = std::shared_ptr{new MetricCollector(this, std::move(reader))}; collectors_.push_back(collector); } @@ -107,7 +107,7 @@ ExemplarFilterType MeterContext::GetExemplarFilter() const noexcept #endif // ENABLE_METRICS_EXEMPLAR_PREVIEW -void MeterContext::AddMeter(std::shared_ptr meter) +void MeterContext::AddMeter(const std::shared_ptr &meter) { std::lock_guard guard(meter_lock_); meters_.push_back(meter); diff --git a/sdk/src/metrics/meter_provider.cc b/sdk/src/metrics/meter_provider.cc index 6ddba6aa7c..4f2ca4b44f 100644 --- a/sdk/src/metrics/meter_provider.cc +++ b/sdk/src/metrics/meter_provider.cc @@ -37,7 +37,7 @@ MeterProvider::MeterProvider(std::unique_ptr context) noexcept {} MeterProvider::MeterProvider(std::unique_ptr views, - sdk::resource::Resource resource) noexcept + const sdk::resource::Resource &resource) noexcept : context_(std::make_shared(std::move(views), resource)) { OTEL_INTERNAL_LOG_DEBUG("[MeterProvider] MeterProvider created."); @@ -110,7 +110,7 @@ const resource::Resource &MeterProvider::GetResource() const noexcept void MeterProvider::AddMetricReader(std::shared_ptr reader) noexcept { - context_->AddMetricReader(reader); + context_->AddMetricReader(std::move(reader)); } void MeterProvider::AddView(std::unique_ptr instrument_selector, diff --git a/sdk/src/metrics/state/metric_collector.cc b/sdk/src/metrics/state/metric_collector.cc index 5ecf41cecf..a790a6b6a1 100644 --- a/sdk/src/metrics/state/metric_collector.cc +++ b/sdk/src/metrics/state/metric_collector.cc @@ -27,7 +27,7 @@ namespace metrics MetricCollector::MetricCollector(opentelemetry::sdk::metrics::MeterContext *context, std::shared_ptr metric_reader) - : meter_context_{context}, metric_reader_{metric_reader} + : meter_context_{context}, metric_reader_{std::move(metric_reader)} { metric_reader_->SetMetricProducer(this); } @@ -48,7 +48,7 @@ bool MetricCollector::Collect( return false; } ResourceMetrics resource_metrics; - meter_context_->ForEachMeter([&](std::shared_ptr meter) noexcept { + meter_context_->ForEachMeter([&](const std::shared_ptr &meter) noexcept { auto collection_ts = std::chrono::system_clock::now(); auto metric_data = meter->Collect(this, collection_ts); if (!metric_data.empty()) diff --git a/sdk/src/metrics/state/temporal_metric_storage.cc b/sdk/src/metrics/state/temporal_metric_storage.cc index 2ba74d9213..c26339a79f 100644 --- a/sdk/src/metrics/state/temporal_metric_storage.cc +++ b/sdk/src/metrics/state/temporal_metric_storage.cc @@ -35,7 +35,7 @@ namespace metrics TemporalMetricStorage::TemporalMetricStorage(InstrumentDescriptor instrument_descriptor, AggregationType aggregation_type, const AggregationConfig *aggregation_config) - : instrument_descriptor_(instrument_descriptor), + : instrument_descriptor_(std::move(instrument_descriptor)), aggregation_type_(aggregation_type), aggregation_config_(aggregation_config) {} @@ -44,7 +44,7 @@ bool TemporalMetricStorage::buildMetrics(CollectorHandle *collector, nostd::span> collectors, opentelemetry::common::SystemTimestamp sdk_start_ts, opentelemetry::common::SystemTimestamp collection_ts, - std::shared_ptr delta_metrics, + const std::shared_ptr &delta_metrics, nostd::function_ref callback) noexcept { std::lock_guard guard(lock_); diff --git a/sdk/src/metrics/sync_instruments.cc b/sdk/src/metrics/sync_instruments.cc index a99fa80868..56429a079f 100644 --- a/sdk/src/metrics/sync_instruments.cc +++ b/sdk/src/metrics/sync_instruments.cc @@ -20,7 +20,7 @@ namespace sdk { namespace metrics { -LongCounter::LongCounter(InstrumentDescriptor instrument_descriptor, +LongCounter::LongCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -80,7 +80,7 @@ void LongCounter::Add(uint64_t value, const opentelemetry::context::Context &con return storage_->RecordLong(value, context); } -DoubleCounter::DoubleCounter(InstrumentDescriptor instrument_descriptor, +DoubleCounter::DoubleCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -164,7 +164,7 @@ void DoubleCounter::Add(double value, const opentelemetry::context::Context &con return storage_->RecordDouble(value, context); } -LongUpDownCounter::LongUpDownCounter(InstrumentDescriptor instrument_descriptor, +LongUpDownCounter::LongUpDownCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -228,7 +228,7 @@ void LongUpDownCounter::Add(int64_t value, const opentelemetry::context::Context return storage_->RecordLong(value, context); } -DoubleUpDownCounter::DoubleUpDownCounter(InstrumentDescriptor instrument_descriptor, +DoubleUpDownCounter::DoubleUpDownCounter(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -292,7 +292,7 @@ void DoubleUpDownCounter::Add(double value, const opentelemetry::context::Contex return storage_->RecordDouble(value, context); } -LongHistogram::LongHistogram(InstrumentDescriptor instrument_descriptor, +LongHistogram::LongHistogram(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { @@ -355,7 +355,7 @@ void LongHistogram::Record(uint64_t value) noexcept } #endif -DoubleHistogram::DoubleHistogram(InstrumentDescriptor instrument_descriptor, +DoubleHistogram::DoubleHistogram(const InstrumentDescriptor &instrument_descriptor, std::unique_ptr storage) : Synchronous(instrument_descriptor, std::move(storage)) { diff --git a/sdk/src/metrics/view/view_factory.cc b/sdk/src/metrics/view/view_factory.cc index 36496f62d6..319c10b956 100644 --- a/sdk/src/metrics/view/view_factory.cc +++ b/sdk/src/metrics/view/view_factory.cc @@ -53,7 +53,7 @@ std::unique_ptr ViewFactory::Create(const std::string &name, auto attributes_processor = std::unique_ptr(new DefaultAttributesProcessor()); - return Create(name, description, unit, aggregation_type, aggregation_config, + return Create(name, description, unit, aggregation_type, std::move(aggregation_config), std::move(attributes_processor)); } @@ -64,7 +64,8 @@ std::unique_ptr ViewFactory::Create(const std::string &name, std::shared_ptr aggregation_config, std::unique_ptr attributes_processor) { - std::unique_ptr view(new View(name, description, unit, aggregation_type, aggregation_config, + std::unique_ptr view(new View(name, description, unit, aggregation_type, + std::move(aggregation_config), std::move(attributes_processor))); return view; } diff --git a/sdk/src/trace/batch_span_processor.cc b/sdk/src/trace/batch_span_processor.cc index 03b79f6ebb..6aa6a49949 100644 --- a/sdk/src/trace/batch_span_processor.cc +++ b/sdk/src/trace/batch_span_processor.cc @@ -29,7 +29,6 @@ #include "opentelemetry/version.h" using opentelemetry::sdk::common::AtomicUniquePtr; -using opentelemetry::sdk::common::CircularBuffer; using opentelemetry::sdk::common::CircularBufferRange; using opentelemetry::trace::SpanContext; diff --git a/sdk/src/trace/samplers/parent.cc b/sdk/src/trace/samplers/parent.cc index a69ede92d4..9bffb7b030 100644 --- a/sdk/src/trace/samplers/parent.cc +++ b/sdk/src/trace/samplers/parent.cc @@ -22,7 +22,7 @@ namespace sdk { namespace trace { -ParentBasedSampler::ParentBasedSampler(std::shared_ptr delegate_sampler) noexcept +ParentBasedSampler::ParentBasedSampler(const std::shared_ptr &delegate_sampler) noexcept : delegate_sampler_(delegate_sampler), description_("ParentBased{" + std::string{delegate_sampler->GetDescription()} + "}") {} diff --git a/sdk/src/trace/samplers/parent_factory.cc b/sdk/src/trace/samplers/parent_factory.cc index 978fb75946..7f1bc088d6 100644 --- a/sdk/src/trace/samplers/parent_factory.cc +++ b/sdk/src/trace/samplers/parent_factory.cc @@ -1,8 +1,10 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/trace/samplers/parent_factory.h" +#include + #include "opentelemetry/sdk/trace/samplers/parent.h" +#include "opentelemetry/sdk/trace/samplers/parent_factory.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -12,9 +14,9 @@ namespace trace { std::unique_ptr ParentBasedSamplerFactory::Create( - std::shared_ptr delegate_sampler) + const std::shared_ptr &delegate_sampler) { - std::unique_ptr sampler(new ParentBasedSampler(delegate_sampler)); + std::unique_ptr sampler(new ParentBasedSampler(std::move(delegate_sampler))); return sampler; } diff --git a/sdk/src/trace/span.cc b/sdk/src/trace/span.cc index ca3a475707..2b9e9d2908 100644 --- a/sdk/src/trace/span.cc +++ b/sdk/src/trace/span.cc @@ -78,7 +78,7 @@ Span::Span(std::shared_ptr &&tracer, return true; }); - links.ForEachKeyValue([&](opentelemetry::trace::SpanContext span_context, + links.ForEachKeyValue([&](const opentelemetry::trace::SpanContext &span_context, const common::KeyValueIterable &attributes) { recordable_->AddLink(span_context, attributes); return true; diff --git a/sdk/src/trace/tracer.cc b/sdk/src/trace/tracer.cc index fd02548c7b..73fc08d5dc 100644 --- a/sdk/src/trace/tracer.cc +++ b/sdk/src/trace/tracer.cc @@ -39,7 +39,7 @@ namespace trace Tracer::Tracer(std::shared_ptr context, std::unique_ptr instrumentation_scope) noexcept - : instrumentation_scope_{std::move(instrumentation_scope)}, context_{context} + : instrumentation_scope_{std::move(instrumentation_scope)}, context_{std::move(context)} {} nostd::shared_ptr Tracer::StartSpan( diff --git a/sdk/src/trace/tracer_context.cc b/sdk/src/trace/tracer_context.cc index 0fb4fd35cf..65300d6f22 100644 --- a/sdk/src/trace/tracer_context.cc +++ b/sdk/src/trace/tracer_context.cc @@ -22,7 +22,7 @@ namespace trace namespace resource = opentelemetry::sdk::resource; TracerContext::TracerContext(std::vector> &&processors, - resource::Resource resource, + const resource::Resource &resource, std::unique_ptr sampler, std::unique_ptr id_generator) noexcept : resource_(resource), diff --git a/sdk/src/trace/tracer_provider.cc b/sdk/src/trace/tracer_provider.cc index 9440e3d469..3b5462a083 100644 --- a/sdk/src/trace/tracer_provider.cc +++ b/sdk/src/trace/tracer_provider.cc @@ -38,7 +38,7 @@ TracerProvider::TracerProvider(std::unique_ptr context) noexcept } TracerProvider::TracerProvider(std::unique_ptr processor, - resource::Resource resource, + const resource::Resource &resource, std::unique_ptr sampler, std::unique_ptr id_generator) noexcept { @@ -49,7 +49,7 @@ TracerProvider::TracerProvider(std::unique_ptr processor, } TracerProvider::TracerProvider(std::vector> &&processors, - resource::Resource resource, + const resource::Resource &resource, std::unique_ptr sampler, std::unique_ptr id_generator) noexcept { diff --git a/sdk/test/common/empty_attributes_test.cc b/sdk/test/common/empty_attributes_test.cc index f37ea0a5c4..894cafc8a7 100644 --- a/sdk/test/common/empty_attributes_test.cc +++ b/sdk/test/common/empty_attributes_test.cc @@ -15,5 +15,5 @@ TEST(EmptyAttributesTest, TestMemory) { auto attributes1 = opentelemetry::sdk::GetEmptyAttributes(); auto attributes2 = opentelemetry::sdk::GetEmptyAttributes(); - EXPECT_EQ(memcmp(&attributes1, &attributes2, sizeof(attributes1)), 0); + EXPECT_EQ(memcmp(&attributes1, &attributes2, sizeof(attributes1)), 0); // NOLINT } diff --git a/sdk/test/logs/batch_log_record_processor_test.cc b/sdk/test/logs/batch_log_record_processor_test.cc index 33db0da479..3bdd849938 100644 --- a/sdk/test/logs/batch_log_record_processor_test.cc +++ b/sdk/test/logs/batch_log_record_processor_test.cc @@ -9,6 +9,7 @@ #include #include #include +#include using namespace opentelemetry::sdk::logs; using namespace opentelemetry::sdk::common; @@ -74,10 +75,10 @@ class MockLogExporter final : public LogRecordExporter std::shared_ptr> is_shutdown, std::shared_ptr> is_export_completed, const std::chrono::milliseconds export_delay = std::chrono::milliseconds(0)) - : logs_received_(logs_received), - force_flush_counter_(force_flush_counter), - is_shutdown_(is_shutdown), - is_export_completed_(is_export_completed), + : logs_received_(std::move(logs_received)), + force_flush_counter_(std::move(force_flush_counter)), + is_shutdown_(std::move(is_shutdown)), + is_export_completed_(std::move(is_export_completed)), export_delay_(export_delay) {} @@ -154,7 +155,8 @@ class BatchLogRecordProcessorTest : public testing::Test // ::testing::Test { return std::shared_ptr(new BatchLogRecordProcessor( std::unique_ptr(new MockLogExporter( - logs_received, force_flush_counter, is_shutdown, is_export_completed, export_delay)), + std::move(logs_received), std::move(force_flush_counter), std::move(is_shutdown), + std::move(is_export_completed), export_delay)), max_queue_size, scheduled_delay_millis, max_export_batch_size)); } }; diff --git a/sdk/test/logs/logger_sdk_test.cc b/sdk/test/logs/logger_sdk_test.cc index 62d523b92a..9e63672d3c 100644 --- a/sdk/test/logs/logger_sdk_test.cc +++ b/sdk/test/logs/logger_sdk_test.cc @@ -3,6 +3,7 @@ #include #include +#include #include "opentelemetry/logs/logger_provider.h" #include "opentelemetry/nostd/string_view.h" @@ -172,7 +173,7 @@ class MockProcessor final : public LogRecordProcessor public: // A processor used for testing that keeps a track of the recordable it received explicit MockProcessor(std::shared_ptr record_received) noexcept - : record_received_(record_received) + : record_received_(std::move(record_received)) {} std::unique_ptr MakeRecordable() noexcept override diff --git a/sdk/test/logs/simple_log_record_processor_test.cc b/sdk/test/logs/simple_log_record_processor_test.cc index 484cc63e71..30e5771394 100644 --- a/sdk/test/logs/simple_log_record_processor_test.cc +++ b/sdk/test/logs/simple_log_record_processor_test.cc @@ -10,6 +10,7 @@ #include #include +#include using namespace opentelemetry::sdk::logs; using namespace opentelemetry::sdk::common; @@ -75,7 +76,7 @@ class TestExporter final : public LogRecordExporter size_t *batch_size_received) : force_flush_counter_(force_flush_counter), shutdown_counter_(shutdown_counter), - logs_received_(logs_received), + logs_received_(std::move(logs_received)), batch_size_received(batch_size_received) {} diff --git a/sdk/test/metrics/async_instruments_test.cc b/sdk/test/metrics/async_instruments_test.cc index 10c0335559..b7ad885bbd 100644 --- a/sdk/test/metrics/async_instruments_test.cc +++ b/sdk/test/metrics/async_instruments_test.cc @@ -12,6 +12,7 @@ using namespace opentelemetry::sdk::metrics; using M = std::map; +// NOLINTNEXTLINE void asyc_generate_measurements(opentelemetry::metrics::ObserverResult /* observer */, void * /* state */) {} diff --git a/sdk/test/metrics/async_metric_storage_test.cc b/sdk/test/metrics/async_metric_storage_test.cc index 3b72e99d96..dcbe105418 100644 --- a/sdk/test/metrics/async_metric_storage_test.cc +++ b/sdk/test/metrics/async_metric_storage_test.cc @@ -262,7 +262,7 @@ TEST_P(WritableMetricStorageTestObservableGaugeFixture, TestAggregation) opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now())); storage.Collect( - collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) { + collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) { for (auto data_attr : metric_data.point_data_attr_) { auto data = opentelemetry::nostd::get(data_attr.point_data); @@ -288,7 +288,7 @@ TEST_P(WritableMetricStorageTestObservableGaugeFixture, TestAggregation) storage.RecordLong(measurements2, opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now())); storage.Collect( - collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) { + collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) { for (auto data_attr : metric_data.point_data_attr_) { auto data = opentelemetry::nostd::get(data_attr.point_data); diff --git a/sdk/test/metrics/cardinality_limit_test.cc b/sdk/test/metrics/cardinality_limit_test.cc index 8c2edb4b0c..3f9483ac1c 100644 --- a/sdk/test/metrics/cardinality_limit_test.cc +++ b/sdk/test/metrics/cardinality_limit_test.cc @@ -26,7 +26,7 @@ TEST(CardinalityLimit, AttributesHashMapBasicTests) return std::unique_ptr(new LongSumAggregation(true)); }; // add 10 unique metric points. 9 should be added to hashmap, 10th should be overflow. - long record_value = 100; + int64_t record_value = 100; for (auto i = 0; i < 10; i++) { FilteredOrderedAttributeMap attributes = {{"key", std::to_string(i)}}; @@ -76,7 +76,7 @@ TEST_P(WritableMetricStorageCardinalityLimitTestFixture, LongCounterSumAggregati #endif nullptr, attributes_limit); - long record_value = 100; + int64_t record_value = 100; // add 9 unique metric points, and 6 more above limit. for (auto i = 0; i < 15; i++) { diff --git a/sdk/test/metrics/instrument_metadata_validator_test.cc b/sdk/test/metrics/instrument_metadata_validator_test.cc index 172df1af3c..28c6d4a4fd 100644 --- a/sdk/test/metrics/instrument_metadata_validator_test.cc +++ b/sdk/test/metrics/instrument_metadata_validator_test.cc @@ -19,9 +19,9 @@ TEST(InstrumentMetadataValidator, TestName) { opentelemetry::sdk::metrics::InstrumentMetaDataValidator validator; std::vector invalid_names = { - "", // empty string - "1sdf", // string starting with number - "\x31\x32\x33\xe2\x82\xac\x41\x41\x41\xe2\x82\xac\x42\x42\x42" // unicode characters + "", // empty string + "1sdf", // string starting with number + "\x31\x32\x33\xe2\x82\xac\x41\x41\x41\xe2\x82\xac\x42\x42\x42", // unicode characters "/\\sdsd", // string starting with special character "***sSSs", // string starting with special character "a\\broken\\path", // contains backward slash diff --git a/sdk/test/metrics/meter_test.cc b/sdk/test/metrics/meter_test.cc index 084f50fc09..b5ed86f55a 100644 --- a/sdk/test/metrics/meter_test.cc +++ b/sdk/test/metrics/meter_test.cc @@ -18,7 +18,7 @@ using namespace opentelemetry::sdk::metrics; namespace { nostd::shared_ptr InitMeter(MetricReader **metricReaderPtr, - std::string meter_name = "meter_name") + const std::string &meter_name = "meter_name") { static std::shared_ptr provider(new MeterProvider()); std::unique_ptr metric_reader(new MockMetricReader()); diff --git a/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc b/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc index 216574a587..88ae56eb3f 100644 --- a/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc +++ b/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc @@ -71,7 +71,7 @@ TEST_P(WritableMetricStorageTestFixture, LongUpDownCounterSumAggregation) auto collection_ts = std::chrono::system_clock::now(); size_t count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { for (auto data_attr : data.point_data_attr_) { auto sum_data = opentelemetry::nostd::get(data_attr.point_data); @@ -105,7 +105,7 @@ TEST_P(WritableMetricStorageTestFixture, LongUpDownCounterSumAggregation) collection_ts = std::chrono::system_clock::now(); count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { if (temporality == AggregationTemporality::kCumulative) { EXPECT_EQ(data.start_ts, sdk_start_ts); @@ -147,7 +147,7 @@ TEST_P(WritableMetricStorageTestFixture, LongUpDownCounterSumAggregation) collection_ts = std::chrono::system_clock::now(); count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { for (auto data_attr : data.point_data_attr_) { auto sum_data = opentelemetry::nostd::get(data_attr.point_data); @@ -224,7 +224,7 @@ TEST_P(WritableMetricStorageTestFixture, DoubleUpDownCounterSumAggregation) auto collection_ts = std::chrono::system_clock::now(); size_t count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { for (auto data_attr : data.point_data_attr_) { auto sum_data = opentelemetry::nostd::get(data_attr.point_data); @@ -259,7 +259,7 @@ TEST_P(WritableMetricStorageTestFixture, DoubleUpDownCounterSumAggregation) collection_ts = std::chrono::system_clock::now(); count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { if (temporality == AggregationTemporality::kCumulative) { EXPECT_EQ(data.start_ts, sdk_start_ts); @@ -301,7 +301,7 @@ TEST_P(WritableMetricStorageTestFixture, DoubleUpDownCounterSumAggregation) collection_ts = std::chrono::system_clock::now(); count_attributes = 0; storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts, - [&](const MetricData data) { + [&](const MetricData &data) { for (auto data_attr : data.point_data_attr_) { auto sum_data = opentelemetry::nostd::get(data_attr.point_data); diff --git a/sdk/test/resource/resource_test.cc b/sdk/test/resource/resource_test.cc index e6b56cae43..419264862c 100644 --- a/sdk/test/resource/resource_test.cc +++ b/sdk/test/resource/resource_test.cc @@ -25,7 +25,8 @@ namespace nostd = opentelemetry::nostd; class TestResource : public Resource { public: - TestResource(ResourceAttributes attributes = ResourceAttributes(), std::string schema_url = {}) + TestResource(const ResourceAttributes &attributes = ResourceAttributes(), + const std::string &schema_url = {}) : Resource(attributes, schema_url) {} }; @@ -122,10 +123,10 @@ TEST(ResourceTest, create_with_emptyatrributes) TEST(ResourceTest, create_with_schemaurl) { - const std::string schema_url = "https://opentelemetry.io/schemas/1.2.0"; - ResourceAttributes attributes = {}; - auto resource = Resource::Create(attributes, schema_url); - auto received_schema_url = resource.GetSchemaURL(); + const std::string schema_url = "https://opentelemetry.io/schemas/1.2.0"; + ResourceAttributes attributes = {}; + auto resource = Resource::Create(attributes, schema_url); + const auto &received_schema_url = resource.GetSchemaURL(); EXPECT_EQ(received_schema_url, schema_url); } diff --git a/sdk/test/trace/batch_span_processor_test.cc b/sdk/test/trace/batch_span_processor_test.cc index 411b4dacfe..9bb09d6e55 100644 --- a/sdk/test/trace/batch_span_processor_test.cc +++ b/sdk/test/trace/batch_span_processor_test.cc @@ -16,6 +16,7 @@ #include #include #include +#include OPENTELEMETRY_BEGIN_NAMESPACE @@ -32,10 +33,10 @@ class MockSpanExporter final : public sdk::trace::SpanExporter std::shared_ptr> is_export_completed = std::shared_ptr>(new std::atomic(false)), const std::chrono::milliseconds export_delay = std::chrono::milliseconds(0)) noexcept - : spans_received_(spans_received), - shut_down_counter_(shut_down_counter), - is_shutdown_(is_shutdown), - is_export_completed_(is_export_completed), + : spans_received_(std::move(spans_received)), + shut_down_counter_(std::move(shut_down_counter)), + is_shutdown_(std::move(is_shutdown)), + is_export_completed_(std::move(is_export_completed)), export_delay_(export_delay) {} @@ -96,7 +97,7 @@ class BatchSpanProcessorTestPeer : public testing::Test { public: std::unique_ptr>> GetTestSpans( - std::shared_ptr processor, + const std::shared_ptr &processor, const int num_spans) { std::unique_ptr>> test_spans( diff --git a/sdk/test/trace/span_data_test.cc b/sdk/test/trace/span_data_test.cc index 98d00843dd..6dfc09bd12 100644 --- a/sdk/test/trace/span_data_test.cc +++ b/sdk/test/trace/span_data_test.cc @@ -96,8 +96,8 @@ TEST(SpanData, EventAttributes) TEST(SpanData, Resources) { SpanData data; - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - auto input_attr = resource.GetAttributes(); + auto resource = opentelemetry::sdk::resource::Resource::Create({}); + const auto &input_attr = resource.GetAttributes(); data.SetResource(resource); auto output_attr = data.GetResource().GetAttributes(); EXPECT_EQ(input_attr, output_attr); diff --git a/sdk/test/trace/tracer_test.cc b/sdk/test/trace/tracer_test.cc index 99bab95b0f..c57b638e3d 100644 --- a/sdk/test/trace/tracer_test.cc +++ b/sdk/test/trace/tracer_test.cc @@ -20,7 +20,6 @@ using opentelemetry::common::SystemTimestamp; namespace nostd = opentelemetry::nostd; namespace common = opentelemetry::common; namespace trace_api = opentelemetry::trace; -using opentelemetry::common::KeyValueIterableView; using opentelemetry::exporter::memory::InMemorySpanData; using opentelemetry::exporter::memory::InMemorySpanExporter; using opentelemetry::trace::SpanContext; From 63fa4fde4ec7d1151cbf4095e442ec1f96dcb4a1 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Fri, 12 Jul 2024 12:17:04 +0200 Subject: [PATCH 36/44] [CI] Build failures with ABSEIL 20240116 and CMAKE 3.30 (#3002) --- ci/fix-abseil-cpp-issue-1536.patch | 23 +++++++++++++++++++ ci/install_abseil.sh | 37 ++++++++++++++++++++++++++++++ tools/format.sh | 4 ++-- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 ci/fix-abseil-cpp-issue-1536.patch diff --git a/ci/fix-abseil-cpp-issue-1536.patch b/ci/fix-abseil-cpp-issue-1536.patch new file mode 100644 index 0000000000..7004cf0479 --- /dev/null +++ b/ci/fix-abseil-cpp-issue-1536.patch @@ -0,0 +1,23 @@ +commit 779a3565ac6c5b69dd1ab9183e500a27633117d5 +Author: Derek Mauro +Date: Tue Jan 30 10:13:25 2024 -0800 + + Avoid export of testonly target absl::test_allocator in CMake builds + + Closes #1536 + + PiperOrigin-RevId: 602764437 + Change-Id: Ia5c20a3874262a2ddb8797f608af17d7e86dd6d6 + +diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt +index 449a2cad..ee9ca9c3 100644 +--- a/absl/container/CMakeLists.txt ++++ b/absl/container/CMakeLists.txt +@@ -213,6 +213,7 @@ absl_cc_library( + DEPS + absl::config + GTest::gmock ++ TESTONLY + ) + + absl_cc_test( diff --git a/ci/install_abseil.sh b/ci/install_abseil.sh index 46a7870627..ced090cc64 100755 --- a/ci/install_abseil.sh +++ b/ci/install_abseil.sh @@ -7,6 +7,8 @@ set -ex export DEBIAN_FRONTEND=noninteractive [ -z "${ABSEIL_CPP_VERSION}" ] && export ABSEIL_CPP_VERSION="20240116.1" +TOPDIR=`pwd` + BUILD_DIR=/tmp/ INSTALL_DIR=/usr/local/ pushd $BUILD_DIR @@ -22,6 +24,41 @@ if [ ! -z "${CXX_STANDARD}" ]; then ABSEIL_CPP_BUILD_OPTIONS=(${ABSEIL_CPP_BUILD_OPTIONS[@]} "-DCMAKE_CXX_STANDARD=${CXX_STANDARD}") fi +# +# ABSEIL_CPP_VERSION="20240116.1" fails to build with CMake 3.30 +# ABSEIL_CPP_VERSION="20240116.2" fails to build with CMake 3.30 +# note that somehow the same builds with CMake 3.29.6 +# +# Error reported: +# CMake Error at CMake/AbseilHelpers.cmake:317 (target_link_libraries): +# The link interface of target "test_allocator" contains: +# +# GTest::gmock +# +# but the target was not found. Possible reasons include: +# +# * There is a typo in the target name. +# * A find_package call is missing for an IMPORTED target. +# * An ALIAS target is missing. +# +# Call Stack (most recent call first): +# absl/container/CMakeLists.txt:206 (absl_cc_library) +# +# Root cause: +# https://github.com/abseil/abseil-cpp/pull/1536 +# +# Applying fix from abseil commit 779a3565ac6c5b69dd1ab9183e500a27633117d5 +# +# TODO(marcalff) Cleanup once abseil is upgraded to the next LTS + + +if [ "${ABSEIL_CPP_VERSION}" = "20240116.1" ] || [ "${ABSEIL_CPP_VERSION}" = "20240116.2" ]; then + echo "Patching abseil" + patch -p1 < ${TOPDIR}/ci/fix-abseil-cpp-issue-1536.patch +else + echo "Not patching abseil" +fi + mkdir build && pushd build cmake "${ABSEIL_CPP_BUILD_OPTIONS[@]}" .. make -j $(nproc) diff --git a/tools/format.sh b/tools/format.sh index 65728b385f..3a3863a8ea 100755 --- a/tools/format.sh +++ b/tools/format.sh @@ -23,8 +23,8 @@ fi # No CRLF line endings, except Windows files. "${SED[@]}" 's/\r$//' $($FIND -name '*.ps1' -prune -o \ -name '*.cmd' -prune -o -type f -print) -# No trailing spaces. -"${SED[@]}" 's/ \+$//' $($FIND -type f -print) +# No trailing spaces, except in patch. +"${SED[@]}" 's/ \+$//' $($FIND -name "*.patch" -prune -o -type f -print) # If not overridden, try to use clang-format-18 or clang-format. if [[ -z "$CLANG_FORMAT" ]]; then From 323a279ec5b2e91f26630830464fb45a3ad10564 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Fri, 12 Jul 2024 14:03:17 -0700 Subject: [PATCH 37/44] [CI] Enable bzlmod (#2995) --- .bazelrc | 3 --- MODULE.bazel | 4 ++-- ci/do_ci.ps1 | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.bazelrc b/.bazelrc index fc170b0e8b..f169347647 100644 --- a/.bazelrc +++ b/.bazelrc @@ -4,9 +4,6 @@ # bazel configurations for running tests under sanitizers. # Based on https://github.com/bazelment/trunk/blob/master/tools/bazel.rc -# TODO: Remove once support is added, avoid MODULE.bazel creation for now -common --enable_bzlmod=false - # Enable automatic configs based on platform common --enable_platform_specific_config diff --git a/MODULE.bazel b/MODULE.bazel index 7b84c2b719..4a03753e15 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -10,8 +10,8 @@ module( bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "com_google_absl") bazel_dep(name = "bazel_skylib", version = "1.5.0") -bazel_dep(name = "curl", version = "8.4.0") -bazel_dep(name = "grpc", version = "1.62.1", repo_name = "com_github_grpc_grpc") +bazel_dep(name = "curl", version = "8.8.0") +bazel_dep(name = "grpc", version = "1.63.1.bcr.1", repo_name = "com_github_grpc_grpc") bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "github_nlohmann_json") bazel_dep(name = "opentelemetry-proto", version = "1.3.1", repo_name = "com_github_opentelemetry_proto") bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing") diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index 62e174854e..bcae6359bb 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -11,8 +11,8 @@ $nproc = (Get-ComputerInfo).CsNumberOfLogicalProcessors $SRC_DIR = (Get-Item -Path ".\").FullName # Workaround https://github.com/bazelbuild/bazel/issues/18683 -$BAZEL_STARTUP_OPTIONS = "--output_base=C:\Out" -$BAZEL_OPTIONS = "--copt=-DENABLE_ASYNC_EXPORT" +$BAZEL_STARTUP_OPTIONS = "--output_base=C:\O" +$BAZEL_OPTIONS = "--copt=-DENABLE_ASYNC_EXPORT --compilation_mode=dbg" $BAZEL_TEST_OPTIONS = "$BAZEL_OPTIONS --test_output=errors" if (!(test-path build)) { From d8ae09e53d6988a063364c86a8362053432a3f9f Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Wed, 17 Jul 2024 07:00:20 -0700 Subject: [PATCH 38/44] [Metrics SDK] Fix hash calculation for nostd::string (#2999) * add test to validate cardinaity limit * format * warning * Format * maint mode CI * modify test to reproduce the issue * Format * remove vscode settings * remove redundant test * remove unused code * fix to calculate hash on string_view * remove iostream * template specialization for const char *, and varous string type tests * unused variable warning * more warnings * format * fix use-after-stack-scope * format * another try * format --------- Co-authored-by: Tom Tan --- .../sdk/common/attributemap_hash.h | 11 ++- sdk/test/metrics/attributes_hashmap_test.cc | 76 ++++++++++++++++++- sdk/test/metrics/cardinality_limit_test.cc | 41 +++++++++- 3 files changed, 122 insertions(+), 6 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/common/attributemap_hash.h b/sdk/include/opentelemetry/sdk/common/attributemap_hash.h index 408070255a..e09b03d08b 100644 --- a/sdk/include/opentelemetry/sdk/common/attributemap_hash.h +++ b/sdk/include/opentelemetry/sdk/common/attributemap_hash.h @@ -35,6 +35,15 @@ inline void GetHash(size_t &seed, const std::vector &arg) } } +// Specialization for const char* +// this creates an intermediate string. +template <> +inline void GetHash(size_t &seed, const char *const &arg) +{ + std::hash hasher; + seed ^= hasher(std::string(arg)) + 0x9e3779b9 + (seed << 6) + (seed >> 2); +} + struct GetHashForAttributeValueVisitor { GetHashForAttributeValueVisitor(size_t &seed) : seed_(seed) {} @@ -71,7 +80,7 @@ inline size_t GetHashForAttributeMap( { return true; } - GetHash(seed, key.data()); + GetHash(seed, key); auto attr_val = nostd::visit(converter, value); nostd::visit(GetHashForAttributeValueVisitor(seed), attr_val); return true; diff --git a/sdk/test/metrics/attributes_hashmap_test.cc b/sdk/test/metrics/attributes_hashmap_test.cc index 7e03deed47..9ae8f5cfd5 100644 --- a/sdk/test/metrics/attributes_hashmap_test.cc +++ b/sdk/test/metrics/attributes_hashmap_test.cc @@ -13,7 +13,6 @@ namespace nostd = opentelemetry::nostd; TEST(AttributesHashMap, BasicTests) { - // Empty map AttributesHashMap hash_map; EXPECT_EQ(hash_map.Size(), 0); @@ -73,3 +72,78 @@ TEST(AttributesHashMap, BasicTests) }); EXPECT_EQ(count, hash_map.Size()); } + +std::string make_unique_string(const char *str) +{ + return std::string(str); +} + +TEST(AttributesHashMap, HashWithKeyValueIterable) +{ + std::string key1 = make_unique_string("k1"); + std::string value1 = make_unique_string("v1"); + std::string key2 = make_unique_string("k2"); + std::string value2 = make_unique_string("v2"); + std::string key3 = make_unique_string("k3"); + std::string value3 = make_unique_string("v3"); + + // Create mock KeyValueIterable instances with the same content but different variables + std::map attributes1({{key1, value1}, {key2, value2}}); + std::map attributes2({{key1, value1}, {key2, value2}}); + std::map attributes3({{key1, value1}, {key2, value2}, {key3, value3}}); + + // Create a callback that filters "k3" key + auto is_key_filter_k3_callback = [](nostd::string_view key) { + if (key == "k3") + { + return false; + } + return true; + }; + // Calculate hash + size_t hash1 = opentelemetry::sdk::common::GetHashForAttributeMap( + opentelemetry::common::KeyValueIterableView>(attributes1), + is_key_filter_k3_callback); + size_t hash2 = opentelemetry::sdk::common::GetHashForAttributeMap( + opentelemetry::common::KeyValueIterableView>(attributes2), + is_key_filter_k3_callback); + + size_t hash3 = opentelemetry::sdk::common::GetHashForAttributeMap( + opentelemetry::common::KeyValueIterableView>(attributes3), + is_key_filter_k3_callback); + + // Expect the hashes to be the same because the content is the same + EXPECT_EQ(hash1, hash2); + // Expect the hashes to be the same because the content is the same + EXPECT_EQ(hash1, hash3); +} + +TEST(AttributesHashMap, HashConsistencyAcrossStringTypes) +{ + const char *c_str = "teststring"; + std::string std_str = "teststring"; + nostd::string_view nostd_str_view = "teststring"; +#if __cplusplus >= 201703L + std::string_view std_str_view = "teststring"; +#endif + + size_t hash_c_str = 0; + size_t hash_std_str = 0; + size_t hash_nostd_str_view = 0; +#if __cplusplus >= 201703L + size_t hash_std_str_view = 0; +#endif + + opentelemetry::sdk::common::GetHash(hash_c_str, c_str); + opentelemetry::sdk::common::GetHash(hash_std_str, std_str); + opentelemetry::sdk::common::GetHash(hash_nostd_str_view, nostd_str_view); +#if __cplusplus >= 201703L + opentelemetry::sdk::common::GetHash(hash_std_str_view, std_str_view); +#endif + + EXPECT_EQ(hash_c_str, hash_std_str); + EXPECT_EQ(hash_c_str, hash_nostd_str_view); +#if __cplusplus >= 201703L + EXPECT_EQ(hash_c_str, hash_std_str_view); +#endif +} diff --git a/sdk/test/metrics/cardinality_limit_test.cc b/sdk/test/metrics/cardinality_limit_test.cc index 3f9483ac1c..cf94112f1a 100644 --- a/sdk/test/metrics/cardinality_limit_test.cc +++ b/sdk/test/metrics/cardinality_limit_test.cc @@ -47,14 +47,47 @@ TEST(CardinalityLimit, AttributesHashMapBasicTests) ->Aggregate(record_value); } EXPECT_EQ(hash_map.Size(), 10); // only one more metric point should be added as overflow. + // record 5 more measurements to already existing (and not-overflow) metric points. They + // should get aggregated to these existing metric points. + for (auto i = 0; i < 5; i++) + { + FilteredOrderedAttributeMap attributes = {{"key", std::to_string(i)}}; + auto hash = opentelemetry::sdk::common::GetHashForAttributeMap(attributes); + static_cast( + hash_map.GetOrSetDefault(attributes, aggregation_callback, hash)) + ->Aggregate(record_value); + } + EXPECT_EQ(hash_map.Size(), 10); // no new metric point added + // get the overflow metric point - auto agg = hash_map.GetOrSetDefault( + auto agg1 = hash_map.GetOrSetDefault( FilteredOrderedAttributeMap({{kAttributesLimitOverflowKey, kAttributesLimitOverflowValue}}), aggregation_callback, kOverflowAttributesHash); - EXPECT_NE(agg, nullptr); - auto sum_agg = static_cast(agg); - EXPECT_EQ(nostd::get(nostd::get(sum_agg->ToPoint()).value_), + EXPECT_NE(agg1, nullptr); + auto sum_agg1 = static_cast(agg1); + EXPECT_EQ(nostd::get(nostd::get(sum_agg1->ToPoint()).value_), record_value * 6); // 1 from previous 10, 5 from current 5. + // get remaining metric points + for (auto i = 0; i < 9; i++) + { + FilteredOrderedAttributeMap attributes = {{"key", std::to_string(i)}}; + auto hash = opentelemetry::sdk::common::GetHashForAttributeMap(attributes); + auto agg2 = hash_map.GetOrSetDefault( + FilteredOrderedAttributeMap({{kAttributesLimitOverflowKey, kAttributesLimitOverflowValue}}), + aggregation_callback, hash); + EXPECT_NE(agg2, nullptr); + auto sum_agg2 = static_cast(agg2); + if (i < 5) + { + EXPECT_EQ(nostd::get(nostd::get(sum_agg2->ToPoint()).value_), + record_value * 2); // 1 from first recording, 1 from third recording + } + else + { + EXPECT_EQ(nostd::get(nostd::get(sum_agg2->ToPoint()).value_), + record_value); // 1 from first recording + } + } } class WritableMetricStorageCardinalityLimitTestFixture From baecbb95bd63df53e0af16e87bc683967962c5f8 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 17 Jul 2024 22:04:10 +0200 Subject: [PATCH 39/44] [RELEASE] Release opentelemetry-cpp version 1.16.1 (#3007) --- CHANGELOG.md | 39 ++++++++++++++++++- api/include/opentelemetry/version.h | 4 +- docs/public/conf.py | 2 +- .../opentelemetry/sdk/version/version.h | 2 +- sdk/src/version/version.cc | 8 ++-- 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92e234a77b..fad2b0cc78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,15 +15,50 @@ Increment the: ## [Unreleased] +## [1.16.1 2024-07-17] + +* [BUILD] Add bazel missing BUILD file + [#2720](https://github.com/open-telemetry/opentelemetry-cpp/pull/2720) + +* [SDK] Added reserve for spans array in BatchSpanProcessor. + [#2724](https://github.com/open-telemetry/opentelemetry-cpp/pull/2724) + +* [DOC] Update "Using triplets" section in building-with-vcpkg documentation. + [#2726](https://github.com/open-telemetry/opentelemetry-cpp/pull/2726) + +* [DOC] Remove comment for unused LoggerProvider initialization params + [#2972](https://github.com/open-telemetry/opentelemetry-cpp/pull/2972) + * [SECURITY] Remove OTLP HTTP support for TLS 1.0 and TLS 1.1, require TLS 1.2 or better - [#2721](https://github.com/open-telemetry/opentelemetry-cpp/pull/2721) + [#2722](https://github.com/open-telemetry/opentelemetry-cpp/pull/2722) + +* [TEST] Fix opentelemetry-collector bind address + [#2989](https://github.com/open-telemetry/opentelemetry-cpp/pull/2989) + +* [EXPORTER] Fix references in AttributeValueVisitor + [#2985](https://github.com/open-telemetry/opentelemetry-cpp/pull/2985) + +* [Code health] include-what-you-use cleanup, part 2 + [#2704](https://github.com/open-telemetry/opentelemetry-cpp/pull/2704) + +* [Code Health] clang-tidy cleanup, part 1 + [#2990](https://github.com/open-telemetry/opentelemetry-cpp/pull/2990) + +* [CI] Build failures with ABSEIL 20240116 and CMAKE 3.30 + [#3002](https://github.com/open-telemetry/opentelemetry-cpp/pull/3002) + +* [CI] Enable bzlmod + [#2995](https://github.com/open-telemetry/opentelemetry-cpp/pull/2995) + +* [Metrics SDK] Fix hash calculation for nostd::string + [#2999](https://github.com/open-telemetry/opentelemetry-cpp/pull/2999) Breaking changes: * [SECURITY] Remove OTLP HTTP support for TLS 1.0 and TLS 1.1, require TLS 1.2 or better - [#2721](https://github.com/open-telemetry/opentelemetry-cpp/pull/2721) + [#2722](https://github.com/open-telemetry/opentelemetry-cpp/pull/2722) * The OTLP HTTP exporter no longer accept options like: * min_TLS = 1.0 * min_TLS = 1.1 diff --git a/api/include/opentelemetry/version.h b/api/include/opentelemetry/version.h index e09c193659..d98ac978f2 100644 --- a/api/include/opentelemetry/version.h +++ b/api/include/opentelemetry/version.h @@ -10,10 +10,10 @@ # define OPENTELEMETRY_ABI_VERSION_NO 1 #endif -#define OPENTELEMETRY_VERSION "1.16.0" +#define OPENTELEMETRY_VERSION "1.16.1" #define OPENTELEMETRY_VERSION_MAJOR 1 #define OPENTELEMETRY_VERSION_MINOR 16 -#define OPENTELEMETRY_VERSION_PATCH 0 +#define OPENTELEMETRY_VERSION_PATCH 1 #define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO) diff --git a/docs/public/conf.py b/docs/public/conf.py index 927e07751a..96caa2b43a 100644 --- a/docs/public/conf.py +++ b/docs/public/conf.py @@ -24,7 +24,7 @@ author = 'OpenTelemetry authors' # The full version, including alpha/beta/rc tags -release = "1.16.0" +release = "1.16.1" # Run sphinx on subprojects and copy output # ----------------------------------------- diff --git a/sdk/include/opentelemetry/sdk/version/version.h b/sdk/include/opentelemetry/sdk/version/version.h index bfc93238b4..86b815e3bc 100644 --- a/sdk/include/opentelemetry/sdk/version/version.h +++ b/sdk/include/opentelemetry/sdk/version/version.h @@ -3,7 +3,7 @@ #pragma once -#define OPENTELEMETRY_SDK_VERSION "1.16.0" +#define OPENTELEMETRY_SDK_VERSION "1.16.1" #include "opentelemetry/version.h" diff --git a/sdk/src/version/version.cc b/sdk/src/version/version.cc index e5fdbda99d..80f2226400 100644 --- a/sdk/src/version/version.cc +++ b/sdk/src/version/version.cc @@ -13,12 +13,12 @@ namespace version { const int major_version = 1; const int minor_version = 16; -const int patch_version = 0; +const int patch_version = 1; const char *pre_release = "NONE"; const char *build_metadata = "NONE"; -const char *short_version = "1.16.0"; -const char *full_version = "1.16.0-NONE-NONE"; -const char *build_date = "Fri Jun 21 16:41:17 UTC 2024"; +const char *short_version = "1.16.1"; +const char *full_version = "1.16.1-NONE-NONE"; +const char *build_date = "Wed Jul 17 17:34:38 UTC 2024"; } // namespace version } // namespace sdk OPENTELEMETRY_END_NAMESPACE From aac2b775afa77840b91a37b4a959c9afae03a06b Mon Sep 17 00:00:00 2001 From: Siddhartha Malladi Date: Wed, 17 Jul 2024 17:19:41 -0400 Subject: [PATCH 40/44] [CI] Add a clang-tidy build (#3001) --- .clang-tidy | 48 ++++-------------- .github/workflows/clang-tidy.yaml | 84 +++++++++++++++++++++++++++++++ CHANGELOG.md | 3 ++ CMakeLists.txt | 6 +++ 4 files changed, 102 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/clang-tidy.yaml diff --git a/.clang-tidy b/.clang-tidy index 5abedb62fd..9a30fbef54 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,6 +3,8 @@ Checks: > -*, + performance-*, + portability-*, abseil-*, -abseil-string-find-str-contains, bugprone-*, @@ -13,7 +15,6 @@ Checks: > -bugprone-unchecked-optional-access, -bugprone-unhandled-exception-at-new, -bugprone-unused-local-non-trivial-variable, - -bugprone-unused-return-value, google-*, -google-build-using-namespace, -google-default-arguments, @@ -29,41 +30,10 @@ Checks: > -misc-non-private-member-variables-in-classes, -misc-unused-alias-decls, -misc-use-anonymous-namespace, - performance-*, - -performance-move-const-arg, - portability-* -# readability-*, -# -readability-convert-member-functions-to-static, -# -readability-else-after-return, -# -readability-function-cognitive-complexity, -# -readability-identifier-length, -# -readability-implicit-bool-conversion, -# -readability-isolate-declaration, -# -readability-magic-numbers, -# -readability-named-parameter, -# -readability-redundant-*, -# -readability-string-compare, -# cppcoreguidelines-*, -# -cppcoreguidelines-avoid-c-arrays, -# -cppcoreguidelines-avoid-magic-numbers, -# -cppcoreguidelines-init-variables, -# -cppcoreguidelines-macro-usage, -# -cppcoreguidelines-non-private-member-variables-in-classes, -# -cppcoreguidelines-pro-*, -# modernize-*, -# -modernize-use-default-member-init, -# -modernize-use-nodiscard, -# -modernize-use-trailing-return-type, -# -modernize-avoid-c-arrays, -# -modernize-use-using - -# Use existing clang-format for formatting the code -# FormatStyle: 'file' - -# TODO: include checks: readability, cppcoreguidelines, modernize , google-readability-namespace-comments, google-readability-avoid-underscore-in-googletest-name, performance-move-const-arg - - - - - - + cppcoreguidelines-*, + -cppcoreguidelines-avoid-c-arrays, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-init-variables, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-non-private-member-variables-in-classes, + -cppcoreguidelines-pro-* \ No newline at end of file diff --git a/.github/workflows/clang-tidy.yaml b/.github/workflows/clang-tidy.yaml new file mode 100644 index 0000000000..9e5f6c26db --- /dev/null +++ b/.github/workflows/clang-tidy.yaml @@ -0,0 +1,84 @@ +name: clang-tidy + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + clang-tidy: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup Environment + env: + PROTOBUF_VERSION: '23.3' + ABSEIL_CPP_VERSION: '20230125.3' + CXX_STANDARD: '14' + run: | + sudo apt update -y + sudo apt install -y --no-install-recommends --no-install-suggests \ + build-essential \ + iwyu \ + cmake \ + libssl-dev \ + libcurl4-openssl-dev \ + libprotobuf-dev \ + protobuf-compiler \ + libgmock-dev \ + libgtest-dev \ + libbenchmark-dev + + if ! command -v clang-tidy &> /dev/null; then + echo "clang-tidy could not be found" + exit 1 + fi + echo "Using clang-tidy version: $(clang-tidy --version)" + echo "clang-tidy installed at: $(which clang-tidy)" + + + - name: Prepare CMake + env: + CC: clang + CXX: clang++ + run: | + mkdir -p build && cd build + echo "Running cmake..." + cmake .. \ + -DCMAKE_CXX_STANDARD=14 \ + -DWITH_STL=CXX14 \ + -DWITH_OTLP_HTTP=ON \ + -DWITH_OTLP_FILE=ON \ + -DWITH_PROMETHEUS=ON \ + -DWITH_ZIPKIN=ON \ + -DWITH_ELASTICSEARCH=ON \ + -DWITH_OTLP_HTTP_COMPRESSION=ON \ + -DWITH_EXAMPLES=ON \ + -DWITH_EXAMPLES_HTTP=ON \ + -DBUILD_W3CTRACECONTEXT_TEST=ON \ + -DWITH_METRICS_EXEMPLAR_PREVIEW=ON \ + -DWITH_ASYNC_EXPORT_PREVIEW=ON \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_CXX_CLANG_TIDY="clang-tidy" + + - name: Run clang-tidy + run: | + cd build + make -j$(nproc) 2>&1 | tee -a clang-tidy.log || exit 1 + + - uses: actions/upload-artifact@v4 + with: + name: Logs (clang-tidy) + path: ./build/clang-tidy.log + + - name: Count warnings + run: | + cd build + COUNT=$(grep -c "warning:" clang-tidy.log) + echo "clang-tidy reported ${COUNT} warning(s)" + +# TODO: include WITH_OTLP_GRPC and WITH_ABSEIL flags. \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index fad2b0cc78..e7e13ec3d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ Increment the: ## [Unreleased] +* [CI] Add a clang-tidy build + [#3001](https://github.com/open-telemetry/opentelemetry-cpp/pull/3001) + ## [1.16.1 2024-07-17] * [BUILD] Add bazel missing BUILD file diff --git a/CMakeLists.txt b/CMakeLists.txt index 711ac14c4c..44ddd05e1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -364,9 +364,12 @@ if(WITH_PROMETHEUS) message(STATUS "Trying to use local prometheus-cpp from submodule") if(EXISTS ${PROJECT_SOURCE_DIR}/third_party/prometheus-cpp/.git) set(SAVED_ENABLE_TESTING ${ENABLE_TESTING}) + set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY}) set(ENABLE_TESTING OFF) + set(CMAKE_CXX_CLANG_TIDY "") add_subdirectory(third_party/prometheus-cpp) set(ENABLE_TESTING ${SAVED_ENABLE_TESTING}) + set(CMAKE_CXX_CLANG_TIDY ${SAVED_CMAKE_CXX_CLANG_TIDY}) else() message( FATAL_ERROR @@ -444,7 +447,10 @@ if(WITH_OTLP_GRPC include(CMakeDependentOption) message(STATUS "PROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_PROTOC_EXECUTABLE}") + set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY}) + set(CMAKE_CXX_CLANG_TIDY "") include(cmake/opentelemetry-proto.cmake) + set(CMAKE_CXX_CLANG_TIDY ${SAVED_CMAKE_CXX_CLANG_TIDY}) endif() # From 0a43c1f2b16e2636e7c768c88957c4f0e4d3f8ce Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 18 Jul 2024 00:48:26 +0200 Subject: [PATCH 41/44] [BUILD] Upgrade to opentelemetry-proto 1.3.2 (#2991) --- MODULE.bazel | 2 +- bazel/repository.bzl | 6 +- cmake/opentelemetry-proto.cmake | 2 +- docs/maintaining-dependencies.md | 321 +++++++++++++++++++++++++++++++ third_party/opentelemetry-proto | 2 +- third_party_release | 2 +- 6 files changed, 328 insertions(+), 7 deletions(-) create mode 100644 docs/maintaining-dependencies.md diff --git a/MODULE.bazel b/MODULE.bazel index 4a03753e15..311d4cbc16 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -13,7 +13,7 @@ bazel_dep(name = "bazel_skylib", version = "1.5.0") bazel_dep(name = "curl", version = "8.8.0") bazel_dep(name = "grpc", version = "1.63.1.bcr.1", repo_name = "com_github_grpc_grpc") bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "github_nlohmann_json") -bazel_dep(name = "opentelemetry-proto", version = "1.3.1", repo_name = "com_github_opentelemetry_proto") +bazel_dep(name = "opentelemetry-proto", version = "1.3.2", repo_name = "com_github_opentelemetry_proto") bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing") bazel_dep(name = "platforms", version = "0.0.8") bazel_dep(name = "prometheus-cpp", version = "1.2.4", repo_name = "com_github_jupp0r_prometheus_cpp") diff --git a/bazel/repository.bzl b/bazel/repository.bzl index bac1e45b34..508b95a39a 100644 --- a/bazel/repository.bzl +++ b/bazel/repository.bzl @@ -88,10 +88,10 @@ def opentelemetry_cpp_deps(): http_archive, name = "com_github_opentelemetry_proto", build_file = "@io_opentelemetry_cpp//bazel:opentelemetry_proto.BUILD", - sha256 = "bed250ceec8e4a83aa5604d7d5595a61945059dc662edd058a9da082283f7a00", - strip_prefix = "opentelemetry-proto-1.3.1", + sha256 = "c069c0d96137cf005d34411fa67dd3b6f1f8c64af1e7fb2fe0089a41c425acd7", + strip_prefix = "opentelemetry-proto-1.3.2", urls = [ - "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.1.tar.gz", + "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.2.tar.gz", ], ) diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake index 62197068e2..498a7e5681 100644 --- a/cmake/opentelemetry-proto.cmake +++ b/cmake/opentelemetry-proto.cmake @@ -49,7 +49,7 @@ else() "opentelemetry-proto=[ \\t]*([A-Za-z0-9_\\.\\-]+)") set(opentelemetry-proto "${CMAKE_MATCH_1}") else() - set(opentelemetry-proto "v1.3.1") + set(opentelemetry-proto "v1.3.2") endif() unset(OTELCPP_THIRD_PARTY_RELEASE_CONTENT) endif() diff --git a/docs/maintaining-dependencies.md b/docs/maintaining-dependencies.md new file mode 100644 index 0000000000..a1969785d8 --- /dev/null +++ b/docs/maintaining-dependencies.md @@ -0,0 +1,321 @@ + +# Maintaining dependencies + +In general, several places in the code base need to be adjusted when +upgrading a dependency to a new version. + +This documentation contains notes about which place to fix, +to make maintenance easier and less error prone. + +This doc is only useful when up to date, +so make sure to add details about missing parts if any. + +Also, another good place to start when upgrading something to N+1 +is to find the commit that upgraded to version N (use `git blame`), +and inspect the commit for the last upgrade. + +## opentelemetry-proto + +### Comments + +Unlike other opentelemetry SIGs, opentelemetry-cpp generates code +from opentelemetry-proto as part of the opentelemetry-cpp build. + +Only the source code of opentelemetry-proto is required, +which is why this repository is used as a git submodule under third_party. + +Code is generated by the protobuf compiler during the build, +so that generated code is never checked in. + +This allows more flexibility, should the compiler (protobuf) be +upgraded even when the source code (opentelemetry-proto) is unchanged. + +### Origin + +The repository for opentelemetry-proto is: + +* [repository](https://github.com/open-telemetry/opentelemetry-proto) + +Check release notes at: + +* [release-notes](https://github.com/open-telemetry/opentelemetry-proto/releases) + +### Upgrade + +When upgrading opentelemetry-proto to a newer release, +a few places in the code need adjustment. + +In this example, we upgrade from 1.3.1 to 1.3.2 + +#### directory third_party/opentelemetry-proto + +This is a `git submodule`, it needs to point to the new tag. + +```shell +cd third_party/opentelemetry-proto +git log -1 +``` + +The current submodule show something like: + +```shell +commit b3060d2104df364136d75a35779e6bd48bac449a (HEAD, tag: v1.3.1) +Author: Damien Mathieu <42@dmathieu.com> +Date: Thu Apr 25 17:55:35 2024 +0200 + + generate profiles proto for CI (#552) +``` + +Pull new tags: + +```shell +git pull --tag origin +``` + +Upgrade to a new tag: + +```shell +git pull origin v1.3.2 +``` + +Check the new state: + +```shell +git log -1 +``` + +```shell +commit 40b3c1b746767cbc13c2e39da3eaf1a23e54ffdd (HEAD, tag: v1.3.2) +Author: jack-berg <34418638+jack-berg@users.noreply.github.com> +Date: Fri Jun 28 08:19:11 2024 -0500 + + Prepare changelog for 1.3.2 release (#563) + + Co-authored-by: Armin Ruech <7052238+arminru@users.noreply.github.com> +``` + +Go back to the root of opentelemetry-cpp + +```shell +cd ../.. +git status +``` + +```shell +On branch upgrade_proto_1.3.2 +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git restore ..." to discard changes in working directory) + modified: third_party/opentelemetry-proto (new commits) +``` + +Add the upgraded submodule: + +```shell +git add third_party/opentelemetry-proto +``` + +#### file third_party_release + +Update the line pointing to the opentelemetry-proto tag. + +```text +opentelemetry-proto=v1.3.2 +``` + +Typical change: + +```shell +[malff@malff-desktop opentelemetry-cpp]$ git diff third_party_release +diff --git a/third_party_release b/third_party_release +index 0bbf67f3..7362473f 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.3.1 ++opentelemetry-proto=v1.3.2 + opentracing-cpp=v1.6.0 + prometheus-cpp=v1.2.4 + vcpkg=2024.02.14 +``` + +#### file bazel/repository.bzl + +Locate the entry for opentelemetry-proto: + +```text + # OTLP Protocol definition + maybe( + http_archive, + name = "com_github_opentelemetry_proto", + build_file = "@io_opentelemetry_cpp//bazel:opentelemetry_proto.BUILD", + sha256 = "bed250ceec8e4a83aa5604d7d5595a61945059dc662edd058a9da082283f7a00", + strip_prefix = "opentelemetry-proto-1.3.1", + urls = [ + "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.1.tar.gz", + ], + ) +``` + +Update the URL to the new tag: + +```text + urls = [ + "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.2.tar.gz", + ], +``` + +Update strip_prefix to the new tag: + +```text + strip_prefix = "opentelemetry-proto-1.3.2", +``` + +Download the new URL: + +```shell +wget https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.2.tar.gz +``` + +Run a checksum on the new file: + +```shell +sha256sum v1.3.2.tar.gz +``` + +```shell +c069c0d96137cf005d34411fa67dd3b6f1f8c64af1e7fb2fe0089a41c425acd7 v1.3.2.tar.gz +``` + +Update the checksum in file bazel/repository.bzl: + +```text + sha256 = "c069c0d96137cf005d34411fa67dd3b6f1f8c64af1e7fb2fe0089a41c425acd7", +``` + +Typical change: + +```shell +[malff@malff-desktop opentelemetry-cpp]$ git diff bazel/repository.bzl +diff --git a/bazel/repository.bzl b/bazel/repository.bzl +index bac1e45b..508b95a3 100644 +--- a/bazel/repository.bzl ++++ b/bazel/repository.bzl +@@ -88,10 +88,10 @@ def opentelemetry_cpp_deps(): + http_archive, + name = "com_github_opentelemetry_proto", + build_file = "@io_opentelemetry_cpp//bazel:opentelemetry_proto.BUILD", +- sha256 = "bed250ceec8e4a83aa5604d7d5595a61945059dc662edd058a9da082283f7a00", +- strip_prefix = "opentelemetry-proto-1.3.1", ++ sha256 = "c069c0d96137cf005d34411fa67dd3b6f1f8c64af1e7fb2fe0089a41c425acd7", ++ strip_prefix = "opentelemetry-proto-1.3.2", + urls = [ +- "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.1.tar.gz", ++ "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.2.tar.gz", + ], + ) +``` + +#### file cmake/opentelemetry-proto.cmake + +Update the tag in the CMake logic: + +```cmake + set(opentelemetry-proto "v1.3.2") +``` + +Typical change: + +```shell +[malff@malff-desktop opentelemetry-cpp]$ git diff cmake/opentelemetry-proto.cmake +diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake +index 19516c3b..dd6213c1 100644 +--- a/cmake/opentelemetry-proto.cmake ++++ b/cmake/opentelemetry-proto.cmake +@@ -49,7 +49,7 @@ else() + "opentelemetry-proto=[ \\t]*([A-Za-z0-9_\\.\\-]+)") + set(opentelemetry-proto "${CMAKE_MATCH_1}") + else() +- set(opentelemetry-proto "v1.3.1") ++ set(opentelemetry-proto "v1.3.2") + endif() + unset(OTELCPP_THIRD_PARTY_RELEASE_CONTENT) + endif() +``` + +If opentelemetry-proto contains new files, +the makefile needs to be adjusted to build the new code. + +Depending on the actual changes in the opentelemetry-proto files, +the C++ code in opentelemetry-cpp may need adjustments. + +Typically, when opentelemetry-proto: + +* defines a new message (for example, for profiling) +* adds new optional fields to an existing message (for example, trace flags) + +the existing C++ code should work as is with the new opentelemetry-proto +format. + +In this case, it is better to: + +* upgrade the opentelemetry-proto version independently with one PR. +* upgrade the C++ code later (to use the new message, of provide new fields) + in a different PR. + +When the C++ code requires a newer minimum version of opentelemetry-proto, +make sure to document this, including in the release notes. + +#### file MODULE.bazel + +Make sure the new tag is available in bazel central: + +* [bazel-central](https://registry.bazel.build/modules/opentelemetry-proto) + +If missing, file a PR to add it, or contact the maintainer: + +* [repository](https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/opentelemetry-proto) + +Update the opentelemetry-proto version to the new tag: + +```text +bazel_dep(name = "opentelemetry-proto", version = "1.3.2", repo_name = "com_github_opentelemetry_proto") +``` + +File `MODULE.bazel` is used in the github CI for repository +opentelemetry-cpp, so using a tag that does not exist (yet) in bazel central +will break the CI build. + +See the known issues section. + +Typical change: + +```shell +[malff@malff-desktop opentelemetry-cpp]$ git diff MODULE.bazel +diff --git a/MODULE.bazel b/MODULE.bazel +index 7b84c2b7..3161ffb1 100644 +--- a/MODULE.bazel ++++ b/MODULE.bazel +@@ -13,7 +13,7 @@ bazel_dep(name = "bazel_skylib", version = "1.5.0") + bazel_dep(name = "curl", version = "8.4.0") + bazel_dep(name = "grpc", version = "1.62.1", repo_name = "com_github_grpc_grpc") + bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "github_nlohmann_json") +-bazel_dep(name = "opentelemetry-proto", version = "1.3.1", repo_name = "com_github_opentelemetry_proto") ++bazel_dep(name = "opentelemetry-proto", version = "1.3.2", repo_name = "com_github_opentelemetry_proto") + bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing") + bazel_dep(name = "platforms", version = "0.0.8") + bazel_dep(name = "prometheus-cpp", version = "1.2.4", repo_name = "com_github_jupp0r_prometheus_cpp") +``` + +### Known issues + +For bazel, two different methods to build exists. + +First, the code can build using file `bazel/repository.bzl`. +This option does not depend on bazel central. + +Secondly, there is also a build using modules, with file `MODULE.bazel`. +This option does depend on bazel central, and CI depends on it. diff --git a/third_party/opentelemetry-proto b/third_party/opentelemetry-proto index b3060d2104..40b3c1b746 160000 --- a/third_party/opentelemetry-proto +++ b/third_party/opentelemetry-proto @@ -1 +1 @@ -Subproject commit b3060d2104df364136d75a35779e6bd48bac449a +Subproject commit 40b3c1b746767cbc13c2e39da3eaf1a23e54ffdd diff --git a/third_party_release b/third_party_release index 0bbf67f3af..7362473f60 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.3.1 +opentelemetry-proto=v1.3.2 opentracing-cpp=v1.6.0 prometheus-cpp=v1.2.4 vcpkg=2024.02.14 From 611906eeafdbfe4a92fd1f81989692a222da1a78 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 18 Jul 2024 01:27:46 +0200 Subject: [PATCH 42/44] [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` (#2717) --- .github/workflows/iwyu.yml | 1 - CHANGELOG.md | 38 ++++++++ CMakeLists.txt | 19 ---- DEPRECATED.md | 80 +---------------- api/CMakeLists.txt | 5 -- ci/do_ci.ps1 | 2 - ci/do_ci.sh | 4 - examples/logs_simple/main.cc | 10 --- examples/metrics_simple/metrics_ostream.cc | 9 -- examples/otlp/file_log_main.cc | 13 --- examples/otlp/file_main.cc | 8 -- examples/otlp/grpc_log_main.cc | 13 --- examples/otlp/grpc_main.cc | 8 -- examples/otlp/http_log_main.cc | 16 ---- examples/otlp/http_main.cc | 8 -- examples/simple/main.cc | 5 -- .../otlp_grpc_log_record_exporter_test.cc | 7 -- .../sdk/logs/event_logger_provider_factory.h | 9 -- .../sdk/logs/logger_provider_factory.h | 32 ------- .../sdk/metrics/meter_provider_factory.h | 26 ------ .../sdk/trace/tracer_provider_factory.h | 64 -------------- sdk/src/logs/event_logger_provider_factory.cc | 11 --- sdk/src/logs/logger_provider_factory.cc | 46 ---------- sdk/src/metrics/meter_provider_factory.cc | 36 -------- sdk/src/trace/tracer_provider_factory.cc | 86 ------------------- 25 files changed, 39 insertions(+), 517 deletions(-) diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 598f57e97e..2c84b84cdc 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -40,7 +40,6 @@ jobs: -DWITH_STL=CXX14 \ -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;" \ -DBUILD_TESTING=OFF \ - -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DBUILD_W3CTRACECONTEXT_TEST=OFF \ -DWITH_OTLP_GRPC=OFF \ -DWITH_OTLP_HTTP=ON \ diff --git a/CHANGELOG.md b/CHANGELOG.md index e7e13ec3d6..bce84c84df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,44 @@ Increment the: * [CI] Add a clang-tidy build [#3001](https://github.com/open-telemetry/opentelemetry-cpp/pull/3001) +* [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` + [#2717](https://github.com/open-telemetry/opentelemetry-cpp/pull/2717) + +Breaking changes: + +* [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` + [#2717](https://github.com/open-telemetry/opentelemetry-cpp/pull/2717) + + * As announced in opentelemetry-cpp previous release 1.16.0, + CMake option `WITH_DEPRECATED_SDK_FACTORY` was temporary, + and to be removed by the next release. + * This option is now removed. + * Code configuring the SDK must be adjusted, as previously described: + + * [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. + ## [1.16.1 2024-07-17] * [BUILD] Add bazel missing BUILD file diff --git a/CMakeLists.txt b/CMakeLists.txt index 44ddd05e1c..d10e831297 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,14 +159,6 @@ 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") @@ -204,13 +196,6 @@ if(NOT WITH_STL STREQUAL "OFF") endif() endif() -if(DEFINED WITH_OTLP) - message( - FATAL_ERROR - "WITH_OTLP is deprecated. Please set either WITH_OTLP_GRPC=ON, WITH_OTLP_HTTP=ON, or both to ON." - ) -endif() - option(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW "Whether to enable mTLS support fro gRPC" OFF) @@ -294,10 +279,6 @@ option( option(WITH_FUNC_TESTS "Whether to build functional tests" ON) -if(DEFINED WITH_LOGS_PREVIEW) - message(WARNING "WITH_LOGS_PREVIEW is removed because logs signal is stable") -endif() - option(WITH_ASYNC_EXPORT_PREVIEW "Whether to enable async export" OFF) # Exemplar specs status is experimental, so behind feature flag by default diff --git a/DEPRECATED.md b/DEPRECATED.md index 7db5ba9d93..0632f50503 100644 --- a/DEPRECATED.md +++ b/DEPRECATED.md @@ -88,85 +88,7 @@ No date set yet for the Jaeger Propagator. ## [opentelemetry-cpp SDK] -### 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 tracer_provider; - tracer_provider = opentelemetry::sdk::trace::TracerProviderFactory::Create(...); -``` - -should be adjusted to: - -```cpp - std::shared_ptr 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 +N/A ## [opentelemetry-cpp Exporter] diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index e07275efed..78e97ad029 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -35,11 +35,6 @@ 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/ci/do_ci.ps1 b/ci/do_ci.ps1 index bcae6359bb..e9c1f64646 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -135,7 +135,6 @@ 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 @@ -160,7 +159,6 @@ 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 efdac9e87e..6d339c8d4e 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -130,7 +130,6 @@ 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}" @@ -153,7 +152,6 @@ 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}" @@ -177,7 +175,6 @@ 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) @@ -199,7 +196,6 @@ 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 444775dc59..3d7dfb8831 100644 --- a/examples/logs_simple/main.cc +++ b/examples/logs_simple/main.cc @@ -44,13 +44,8 @@ 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 provider = - opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); -#else std::shared_ptr provider = opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global trace provider const std::shared_ptr &api_provider = provider; @@ -70,13 +65,8 @@ void InitLogger() std::unique_ptr(new logs_exporter::OStreamLogRecordExporter); auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - std::shared_ptr provider( - opentelemetry::sdk::logs::LoggerProviderFactory::Create(std::move(processor))); -#else std::shared_ptr provider( opentelemetry::sdk::logs::LoggerProviderFactory::Create(std::move(processor))); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global logger provider const std::shared_ptr &api_provider = provider; diff --git a/examples/metrics_simple/metrics_ostream.cc b/examples/metrics_simple/metrics_ostream.cc index 5871b5e6a3..5bdc7339eb 100644 --- a/examples/metrics_simple/metrics_ostream.cc +++ b/examples/metrics_simple/metrics_ostream.cc @@ -57,12 +57,7 @@ void InitMetrics(const std::string &name) auto reader = metrics_sdk::PeriodicExportingMetricReaderFactory::Create(std::move(exporter), options); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - auto u_provider = opentelemetry::sdk::metrics::MeterProviderFactory::Create(); - auto *provider = static_cast(u_provider.get()); -#else auto provider = opentelemetry::sdk::metrics::MeterProviderFactory::Create(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ provider->AddMetricReader(std::move(reader)); @@ -118,11 +113,7 @@ void InitMetrics(const std::string &name) provider->AddView(std::move(histogram_instrument_selector), std::move(histogram_meter_selector), std::move(histogram_view)); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - std::shared_ptr api_provider(std::move(u_provider)); -#else std::shared_ptr api_provider(std::move(provider)); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ metrics_api::Provider::SetMeterProvider(api_provider); } diff --git a/examples/otlp/file_log_main.cc b/examples/otlp/file_log_main.cc index 30eb71cc2b..3cd59f7240 100644 --- a/examples/otlp/file_log_main.cc +++ b/examples/otlp/file_log_main.cc @@ -46,13 +46,8 @@ namespace opentelemetry::exporter::otlp::OtlpFileExporterOptions opts; opentelemetry::exporter::otlp::OtlpFileLogRecordExporterOptions log_opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr tracer_provider; -std::shared_ptr logger_provider; -#else std::shared_ptr tracer_provider; std::shared_ptr logger_provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -71,11 +66,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (tracer_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(tracer_provider.get())->ForceFlush(); -#else tracer_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } tracer_provider.reset(); @@ -99,11 +90,7 @@ void CleanupLogger() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (logger_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(logger_provider.get())->ForceFlush(); -#else logger_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } logger_provider.reset(); diff --git a/examples/otlp/file_main.cc b/examples/otlp/file_main.cc index 243ad44428..377662aee4 100644 --- a/examples/otlp/file_main.cc +++ b/examples/otlp/file_main.cc @@ -31,11 +31,7 @@ namespace { opentelemetry::exporter::otlp::OtlpFileExporterOptions opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr provider; -#else std::shared_ptr provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -54,11 +50,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(provider.get())->ForceFlush(); -#else provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } provider.reset(); diff --git a/examples/otlp/grpc_log_main.cc b/examples/otlp/grpc_log_main.cc index 24037f6190..c7aca2ea31 100644 --- a/examples/otlp/grpc_log_main.cc +++ b/examples/otlp/grpc_log_main.cc @@ -38,13 +38,8 @@ namespace opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts; opentelemetry::exporter::otlp::OtlpGrpcLogRecordExporterOptions log_opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr tracer_provider; -std::shared_ptr logger_provider; -#else std::shared_ptr tracer_provider; std::shared_ptr logger_provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -63,11 +58,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (tracer_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(tracer_provider.get())->ForceFlush(); -#else tracer_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } tracer_provider.reset(); @@ -92,11 +83,7 @@ void CleanupLogger() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (logger_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(logger_provider.get())->ForceFlush(); -#else logger_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } logger_provider.reset(); diff --git a/examples/otlp/grpc_main.cc b/examples/otlp/grpc_main.cc index 15499985af..9b29e16edd 100644 --- a/examples/otlp/grpc_main.cc +++ b/examples/otlp/grpc_main.cc @@ -24,11 +24,7 @@ namespace { opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr provider; -#else std::shared_ptr provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -47,11 +43,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(provider.get())->ForceFlush(); -#else provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } provider.reset(); diff --git a/examples/otlp/http_log_main.cc b/examples/otlp/http_log_main.cc index 37bace2b0f..4f42b61ce9 100644 --- a/examples/otlp/http_log_main.cc +++ b/examples/otlp/http_log_main.cc @@ -48,11 +48,7 @@ namespace opentelemetry::exporter::otlp::OtlpHttpExporterOptions trace_opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr tracer_provider; -#else std::shared_ptr tracer_provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -88,11 +84,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (tracer_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(tracer_provider.get())->ForceFlush(); -#else tracer_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } tracer_provider.reset(); @@ -102,11 +94,7 @@ void CleanupTracer() opentelemetry::exporter::otlp::OtlpHttpLogRecordExporterOptions logger_opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr logger_provider; -#else std::shared_ptr logger_provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitLogger() { @@ -126,11 +114,7 @@ void CleanupLogger() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (logger_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(logger_provider.get())->ForceFlush(); -#else logger_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } logger_provider.reset(); diff --git a/examples/otlp/http_main.cc b/examples/otlp/http_main.cc index 6217bdcb34..ce88e46fca 100644 --- a/examples/otlp/http_main.cc +++ b/examples/otlp/http_main.cc @@ -35,11 +35,7 @@ namespace { opentelemetry::exporter::otlp::OtlpHttpExporterOptions opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr provider; -#else std::shared_ptr provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -57,11 +53,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(provider.get())->ForceFlush(); -#else provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } provider.reset(); diff --git a/examples/simple/main.cc b/examples/simple/main.cc index 349aec500a..245786688c 100644 --- a/examples/simple/main.cc +++ b/examples/simple/main.cc @@ -31,13 +31,8 @@ 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 provider = - opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); -#else std::shared_ptr provider = opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global trace provider const std::shared_ptr &api_provider = provider; 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 4c7a9fd7f1..90827f576f 100644 --- a/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc @@ -288,17 +288,10 @@ TEST_F(OtlpGrpcLogRecordExporterTestPeer, ExportIntegrationTest) std::unique_ptr trace_stub_interface( trace_mock_stub); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - auto trace_provider = opentelemetry::nostd::shared_ptr( - 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::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(_, _, _)) 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 621cbea6c8..5559605171 100644 --- a/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h @@ -24,16 +24,7 @@ class EventLoggerProviderFactory * Create a EventLoggerProvider. */ -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create(); -# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ - -#else static std::unique_ptr Create(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace logs diff --git a/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h b/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h index 7b8f636e68..490393209c 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h @@ -24,36 +24,6 @@ namespace logs class OPENTELEMETRY_EXPORT LoggerProviderFactory { public: -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr &&processor); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr &&processor, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr context); - -# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ - -#else - /** * Create a LoggerProvider. */ @@ -85,8 +55,6 @@ class OPENTELEMETRY_EXPORT LoggerProviderFactory */ static std::unique_ptr Create( std::unique_ptr context); - -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace logs diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h index cb9106ddc8..499c87ae6a 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h @@ -21,30 +21,6 @@ namespace metrics class OPENTELEMETRY_EXPORT MeterProviderFactory { public: -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create(); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr views); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr views, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr context); - -# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ - -#else - static std::unique_ptr Create(); static std::unique_ptr Create( @@ -56,8 +32,6 @@ class OPENTELEMETRY_EXPORT MeterProviderFactory static std::unique_ptr Create( std::unique_ptr context); - -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace metrics diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h b/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h index 7c4b6903de..ed451a8c99 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h @@ -28,68 +28,6 @@ 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 Create( - std::unique_ptr processor); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator); - - /* Serie of builders with a vector of processor. */ - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator); - - /* Create with a tracer context. */ - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr context); - -# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ - -#else - /* Serie of builders with a single processor. */ static std::unique_ptr Create( @@ -134,8 +72,6 @@ class OPENTELEMETRY_EXPORT TracerProviderFactory static std::unique_ptr Create( std::unique_ptr 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 7f5c8cadf1..daff8a8590 100644 --- a/sdk/src/logs/event_logger_provider_factory.cc +++ b/sdk/src/logs/event_logger_provider_factory.cc @@ -11,22 +11,11 @@ namespace sdk namespace logs { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr EventLoggerProviderFactory::Create() -{ - return std::unique_ptr(new EventLoggerProvider()); -} - -#else - std::unique_ptr EventLoggerProviderFactory::Create() { return std::unique_ptr(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 08567c65d9..530d1c2db4 100644 --- a/sdk/src/logs/logger_provider_factory.cc +++ b/sdk/src/logs/logger_provider_factory.cc @@ -18,50 +18,6 @@ namespace sdk namespace logs { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr LoggerProviderFactory::Create( - std::unique_ptr &&processor) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processor), resource); -} - -std::unique_ptr LoggerProviderFactory::Create( - std::unique_ptr &&processor, - const opentelemetry::sdk::resource::Resource &resource) -{ - std::unique_ptr provider( - new LoggerProvider(std::move(processor), resource)); - return provider; -} - -std::unique_ptr LoggerProviderFactory::Create( - std::vector> &&processors) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processors), resource); -} - -std::unique_ptr LoggerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource) -{ - std::unique_ptr provider( - new LoggerProvider(std::move(processors), resource)); - return provider; -} - -std::unique_ptr LoggerProviderFactory::Create( - std::unique_ptr context) -{ - std::unique_ptr provider( - new LoggerProvider(std::move(context))); - return provider; -} - -#else - std::unique_ptr LoggerProviderFactory::Create( std::unique_ptr &&processor) { @@ -102,8 +58,6 @@ std::unique_ptr LoggerProviderFactory: 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 7749a13124..c5e368aca6 100644 --- a/sdk/src/metrics/meter_provider_factory.cc +++ b/sdk/src/metrics/meter_provider_factory.cc @@ -18,40 +18,6 @@ namespace sdk namespace metrics { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr MeterProviderFactory::Create() -{ - auto views = ViewRegistryFactory::Create(); - return Create(std::move(views)); -} - -std::unique_ptr MeterProviderFactory::Create( - std::unique_ptr views) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(views), resource); -} - -std::unique_ptr MeterProviderFactory::Create( - std::unique_ptr views, - const opentelemetry::sdk::resource::Resource &resource) -{ - std::unique_ptr provider( - new opentelemetry::sdk::metrics::MeterProvider(std::move(views), resource)); - return provider; -} - -std::unique_ptr MeterProviderFactory::Create( - std::unique_ptr context) -{ - std::unique_ptr provider( - new opentelemetry::sdk::metrics::MeterProvider(std::move(context))); - return provider; -} - -#else - std::unique_ptr MeterProviderFactory::Create() { auto views = ViewRegistryFactory::Create(); @@ -82,8 +48,6 @@ std::unique_ptr MeterProviderFactory 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 eeb18a1e59..eaeb669b91 100644 --- a/sdk/src/trace/tracer_provider_factory.cc +++ b/sdk/src/trace/tracer_provider_factory.cc @@ -22,90 +22,6 @@ namespace sdk namespace trace { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processor), resource); -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource) -{ - auto sampler = AlwaysOnSamplerFactory::Create(); - return Create(std::move(processor), resource, std::move(sampler)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler) -{ - auto id_generator = RandomIdGeneratorFactory::Create(); - return Create(std::move(processor), resource, std::move(sampler), std::move(id_generator)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator) -{ - std::unique_ptr provider( - new opentelemetry::sdk::trace::TracerProvider(std::move(processor), resource, - std::move(sampler), std::move(id_generator))); - return provider; -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processors), resource); -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource) -{ - auto sampler = AlwaysOnSamplerFactory::Create(); - return Create(std::move(processors), resource, std::move(sampler)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler) -{ - auto id_generator = RandomIdGeneratorFactory::Create(); - return Create(std::move(processors), resource, std::move(sampler), std::move(id_generator)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator) -{ - std::unique_ptr provider( - new opentelemetry::sdk::trace::TracerProvider(std::move(processors), resource, - std::move(sampler), std::move(id_generator))); - return provider; -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr context) -{ - std::unique_ptr provider( - new opentelemetry::sdk::trace::TracerProvider(std::move(context))); - return provider; -} - -#else - std::unique_ptr TracerProviderFactory::Create( std::unique_ptr processor) { @@ -186,8 +102,6 @@ std::unique_ptr TracerProviderFactory return provider; } -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - } // namespace trace } // namespace sdk OPENTELEMETRY_END_NAMESPACE From f195b9e3da9c7987c377fafe8a7a6873b0d34549 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Fri, 19 Jul 2024 17:34:40 +0800 Subject: [PATCH 43/44] [EXPORTER] ForceFlush before canceling the running requests on shutdown. (#2727) --- .../exporters/otlp/otlp_http_client.h | 5 ++- exporters/otlp/src/otlp_grpc_client.cc | 9 ++++- exporters/otlp/src/otlp_http_client.cc | 38 ++++++++++++++----- 3 files changed, 39 insertions(+), 13 deletions(-) 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 6806f1cdf9..3753704bb3 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include @@ -275,7 +276,7 @@ class OtlpHttpClient std::shared_ptr http_client); // Stores if this HTTP client had its Shutdown() method called - bool is_shutdown_; + std::atomic is_shutdown_; // The configuration options associated with this HTTP client. const OtlpHttpClientOptions options_; @@ -296,6 +297,8 @@ class OtlpHttpClient // Condition variable and mutex to control the concurrency count of running sessions std::mutex session_waker_lock_; std::condition_variable session_waker_; + std::atomic start_session_counter_; + std::atomic finished_session_counter_; }; } // namespace otlp } // namespace exporter diff --git a/exporters/otlp/src/otlp_grpc_client.cc b/exporters/otlp/src/otlp_grpc_client.cc index a5760bdd81..d3d59bce6e 100644 --- a/exporters/otlp/src/otlp_grpc_client.cc +++ b/exporters/otlp/src/otlp_grpc_client.cc @@ -567,14 +567,19 @@ bool OtlpGrpcClient::Shutdown(std::chrono::microseconds timeout) noexcept return true; } + bool force_flush_result; if (false == is_shutdown_.exchange(true, std::memory_order_acq_rel)) { - is_shutdown_ = true; + force_flush_result = ForceFlush(timeout); async_data_->cq.Shutdown(); } + else + { + force_flush_result = ForceFlush(timeout); + } - return ForceFlush(timeout); + return force_flush_result; } #endif diff --git a/exporters/otlp/src/otlp_http_client.cc b/exporters/otlp/src/otlp_http_client.cc index 94f02a9967..07b9108a3a 100644 --- a/exporters/otlp/src/otlp_http_client.cc +++ b/exporters/otlp/src/otlp_http_client.cc @@ -41,9 +41,11 @@ // clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep -#include +// clang-format on #include +#include #include +// clang-format off #include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep // clang-format on @@ -661,7 +663,11 @@ void ConvertListFieldToJson(nlohmann::json &value, } // namespace OtlpHttpClient::OtlpHttpClient(OtlpHttpClientOptions &&options) - : is_shutdown_(false), options_(options), http_client_(http_client::HttpClientFactory::Create()) + : is_shutdown_(false), + options_(options), + http_client_(http_client::HttpClientFactory::Create()), + start_session_counter_(0), + finished_session_counter_(0) { http_client_->SetMaxSessionsPerConnection(options_.max_requests_per_connection); } @@ -700,7 +706,11 @@ OtlpHttpClient::~OtlpHttpClient() OtlpHttpClient::OtlpHttpClient(OtlpHttpClientOptions &&options, std::shared_ptr http_client) - : is_shutdown_(false), options_(options), http_client_(std::move(http_client)) + : is_shutdown_(false), + options_(options), + http_client_(std::move(http_client)), + start_session_counter_(0), + finished_session_counter_(0) { http_client_->SetMaxSessionsPerConnection(options_.max_requests_per_connection); } @@ -799,6 +809,8 @@ bool OtlpHttpClient::ForceFlush(std::chrono::microseconds timeout) noexcept timeout_steady = (std::chrono::steady_clock::duration::max)(); } + size_t wait_counter = start_session_counter_.load(std::memory_order_acquire); + while (timeout_steady > std::chrono::steady_clock::duration::zero()) { { @@ -816,7 +828,7 @@ bool OtlpHttpClient::ForceFlush(std::chrono::microseconds timeout) noexcept { cleanupGCSessions(); } - else + else if (finished_session_counter_.load(std::memory_order_acquire) >= wait_counter) { break; } @@ -829,20 +841,24 @@ bool OtlpHttpClient::ForceFlush(std::chrono::microseconds timeout) noexcept bool OtlpHttpClient::Shutdown(std::chrono::microseconds timeout) noexcept { + is_shutdown_.store(true, std::memory_order_release); + + bool force_flush_result = ForceFlush(timeout); + { std::lock_guard guard{session_manager_lock_}; - is_shutdown_ = true; // Shutdown the session manager http_client_->CancelAllSessions(); http_client_->FinishAllSessions(); } - ForceFlush(timeout); - + // Wait util all sessions are canceled. while (cleanupGCSessions()) - ; - return true; + { + ForceFlush(std::chrono::milliseconds{1}); + } + return force_flush_result; } void OtlpHttpClient::ReleaseSession( @@ -859,6 +875,7 @@ void OtlpHttpClient::ReleaseSession( gc_sessions_.emplace_back(std::move(session_iter->second)); running_sessions_.erase(session_iter); + finished_session_counter_.fetch_add(1, std::memory_order_release); has_session = true; } @@ -1003,6 +1020,7 @@ void OtlpHttpClient::addSession(HttpSessionData &&session_data) noexcept store_session_data = std::move(session_data); } + start_session_counter_.fetch_add(1, std::memory_order_release); // Send request after the session is added session->SendRequest(handle); } @@ -1027,7 +1045,7 @@ bool OtlpHttpClient::cleanupGCSessions() noexcept bool OtlpHttpClient::IsShutdown() const noexcept { - return is_shutdown_; + return is_shutdown_.load(std::memory_order_acquire); } } // namespace otlp From 4520aa598b7c100eefbb4ce9a9f73cb50bb69514 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Fri, 19 Jul 2024 18:12:48 +0800 Subject: [PATCH 44/44] [SDK] Fix crash in `PeriodicExportingMetricReader`. (#2983) --- api/include/opentelemetry/common/macros.h | 31 ++++++++ examples/plugin/plugin/tracer.cc | 1 + exporters/otlp/src/otlp_file_client.cc | 22 +++--- .../periodic_exporting_metric_reader.cc | 77 ++++++++++++++----- .../periodic_exporting_metric_reader_test.cc | 38 +++++++-- 5 files changed, 133 insertions(+), 36 deletions(-) diff --git a/api/include/opentelemetry/common/macros.h b/api/include/opentelemetry/common/macros.h index b4a270084d..b74c1048fc 100644 --- a/api/include/opentelemetry/common/macros.h +++ b/api/include/opentelemetry/common/macros.h @@ -387,6 +387,37 @@ point. #endif +// OPENTELEMETRY_HAVE_EXCEPTIONS +// +// Checks whether the compiler both supports and enables exceptions. Many +// compilers support a "no exceptions" mode that disables exceptions. +// +// Generally, when OPENTELEMETRY_HAVE_EXCEPTIONS is not defined: +// +// * Code using `throw` and `try` may not compile. +// * The `noexcept` specifier will still compile and behave as normal. +// * The `noexcept` operator may still return `false`. +// +// For further details, consult the compiler's documentation. +#ifndef OPENTELEMETRY_HAVE_EXCEPTIONS +# if defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__) < 306 +// Clang < 3.6 +// http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro +# if defined(__EXCEPTIONS) && OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) +# define OPENTELEMETRY_HAVE_EXCEPTIONS 1 +# endif // defined(__EXCEPTIONS) && OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) +# elif OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) +# define OPENTELEMETRY_HAVE_EXCEPTIONS 1 +// Handle remaining special cases and default to exceptions being supported. +# elif !(defined(__GNUC__) && !defined(__EXCEPTIONS) && !defined(__cpp_exceptions)) && \ + !(defined(_MSC_VER) && !defined(_CPPUNWIND)) +# define OPENTELEMETRY_HAVE_EXCEPTIONS 1 +# endif +#endif +#ifndef OPENTELEMETRY_HAVE_EXCEPTIONS +# define OPENTELEMETRY_HAVE_EXCEPTIONS 0 +#endif + /* OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND indicates that a resource owned by a function parameter or implicit object parameter is retained by the return value of the diff --git a/examples/plugin/plugin/tracer.cc b/examples/plugin/plugin/tracer.cc index 5361197584..05ff971fb1 100644 --- a/examples/plugin/plugin/tracer.cc +++ b/examples/plugin/plugin/tracer.cc @@ -9,6 +9,7 @@ #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/timestamp.h" #include "opentelemetry/context/context_value.h" +#include "opentelemetry/nostd/utility.h" #include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_metadata.h" #include "tracer.h" diff --git a/exporters/otlp/src/otlp_file_client.cc b/exporters/otlp/src/otlp_file_client.cc index 62552bdeff..8efa5c15b5 100644 --- a/exporters/otlp/src/otlp_file_client.cc +++ b/exporters/otlp/src/otlp_file_client.cc @@ -14,8 +14,6 @@ // clang-format on #include "google/protobuf/message.h" -#include "google/protobuf/reflection.h" -#include "google/protobuf/stubs/common.h" #include "nlohmann/json.hpp" // clang-format off @@ -28,15 +26,26 @@ #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/version.h" +#ifdef _MSC_VER +# include +# define strcasecmp _stricmp +#else +# include +#endif + +#include #include #include +#include #include -#include #include +#include #include +#include #include #include #include +#include #include #if !defined(__CYGWIN__) && defined(_WIN32) @@ -64,11 +73,8 @@ #else -# include -# include # include # include -# include # include # define FS_ACCESS(x) access(x, F_OK) @@ -89,10 +95,6 @@ # undef GetMessage #endif -#ifdef _MSC_VER -# define strcasecmp _stricmp -#endif - #if (defined(_MSC_VER) && _MSC_VER >= 1600) || \ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || defined(__STDC_LIB_EXT1__) # ifdef _MSC_VER diff --git a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc index f6ae47977d..7ca2747337 100644 --- a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc +++ b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc @@ -13,6 +13,7 @@ #include #include +#include "opentelemetry/common/macros.h" #include "opentelemetry/common/timestamp.h" #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/metrics/export/metric_producer.h" @@ -29,6 +30,10 @@ # include #endif +#if OPENTELEMETRY_HAVE_EXCEPTIONS +# include +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { @@ -90,31 +95,61 @@ void PeriodicExportingMetricReader::DoBackgroundWork() bool PeriodicExportingMetricReader::CollectAndExportOnce() { std::atomic cancel_export_for_timeout{false}; - auto future_receive = std::async(std::launch::async, [this, &cancel_export_for_timeout] { - Collect([this, &cancel_export_for_timeout](ResourceMetrics &metric_data) { - if (cancel_export_for_timeout) - { - OTEL_INTERNAL_LOG_ERROR( - "[Periodic Exporting Metric Reader] Collect took longer configured time: " - << export_timeout_millis_.count() << " ms, and timed out"); - return false; - } - this->exporter_->Export(metric_data); - return true; - }); - }); - std::future_status status; std::uint64_t notify_force_flush = force_flush_pending_sequence_.load(std::memory_order_acquire); - do + std::unique_ptr task_thread; + +#if OPENTELEMETRY_HAVE_EXCEPTIONS + try { - status = future_receive.wait_for(std::chrono::milliseconds(export_timeout_millis_)); - if (status == std::future_status::timeout) +#endif + std::promise sender; + auto receiver = sender.get_future(); + + task_thread.reset(new std::thread([this, &cancel_export_for_timeout] { + this->Collect([this, &cancel_export_for_timeout](ResourceMetrics &metric_data) { + if (cancel_export_for_timeout.load(std::memory_order_acquire)) + { + OTEL_INTERNAL_LOG_ERROR( + "[Periodic Exporting Metric Reader] Collect took longer configured time: " + << this->export_timeout_millis_.count() << " ms, and timed out"); + return false; + } + this->exporter_->Export(metric_data); + return true; + }); + })); + + std::future_status status; + do { - cancel_export_for_timeout = true; - break; - } - } while (status != std::future_status::ready); + status = receiver.wait_for(std::chrono::milliseconds(export_timeout_millis_)); + if (status == std::future_status::timeout) + { + cancel_export_for_timeout.store(true, std::memory_order_release); + break; + } + } while (status != std::future_status::ready); +#if OPENTELEMETRY_HAVE_EXCEPTIONS + } + catch (std::exception &e) + { + OTEL_INTERNAL_LOG_ERROR("[Periodic Exporting Metric Reader] Collect failed with exception " + << e.what()); + return false; + } + catch (...) + { + OTEL_INTERNAL_LOG_ERROR( + "[Periodic Exporting Metric Reader] Collect failed with unknown exception"); + return false; + } +#endif + + if (task_thread && task_thread->joinable()) + { + task_thread->join(); + } std::uint64_t notified_sequence = force_flush_notified_sequence_.load(std::memory_order_acquire); while (notify_force_flush > notified_sequence) diff --git a/sdk/test/metrics/periodic_exporting_metric_reader_test.cc b/sdk/test/metrics/periodic_exporting_metric_reader_test.cc index e115f79f75..f65c10ca05 100644 --- a/sdk/test/metrics/periodic_exporting_metric_reader_test.cc +++ b/sdk/test/metrics/periodic_exporting_metric_reader_test.cc @@ -7,6 +7,10 @@ #include +#include +#include +#include + using namespace opentelemetry; using namespace opentelemetry::sdk::instrumentationscope; using namespace opentelemetry::sdk::metrics; @@ -14,8 +18,14 @@ using namespace opentelemetry::sdk::metrics; class MockPushMetricExporter : public PushMetricExporter { public: + MockPushMetricExporter(std::chrono::milliseconds wait) : wait_(wait) {} + opentelemetry::sdk::common::ExportResult Export(const ResourceMetrics &record) noexcept override { + if (wait_ > std::chrono::milliseconds::zero()) + { + std::this_thread::sleep_for(wait_); + } records_.push_back(record); return opentelemetry::sdk::common::ExportResult::kSuccess; } @@ -34,6 +44,7 @@ class MockPushMetricExporter : public PushMetricExporter private: std::vector records_; + std::chrono::milliseconds wait_; }; class MockMetricProducer : public MetricProducer @@ -61,17 +72,34 @@ class MockMetricProducer : public MetricProducer TEST(PeriodicExporingMetricReader, BasicTests) { - std::unique_ptr exporter(new MockPushMetricExporter()); + std::unique_ptr exporter( + new MockPushMetricExporter(std::chrono::milliseconds{0})); PeriodicExportingMetricReaderOptions options; options.export_timeout_millis = std::chrono::milliseconds(200); options.export_interval_millis = std::chrono::milliseconds(500); auto exporter_ptr = exporter.get(); - PeriodicExportingMetricReader reader(std::move(exporter), options); + std::shared_ptr reader = + std::make_shared(std::move(exporter), options); MockMetricProducer producer; - reader.SetMetricProducer(&producer); + reader->SetMetricProducer(&producer); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - EXPECT_NO_THROW(reader.ForceFlush()); - reader.Shutdown(); + EXPECT_NO_THROW(reader->ForceFlush()); + reader->Shutdown(); EXPECT_EQ(static_cast(exporter_ptr)->GetDataCount(), static_cast(&producer)->GetDataCount()); } + +TEST(PeriodicExporingMetricReader, Timeout) +{ + std::unique_ptr exporter( + new MockPushMetricExporter(std::chrono::milliseconds{2000})); + PeriodicExportingMetricReaderOptions options; + options.export_timeout_millis = std::chrono::milliseconds(200); + options.export_interval_millis = std::chrono::milliseconds(500); + std::shared_ptr reader = + std::make_shared(std::move(exporter), options); + MockMetricProducer producer; + reader->SetMetricProducer(&producer); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + reader->Shutdown(); +}