Skip to content

Commit f023c03

Browse files
authored
chore(sdk): use strong_count for queue capacity callback liveness check (#3626)
1 parent 48c5637 commit f023c03

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

opentelemetry-sdk/src/logs/batch_log_processor.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,11 @@ impl BatchLogProcessor {
422422
)
423423
.with_unit("{log_record}")
424424
.with_callback(move |observer| {
425-
// The capacity value is constant; the Weak upgrade is only a
426-
// liveness guard so a dropped processor stops emitting this
427-
// otherwise-unregisterable callback.
428-
if capacity_state.upgrade().is_some() {
425+
// The capacity value is constant; this is only a liveness
426+
// guard so a dropped processor stops emitting this
427+
// otherwise-unregisterable callback. `strong_count()` is
428+
// sufficient since the callback never reads the state.
429+
if capacity_state.strong_count() > 0 {
429430
observer.observe(capacity_value, &capacity_attrs);
430431
}
431432
})

0 commit comments

Comments
 (0)