fix(common): clippy issues raised by 1.63 (#862)

* fix(common): clippy issue raised by 1.63

* fix(common): nightly issues

* fix(jaeger): take self reference for `collector_password`

* fix(common): pin serde to 1.0142 as workaround of https://github.com/rust-lang/cargo/issues/10954

* fix(doc): fix type link in docs
This commit is contained in:
Zhongyang Wu 2022-08-13 18:47:28 -07:00 committed by GitHub
parent aec7d0b643
commit c92a1ad5af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 33 additions and 25 deletions

View File

@ -70,6 +70,8 @@ jobs:
profile: minimal
toolchain: 1.49
override: true
- name: Prepare minimal package versions
run: cargo update -p serde --precise 1.0.142
- name: Run tests
run: cargo --version &&
cargo test --verbose --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,rt-tokio,testing &&

View File

@ -24,6 +24,7 @@ impl<'a> Injector for MetadataMap<'a> {
}
}
#[allow(clippy::derive_partial_eq_without_eq)] // tonic don't derive Eq for generated types. We shouldn't manually change it.
pub mod hello_world {
tonic::include_proto!("helloworld");
}

View File

@ -12,6 +12,7 @@ use opentelemetry::{
};
use std::error::Error;
#[allow(clippy::derive_partial_eq_without_eq)] // tonic don't derive Eq for generated types. We shouldn't manually change it.
pub mod hello_world {
tonic::include_proto!("helloworld"); // The string specified here must match the proto package name.
}

View File

@ -20,6 +20,7 @@ impl<'a> Injector for MetadataMap<'a> {
}
}
#[allow(clippy::derive_partial_eq_without_eq)] // tonic don't derive Eq for generated types. We shouldn't manually change it.
pub mod hello_world {
tonic::include_proto!("helloworld");
}

View File

@ -7,6 +7,7 @@ use tracing::*;
use tracing_opentelemetry::OpenTelemetrySpanExt;
use tracing_subscriber::prelude::*;
#[allow(clippy::derive_partial_eq_without_eq)] // tonic don't derive Eq for generated types. We shouldn't manually change it.
pub mod hello_world {
tonic::include_proto!("helloworld"); // The string specified here must match the proto package name
}

View File

@ -375,7 +375,7 @@ impl BaggageExt for Context {
/// `BaggageMetadata` can be added to values in the form of a property set,
/// represented as semi-colon `;` delimited list of names and/or name/value
/// pairs, e.g. `;k1=v1;k2;k3=v3`.
#[derive(Clone, Debug, PartialOrd, PartialEq, Default)]
#[derive(Clone, Debug, PartialOrd, PartialEq, Eq, Default)]
pub struct BaggageMetadata(String);
impl BaggageMetadata {

View File

@ -245,7 +245,7 @@ pub enum Value {
}
/// Wrapper for string-like values
#[derive(Clone, PartialEq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct StringValue(OtelString);
impl fmt::Debug for StringValue {

View File

@ -169,7 +169,7 @@ impl Context {
pub fn get<T: 'static>(&self) -> Option<&T> {
self.entries
.get(&TypeId::of::<T>())
.and_then(|rc| (&*rc).downcast_ref())
.and_then(|rc| rc.downcast_ref())
}
/// Returns a copy of the context with the new value included.
@ -324,8 +324,8 @@ impl Drop for ContextGuard {
/// while the context is still borrowed.
fn get_current<F: FnMut(&Context) -> T, T>(mut f: F) -> T {
CURRENT_CONTEXT
.try_with(|cx| f(&*cx.borrow()))
.unwrap_or_else(|_| DEFAULT_CONTEXT.with(|cx| f(&*cx)))
.try_with(|cx| f(&cx.borrow()))
.unwrap_or_else(|_| DEFAULT_CONTEXT.with(|cx| f(cx)))
}
/// With TypeIds as keys, there's no need to hash them. They are already hashes

View File

@ -73,7 +73,7 @@ impl<T> From<PoisonError<T>> for MetricsError {
}
/// Units denote underlying data units tracked by `Meter`s.
#[derive(Clone, Default, Debug, PartialEq, Hash)]
#[derive(Clone, Default, Debug, PartialEq, Eq, Hash)]
pub struct Unit(Cow<'static, str>);
impl Unit {

View File

@ -36,7 +36,7 @@ impl SpanRef<'_> {
fn with_inner_mut<F: FnOnce(&mut global::BoxedSpan)>(&self, f: F) {
if let Some(ref inner) = self.0.inner {
match inner.lock() {
Ok(mut locked) => f(&mut *locked),
Ok(mut locked) => f(&mut locked),
Err(err) => global::handle_error(err),
}
}
@ -269,7 +269,7 @@ impl TraceContextExt for Context {
if let Some(span) = self.get::<SynchronizedSpan>() {
SpanRef(span)
} else {
SpanRef(&*NOOP_SPAN)
SpanRef(&NOOP_SPAN)
}
}

View File

@ -204,7 +204,7 @@ pub trait Span {
/// | `Producer` | | yes | | maybe |
/// | `Consumer` | | yes | maybe | |
/// | `Internal` | | | | |
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum SpanKind {
/// Indicates that the span describes a request to some remote service. This
/// span is usually the parent of a remote `SpanKind::Server` span and does

View File

@ -406,7 +406,7 @@ pub struct SamplingResult {
}
/// Decision about whether or not to sample
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum SamplingDecision {
/// Span will not be recorded and all events and attributes will be dropped.
Drop,

View File

@ -261,7 +261,7 @@ impl CollectorPipeline {
/// If users uses custom http client. This function can help retrieve the value of
/// `OTEL_EXPORTER_JAEGER_USER` environment variable.
pub fn collector_username(&self) -> Option<String> {
(&self.collector_username).clone()
self.collector_username.clone()
}
/// Get the collector's password set in the builder. Default to be the value of
@ -269,8 +269,8 @@ impl CollectorPipeline {
///
/// If users uses custom http client. This function can help retrieve the value of
/// `OTEL_EXPORTER_JAEGER_PASSWORD` environment variable.
pub fn collector_password(self) -> Option<String> {
(&self.collector_password).clone()
pub fn collector_password(&self) -> Option<String> {
self.collector_password.clone()
}
/// Custom http client used to send spans.

View File

@ -1,4 +1,5 @@
#[allow(unused, missing_docs)]
#[allow(unused, missing_docs, clippy::derive_partial_eq_without_eq)]
// tonic don't derive Eq. We shouldn't manually change it.)]
pub mod jaeger_api_v2;
#[allow(missing_docs)]
@ -48,7 +49,7 @@ pub mod jaeger_client {
.await
.unwrap();
return if let Some(spans) = resp
if let Some(spans) = resp
.get_mut()
.message()
.await
@ -57,7 +58,7 @@ pub mod jaeger_client {
spans.spans
} else {
vec![]
};
}
}
/// Find traces belongs the service.

View File

@ -1,6 +1,6 @@
//! OTEL metric exporter
//!
//! Defines a [Exporter] to send metric data to backend via OTEL protocol.
//! Defines a [MetricsExporter] to send metric data to backend via OTEL protocol.
//!
//! Currently, OTEL metrics exporter only support GRPC connection via tonic on tokio runtime.

View File

@ -19,8 +19,8 @@ pub mod tonic {
use opentelemetry::{Key, Value};
/// Convert [`Number`](opentelemetry::metrics::Number) to target type based
/// on it's [`NumberKind`](opentelemetry::metrics::NumberKind).
/// Convert [`Number`](opentelemetry::sdk::metrics::sdk_api::Number) to target type based
/// on it's [`NumberKind`](opentelemetry::sdk::metrics::sdk_api::NumberKind).
pub trait FromNumber {
fn from_number(number: Number, number_kind: &NumberKind) -> Self;
}

View File

@ -90,7 +90,7 @@ pub trait Histogram: Sum + Count + Aggregation {
/// For example, test for a Histogram before testing for a Sum, and so on.
///
/// [`Aggregator`]: crate::metrics::aggregators::Aggregator
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AggregationKind(&'static str);
impl AggregationKind {

View File

@ -46,7 +46,7 @@ impl TemporalitySelector for StatelessTemporalitySelector {
/// Temporality indicates the temporal aggregation exported by an exporter.
/// These bits may be OR-d together when multiple exporters are in use.
#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Temporality {
/// Indicates that an Exporter expects a Cumulative Aggregation.

View File

@ -5,7 +5,7 @@ use std::hash::{Hash, Hasher};
/// Descriptor contains all the settings that describe an instrument, including
/// its name, metric kind, number kind, and the configurable options.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Descriptor {
name: String,
instrument_kind: InstrumentKind,

View File

@ -1,5 +1,5 @@
/// Kinds of OpenTelemetry metric instruments
#[derive(Clone, Debug, PartialEq, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum InstrumentKind {
/// A histogram instrument
Histogram,

View File

@ -201,7 +201,7 @@ impl From<u64> for Number {
}
/// A descriptor for the encoded data type of a `Number`
#[derive(Clone, Debug, PartialEq, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum NumberKind {
/// A Number that stores `i64` values.
I64,

View File

@ -5,7 +5,7 @@ use std::collections::VecDeque;
/// This queue maintains an ordered list of elements, and a count of
/// dropped elements. Elements are removed from the queue in a first
/// in first out fashion.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct EvictedQueue<T> {
queue: Option<VecDeque<T>>,
max_len: u32,

View File

@ -49,6 +49,7 @@ use tonic::{
#[cfg(feature = "yup-authorizer")]
use yup_oauth2::authenticator::Authenticator;
#[allow(clippy::derive_partial_eq_without_eq)] // tonic doesn't derive Eq for generated types
pub mod proto;
use proto::devtools::cloudtrace::v2::BatchWriteSpansRequest;