From 000a54e76b34139b23fdcf7acfd25ca456c4a46d Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Tue, 3 Feb 2026 09:29:22 +0100 Subject: [PATCH 1/3] [SDK] Invalid thread instrumentation in PeriodicExportingMetricReader --- .../export/periodic_exporting_metric_reader.h | 1 - ..._exporting_metric_reader_runtime_options.h | 2 -- .../periodic_exporting_metric_reader.cc | 20 ++----------------- 3 files changed, 2 insertions(+), 21 deletions(-) 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 bb8db1ac09..93c183f83f 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 @@ -62,7 +62,6 @@ class PeriodicExportingMetricReader : public MetricReader /* The background worker thread */ std::shared_ptr worker_thread_instrumentation_; - std::shared_ptr collect_thread_instrumentation_; std::thread worker_thread_; }; diff --git a/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_runtime_options.h b/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_runtime_options.h index f816fc05a0..79e6f2754c 100644 --- a/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_runtime_options.h +++ b/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_runtime_options.h @@ -21,8 +21,6 @@ struct PeriodicExportingMetricReaderRuntimeOptions { std::shared_ptr periodic_thread_instrumentation = std::shared_ptr(nullptr); - std::shared_ptr collect_thread_instrumentation = - std::shared_ptr(nullptr); }; } // namespace metrics diff --git a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc index 099b9ac122..215526505b 100644 --- a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc +++ b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc @@ -43,8 +43,7 @@ PeriodicExportingMetricReader::PeriodicExportingMetricReader( : exporter_{std::move(exporter)}, export_interval_millis_{options.export_interval_millis}, export_timeout_millis_{options.export_timeout_millis}, - worker_thread_instrumentation_(nullptr), - collect_thread_instrumentation_(nullptr) + worker_thread_instrumentation_(nullptr) { if (export_interval_millis_ <= export_timeout_millis_) { @@ -63,8 +62,7 @@ PeriodicExportingMetricReader::PeriodicExportingMetricReader( : exporter_{std::move(exporter)}, export_interval_millis_{options.export_interval_millis}, export_timeout_millis_{options.export_timeout_millis}, - worker_thread_instrumentation_(runtime_options.periodic_thread_instrumentation), - collect_thread_instrumentation_(runtime_options.collect_thread_instrumentation) + worker_thread_instrumentation_(runtime_options.periodic_thread_instrumentation) { if (export_interval_millis_ <= export_timeout_millis_) { @@ -161,13 +159,6 @@ bool PeriodicExportingMetricReader::CollectAndExportOnce() try { #endif -#ifdef ENABLE_THREAD_INSTRUMENTATION_PREVIEW - if (collect_thread_instrumentation_ != nullptr) - { - collect_thread_instrumentation_->OnStart(); - collect_thread_instrumentation_->BeforeLoad(); - } -#endif /* ENABLE_THREAD_INSTRUMENTATION_PREVIEW */ auto start = std::chrono::steady_clock::now(); this->Collect([this, &start](ResourceMetrics &metric_data) { auto end = std::chrono::steady_clock::now(); @@ -182,13 +173,6 @@ bool PeriodicExportingMetricReader::CollectAndExportOnce() return true; }); -#ifdef ENABLE_THREAD_INSTRUMENTATION_PREVIEW - if (collect_thread_instrumentation_ != nullptr) - { - collect_thread_instrumentation_->AfterLoad(); - collect_thread_instrumentation_->OnEnd(); - } -#endif /* ENABLE_THREAD_INSTRUMENTATION_PREVIEW */ #if OPENTELEMETRY_HAVE_EXCEPTIONS } catch (std::exception &e) From fe0d367ab3250a20d8b28f98136cad7080baee4b Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Tue, 3 Feb 2026 09:37:15 +0100 Subject: [PATCH 2/3] CHANGELOG --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3744d36ae4..2381e5890a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,9 @@ Increment the: * [CONFIGURATION] File configuration - exemplar filter [#3837](https://github.com/open-telemetry/opentelemetry-cpp/pull/3837) +* [SDK] Invalid thread instrumentation in PeriodicExportingMetricReader + [#3842](https://github.com/open-telemetry/opentelemetry-cpp/pull/3842) + Breaking changes: * [CONFIGURATION] File configuration - remove zipkin @@ -66,6 +69,13 @@ Breaking changes: * The Tls properties for Grpc and Http are renamed, due to an upstream schema change. +* [SDK] Invalid thread instrumentation in PeriodicExportingMetricReader + [#3842](https://github.com/open-telemetry/opentelemetry-cpp/pull/3842) + * The collect thread in the periodic exporting metric reader no longer + exists. + * As a result, member `collect_thread_instrumentation` in class + `PeriodicExportingMetricReaderRuntimeOptions` is removed. + ## [1.24 2025-11-20] * [RELEASE] Bump main branch to 1.24-dev From c11a14a3737abe0727c3d326f3cdf2aa6ae8642d Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Tue, 3 Feb 2026 09:45:26 +0100 Subject: [PATCH 3/3] Fix examples --- examples/otlp/http_instrumented_main.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/otlp/http_instrumented_main.cc b/examples/otlp/http_instrumented_main.cc index 745d65216f..7a82abde27 100644 --- a/examples/otlp/http_instrumented_main.cc +++ b/examples/otlp/http_instrumented_main.cc @@ -229,10 +229,7 @@ void InitMetrics() #ifdef ENABLE_THREAD_INSTRUMENTATION_PREVIEW auto reader_periodic_instr = std::shared_ptr( new MyThreadInstrumentation("PeriodicExportingMetricReader(periodic)", "", "medium")); - auto reader_collect_instr = std::shared_ptr( - new MyThreadInstrumentation("PeriodicExportingMetricReader(collect)", "", "medium")); reader_rt_opts.periodic_thread_instrumentation = reader_periodic_instr; - reader_rt_opts.collect_thread_instrumentation = reader_collect_instr; #endif /* ENABLE_THREAD_INSTRUMENTATION_PREVIEW */ auto reader = opentelemetry::sdk::metrics::PeriodicExportingMetricReaderFactory::Create( std::move(exporter), reader_options, reader_rt_opts);