Skip to content

Commit 578c101

Browse files
authored
[SDK] Invalid thread instrumentation in PeriodicExportingMetricReader (#3842)
1 parent 437ad43 commit 578c101

File tree

5 files changed

+12
-24
lines changed

5 files changed

+12
-24
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ Increment the:
5454
* [CONFIGURATION] File configuration - exemplar filter
5555
[#3837](https://github.com/open-telemetry/opentelemetry-cpp/pull/3837)
5656

57+
* [SDK] Invalid thread instrumentation in PeriodicExportingMetricReader
58+
[#3842](https://github.com/open-telemetry/opentelemetry-cpp/pull/3842)
59+
5760
Breaking changes:
5861

5962
* [CONFIGURATION] File configuration - remove zipkin
@@ -66,6 +69,13 @@ Breaking changes:
6669
* The Tls properties for Grpc and Http are renamed,
6770
due to an upstream schema change.
6871

72+
* [SDK] Invalid thread instrumentation in PeriodicExportingMetricReader
73+
[#3842](https://github.com/open-telemetry/opentelemetry-cpp/pull/3842)
74+
* The collect thread in the periodic exporting metric reader no longer
75+
exists.
76+
* As a result, member `collect_thread_instrumentation` in class
77+
`PeriodicExportingMetricReaderRuntimeOptions` is removed.
78+
6979
## [1.24 2025-11-20]
7080

7181
* [RELEASE] Bump main branch to 1.24-dev

examples/otlp/http_instrumented_main.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,7 @@ void InitMetrics()
229229
#ifdef ENABLE_THREAD_INSTRUMENTATION_PREVIEW
230230
auto reader_periodic_instr = std::shared_ptr<opentelemetry::sdk::common::ThreadInstrumentation>(
231231
new MyThreadInstrumentation("PeriodicExportingMetricReader(periodic)", "", "medium"));
232-
auto reader_collect_instr = std::shared_ptr<opentelemetry::sdk::common::ThreadInstrumentation>(
233-
new MyThreadInstrumentation("PeriodicExportingMetricReader(collect)", "", "medium"));
234232
reader_rt_opts.periodic_thread_instrumentation = reader_periodic_instr;
235-
reader_rt_opts.collect_thread_instrumentation = reader_collect_instr;
236233
#endif /* ENABLE_THREAD_INSTRUMENTATION_PREVIEW */
237234
auto reader = opentelemetry::sdk::metrics::PeriodicExportingMetricReaderFactory::Create(
238235
std::move(exporter), reader_options, reader_rt_opts);

sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class PeriodicExportingMetricReader : public MetricReader
6262

6363
/* The background worker thread */
6464
std::shared_ptr<sdk::common::ThreadInstrumentation> worker_thread_instrumentation_;
65-
std::shared_ptr<sdk::common::ThreadInstrumentation> collect_thread_instrumentation_;
6665
std::thread worker_thread_;
6766
};
6867

sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_runtime_options.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ struct PeriodicExportingMetricReaderRuntimeOptions
2121
{
2222
std::shared_ptr<sdk::common::ThreadInstrumentation> periodic_thread_instrumentation =
2323
std::shared_ptr<sdk::common::ThreadInstrumentation>(nullptr);
24-
std::shared_ptr<sdk::common::ThreadInstrumentation> collect_thread_instrumentation =
25-
std::shared_ptr<sdk::common::ThreadInstrumentation>(nullptr);
2624
};
2725

2826
} // namespace metrics

sdk/src/metrics/export/periodic_exporting_metric_reader.cc

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ PeriodicExportingMetricReader::PeriodicExportingMetricReader(
4343
: exporter_{std::move(exporter)},
4444
export_interval_millis_{options.export_interval_millis},
4545
export_timeout_millis_{options.export_timeout_millis},
46-
worker_thread_instrumentation_(nullptr),
47-
collect_thread_instrumentation_(nullptr)
46+
worker_thread_instrumentation_(nullptr)
4847
{
4948
if (export_interval_millis_ <= export_timeout_millis_)
5049
{
@@ -63,8 +62,7 @@ PeriodicExportingMetricReader::PeriodicExportingMetricReader(
6362
: exporter_{std::move(exporter)},
6463
export_interval_millis_{options.export_interval_millis},
6564
export_timeout_millis_{options.export_timeout_millis},
66-
worker_thread_instrumentation_(runtime_options.periodic_thread_instrumentation),
67-
collect_thread_instrumentation_(runtime_options.collect_thread_instrumentation)
65+
worker_thread_instrumentation_(runtime_options.periodic_thread_instrumentation)
6866
{
6967
if (export_interval_millis_ <= export_timeout_millis_)
7068
{
@@ -161,13 +159,6 @@ bool PeriodicExportingMetricReader::CollectAndExportOnce()
161159
try
162160
{
163161
#endif
164-
#ifdef ENABLE_THREAD_INSTRUMENTATION_PREVIEW
165-
if (collect_thread_instrumentation_ != nullptr)
166-
{
167-
collect_thread_instrumentation_->OnStart();
168-
collect_thread_instrumentation_->BeforeLoad();
169-
}
170-
#endif /* ENABLE_THREAD_INSTRUMENTATION_PREVIEW */
171162
auto start = std::chrono::steady_clock::now();
172163
this->Collect([this, &start](ResourceMetrics &metric_data) {
173164
auto end = std::chrono::steady_clock::now();
@@ -182,13 +173,6 @@ bool PeriodicExportingMetricReader::CollectAndExportOnce()
182173
return true;
183174
});
184175

185-
#ifdef ENABLE_THREAD_INSTRUMENTATION_PREVIEW
186-
if (collect_thread_instrumentation_ != nullptr)
187-
{
188-
collect_thread_instrumentation_->AfterLoad();
189-
collect_thread_instrumentation_->OnEnd();
190-
}
191-
#endif /* ENABLE_THREAD_INSTRUMENTATION_PREVIEW */
192176
#if OPENTELEMETRY_HAVE_EXCEPTIONS
193177
}
194178
catch (std::exception &e)

0 commit comments

Comments
 (0)