Skip to content

Commit a7893df

Browse files
feat(sdk): add 32-bit platform support using portable-atomic
Replace std::sync::atomic::{AtomicI64, AtomicU64} with portable-atomic equivalents in the metrics module. This enables compilation on 32-bit ARM platforms (armv5te, armv7) which lack native 64-bit atomics. The portable-atomic crate uses native atomics on 64-bit platforms (zero overhead) and provides a software fallback on 32-bit platforms.
1 parent 8cfa981 commit a7893df

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

opentelemetry-sdk/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ url = { workspace = true, optional = true }
2525
tokio = { workspace = true, default-features = false, optional = true }
2626
tokio-stream = { workspace = true, optional = true }
2727
http = { workspace = true, optional = true }
28+
portable-atomic = { version = "1", default-features = false, features = ["fallback"] }
2829

2930
[package.metadata.docs.rs]
3031
all-features = true

opentelemetry-sdk/src/metrics/internal/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ use std::cmp::min;
1010
use std::collections::{HashMap, HashSet};
1111
use std::mem::swap;
1212
use std::ops::{Add, AddAssign, DerefMut, Sub};
13-
use std::sync::atomic::{AtomicBool, AtomicI64, AtomicU64, AtomicUsize, Ordering};
13+
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
14+
use portable_atomic::{AtomicI64, AtomicU64};
1415
use std::sync::{Arc, OnceLock, RwLock};
1516

1617
pub(crate) use aggregate::{AggregateBuilder, AggregateFns, ComputeAggregation, Measure};

0 commit comments

Comments
 (0)