Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: AtomicI64, AtomicU64 for build mipsel processor #2301

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ tracing = { version = "0.1", default-features = false }
tracing-core = { version = "0.1", default-features = false }
tracing-subscriber = { version = "0.3", default-features = false }
url = { version = "2.5.2", default-features = false } #https://github.com/servo/rust-url/issues/992
portable-atomic = "1.9.0"
3 changes: 3 additions & 0 deletions opentelemetry-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ tokio-stream = { workspace = true, optional = true }
http = { workspace = true, optional = true }
tracing = {workspace = true, optional = true}

[target.'cfg(any(target_arch = "powerpc", target_arch = "mips"))'.dependencies]
portable-atomic = {workspace = true}

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
Expand Down
20 changes: 13 additions & 7 deletions opentelemetry-sdk/src/metrics/internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use core::fmt;
use std::collections::{HashMap, HashSet};
use std::mem::take;
use std::ops::{Add, AddAssign, DerefMut, Sub};
use std::sync::atomic::{AtomicBool, AtomicI64, AtomicU64, AtomicUsize, Ordering};
use std::sync::atomic::Ordering;
use std::sync::{Arc, RwLock};

use aggregate::is_under_cardinality_limit;
Expand All @@ -18,6 +18,12 @@ pub(crate) use exponential_histogram::{EXPO_MAX_SCALE, EXPO_MIN_SCALE};
use once_cell::sync::Lazy;
use opentelemetry::{otel_warn, KeyValue};

#[cfg(any(target_arch = "mips", target_arch = "powerpc"))]
use portable_atomic::{AtomicBool, AtomicI64, AtomicU64, AtomicUsize};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these the only place this SDK uses Atomics?


#[cfg(not(any(target_arch = "mips", target_arch = "powerpc")))]
use std::sync::atomic::{AtomicBool, AtomicI64, AtomicU64, AtomicUsize};

use crate::metrics::AttributeSet;

pub(crate) static STREAM_OVERFLOW_ATTRIBUTES: Lazy<Vec<KeyValue>> =
Expand Down Expand Up @@ -410,8 +416,8 @@ mod tests {
#[test]
fn can_add_and_get_u64_atomic_value() {
let atomic = u64::new_atomic_tracker(0);
atomic.add(15);
atomic.add(10);
AtomicTracker::add(&atomic, 15);
AtomicTracker::add(&atomic, 10);

let value = atomic.get_value();
assert_eq!(value, 25);
Expand All @@ -420,7 +426,7 @@ mod tests {
#[test]
fn can_reset_u64_atomic_value() {
let atomic = u64::new_atomic_tracker(0);
atomic.add(15);
AtomicTracker::add(&atomic, 15);

let value = atomic.get_and_reset_value();
let value2 = atomic.get_value();
Expand Down Expand Up @@ -449,8 +455,8 @@ mod tests {
#[test]
fn can_add_and_get_i64_atomic_value() {
let atomic = i64::new_atomic_tracker(0);
atomic.add(15);
atomic.add(-10);
AtomicTracker::add(&atomic, 15);
AtomicTracker::add(&atomic, -10);

let value = atomic.get_value();
assert_eq!(value, 5);
Expand All @@ -459,7 +465,7 @@ mod tests {
#[test]
fn can_reset_i64_atomic_value() {
let atomic = i64::new_atomic_tracker(0);
atomic.add(15);
AtomicTracker::add(&atomic, 15);

let value = atomic.get_and_reset_value();
let value2 = atomic.get_value();
Expand Down
Loading