diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b9a7b9d29..10cd130829 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 && diff --git a/examples/grpc/src/client.rs b/examples/grpc/src/client.rs index df2e65ab14..b19632a435 100644 --- a/examples/grpc/src/client.rs +++ b/examples/grpc/src/client.rs @@ -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"); } diff --git a/examples/grpc/src/server.rs b/examples/grpc/src/server.rs index b4f02b5e2e..7afa02bd6d 100644 --- a/examples/grpc/src/server.rs +++ b/examples/grpc/src/server.rs @@ -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. } diff --git a/examples/tracing-grpc/src/client.rs b/examples/tracing-grpc/src/client.rs index 5c522be91c..8321eab3c9 100644 --- a/examples/tracing-grpc/src/client.rs +++ b/examples/tracing-grpc/src/client.rs @@ -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"); } diff --git a/examples/tracing-grpc/src/server.rs b/examples/tracing-grpc/src/server.rs index e75a1332ae..7276d67106 100644 --- a/examples/tracing-grpc/src/server.rs +++ b/examples/tracing-grpc/src/server.rs @@ -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 } diff --git a/opentelemetry-api/src/baggage.rs b/opentelemetry-api/src/baggage.rs index 21ff618b6e..65f32615d7 100644 --- a/opentelemetry-api/src/baggage.rs +++ b/opentelemetry-api/src/baggage.rs @@ -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 { diff --git a/opentelemetry-api/src/common.rs b/opentelemetry-api/src/common.rs index 44eae5cf1a..e8a9df0060 100644 --- a/opentelemetry-api/src/common.rs +++ b/opentelemetry-api/src/common.rs @@ -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 { diff --git a/opentelemetry-api/src/context.rs b/opentelemetry-api/src/context.rs index bcd4ffcd4f..b1e145e4cb 100644 --- a/opentelemetry-api/src/context.rs +++ b/opentelemetry-api/src/context.rs @@ -169,7 +169,7 @@ impl Context { pub fn get(&self) -> Option<&T> { self.entries .get(&TypeId::of::()) - .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 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 diff --git a/opentelemetry-api/src/metrics/mod.rs b/opentelemetry-api/src/metrics/mod.rs index bb6e2ca40b..a2613224ed 100644 --- a/opentelemetry-api/src/metrics/mod.rs +++ b/opentelemetry-api/src/metrics/mod.rs @@ -73,7 +73,7 @@ impl From> 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 { diff --git a/opentelemetry-api/src/trace/context.rs b/opentelemetry-api/src/trace/context.rs index 60aad31fdd..5ead991c2e 100644 --- a/opentelemetry-api/src/trace/context.rs +++ b/opentelemetry-api/src/trace/context.rs @@ -36,7 +36,7 @@ impl SpanRef<'_> { fn with_inner_mut(&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::() { SpanRef(span) } else { - SpanRef(&*NOOP_SPAN) + SpanRef(&NOOP_SPAN) } } diff --git a/opentelemetry-api/src/trace/span.rs b/opentelemetry-api/src/trace/span.rs index 1984e1c4c7..ff2e8b5f89 100644 --- a/opentelemetry-api/src/trace/span.rs +++ b/opentelemetry-api/src/trace/span.rs @@ -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 diff --git a/opentelemetry-api/src/trace/tracer.rs b/opentelemetry-api/src/trace/tracer.rs index e36d32c5c5..dde5cbe7b3 100644 --- a/opentelemetry-api/src/trace/tracer.rs +++ b/opentelemetry-api/src/trace/tracer.rs @@ -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, diff --git a/opentelemetry-jaeger/src/exporter/config/collector/mod.rs b/opentelemetry-jaeger/src/exporter/config/collector/mod.rs index 7460414d4c..9455763a64 100644 --- a/opentelemetry-jaeger/src/exporter/config/collector/mod.rs +++ b/opentelemetry-jaeger/src/exporter/config/collector/mod.rs @@ -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 { - (&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 { - (&self.collector_password).clone() + pub fn collector_password(&self) -> Option { + self.collector_password.clone() } /// Custom http client used to send spans. diff --git a/opentelemetry-jaeger/src/testing/mod.rs b/opentelemetry-jaeger/src/testing/mod.rs index 04231664a2..36d2c3a222 100644 --- a/opentelemetry-jaeger/src/testing/mod.rs +++ b/opentelemetry-jaeger/src/testing/mod.rs @@ -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. diff --git a/opentelemetry-otlp/src/metric.rs b/opentelemetry-otlp/src/metric.rs index 582223dd5d..3300421451 100644 --- a/opentelemetry-otlp/src/metric.rs +++ b/opentelemetry-otlp/src/metric.rs @@ -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. diff --git a/opentelemetry-proto/src/transform/metrics.rs b/opentelemetry-proto/src/transform/metrics.rs index d95574dbfe..b31e08e80c 100644 --- a/opentelemetry-proto/src/transform/metrics.rs +++ b/opentelemetry-proto/src/transform/metrics.rs @@ -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; } diff --git a/opentelemetry-sdk/src/export/metrics/aggregation/mod.rs b/opentelemetry-sdk/src/export/metrics/aggregation/mod.rs index d854b367bf..700c16d9c9 100644 --- a/opentelemetry-sdk/src/export/metrics/aggregation/mod.rs +++ b/opentelemetry-sdk/src/export/metrics/aggregation/mod.rs @@ -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 { diff --git a/opentelemetry-sdk/src/export/metrics/aggregation/temporality.rs b/opentelemetry-sdk/src/export/metrics/aggregation/temporality.rs index f3c570fdcc..afcc058fda 100644 --- a/opentelemetry-sdk/src/export/metrics/aggregation/temporality.rs +++ b/opentelemetry-sdk/src/export/metrics/aggregation/temporality.rs @@ -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. diff --git a/opentelemetry-sdk/src/metrics/sdk_api/descriptor.rs b/opentelemetry-sdk/src/metrics/sdk_api/descriptor.rs index dc324ce11e..59f83401b3 100644 --- a/opentelemetry-sdk/src/metrics/sdk_api/descriptor.rs +++ b/opentelemetry-sdk/src/metrics/sdk_api/descriptor.rs @@ -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, diff --git a/opentelemetry-sdk/src/metrics/sdk_api/instrument_kind.rs b/opentelemetry-sdk/src/metrics/sdk_api/instrument_kind.rs index 28cc372d32..3163dd1e74 100644 --- a/opentelemetry-sdk/src/metrics/sdk_api/instrument_kind.rs +++ b/opentelemetry-sdk/src/metrics/sdk_api/instrument_kind.rs @@ -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, diff --git a/opentelemetry-sdk/src/metrics/sdk_api/number.rs b/opentelemetry-sdk/src/metrics/sdk_api/number.rs index 26e10c1ab7..547dcf82d7 100644 --- a/opentelemetry-sdk/src/metrics/sdk_api/number.rs +++ b/opentelemetry-sdk/src/metrics/sdk_api/number.rs @@ -201,7 +201,7 @@ impl From 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, diff --git a/opentelemetry-sdk/src/trace/evicted_queue.rs b/opentelemetry-sdk/src/trace/evicted_queue.rs index 56ec3c5bc0..c54d880057 100644 --- a/opentelemetry-sdk/src/trace/evicted_queue.rs +++ b/opentelemetry-sdk/src/trace/evicted_queue.rs @@ -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 { queue: Option>, max_len: u32, diff --git a/opentelemetry-stackdriver/src/lib.rs b/opentelemetry-stackdriver/src/lib.rs index 5de27b8611..b7b40e8556 100644 --- a/opentelemetry-stackdriver/src/lib.rs +++ b/opentelemetry-stackdriver/src/lib.rs @@ -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;