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 new nightly clippy lints #400

Merged
merged 3 commits into from Dec 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions opentelemetry-jaeger/src/exporter/collector.rs
Expand Up @@ -33,14 +33,14 @@ mod collector_client {

impl CollectorAsyncClientHttp {
/// Create a new HTTP collector client
pub(crate) fn new(endpoint: Uri, client: Box<dyn HttpClient>) -> thrift::Result<Self> {
pub(crate) fn new(endpoint: Uri, client: Box<dyn HttpClient>) -> Self {
let payload_size_estimate = AtomicUsize::new(512);

Ok(CollectorAsyncClientHttp {
CollectorAsyncClientHttp {
endpoint,
client,
payload_size_estimate,
})
}
}

/// Submit list of Jaeger batches
Expand Down
14 changes: 6 additions & 8 deletions opentelemetry-jaeger/src/exporter/mod.rs
Expand Up @@ -390,8 +390,7 @@ impl PipelineBuilder {
Box::new(client)
});

let collector = CollectorAsyncClientHttp::new(collector_endpoint, client)
.map_err::<Error, _>(Into::into)?;
let collector = CollectorAsyncClientHttp::new(collector_endpoint, client);
Ok((self.process, uploader::BatchUploader::Collector(collector)))
} else {
let endpoint = self.agent_endpoint.as_slice();
Expand Down Expand Up @@ -568,7 +567,7 @@ fn convert_otel_span_into_jaeger_span(
.duration_since(span.start_time)
.unwrap_or_else(|_| Duration::from_secs(0))
.as_micros() as i64,
tags: build_span_tags(
tags: Some(build_span_tags(
span.attributes,
if export_instrument_lib {
Some(span.instrumentation_lib)
Expand All @@ -578,7 +577,7 @@ fn convert_otel_span_into_jaeger_span(
span.status_code,
span.status_message,
span.span_kind,
),
)),
logs: events_to_logs(span.message_events),
}
}
Expand All @@ -604,7 +603,7 @@ fn build_span_tags(
status_code: StatusCode,
status_message: String,
kind: SpanKind,
) -> Option<Vec<jaeger::Tag>> {
) -> Vec<jaeger::Tag> {
let mut user_overrides = UserOverrides::default();
// TODO determine if namespacing is required to avoid collisions with set attributes
let mut tags = attrs
Expand Down Expand Up @@ -658,7 +657,7 @@ fn build_span_tags(
}
}

Some(tags)
tags
}

const ERROR: &str = "error";
Expand Down Expand Up @@ -838,8 +837,7 @@ mod tests {
status_code,
error_msg,
SpanKind::Client,
)
.unwrap_or_default();
);
if let Some(val) = status_tag_val {
assert_tag_contains(tags.clone(), OTEL_STATUS_CODE, val);
} else {
Expand Down
88 changes: 56 additions & 32 deletions opentelemetry/src/api/metrics/number.rs
Expand Up @@ -92,24 +92,36 @@ impl AtomicNumber {
/// `inf` for `f64`.
pub fn fetch_add(&self, number_kind: &NumberKind, val: &Number) {
match number_kind {
NumberKind::I64 => loop {
let current = self.0.load(Ordering::Acquire);
let new = (current as i64).wrapping_add(val.0 as i64) as u64;
let swapped = self.0.compare_and_swap(current, new, Ordering::Release);
if swapped == current {
return;
NumberKind::I64 => {
let mut old = self.0.load(Ordering::Acquire);
loop {
let new = (old as i64).wrapping_add(val.0 as i64) as u64;
match self.0.compare_exchange_weak(
old,
new,
Ordering::AcqRel,
Ordering::Acquire,
) {
Ok(_) => break,
Err(x) => old = x,
};
}
},
NumberKind::F64 => loop {
let current = self.0.load(Ordering::Acquire);
let new = u64_to_f64(current) + u64_to_f64(val.0);
let swapped = self
.0
.compare_and_swap(current, f64_to_u64(new), Ordering::Release);
if swapped == current {
return;
}
NumberKind::F64 => {
let mut old = self.0.load(Ordering::Acquire);
loop {
let new = u64_to_f64(old) + u64_to_f64(val.0);
match self.0.compare_exchange_weak(
old,
f64_to_u64(new),
Ordering::AcqRel,
Ordering::Acquire,
) {
Ok(_) => break,
Err(x) => old = x,
};
}
},
}
NumberKind::U64 => {
self.0.fetch_add(val.0, Ordering::AcqRel);
}
Expand All @@ -122,24 +134,36 @@ impl AtomicNumber {
/// `-inf` for `f64`.
pub fn fetch_sub(&self, number_kind: &NumberKind, val: &Number) {
match number_kind {
NumberKind::I64 => loop {
let current = self.0.load(Ordering::Acquire);
let new = (current as i64).wrapping_sub(val.0 as i64) as u64;
let swapped = self.0.compare_and_swap(current, new, Ordering::Release);
if swapped == current {
return;
NumberKind::I64 => {
let mut old = self.0.load(Ordering::Acquire);
loop {
let new = (old as i64).wrapping_sub(val.0 as i64) as u64;
match self.0.compare_exchange_weak(
old,
new,
Ordering::AcqRel,
Ordering::Relaxed,
) {
Ok(_) => break,
Err(x) => old = x,
};
}
},
NumberKind::F64 => loop {
let current = self.0.load(Ordering::Acquire);
let new = u64_to_f64(current) - u64_to_f64(val.0);
let swapped = self
.0
.compare_and_swap(current, f64_to_u64(new), Ordering::Release);
if swapped == current {
return;
}
NumberKind::F64 => {
let mut old = self.0.load(Ordering::Acquire);
loop {
let new = u64_to_f64(old) - u64_to_f64(val.0);
match self.0.compare_exchange_weak(
old,
f64_to_u64(new),
Ordering::AcqRel,
Ordering::Acquire,
) {
Ok(_) => break,
Err(x) => old = x,
};
}
},
}
NumberKind::U64 => {
self.0.fetch_sub(val.0, Ordering::AcqRel);
}
Expand Down