From f203b0327f1833536a03e63a206724ae46c517d4 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Mon, 15 Apr 2024 09:59:00 -0700 Subject: [PATCH] Replace unmaintained actions-rs/toolchain action. (#1655) Co-authored-by: Zhongyang Wu --- .github/workflows/ci.yml | 30 +++++---------- .github/workflows/integration_tests.yml | 4 +- opentelemetry-http/src/lib.rs | 1 - .../src/propagator.rs | 7 +--- .../src/exporter/config/agent.rs | 5 +-- .../src/exporter/config/collector/mod.rs | 1 - opentelemetry-otlp/src/logs.rs | 2 +- opentelemetry-sdk/src/logs/log_emitter.rs | 2 +- opentelemetry-sdk/src/metrics/view.rs | 1 - opentelemetry-sdk/src/propagation/baggage.rs | 4 +- .../src/propagation/trace_context.rs | 5 --- opentelemetry-sdk/src/resource/mod.rs | 2 - opentelemetry-sdk/src/trace/sampler.rs | 4 +- opentelemetry-sdk/src/trace/span.rs | 4 +- opentelemetry-zipkin/src/propagator/mod.rs | 6 +-- opentelemetry/src/baggage.rs | 1 - .../src/metrics/instruments/counter.rs | 2 +- .../src/metrics/instruments/gauge.rs | 2 +- .../src/metrics/instruments/histogram.rs | 1 - opentelemetry/src/metrics/instruments/mod.rs | 1 - .../metrics/instruments/up_down_counter.rs | 2 +- opentelemetry/src/propagation/mod.rs | 1 - opentelemetry/src/trace/noop.rs | 2 +- stress/src/logs.rs | 37 +------------------ 24 files changed, 24 insertions(+), 103 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a7c891c42..5e4d59a5c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,11 +24,12 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} components: rustfmt - profile: minimal + - name: "Set rustup profile" + run: rustup set profile minimal - uses: arduino/setup-protoc@v3 - name: Test run: ./scripts/test.sh @@ -38,11 +39,9 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@stable with: - toolchain: stable components: rustfmt - profile: minimal - uses: arduino/setup-protoc@v3 - uses: actions-rs/cargo@v1 with: @@ -57,11 +56,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@nightly with: - toolchain: nightly-2024-02-07 components: rustfmt - override: true - name: external-type-check run: | cargo install cargo-check-external-types @@ -76,11 +73,9 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@stable with: - toolchain: stable components: rustfmt - profile: minimal - uses: arduino/setup-protoc@v3 - name: Build run: | @@ -92,11 +87,7 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: 1.65.0 - override: true + - uses: dtolnay/rust-toolchain@1.65.0 - name: Patch dependencies versions # some dependencies bump MSRV without major version bump run: ./scripts/patch_dependencies.sh - name: Run tests @@ -117,11 +108,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@nightly with: - toolchain: nightly components: rustfmt - override: true - uses: arduino/setup-protoc@v3 - name: doc run: cargo doc --no-deps --all-features @@ -136,11 +125,10 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@stable with: toolchain: stable components: rustfmt,llvm-tools-preview - override: true - uses: arduino/setup-protoc@v3 - name: cargo install cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index e68c278103..2f21b5f3db 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -20,11 +20,9 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@stable with: - toolchain: stable components: rustfmt - profile: minimal - uses: arduino/setup-protoc@v3 - name: Run integration tests using docker compose run: ./scripts/integration_tests.sh diff --git a/opentelemetry-http/src/lib.rs b/opentelemetry-http/src/lib.rs index a4564e8810..2e68cead25 100644 --- a/opentelemetry-http/src/lib.rs +++ b/opentelemetry-http/src/lib.rs @@ -67,7 +67,6 @@ pub trait HttpClient: Debug + Send + Sync { #[cfg(feature = "reqwest")] mod reqwest { use super::{async_trait, Bytes, HttpClient, HttpError, Request, Response}; - use std::convert::TryInto; #[async_trait] impl HttpClient for reqwest::Client { diff --git a/opentelemetry-jaeger-propagator/src/propagator.rs b/opentelemetry-jaeger-propagator/src/propagator.rs index 4ddc5644da..f773e40f63 100644 --- a/opentelemetry-jaeger-propagator/src/propagator.rs +++ b/opentelemetry-jaeger-propagator/src/propagator.rs @@ -214,12 +214,7 @@ impl TextMapPropagator for Propagator { #[cfg(test)] mod tests { use super::*; - use opentelemetry::{ - propagation::{Injector, TextMapPropagator}, - testing::trace::TestSpan, - trace::{SpanContext, SpanId, TraceContextExt, TraceFlags, TraceId, TraceState}, - Context, - }; + use opentelemetry::testing::trace::TestSpan; use std::collections::HashMap; const LONG_TRACE_ID_STR: &str = "000000000000004d0000000000000016"; diff --git a/opentelemetry-jaeger/src/exporter/config/agent.rs b/opentelemetry-jaeger/src/exporter/config/agent.rs index cd37521cb2..1c523307f3 100644 --- a/opentelemetry-jaeger/src/exporter/config/agent.rs +++ b/opentelemetry-jaeger/src/exporter/config/agent.rs @@ -4,11 +4,8 @@ use std::sync::Arc; use std::{env, net}; use opentelemetry::trace::TraceError; +use opentelemetry_sdk::trace::{BatchConfig, Config, TracerProvider}; use opentelemetry_sdk::trace::{BatchSpanProcessor, Tracer}; -use opentelemetry_sdk::{ - self, - trace::{BatchConfig, Config, TracerProvider}, -}; use crate::exporter::agent::{AgentAsyncClientUdp, AgentSyncClientUdp}; use crate::exporter::config::{ diff --git a/opentelemetry-jaeger/src/exporter/config/collector/mod.rs b/opentelemetry-jaeger/src/exporter/config/collector/mod.rs index 7d47e4ade1..1df9e51c76 100644 --- a/opentelemetry-jaeger/src/exporter/config/collector/mod.rs +++ b/opentelemetry-jaeger/src/exporter/config/collector/mod.rs @@ -1,5 +1,4 @@ use std::borrow::BorrowMut; -use std::convert::TryFrom; use std::env; use std::sync::Arc; #[cfg(feature = "collector_client")] diff --git a/opentelemetry-otlp/src/logs.rs b/opentelemetry-otlp/src/logs.rs index a9ec267d0c..63e3ddabd9 100644 --- a/opentelemetry-otlp/src/logs.rs +++ b/opentelemetry-otlp/src/logs.rs @@ -16,7 +16,7 @@ use opentelemetry::{ global, logs::{LogError, LoggerProvider}, }; -use opentelemetry_sdk::{self, export::logs::LogData, runtime::RuntimeChannel}; +use opentelemetry_sdk::{export::logs::LogData, runtime::RuntimeChannel}; /// Compression algorithm to use, defaults to none. pub const OTEL_EXPORTER_OTLP_LOGS_COMPRESSION: &str = "OTEL_EXPORTER_OTLP_LOGS_COMPRESSION"; diff --git a/opentelemetry-sdk/src/logs/log_emitter.rs b/opentelemetry-sdk/src/logs/log_emitter.rs index e4c807c824..e5efc4eefb 100644 --- a/opentelemetry-sdk/src/logs/log_emitter.rs +++ b/opentelemetry-sdk/src/logs/log_emitter.rs @@ -248,7 +248,7 @@ mod tests { use opentelemetry::global::{logger, set_logger_provider, shutdown_logger_provider}; use opentelemetry::logs::Logger; use opentelemetry::{Key, KeyValue, Value}; - use std::sync::{Arc, Mutex}; + use std::sync::Mutex; use std::thread; #[test] diff --git a/opentelemetry-sdk/src/metrics/view.rs b/opentelemetry-sdk/src/metrics/view.rs index 58c583aba9..139ec05018 100644 --- a/opentelemetry-sdk/src/metrics/view.rs +++ b/opentelemetry-sdk/src/metrics/view.rs @@ -177,7 +177,6 @@ pub fn new_view(criteria: Instrument, mask: Stream) -> Result> { #[cfg(test)] mod tests { use super::*; - use crate::metrics::Instrument; #[test] fn test_new_view_matching_all() { let criteria = Instrument::new().name("*"); diff --git a/opentelemetry-sdk/src/propagation/baggage.rs b/opentelemetry-sdk/src/propagation/baggage.rs index 100c189e47..9c0d77d0ee 100644 --- a/opentelemetry-sdk/src/propagation/baggage.rs +++ b/opentelemetry-sdk/src/propagation/baggage.rs @@ -155,9 +155,7 @@ impl TextMapPropagator for BaggagePropagator { #[cfg(test)] mod tests { use super::*; - use opentelemetry::{ - baggage::BaggageMetadata, propagation::TextMapPropagator, Key, KeyValue, StringValue, Value, - }; + use opentelemetry::{baggage::BaggageMetadata, Key, KeyValue, StringValue, Value}; use std::collections::HashMap; #[rustfmt::skip] diff --git a/opentelemetry-sdk/src/propagation/trace_context.rs b/opentelemetry-sdk/src/propagation/trace_context.rs index 8ff71c67f2..ced269c2d2 100644 --- a/opentelemetry-sdk/src/propagation/trace_context.rs +++ b/opentelemetry-sdk/src/propagation/trace_context.rs @@ -154,12 +154,7 @@ impl TextMapPropagator for TraceContextPropagator { mod tests { use super::*; use crate::testing::trace::TestSpan; - use opentelemetry::{ - propagation::{Extractor, Injector, TextMapPropagator}, - trace::{SpanContext, SpanId, TraceId}, - }; use std::collections::HashMap; - use std::str::FromStr; #[rustfmt::skip] fn extract_data() -> Vec<(&'static str, &'static str, SpanContext)> { diff --git a/opentelemetry-sdk/src/resource/mod.rs b/opentelemetry-sdk/src/resource/mod.rs index 83a137e039..657b7c98fa 100644 --- a/opentelemetry-sdk/src/resource/mod.rs +++ b/opentelemetry-sdk/src/resource/mod.rs @@ -259,8 +259,6 @@ pub trait ResourceDetector { #[cfg(test)] mod tests { use super::*; - use crate::resource::EnvResourceDetector; - use std::collections::HashMap; use std::time; #[test] diff --git a/opentelemetry-sdk/src/trace/sampler.rs b/opentelemetry-sdk/src/trace/sampler.rs index 02ba4f3f8c..572a17b554 100644 --- a/opentelemetry-sdk/src/trace/sampler.rs +++ b/opentelemetry-sdk/src/trace/sampler.rs @@ -4,7 +4,6 @@ use opentelemetry::{ }, Context, KeyValue, }; -use std::convert::TryInto; #[cfg(feature = "jaeger_remote_sampler")] mod jaeger_remote; @@ -250,8 +249,7 @@ pub(crate) fn sample_based_on_probability(prob: &f64, trace_id: TraceId) -> Samp mod tests { use super::*; use crate::testing::trace::TestSpan; - use crate::trace::{Sampler, ShouldSample}; - use opentelemetry::trace::{SamplingDecision, SpanContext, SpanId, TraceFlags, TraceState}; + use opentelemetry::trace::{SpanContext, SpanId, TraceFlags}; use rand::Rng; #[rustfmt::skip] diff --git a/opentelemetry-sdk/src/trace/span.rs b/opentelemetry-sdk/src/trace/span.rs index 2872363aa5..5f6fcba49c 100644 --- a/opentelemetry-sdk/src/trace/span.rs +++ b/opentelemetry-sdk/src/trace/span.rs @@ -283,8 +283,8 @@ mod tests { DEFAULT_MAX_ATTRIBUTES_PER_SPAN, DEFAULT_MAX_EVENT_PER_SPAN, DEFAULT_MAX_LINKS_PER_SPAN, }; use crate::trace::{SpanEvents, SpanLinks}; - use opentelemetry::trace::{self, Link, SpanBuilder, TraceFlags, TraceId, Tracer}; - use opentelemetry::{trace::Span as _, trace::TracerProvider, KeyValue}; + use opentelemetry::trace::{self, SpanBuilder, TraceFlags, TraceId, Tracer}; + use opentelemetry::{trace::Span as _, trace::TracerProvider}; use std::time::Duration; use std::vec; diff --git a/opentelemetry-zipkin/src/propagator/mod.rs b/opentelemetry-zipkin/src/propagator/mod.rs index 2ac8ed0935..b0c834ea43 100644 --- a/opentelemetry-zipkin/src/propagator/mod.rs +++ b/opentelemetry-zipkin/src/propagator/mod.rs @@ -306,11 +306,7 @@ impl TextMapPropagator for Propagator { #[cfg(test)] mod tests { use super::*; - use opentelemetry::{ - propagation::TextMapPropagator, - testing::trace::TestSpan, - trace::{SpanContext, SpanId, TraceFlags, TraceId}, - }; + use opentelemetry::testing::trace::TestSpan; use std::collections::HashMap; const TRACE_ID_STR: &str = "4bf92f3577b34da6a3ce929d0e0e4736"; diff --git a/opentelemetry/src/baggage.rs b/opentelemetry/src/baggage.rs index 62a8cb66b8..4caa4647a1 100644 --- a/opentelemetry/src/baggage.rs +++ b/opentelemetry/src/baggage.rs @@ -18,7 +18,6 @@ use crate::{Context, Key, KeyValue, Value}; use once_cell::sync::Lazy; use std::collections::{hash_map, HashMap}; use std::fmt; -use std::iter::FromIterator; static DEFAULT_BAGGAGE: Lazy = Lazy::new(Baggage::default); diff --git a/opentelemetry/src/metrics/instruments/counter.rs b/opentelemetry/src/metrics/instruments/counter.rs index 171b6a49ea..c10ac70405 100644 --- a/opentelemetry/src/metrics/instruments/counter.rs +++ b/opentelemetry/src/metrics/instruments/counter.rs @@ -3,8 +3,8 @@ use crate::{ KeyValue, }; use core::fmt; +use std::any::Any; use std::sync::Arc; -use std::{any::Any, convert::TryFrom}; /// An SDK implemented instrument that records increasing values. pub trait SyncCounter { diff --git a/opentelemetry/src/metrics/instruments/gauge.rs b/opentelemetry/src/metrics/instruments/gauge.rs index ab9fb2e05d..3e82ca680c 100644 --- a/opentelemetry/src/metrics/instruments/gauge.rs +++ b/opentelemetry/src/metrics/instruments/gauge.rs @@ -3,8 +3,8 @@ use crate::{ KeyValue, }; use core::fmt; +use std::any::Any; use std::sync::Arc; -use std::{any::Any, convert::TryFrom}; /// An SDK implemented instrument that records independent values pub trait SyncGauge { diff --git a/opentelemetry/src/metrics/instruments/histogram.rs b/opentelemetry/src/metrics/instruments/histogram.rs index c6246ebee2..e595ccd128 100644 --- a/opentelemetry/src/metrics/instruments/histogram.rs +++ b/opentelemetry/src/metrics/instruments/histogram.rs @@ -3,7 +3,6 @@ use crate::{ KeyValue, }; use core::fmt; -use std::convert::TryFrom; use std::sync::Arc; /// An SDK implemented instrument that records a distribution of values. diff --git a/opentelemetry/src/metrics/instruments/mod.rs b/opentelemetry/src/metrics/instruments/mod.rs index 137712d735..ad6b34e88c 100644 --- a/opentelemetry/src/metrics/instruments/mod.rs +++ b/opentelemetry/src/metrics/instruments/mod.rs @@ -3,7 +3,6 @@ use crate::KeyValue; use core::fmt; use std::any::Any; use std::borrow::Cow; -use std::convert::TryFrom; use std::marker; use std::sync::Arc; diff --git a/opentelemetry/src/metrics/instruments/up_down_counter.rs b/opentelemetry/src/metrics/instruments/up_down_counter.rs index 1134ecedad..5c92025661 100644 --- a/opentelemetry/src/metrics/instruments/up_down_counter.rs +++ b/opentelemetry/src/metrics/instruments/up_down_counter.rs @@ -3,8 +3,8 @@ use crate::{ KeyValue, }; use core::fmt; +use std::any::Any; use std::sync::Arc; -use std::{any::Any, convert::TryFrom}; use super::{AsyncInstrument, AsyncInstrumentBuilder}; diff --git a/opentelemetry/src/propagation/mod.rs b/opentelemetry/src/propagation/mod.rs index 535d589d00..35005f881a 100644 --- a/opentelemetry/src/propagation/mod.rs +++ b/opentelemetry/src/propagation/mod.rs @@ -96,7 +96,6 @@ impl PropagationError { #[cfg(test)] mod tests { use super::*; - use std::collections::HashMap; #[test] fn hash_map_get() { diff --git a/opentelemetry/src/trace/noop.rs b/opentelemetry/src/trace/noop.rs index 74bc81d9a2..d46a657a2e 100644 --- a/opentelemetry/src/trace/noop.rs +++ b/opentelemetry/src/trace/noop.rs @@ -164,7 +164,7 @@ impl TextMapPropagator for NoopTextMapPropagator { mod tests { use super::*; use crate::testing::trace::TestSpan; - use crate::trace::{self, Span, TraceState, Tracer}; + use crate::trace::{Span, TraceState, Tracer}; fn valid_span_context() -> trace::SpanContext { trace::SpanContext::new( diff --git a/stress/src/logs.rs b/stress/src/logs.rs index 27ddb40965..aaa3a1d7ae 100644 --- a/stress/src/logs.rs +++ b/stress/src/logs.rs @@ -1,39 +1,10 @@ use opentelemetry_appender_tracing::layer; use opentelemetry_sdk::logs::{LogProcessor, LoggerProvider}; use tracing::error; -use tracing_subscriber::{prelude::*, Layer}; +use tracing_subscriber::prelude::*; mod throughput; -struct NoopEventVisitor; - -impl tracing::field::Visit for NoopEventVisitor { - fn record_debug(&mut self, _field: &tracing::field::Field, _value: &dyn std::fmt::Debug) {} -} - -struct NoOpLogLayer; -impl Layer for NoOpLogLayer -where - S: tracing::Subscriber, -{ - fn on_event( - &self, - event: &tracing::Event<'_>, - _ctx: tracing_subscriber::layer::Context<'_, S>, - ) { - let mut visitor = NoopEventVisitor; - event.record(&mut visitor); - } - - fn event_enabled( - &self, - _event: &tracing::Event<'_>, - _ctx: tracing_subscriber::layer::Context<'_, S>, - ) -> bool { - true - } -} - #[derive(Debug)] pub struct NoOpLogProcessor; @@ -67,12 +38,6 @@ fn main() { // Use the OpenTelemetryTracingBridge to test the throughput of the appender-tracing. let layer = layer::OpenTelemetryTracingBridge::new(&provider); tracing_subscriber::registry().with(layer).init(); - - // Use a "Do-Nothing" layer to test the throughput of the tracing system without - // OpenTelemetry overhead. This helps measure the OpenTelemetry overhead. - // let noop_layer = NoOpLogLayer; - // tracing_subscriber::registry().with(noop_layer).init(); - throughput::test_throughput(test_log); }