diff --git a/.rustfmt.toml b/.rustfmt.toml index 3d8af21ab6c20..94966055e5b67 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,4 +1,4 @@ -edition = "2021" +edition = "2024" newline_style = "unix" reorder_imports = true diff --git a/Cargo.toml b/Cargo.toml index a1fd13290f6ef..ebbe292270a8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "vector" version = "0.50.0" authors = ["Vector Contributors "] -edition = "2021" +edition = "2024" description = "A lightweight and ultra-fast tool for building observability pipelines" homepage = "https://vector.dev" license = "MPL-2.0" diff --git a/aqua/aqua.yaml b/aqua/aqua.yaml index 1578594139012..37c8ae623bbe8 100644 --- a/aqua/aqua.yaml +++ b/aqua/aqua.yaml @@ -6,7 +6,7 @@ registries: ref: v4.268.0 # renovate: depName=aquaproj/aqua-registry packages: - name: rustwasm/wasm-pack@v0.13.1 - - name: crates.io/cargo-deb@3.4.1 + - name: crates.io/cargo-deb@2.9.3 - name: cross-rs/cross@v0.2.5 - name: nextest-rs/nextest/cargo-nextest@cargo-nextest-0.9.47 - name: EmbarkStudios/cargo-deny@0.16.2 diff --git a/benches/batch.rs b/benches/batch.rs index 6734c8da8ae9c..cb1aaa53d6cdd 100644 --- a/benches/batch.rs +++ b/benches/batch.rs @@ -1,13 +1,13 @@ use std::{convert::Infallible, time::Duration}; use bytes::{BufMut, Bytes, BytesMut}; -use criterion::{criterion_group, Criterion, SamplingMode, Throughput}; -use futures::{future, stream, SinkExt, StreamExt}; +use criterion::{Criterion, SamplingMode, Throughput, criterion_group}; +use futures::{SinkExt, StreamExt, future, stream}; use vector::{ sinks::util::{ - batch::{Batch, BatchConfig, BatchError, BatchSettings, BatchSize, PushResult}, BatchSink, Buffer, Compression, EncodedEvent, Merged, Partition, PartitionBatchSink, SinkBatchSettings, + batch::{Batch, BatchConfig, BatchError, BatchSettings, BatchSize, PushResult}, }, test_util::{random_lines, runtime}, }; diff --git a/benches/codecs/character_delimited_bytes.rs b/benches/codecs/character_delimited_bytes.rs index 9714937960b70..38cf2d7ae77de 100644 --- a/benches/codecs/character_delimited_bytes.rs +++ b/benches/codecs/character_delimited_bytes.rs @@ -2,13 +2,13 @@ use std::{fmt, time::Duration}; use bytes::BytesMut; use criterion::{ - criterion_group, measurement::WallTime, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, - SamplingMode, Throughput, + BatchSize, BenchmarkGroup, BenchmarkId, Criterion, SamplingMode, Throughput, criterion_group, + measurement::WallTime, }; use tokio_util::codec::Decoder; use vector_lib::codecs::{ - decoding::{Deserializer, Framer}, BytesDeserializer, CharacterDelimitedDecoder, + decoding::{Deserializer, Framer}, }; #[derive(Debug)] diff --git a/benches/codecs/encoder.rs b/benches/codecs/encoder.rs index 63091ec46ee5f..ccbf4c2b09a03 100644 --- a/benches/codecs/encoder.rs +++ b/benches/codecs/encoder.rs @@ -2,12 +2,12 @@ use std::time::Duration; use bytes::{BufMut, BytesMut}; use criterion::{ - criterion_group, measurement::WallTime, BatchSize, BenchmarkGroup, Criterion, SamplingMode, - Throughput, + BatchSize, BenchmarkGroup, Criterion, SamplingMode, Throughput, criterion_group, + measurement::WallTime, }; use tokio_util::codec::Encoder; use vector::event::{Event, LogEvent}; -use vector_lib::codecs::{encoding::Framer, JsonSerializerConfig, NewlineDelimitedEncoder}; +use vector_lib::codecs::{JsonSerializerConfig, NewlineDelimitedEncoder, encoding::Framer}; use vector_lib::{btreemap, byte_size_of::ByteSizeOf}; #[derive(Debug, Clone)] diff --git a/benches/codecs/newline_bytes.rs b/benches/codecs/newline_bytes.rs index 20e1d586b6850..2c777b62e6c80 100644 --- a/benches/codecs/newline_bytes.rs +++ b/benches/codecs/newline_bytes.rs @@ -2,12 +2,12 @@ use std::{fmt, time::Duration}; use bytes::BytesMut; use criterion::{ - criterion_group, measurement::WallTime, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, - SamplingMode, Throughput, + BatchSize, BenchmarkGroup, BenchmarkId, Criterion, SamplingMode, Throughput, criterion_group, + measurement::WallTime, }; use tokio_util::codec::Decoder; use vector_lib::codecs::{ - decoding::Deserializer, decoding::Framer, BytesDeserializer, NewlineDelimitedDecoder, + BytesDeserializer, NewlineDelimitedDecoder, decoding::Deserializer, decoding::Framer, }; #[derive(Debug)] diff --git a/benches/distribution_statistic.rs b/benches/distribution_statistic.rs index 891a9c34f9907..af62b1b39d08a 100644 --- a/benches/distribution_statistic.rs +++ b/benches/distribution_statistic.rs @@ -1,4 +1,4 @@ -use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; +use criterion::{BatchSize, Criterion, criterion_group, criterion_main}; use rand::distr::Distribution; use rand::{distr::Uniform, seq::SliceRandom}; use vector::{event::metric::Sample, sinks::util::statistic::DistributionStatistic}; diff --git a/benches/dnstap/mod.rs b/benches/dnstap/mod.rs index 2110941f337ef..2c0673590be18 100644 --- a/benches/dnstap/mod.rs +++ b/benches/dnstap/mod.rs @@ -1,7 +1,7 @@ -use base64::engine::general_purpose::STANDARD; use base64::Engine; +use base64::engine::general_purpose::STANDARD; use bytes::Bytes; -use criterion::{criterion_group, criterion_main, BatchSize, Criterion, Throughput}; +use criterion::{BatchSize, Criterion, Throughput, criterion_group, criterion_main}; use dnsmsg_parser::dns_message_parser::DnsParserOptions; use dnstap_parser::parser::DnstapParser; use vector::event::LogEvent; diff --git a/benches/enrichment_tables.rs b/benches/enrichment_tables.rs index b56f4f794627e..73cfb9e938b44 100644 --- a/benches/enrichment_tables.rs +++ b/benches/enrichment_tables.rs @@ -1,13 +1,13 @@ use std::time::SystemTime; use chrono::prelude::*; -use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; +use criterion::{BatchSize, Criterion, criterion_group, criterion_main}; use vector::enrichment_tables::file::FileData; use vector::enrichment_tables::{ + Condition, Table, file::File, geoip::{Geoip, GeoipConfig}, mmdb::{Mmdb, MmdbConfig}, - Condition, Table, }; use vector_lib::enrichment::Case; use vrl::value::{ObjectMap, Value}; @@ -241,7 +241,7 @@ fn benchmark_enrichment_tables_geoip(c: &mut Criterion) { let mut group = c.benchmark_group("enrichment_tables_geoip"); let build = |path: &str| { Geoip::new(GeoipConfig { - path: path.to_string(), + path: path.into(), locale: "en".to_string(), }) .unwrap() @@ -320,12 +320,7 @@ fn benchmark_enrichment_tables_geoip(c: &mut Criterion) { fn benchmark_enrichment_tables_mmdb(c: &mut Criterion) { let mut group = c.benchmark_group("enrichment_tables_mmdb"); - let build = |path: &str| { - Mmdb::new(MmdbConfig { - path: path.to_string(), - }) - .unwrap() - }; + let build = |path: &str| Mmdb::new(MmdbConfig { path: path.into() }).unwrap(); group.bench_function("enrichment_tables/mmdb_isp", |b| { let table = build("tests/data/GeoIP2-ISP-Test.mmdb"); diff --git a/benches/event.rs b/benches/event.rs index cb48f6101add3..21dbf7b69dc02 100644 --- a/benches/event.rs +++ b/benches/event.rs @@ -1,5 +1,5 @@ use bytes::Bytes; -use criterion::{criterion_group, BatchSize, Criterion}; +use criterion::{BatchSize, Criterion, criterion_group}; use vector::event::LogEvent; use vrl::event_path; diff --git a/benches/files.rs b/benches/files.rs index 49153a378de48..5754001d15451 100644 --- a/benches/files.rs +++ b/benches/files.rs @@ -1,8 +1,8 @@ use std::{convert::TryInto, path::PathBuf, time::Duration}; use bytes::Bytes; -use criterion::{criterion_group, BatchSize, Criterion, SamplingMode, Throughput}; -use futures::{stream, SinkExt, StreamExt}; +use criterion::{BatchSize, Criterion, SamplingMode, Throughput, criterion_group}; +use futures::{SinkExt, StreamExt, stream}; use tempfile::tempdir; use tokio::fs::OpenOptions; use tokio_util::codec::{BytesCodec, FramedWrite}; @@ -10,7 +10,7 @@ use vector::{ config, sinks, sources, test_util::{random_lines, runtime, start_topology}, }; -use vector_lib::codecs::{encoding::FramingConfig, TextSerializerConfig}; +use vector_lib::codecs::{TextSerializerConfig, encoding::FramingConfig}; fn benchmark_files_no_partitions(c: &mut Criterion) { let num_lines: usize = 10_000; diff --git a/benches/http.rs b/benches/http.rs index 84d97eb1a6be1..e8ed333af5be5 100644 --- a/benches/http.rs +++ b/benches/http.rs @@ -1,14 +1,14 @@ use std::net::SocketAddr; -use criterion::{criterion_group, BatchSize, BenchmarkId, Criterion, SamplingMode, Throughput}; +use criterion::{BatchSize, BenchmarkId, Criterion, SamplingMode, Throughput, criterion_group}; use futures::TryFutureExt; use hyper::{ - service::{make_service_fn, service_fn}, Body, Response, Server, + service::{make_service_fn, service_fn}, }; use tokio::runtime::Runtime; use vector::{ - config, + Error, config, sinks::{ self, util::{BatchConfig, Compression}, @@ -16,9 +16,8 @@ use vector::{ sources, template::Template, test_util::{next_addr, random_lines, runtime, send_lines, start_topology, wait_for_tcp}, - Error, }; -use vector_lib::codecs::{encoding::FramingConfig, TextSerializerConfig}; +use vector_lib::codecs::{TextSerializerConfig, encoding::FramingConfig}; fn benchmark_http(c: &mut Criterion) { let num_lines: usize = 1_000; diff --git a/benches/languages.rs b/benches/languages.rs index 6e0b0417055ad..ae99eb81cd45d 100644 --- a/benches/languages.rs +++ b/benches/languages.rs @@ -1,8 +1,8 @@ -use criterion::{criterion_group, criterion_main, BatchSize, Criterion, SamplingMode, Throughput}; +use criterion::{BatchSize, Criterion, SamplingMode, Throughput, criterion_group, criterion_main}; use indoc::indoc; use vector::{ config, - test_util::{next_addr, runtime, send_lines, start_topology, wait_for_tcp, CountReceiver}, + test_util::{CountReceiver, next_addr, runtime, send_lines, start_topology, wait_for_tcp}, }; criterion_group!( diff --git a/benches/loki.rs b/benches/loki.rs index 4ff2ca4a12548..e0183d10cc683 100644 --- a/benches/loki.rs +++ b/benches/loki.rs @@ -1,6 +1,6 @@ use std::convert::TryFrom; -use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; +use criterion::{BatchSize, Criterion, criterion_group, criterion_main}; use vector::{sinks::loki::valid_label_name, template::Template}; const VALID: [&str; 4] = ["name", " name ", "bee_bop", "a09b"]; diff --git a/benches/lua.rs b/benches/lua.rs index 8bf99aaf9f0d4..f584f471057f8 100644 --- a/benches/lua.rs +++ b/benches/lua.rs @@ -1,7 +1,7 @@ use std::pin::Pin; -use criterion::{criterion_group, BatchSize, Criterion, Throughput}; -use futures::{stream, SinkExt, Stream, StreamExt}; +use criterion::{BatchSize, Criterion, Throughput, criterion_group}; +use futures::{SinkExt, Stream, StreamExt, stream}; use indoc::indoc; use transforms::lua::v2::LuaConfig; use vector::{ diff --git a/benches/metrics_snapshot.rs b/benches/metrics_snapshot.rs index 637335967826c..279911e5e65a4 100644 --- a/benches/metrics_snapshot.rs +++ b/benches/metrics_snapshot.rs @@ -1,4 +1,4 @@ -use criterion::{criterion_group, BenchmarkId, Criterion}; +use criterion::{BenchmarkId, Criterion, criterion_group}; fn benchmark(c: &mut Criterion) { let mut group = c.benchmark_group("metrics_snapshot"); diff --git a/benches/remap.rs b/benches/remap.rs index 2cf0829ba2f4a..518d2cc4d45f3 100644 --- a/benches/remap.rs +++ b/benches/remap.rs @@ -1,13 +1,13 @@ use std::collections::HashMap; use chrono::{DateTime, Utc}; -use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; +use criterion::{BatchSize, Criterion, criterion_group, criterion_main}; use vector::{ config::{DataType, TransformOutput}, event::{Event, LogEvent, Value}, transforms::{ - remap::{Remap, RemapConfig}, SyncTransform, TransformOutputsBuf, + remap::{Remap, RemapConfig}, }, }; use vrl::event_path; diff --git a/benches/template.rs b/benches/template.rs index 008df426c98bc..ae34292a7e695 100644 --- a/benches/template.rs +++ b/benches/template.rs @@ -1,7 +1,7 @@ use std::convert::TryFrom; use chrono::Utc; -use criterion::{criterion_group, BatchSize, Criterion}; +use criterion::{BatchSize, Criterion, criterion_group}; use vector::{config::log_schema, event::Event, event::LogEvent}; fn bench_elasticsearch_index(c: &mut Criterion) { diff --git a/benches/transform/common.rs b/benches/transform/common.rs index 481e65e2d7541..d56c2e46ecf82 100644 --- a/benches/transform/common.rs +++ b/benches/transform/common.rs @@ -6,7 +6,7 @@ use std::{ task::{Context, Poll}, }; -use futures::{task::noop_waker, Stream}; +use futures::{Stream, task::noop_waker}; use vector::event::{Event, LogEvent}; // == Streams == diff --git a/benches/transform/dedupe.rs b/benches/transform/dedupe.rs index 2e95f5d28a9f7..743b66e209284 100644 --- a/benches/transform/dedupe.rs +++ b/benches/transform/dedupe.rs @@ -1,10 +1,10 @@ use core::fmt; use std::{num::NonZeroUsize, time::Duration}; -use crate::common::{consume, FixedLogStream}; +use crate::common::{FixedLogStream, consume}; use criterion::{ - criterion_group, measurement::WallTime, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, - SamplingMode, Throughput, + BatchSize, BenchmarkGroup, BenchmarkId, Criterion, SamplingMode, Throughput, criterion_group, + measurement::WallTime, }; use vector::transforms::dedupe::common::{CacheConfig, FieldMatchConfig, TimedCacheConfig}; use vector::transforms::dedupe::config::DedupeConfig; diff --git a/benches/transform/filter.rs b/benches/transform/filter.rs index c2e7b2f7222af..a1538cd090000 100644 --- a/benches/transform/filter.rs +++ b/benches/transform/filter.rs @@ -1,12 +1,12 @@ use std::time::Duration; use criterion::{ - criterion_group, measurement::WallTime, BatchSize, BenchmarkGroup, Criterion, SamplingMode, - Throughput, + BatchSize, BenchmarkGroup, Criterion, SamplingMode, Throughput, criterion_group, + measurement::WallTime, }; use vector::{ conditions::Condition, - transforms::{filter::Filter, FunctionTransform, OutputBuffer}, + transforms::{FunctionTransform, OutputBuffer, filter::Filter}, }; use vector_lib::event::{Event, LogEvent}; diff --git a/benches/transform/reduce.rs b/benches/transform/reduce.rs index fd3f54275766a..0e074d5c08ef6 100644 --- a/benches/transform/reduce.rs +++ b/benches/transform/reduce.rs @@ -1,10 +1,10 @@ use core::fmt; use std::{num::NonZeroUsize, time::Duration}; -use crate::common::{consume, FixedLogStream}; +use crate::common::{FixedLogStream, consume}; use criterion::{ - criterion_group, measurement::WallTime, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, - SamplingMode, Throughput, + BatchSize, BenchmarkGroup, BenchmarkId, Criterion, SamplingMode, Throughput, criterion_group, + measurement::WallTime, }; use indexmap::IndexMap; use vector::transforms::reduce::config::ReduceConfig; diff --git a/benches/transform/route.rs b/benches/transform/route.rs index c49ce47f13404..33b0caa52e273 100644 --- a/benches/transform/route.rs +++ b/benches/transform/route.rs @@ -3,13 +3,13 @@ use std::time::Duration; use bytes::Bytes; use criterion::{ - criterion_group, measurement::WallTime, BatchSize, BenchmarkGroup, BenchmarkId, Criterion, - SamplingMode, Throughput, + BatchSize, BenchmarkGroup, BenchmarkId, Criterion, SamplingMode, Throughput, criterion_group, + measurement::WallTime, }; use vector::config::TransformContext; use vector::transforms::{ - route::{Route, RouteConfig}, TransformOutputsBuf, + route::{Route, RouteConfig}, }; use vector_lib::{ config::{DataType, TransformOutput}, diff --git a/scripts/environment/prepare.sh b/scripts/environment/prepare.sh index 7bb54c3dc0f61..1721acd12c771 100755 --- a/scripts/environment/prepare.sh +++ b/scripts/environment/prepare.sh @@ -117,8 +117,8 @@ if contains_module rustup; then fi set -e -o verbose if contains_module cargo-deb; then - if [[ "$(cargo-deb --version 2>/dev/null)" != "3.4.1" ]]; then - rustup run stable cargo "${install[@]}" cargo-deb --version 3.4.1 --force --locked + if [[ "$(cargo-deb --version 2>/dev/null)" != "2.9.3" ]]; then + rustup run stable cargo "${install[@]}" cargo-deb --version 2.9.3 --force --locked fi fi diff --git a/scripts/package-deb.sh b/scripts/package-deb.sh index cec0ed5038aa8..29f2c793d10d2 100755 --- a/scripts/package-deb.sh +++ b/scripts/package-deb.sh @@ -71,6 +71,11 @@ cat LICENSE NOTICE >"$PROJECT_ROOT/target/debian-license.txt" # --no-build # because this step should follow a build +# TODO: Remove this after the Vector docker image contains a newer cargo-deb version. +# Temporary override of cargo-deb to support Rust 2024 edition. +if [[ "$(cargo-deb --version 2>/dev/null)" != "2.9.3" ]]; then + cargo install cargo-deb --version 2.9.3 --force --locked +fi cargo deb --target "$TARGET" --deb-version "${PACKAGE_VERSION}-1" --variant "$TARGET" --no-build --no-strip # Rename the resulting .deb file to remove TARGET from name. diff --git a/src/api/handler.rs b/src/api/handler.rs index 3e4ec2c5b5aa5..72ecfce87c1dc 100644 --- a/src/api/handler.rs +++ b/src/api/handler.rs @@ -1,10 +1,10 @@ use std::sync::{ - atomic::{self, AtomicBool}, Arc, + atomic::{self, AtomicBool}, }; use serde_json::json; -use warp::{reply::json, Rejection, Reply}; +use warp::{Rejection, Reply, reply::json}; // Health handler, responds with '{ ok: true }' when running and '{ ok: false}' // when shutting down diff --git a/src/api/schema/components/mod.rs b/src/api/schema/components/mod.rs index b65b2a4cec230..69d509e449a50 100644 --- a/src/api/schema/components/mod.rs +++ b/src/api/schema/components/mod.rs @@ -10,7 +10,7 @@ use std::{ }; use async_graphql::{Enum, InputObject, Interface, Object, Subscription}; -use tokio_stream::{wrappers::BroadcastStream, Stream, StreamExt}; +use tokio_stream::{Stream, StreamExt, wrappers::BroadcastStream}; use vector_lib::internal_event::DEFAULT_OUTPUT; use crate::{ @@ -19,7 +19,7 @@ use crate::{ filter::{self, filter_items}, relay, sort, }, - config::{get_transform_output_ids, ComponentKey, Config}, + config::{ComponentKey, Config, get_transform_output_ids}, filter_check, }; diff --git a/src/api/schema/components/sink.rs b/src/api/schema/components/sink.rs index 919a0ec63f113..e92c2133f7fc7 100644 --- a/src/api/schema/components/sink.rs +++ b/src/api/schema/components/sink.rs @@ -2,7 +2,7 @@ use std::cmp; use async_graphql::{Enum, InputObject, Object}; -use super::{source, state, transform, Component}; +use super::{Component, source, state, transform}; use crate::{ api::schema::{ filter, diff --git a/src/api/schema/components/source.rs b/src/api/schema/components/source.rs index 65dcb691d8996..b10846803601f 100644 --- a/src/api/schema/components/source.rs +++ b/src/api/schema/components/source.rs @@ -2,11 +2,11 @@ use std::cmp; use async_graphql::{Enum, InputObject, Object}; -use super::{sink, state, transform, Component}; +use super::{Component, sink, state, transform}; use crate::{ api::schema::{ filter, - metrics::{self, outputs_by_component_key, IntoSourceMetrics, Output}, + metrics::{self, IntoSourceMetrics, Output, outputs_by_component_key}, sort, }, config::{ComponentKey, DataType, OutputId}, diff --git a/src/api/schema/components/state.rs b/src/api/schema/components/state.rs index 615f3b2e26479..1bb04894d81a9 100644 --- a/src/api/schema/components/state.rs +++ b/src/api/schema/components/state.rs @@ -3,7 +3,7 @@ use std::{ sync::{Arc, LazyLock, RwLock}, }; -use super::{sink, source, transform, Component}; +use super::{Component, sink, source, transform}; use crate::config::{ComponentKey, OutputId}; pub const INVARIANT: &str = "Couldn't acquire lock on Vector components. Please report this."; diff --git a/src/api/schema/components/transform.rs b/src/api/schema/components/transform.rs index 6d53a9bbd3acf..6c8b50eb205e8 100644 --- a/src/api/schema/components/transform.rs +++ b/src/api/schema/components/transform.rs @@ -2,11 +2,11 @@ use std::cmp; use async_graphql::{Enum, InputObject, Object}; -use super::{sink, source, state, Component}; +use super::{Component, sink, source, state}; use crate::{ api::schema::{ filter, - metrics::{self, outputs_by_component_key, IntoTransformMetrics, Output}, + metrics::{self, IntoTransformMetrics, Output, outputs_by_component_key}, sort, }, config::{ComponentKey, Inputs, OutputId}, diff --git a/src/api/schema/events/metric.rs b/src/api/schema/events/metric.rs index f25b383f4a930..8fbd54d09af38 100644 --- a/src/api/schema/events/metric.rs +++ b/src/api/schema/events/metric.rs @@ -126,10 +126,14 @@ impl Metric { .expect("logfmt serialization of metric event failed: conversion to serde Value failed. Please report."); match json { Value::Object(map) => encode_logfmt::encode_map( - &map.into_iter().map(|(k,v)| (event::KeyString::from(k), v)).collect(), + &map.into_iter() + .map(|(k, v)| (event::KeyString::from(k), v)) + .collect(), ) .expect("logfmt serialization of metric event failed. Please report."), - _ => panic!("logfmt serialization of metric event failed: metric converted to unexpected serde Value. Please report."), + _ => panic!( + "logfmt serialization of metric event failed: metric converted to unexpected serde Value. Please report." + ), } } } diff --git a/src/api/schema/events/mod.rs b/src/api/schema/events/mod.rs index e734169afd31d..dc6f26b254f9f 100644 --- a/src/api/schema/events/mod.rs +++ b/src/api/schema/events/mod.rs @@ -6,9 +6,9 @@ pub mod trace; use async_graphql::{Context, Subscription}; use encoding::EventEncodingType; -use futures::{stream, Stream, StreamExt}; -use output::{from_tap_payload_to_output_events, OutputEventsPayload}; -use rand::{rngs::SmallRng, Rng, SeedableRng}; +use futures::{Stream, StreamExt, stream}; +use output::{OutputEventsPayload, from_tap_payload_to_output_events}; +use rand::{Rng, SeedableRng, rngs::SmallRng}; use std::time::{SystemTime, UNIX_EPOCH}; use tokio::{select, sync::mpsc, time}; use tokio_stream::wrappers::ReceiverStream; diff --git a/src/api/schema/filter.rs b/src/api/schema/filter.rs index 438a4d7587207..ac8f7f551d2ae 100644 --- a/src/api/schema/filter.rs +++ b/src/api/schema/filter.rs @@ -2,7 +2,7 @@ use std::collections::BTreeSet; use async_graphql::{InputObject, InputType}; -use super::components::{source, ComponentKind}; +use super::components::{ComponentKind, source}; /// Takes an `&Option` and returns early if false #[macro_export] diff --git a/src/api/schema/health.rs b/src/api/schema/health.rs index 36500f21f7afa..0ee3d1d897cb1 100644 --- a/src/api/schema/health.rs +++ b/src/api/schema/health.rs @@ -1,7 +1,7 @@ use async_graphql::{Object, SimpleObject, Subscription}; use chrono::{DateTime, Utc}; use tokio::time::Duration; -use tokio_stream::{wrappers::IntervalStream, Stream, StreamExt}; +use tokio_stream::{Stream, StreamExt, wrappers::IntervalStream}; #[derive(SimpleObject)] pub struct Heartbeat { diff --git a/src/api/schema/metrics/filter.rs b/src/api/schema/metrics/filter.rs index 1236119c87af3..c85379edeeff4 100644 --- a/src/api/schema/metrics/filter.rs +++ b/src/api/schema/metrics/filter.rs @@ -5,8 +5,8 @@ use tokio::time::Duration; use tokio_stream::{Stream, StreamExt}; use super::{ - filter_output_metric, OutputThroughput, ReceivedBytesTotal, ReceivedEventsTotal, - SentBytesTotal, SentEventsTotal, + OutputThroughput, ReceivedBytesTotal, ReceivedEventsTotal, SentBytesTotal, SentEventsTotal, + filter_output_metric, }; use crate::{ config::ComponentKey, @@ -27,11 +27,7 @@ pub fn sum_metrics<'a, I: IntoIterator>(metrics: I) -> Option Some(iter.fold( m.clone(), |mut m1, m2| { - if m1.update(m2) { - m1 - } else { - m2.clone() - } + if m1.update(m2) { m1 } else { m2.clone() } }, )) } diff --git a/src/api/schema/metrics/output.rs b/src/api/schema/metrics/output.rs index 1bf67791dc7c1..e1fd0976e7b48 100644 --- a/src/api/schema/metrics/output.rs +++ b/src/api/schema/metrics/output.rs @@ -1,7 +1,7 @@ use async_graphql::Object; use vector_lib::config::ComponentKey; -use super::{by_component_key, sum_metrics, SentEventsTotal}; +use super::{SentEventsTotal, by_component_key, sum_metrics}; use crate::event::Metric; #[derive(Debug, Clone)] diff --git a/src/api/schema/metrics/source/file.rs b/src/api/schema/metrics/source/file.rs index 93a3141860d5f..50b89eb69c831 100644 --- a/src/api/schema/metrics/source/file.rs +++ b/src/api/schema/metrics/source/file.rs @@ -4,7 +4,7 @@ use async_graphql::{Enum, InputObject, Object}; use crate::{ api::schema::{ - filter::{filter_items, CustomFilter, StringFilter}, + filter::{CustomFilter, StringFilter, filter_items}, metrics::{self, MetricsFilter}, relay, sort, }, @@ -135,10 +135,11 @@ pub struct FileSourceMetricsFilesFilter { impl CustomFilter> for FileSourceMetricsFilesFilter { fn matches(&self, file: &FileSourceMetricFile<'_>) -> bool { - filter_check!(self - .name - .as_ref() - .map(|f| f.iter().all(|f| f.filter_value(file.get_name())))); + filter_check!( + self.name + .as_ref() + .map(|f| f.iter().all(|f| f.filter_value(file.get_name()))) + ); true } diff --git a/src/api/schema/relay.rs b/src/api/schema/relay.rs index 83f397a9d8f76..3124a2272a66e 100644 --- a/src/api/schema/relay.rs +++ b/src/api/schema/relay.rs @@ -1,10 +1,10 @@ use std::convert::Infallible; use async_graphql::{ - connection::{self, Connection, CursorType, Edge, EmptyFields}, Result, SimpleObject, + connection::{self, Connection, CursorType, Edge, EmptyFields}, }; -use base64::prelude::{Engine as _, BASE64_URL_SAFE_NO_PAD}; +use base64::prelude::{BASE64_URL_SAFE_NO_PAD, Engine as _}; /// Base64 invalid states, used by `Base64Cursor`. pub enum Base64CursorError { diff --git a/src/api/schema/sort.rs b/src/api/schema/sort.rs index aaefe41293fc1..8e40750c88a83 100644 --- a/src/api/schema/sort.rs +++ b/src/api/schema/sort.rs @@ -8,8 +8,8 @@ use itertools::{ use crate::api::schema::{ components::{ - sink::SinksSortFieldName, source::SourcesSortFieldName, transform::TransformsSortFieldName, - ComponentsSortFieldName, + ComponentsSortFieldName, sink::SinksSortFieldName, source::SourcesSortFieldName, + transform::TransformsSortFieldName, }, metrics::source::file::FileSourceMetricFilesSortFieldName, }; diff --git a/src/api/server.rs b/src/api/server.rs index caf6512b62d3e..76e3f24ce24c1 100644 --- a/src/api/server.rs +++ b/src/api/server.rs @@ -1,21 +1,21 @@ use std::{ convert::Infallible, net::SocketAddr, - sync::{atomic::AtomicBool, Arc}, + sync::{Arc, atomic::AtomicBool}, }; use async_graphql::{ - http::{playground_source, GraphQLPlaygroundConfig, WebSocketProtocols}, Data, Request, Schema, + http::{GraphQLPlaygroundConfig, WebSocketProtocols, playground_source}, }; -use async_graphql_warp::{graphql_protocol, GraphQLResponse, GraphQLWebSocket}; -use hyper::{server::conn::AddrIncoming, service::make_service_fn, Server as HyperServer}; +use async_graphql_warp::{GraphQLResponse, GraphQLWebSocket, graphql_protocol}; +use hyper::{Server as HyperServer, server::conn::AddrIncoming, service::make_service_fn}; use tokio::runtime::Handle; use tokio::sync::oneshot; use tower::ServiceBuilder; use tracing::Span; use vector_lib::tap::topology; -use warp::{filters::BoxedFilter, http::Response, ws::Ws, Filter, Reply}; +use warp::{Filter, Reply, filters::BoxedFilter, http::Response, ws::Ws}; use super::{handler, schema}; use crate::{ diff --git a/src/api/tests.rs b/src/api/tests.rs index 6d7cd0a20596f..40203b0168aa1 100644 --- a/src/api/tests.rs +++ b/src/api/tests.rs @@ -69,12 +69,12 @@ async fn sink_events() { Some(TapPayload::Notification(Notification::Matched(matched))) if matched.pattern == pattern_matched => { - continue + continue; } Some(TapPayload::Notification(Notification::NotMatched(not_matched))) if not_matched.pattern == pattern_not_matched => { - continue + continue; } _ => panic!("unexpected payload"), } @@ -340,13 +340,17 @@ async fn integration_test_transform_input() { assert_notification(tap_events[1][0].clone()), assert_notification(tap_events[2][0].clone()), ]; - assert!(notifications - .iter() - .any(|n| *n == Notification::Matched(Matched::new("transform".to_string())))); + assert!( + notifications + .iter() + .any(|n| *n == Notification::Matched(Matched::new("transform".to_string()))) + ); // "in" is not matched since it corresponds to a source - assert!(notifications - .iter() - .any(|n| *n == Notification::NotMatched(NotMatched::new("in".to_string())))); + assert!( + notifications + .iter() + .any(|n| *n == Notification::NotMatched(NotMatched::new("in".to_string()))) + ); // "in" generates an invalid match notification to warn against an // attempt to tap the input of a source assert!(notifications.iter().any(|n| *n diff --git a/src/app.rs b/src/app.rs index c5c69a8209a9c..b00208980e0ab 100644 --- a/src/app.rs +++ b/src/app.rs @@ -10,13 +10,13 @@ use std::{ use exitcode::ExitCode; use futures::StreamExt; use tokio::runtime::{self, Runtime}; -use tokio::sync::{broadcast::error::RecvError, MutexGuard}; +use tokio::sync::{MutexGuard, broadcast::error::RecvError}; use tokio_stream::wrappers::UnboundedReceiverStream; #[cfg(feature = "api")] use crate::{api, internal_events::ApiStarted}; use crate::{ - cli::{handle_config_errors, LogFormat, Opts, RootOpts, WatchConfigMethod}, + cli::{LogFormat, Opts, RootOpts, WatchConfigMethod, handle_config_errors}, config::{self, ComponentConfig, Config, ConfigPath}, heartbeat, internal_events::{VectorConfigLoadError, VectorQuit, VectorStarted, VectorStopped}, @@ -158,7 +158,9 @@ impl ApplicationConfig { } } } else { - info!(message="API is disabled, enable by setting `api.enabled` to `true` and use commands like `vector top`."); + info!( + message = "API is disabled, enable by setting `api.enabled` to `true` and use commands like `vector top`." + ); None } } @@ -206,7 +208,9 @@ impl Application { // Can only log this after initializing the logging subsystem if opts.root.openssl_no_probe { - debug!(message = "Disabled probing and configuration of root certificate locations on the system for OpenSSL."); + debug!( + message = "Disabled probing and configuration of root certificate locations on the system for OpenSSL." + ); } let runtime = build_runtime(opts.root.threads, "vector-worker")?; diff --git a/src/async_read.rs b/src/async_read.rs index 6dc0f0f7d83dd..0ab27f2a01625 100644 --- a/src/async_read.rs +++ b/src/async_read.rs @@ -66,7 +66,7 @@ where mod tests { use futures::FutureExt; use tokio::{ - fs::{remove_file, File}, + fs::{File, remove_file}, io::{AsyncBufReadExt, AsyncWriteExt, BufReader, BufWriter}, }; diff --git a/src/aws/auth.rs b/src/aws/auth.rs index 1ed174096dfa1..7fca5f30d3914 100644 --- a/src/aws/auth.rs +++ b/src/aws/auth.rs @@ -6,11 +6,11 @@ use aws_config::{ profile::ProfileFileCredentialsProvider, provider_config::ProviderConfig, sts::AssumeRoleProviderBuilder, }; -use aws_credential_types::{provider::SharedCredentialsProvider, Credentials}; +use aws_credential_types::{Credentials, provider::SharedCredentialsProvider}; use aws_runtime::env_config::file::{EnvConfigFileKind, EnvConfigFiles}; use aws_smithy_async::time::SystemTimeSource; use aws_smithy_runtime_api::client::identity::SharedIdentityCache; -use aws_types::{region::Region, SdkConfig}; +use aws_types::{SdkConfig, region::Region}; use serde_with::serde_as; use vector_lib::configurable::configurable_component; use vector_lib::{config::proxy::ProxyConfig, sensitive_string::SensitiveString, tls::TlsConfig}; diff --git a/src/aws/mod.rs b/src/aws/mod.rs index dbfc742878ae8..703c6cb4262b1 100644 --- a/src/aws/mod.rs +++ b/src/aws/mod.rs @@ -5,7 +5,7 @@ pub mod timeout; pub use auth::{AwsAuthentication, ImdsAuthentication}; use aws_config::{ - meta::region::ProvideRegion, retry::RetryConfig, timeout::TimeoutConfig, Region, SdkConfig, + Region, SdkConfig, meta::region::ProvideRegion, retry::RetryConfig, timeout::TimeoutConfig, }; use aws_credential_types::provider::{ProvideCredentials, SharedCredentialsProvider}; use aws_sigv4::{ @@ -28,7 +28,7 @@ use aws_types::sdk_config::SharedHttpClient; use bytes::Bytes; use futures_util::FutureExt; use http::HeaderMap; -use http_body::{combinators::BoxBody, Body}; +use http_body::{Body, combinators::BoxBody}; use pin_project::pin_project; use regex::RegexSet; pub use region::RegionOrEndpoint; @@ -37,8 +37,8 @@ use std::{ error::Error, pin::Pin, sync::{ - atomic::{AtomicUsize, Ordering}, Arc, OnceLock, + atomic::{AtomicUsize, Ordering}, }, task::{Context, Poll}, time::{Duration, SystemTime}, diff --git a/src/aws/region.rs b/src/aws/region.rs index 4c13d53b02f79..4a777a4657639 100644 --- a/src/aws/region.rs +++ b/src/aws/region.rs @@ -55,24 +55,30 @@ mod tests { #[test] fn optional() { - assert!(toml::from_str::(indoc! {" - "}) - .is_ok()); + assert!( + toml::from_str::(indoc! {" + "}) + .is_ok() + ); } #[test] fn region_optional() { - assert!(toml::from_str::(indoc! {r#" + assert!( + toml::from_str::(indoc! {r#" endpoint = "http://localhost:8080" "#}) - .is_ok()); + .is_ok() + ); } #[test] fn endpoint_optional() { - assert!(toml::from_str::(indoc! {r#" + assert!( + toml::from_str::(indoc! {r#" region = "us-east-1" "#}) - .is_ok()); + .is_ok() + ); } } diff --git a/src/codecs/decoding/decoder.rs b/src/codecs/decoding/decoder.rs index 816cedfdd820c..6569742ff2d6d 100644 --- a/src/codecs/decoding/decoder.rs +++ b/src/codecs/decoding/decoder.rs @@ -1,8 +1,8 @@ use bytes::{Bytes, BytesMut}; use smallvec::SmallVec; use vector_lib::codecs::decoding::{ - format::Deserializer as _, BoxedFramingError, BytesDeserializer, Deserializer, Error, Framer, - NewlineDelimitedDecoder, + BoxedFramingError, BytesDeserializer, Deserializer, Error, Framer, NewlineDelimitedDecoder, + format::Deserializer as _, }; use vector_lib::config::LogNamespace; @@ -103,11 +103,11 @@ impl tokio_util::codec::Decoder for Decoder { mod tests { use super::Decoder; use bytes::Bytes; - use futures::{stream, StreamExt}; + use futures::{StreamExt, stream}; use tokio_util::{codec::FramedRead, io::StreamReader}; use vector_lib::codecs::{ - decoding::{Deserializer, Framer}, JsonDeserializer, NewlineDelimitedDecoder, StreamDecodingError, + decoding::{Deserializer, Framer}, }; use vrl::value::Value; diff --git a/src/codecs/encoding/config.rs b/src/codecs/encoding/config.rs index c3d77a5abde2c..f3653bc76edfa 100644 --- a/src/codecs/encoding/config.rs +++ b/src/codecs/encoding/config.rs @@ -1,7 +1,7 @@ use crate::codecs::Transformer; use vector_lib::codecs::{ - encoding::{Framer, FramingConfig, Serializer, SerializerConfig}, CharacterDelimitedEncoder, LengthDelimitedEncoder, NewlineDelimitedEncoder, + encoding::{Framer, FramingConfig, Serializer, SerializerConfig}, }; use vector_lib::configurable::configurable_component; @@ -156,7 +156,7 @@ where #[cfg(test)] mod test { - use vector_lib::lookup::lookup_v2::{parse_value_path, ConfigValuePath}; + use vector_lib::lookup::lookup_v2::{ConfigValuePath, parse_value_path}; use super::*; use crate::codecs::encoding::TimestampFormat; diff --git a/src/codecs/encoding/encoder.rs b/src/codecs/encoding/encoder.rs index 94ef9fe0408f9..e5d9875ef67b6 100644 --- a/src/codecs/encoding/encoder.rs +++ b/src/codecs/encoding/encoder.rs @@ -1,8 +1,8 @@ use bytes::BytesMut; use tokio_util::codec::Encoder as _; use vector_lib::codecs::{ - encoding::{Error, Framer, Serializer}, CharacterDelimitedEncoder, NewlineDelimitedEncoder, TextSerializerConfig, + encoding::{Error, Framer, Serializer}, }; use crate::{ diff --git a/src/codecs/encoding/transformer.rs b/src/codecs/encoding/transformer.rs index 4b9583e1f53e6..a2b69952fb36d 100644 --- a/src/codecs/encoding/transformer.rs +++ b/src/codecs/encoding/transformer.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Deserializer}; use vector_lib::configurable::configurable_component; use vector_lib::event::{LogEvent, MaybeAsLogMut}; use vector_lib::lookup::lookup_v2::ConfigValuePath; -use vector_lib::lookup::{event_path, PathPrefix}; +use vector_lib::lookup::{PathPrefix, event_path}; use vector_lib::schema::meaning; use vrl::path::OwnedValuePath; use vrl::value::Value; @@ -267,7 +267,7 @@ pub enum TimestampFormat { mod tests { use indoc::indoc; use vector_lib::btreemap; - use vector_lib::config::{log_schema, LogNamespace}; + use vector_lib::config::{LogNamespace, log_schema}; use vector_lib::lookup::path::parse_target_path; use vrl::value::Kind; diff --git a/src/codecs/ready_frames.rs b/src/codecs/ready_frames.rs index a707140b23001..773b979fea11b 100644 --- a/src/codecs/ready_frames.rs +++ b/src/codecs/ready_frames.rs @@ -115,7 +115,7 @@ where #[cfg(test)] mod test { - use futures::{channel::mpsc, poll, task::Poll, SinkExt, StreamExt}; + use futures::{SinkExt, StreamExt, channel::mpsc, poll, task::Poll}; use super::ReadyFrames; diff --git a/src/common/http/server_auth.rs b/src/common/http/server_auth.rs index 0b3eda4c43184..4874418460d3a 100644 --- a/src/common/http/server_auth.rs +++ b/src/common/http/server_auth.rs @@ -2,21 +2,20 @@ use std::{collections::HashMap, fmt, net::SocketAddr}; use bytes::Bytes; -use headers::{authorization::Credentials, Authorization}; -use http::{header::AUTHORIZATION, HeaderMap, HeaderValue, StatusCode}; +use headers::{Authorization, authorization::Credentials}; +use http::{HeaderMap, HeaderValue, StatusCode, header::AUTHORIZATION}; use serde::{ - de::{Error, MapAccess, Visitor}, Deserialize, + de::{Error, MapAccess, Visitor}, }; use vector_config::configurable_component; use vector_lib::{ - compile_vrl, + TimeZone, compile_vrl, event::{Event, LogEvent, VrlTarget}, sensitive_string::SensitiveString, - TimeZone, }; use vrl::{ - compiler::{runtime::Runtime, CompilationResult, CompileConfig, Program}, + compiler::{CompilationResult, CompileConfig, Program, runtime::Runtime}, core::Value, diagnostic::Formatter, prelude::TypeState, diff --git a/src/common/websocket.rs b/src/common/websocket.rs index f545bc92adb1b..e46aa01221c95 100644 --- a/src/common/websocket.rs +++ b/src/common/websocket.rs @@ -10,15 +10,14 @@ use vector_config_macros::configurable_component; use snafu::{ResultExt, Snafu}; use tokio::{net::TcpStream, time}; use tokio_tungstenite::{ - client_async_with_config, + WebSocketStream, client_async_with_config, tungstenite::{ - client::{uri_mode, IntoClientRequest}, + client::{IntoClientRequest, uri_mode}, error::{Error as TungsteniteError, ProtocolError, UrlError}, handshake::client::Request, protocol::WebSocketConfig, stream::Mode as UriMode, }, - WebSocketStream, }; use crate::{ diff --git a/src/components/validation/mod.rs b/src/components/validation/mod.rs index a786a56571120..cd0b2e2715b95 100644 --- a/src/components/validation/mod.rs +++ b/src/components/validation/mod.rs @@ -436,7 +436,10 @@ fn get_validation_configuration_from_test_case_path( #[cfg(feature = "component-validation-runner")] pub fn validate_component(test_case_data_path: std::path::PathBuf) { if !test_case_data_path.exists() { - panic!("Component validation test invoked with path to test case data that could not be found: {}", test_case_data_path.to_string_lossy()); + panic!( + "Component validation test invoked with path to test case data that could not be found: {}", + test_case_data_path.to_string_lossy() + ); } let configuration = get_validation_configuration_from_test_case_path(&test_case_data_path) diff --git a/src/components/validation/resources/event.rs b/src/components/validation/resources/event.rs index 46ae48378ae1f..065b781abd480 100644 --- a/src/components/validation/resources/event.rs +++ b/src/components/validation/resources/event.rs @@ -9,8 +9,8 @@ use vector_lib::codecs::encoding::format::JsonSerializerOptions; use crate::codecs::Encoder; use vector_lib::codecs::{ - encoding, JsonSerializer, LengthDelimitedEncoder, LogfmtSerializer, MetricTagValues, - NewlineDelimitedEncoder, + JsonSerializer, LengthDelimitedEncoder, LogfmtSerializer, MetricTagValues, + NewlineDelimitedEncoder, encoding, }; use vector_lib::event::{Event, LogEvent}; diff --git a/src/components/validation/resources/http.rs b/src/components/validation/resources/http.rs index 0be7d4de4bd3c..439f1766ca1a4 100644 --- a/src/components/validation/resources/http.rs +++ b/src/components/validation/resources/http.rs @@ -7,30 +7,29 @@ use std::{ }; use axum::{ + Router, response::IntoResponse, routing::{MethodFilter, MethodRouter}, - Router, }; use bytes::{BufMut as _, BytesMut}; use http::{Method, Request, StatusCode, Uri}; use hyper::{Body, Client, Server}; use tokio::{ select, - sync::{mpsc, oneshot, Mutex, Notify}, + sync::{Mutex, Notify, mpsc, oneshot}, }; use tokio_util::codec::Decoder; use crate::components::validation::{ - sync::{Configuring, TaskCoordinator}, RunnerMetrics, + sync::{Configuring, TaskCoordinator}, }; use vector_lib::{ - codecs::encoding::Framer, codecs::encoding::Serializer::Json, - codecs::CharacterDelimitedEncoder, config::LogNamespace, event::Event, - EstimatedJsonEncodedSizeOf, + EstimatedJsonEncodedSizeOf, codecs::CharacterDelimitedEncoder, codecs::encoding::Framer, + codecs::encoding::Serializer::Json, config::LogNamespace, event::Event, }; -use super::{encode_test_event, ResourceCodec, ResourceDirection, TestEvent}; +use super::{ResourceCodec, ResourceDirection, TestEvent, encode_test_event}; /// An HTTP resource. #[derive(Clone)] @@ -336,11 +335,17 @@ impl HttpResourceOutputContext<'_> { // entire payload which may contain multiple frames and their delimiters. Ok(Some((events, decoded_byte_size))) => { if should_reject { - info!(internal_log_rate_limit = true, "HTTP server external output resource decoded {decoded_byte_size:?} bytes but test case configured to reject.", ); + info!( + internal_log_rate_limit = true, + "HTTP server external output resource decoded {decoded_byte_size:?} bytes but test case configured to reject.", + ); } else { let mut output_runner_metrics = output_runner_metrics.lock().await; - info!(internal_log_rate_limit = true, "HTTP server external output resource decoded {decoded_byte_size:?} bytes."); + info!( + internal_log_rate_limit = true, + "HTTP server external output resource decoded {decoded_byte_size:?} bytes." + ); // Update the runner metrics for the received events. This will later // be used in the Validators, as the "expected" case. diff --git a/src/components/validation/resources/mod.rs b/src/components/validation/resources/mod.rs index f6727d24d517e..c667e8c5b4e30 100644 --- a/src/components/validation/resources/mod.rs +++ b/src/components/validation/resources/mod.rs @@ -3,15 +3,15 @@ mod http; use std::sync::Arc; -use tokio::sync::{mpsc, Mutex}; +use tokio::sync::{Mutex, mpsc}; use vector_lib::{ codecs::{ + BytesEncoder, decoding::{self, DeserializerConfig}, encoding::{ self, Framer, FramingConfig, JsonSerializerConfig, SerializerConfig, TextSerializerConfig, }, - BytesEncoder, }, config::LogNamespace, }; @@ -19,13 +19,13 @@ use vector_lib::{config::DataType, event::Event}; use crate::codecs::{Decoder, DecodingConfig, Encoder, EncodingConfig, EncodingConfigWithFraming}; -pub use self::event::{encode_test_event, TestEvent}; +pub use self::event::{TestEvent, encode_test_event}; pub use self::http::HttpResourceConfig; use self::http::HttpResourceOutputContext; use super::{ - sync::{Configuring, TaskCoordinator}, RunnerMetrics, + sync::{Configuring, TaskCoordinator}, }; /// The codec used by the external resource. diff --git a/src/components/validation/runner/config.rs b/src/components/validation/runner/config.rs index 1afc21e5d5fdb..1dca540bb1a0c 100644 --- a/src/components/validation/runner/config.rs +++ b/src/components/validation/runner/config.rs @@ -2,10 +2,10 @@ use vector_lib::config::LogNamespace; use crate::{ components::validation::{ + ComponentConfiguration, ComponentType, ValidationConfiguration, component_names::*, sync::{Configuring, TaskCoordinator}, util::GrpcAddress, - ComponentConfiguration, ComponentType, ValidationConfiguration, }, config::{BoxedSink, BoxedSource, BoxedTransform, ConfigBuilder}, sinks::vector::VectorConfig as VectorSinkConfig, diff --git a/src/components/validation/runner/io.rs b/src/components/validation/runner/io.rs index bc06761b17028..94607e61aa0a2 100644 --- a/src/components/validation/runner/io.rs +++ b/src/components/validation/runner/io.rs @@ -4,10 +4,10 @@ use http::{Request, Response}; use hyper::Body; use tokio::{pin, select, sync::mpsc}; use tonic::{ + Status, body::BoxBody, server::NamedService, transport::{Channel, Endpoint}, - Status, }; use tower::Service; use vector_lib::shutdown::ShutdownSignal; @@ -15,9 +15,9 @@ use vector_lib::{event::Event, tls::MaybeTlsSettings}; use crate::{ components::validation::{ + TestEvent, sync::{Configuring, TaskCoordinator}, util::GrpcAddress, - TestEvent, }, proto::vector::{ Client as VectorClient, HealthCheckRequest, HealthCheckResponse, PushEventsRequest, diff --git a/src/components/validation/runner/mod.rs b/src/components/validation/runner/mod.rs index 1316499bb13ac..d5e1831ad93b5 100644 --- a/src/components/validation/runner/mod.rs +++ b/src/components/validation/runner/mod.rs @@ -10,15 +10,15 @@ use tokio::{ runtime::Builder, select, sync::{ - mpsc::{self, Receiver, Sender}, Mutex, + mpsc::{self, Receiver, Sender}, }, task::JoinHandle, }; use tokio_util::codec::Encoder as _; use vector_lib::{ - codecs::encoding, config::LogNamespace, event::Event, EstimatedJsonEncodedSizeOf, + EstimatedJsonEncodedSizeOf, codecs::encoding, config::LogNamespace, event::Event, }; use crate::{ @@ -30,9 +30,9 @@ use crate::{ }; use super::{ + ComponentType, TestCaseExpectation, TestEvent, ValidationConfiguration, Validator, encode_test_event, sync::{Configuring, TaskCoordinator}, - ComponentType, TestCaseExpectation, TestEvent, ValidationConfiguration, Validator, }; pub use self::config::TopologyBuilder; @@ -70,8 +70,12 @@ impl RunnerInput { controlled_edge: Option>, ) -> mpsc::Sender { match (self, controlled_edge) { - (Self::External(_), Some(_)) => panic!("Runner input declared as external resource, but controlled input edge was also specified."), - (Self::Controlled, None) => panic!("Runner input declared as controlled, but no controlled input edge was specified."), + (Self::External(_), Some(_)) => panic!( + "Runner input declared as external resource, but controlled input edge was also specified." + ), + (Self::Controlled, None) => panic!( + "Runner input declared as controlled, but no controlled input edge was specified." + ), (Self::External(tx), None) => tx, (Self::Controlled, Some(tx)) => tx, } @@ -113,8 +117,12 @@ impl RunnerOutput { controlled_edge: Option>>, ) -> mpsc::Receiver> { match (self, controlled_edge) { - (Self::External(_), Some(_)) => panic!("Runner output declared as external resource, but controlled output edge was also specified."), - (Self::Controlled, None) => panic!("Runner output declared as controlled, but no controlled output edge was specified."), + (Self::External(_), Some(_)) => panic!( + "Runner output declared as external resource, but controlled output edge was also specified." + ), + (Self::Controlled, None) => panic!( + "Runner output declared as controlled, but no controlled output edge was specified." + ), (Self::External(rx), None) => rx, (Self::Controlled, Some(rx)) => rx, } @@ -580,7 +588,7 @@ fn spawn_input_driver( // thus we need to add it here so the expected values for the comparisons on transforms // and sinks are accurate. if component_type != ComponentType::Source { - if let Event::Log(ref mut log) = input_event.get_event() { + if let Event::Log(log) = input_event.get_event() { log_namespace.insert_standard_vector_source_metadata(log, "vector", now); } } diff --git a/src/components/validation/runner/telemetry.rs b/src/components/validation/runner/telemetry.rs index 83c12c02db9c4..37830099d20fb 100644 --- a/src/components/validation/runner/telemetry.rs +++ b/src/components/validation/runner/telemetry.rs @@ -17,7 +17,7 @@ use crate::{ test_util::next_addr, }; -use super::io::{spawn_grpc_server, EventForwardService}; +use super::io::{EventForwardService, spawn_grpc_server}; const INTERNAL_LOGS_KEY: &str = "_telemetry_logs"; const INTERNAL_METRICS_KEY: &str = "_telemetry_metrics"; diff --git a/src/components/validation/sync.rs b/src/components/validation/sync.rs index 92f359af6a47a..694e8cb98b478 100644 --- a/src/components/validation/sync.rs +++ b/src/components/validation/sync.rs @@ -1,9 +1,9 @@ use std::sync::{ - atomic::{AtomicUsize, Ordering}, Arc, Mutex, + atomic::{AtomicUsize, Ordering}, }; -use tokio::sync::{oneshot, Notify}; +use tokio::sync::{Notify, oneshot}; struct WaitGroupState { registered: AtomicUsize, diff --git a/src/components/validation/validators/component_spec/mod.rs b/src/components/validation/validators/component_spec/mod.rs index 26ffd292c5cf7..7a9b0afa0b3ec 100644 --- a/src/components/validation/validators/component_spec/mod.rs +++ b/src/components/validation/validators/component_spec/mod.rs @@ -1,5 +1,5 @@ use crate::components::validation::{ - component_names::*, ComponentType, RunnerMetrics, TestCaseExpectation, TestEvent, + ComponentType, RunnerMetrics, TestCaseExpectation, TestEvent, component_names::*, }; use vector_lib::event::{Event, Metric, MetricKind}; @@ -129,11 +129,7 @@ fn validate_telemetry( } }); - if errs.is_empty() { - Ok(out) - } else { - Err(errs) - } + if errs.is_empty() { Ok(out) } else { Err(errs) } } fn validate_metric( diff --git a/src/conditions/datadog_search.rs b/src/conditions/datadog_search.rs index cf08404b7c81e..d506e8b7f2ba0 100644 --- a/src/conditions/datadog_search.rs +++ b/src/conditions/datadog_search.rs @@ -5,7 +5,7 @@ use bytes::Bytes; use vector_lib::configurable::configurable_component; use vector_lib::event::{Event, LogEvent, Value}; use vrl::datadog_filter::regex::{wildcard_regex, word_regex}; -use vrl::datadog_filter::{build_matcher, Filter, Matcher, Resolver, Run}; +use vrl::datadog_filter::{Filter, Matcher, Resolver, Run, build_matcher}; use vrl::datadog_search_syntax::{Comparison, ComparisonValue, Field, QueryNode}; use super::{Condition, Conditional, ConditionalConfig}; diff --git a/src/conditions/is_log.rs b/src/conditions/is_log.rs index 940b1d5011e49..1b365f12cd2f6 100644 --- a/src/conditions/is_log.rs +++ b/src/conditions/is_log.rs @@ -17,8 +17,8 @@ pub(crate) fn check_is_log_with_context(e: Event) -> (Result<(), String>, Event) mod test { use super::check_is_log; use crate::event::{ - metric::{Metric, MetricKind, MetricValue}, Event, LogEvent, + metric::{Metric, MetricKind, MetricValue}, }; #[test] diff --git a/src/conditions/is_metric.rs b/src/conditions/is_metric.rs index 9d68f847e372f..a7ca5c1cd6aff 100644 --- a/src/conditions/is_metric.rs +++ b/src/conditions/is_metric.rs @@ -17,8 +17,8 @@ pub(crate) fn check_is_metric_with_context(e: Event) -> (Result<(), String>, Eve mod test { use super::check_is_metric; use crate::event::{ - metric::{Metric, MetricKind, MetricValue}, Event, LogEvent, + metric::{Metric, MetricKind, MetricValue}, }; #[test] diff --git a/src/conditions/is_trace.rs b/src/conditions/is_trace.rs index 29aa7dbde359a..1166439a2e0f4 100644 --- a/src/conditions/is_trace.rs +++ b/src/conditions/is_trace.rs @@ -17,8 +17,8 @@ pub(crate) fn check_is_trace_with_context(e: Event) -> (Result<(), String>, Even mod test { use super::check_is_trace; use crate::event::{ - metric::{Metric, MetricKind, MetricValue}, Event, LogEvent, TraceEvent, + metric::{Metric, MetricKind, MetricValue}, }; #[test] diff --git a/src/conditions/vrl.rs b/src/conditions/vrl.rs index 267a7e01f19a4..d47810aa8e77d 100644 --- a/src/conditions/vrl.rs +++ b/src/conditions/vrl.rs @@ -1,5 +1,5 @@ use vector_lib::configurable::configurable_component; -use vector_lib::{compile_vrl, emit, TimeZone}; +use vector_lib::{TimeZone, compile_vrl, emit}; use vrl::compiler::runtime::{Runtime, RuntimeResult, Terminate}; use vrl::compiler::{CompilationResult, CompileConfig, Program, TypeState, VrlRuntime}; use vrl::diagnostic::Formatter; diff --git a/src/config/builder.rs b/src/config/builder.rs index 33889a67833c1..b71e9de747a2f 100644 --- a/src/config/builder.rs +++ b/src/config/builder.rs @@ -9,9 +9,8 @@ use crate::{enrichment_tables::EnrichmentTables, providers::Providers, secrets:: #[cfg(feature = "api")] use super::api; use super::{ - compiler, schema, BoxedSink, BoxedSource, BoxedTransform, ComponentKey, Config, - EnrichmentTableOuter, HealthcheckOptions, SinkOuter, SourceOuter, TestDefinition, - TransformOuter, + BoxedSink, BoxedSource, BoxedTransform, ComponentKey, Config, EnrichmentTableOuter, + HealthcheckOptions, SinkOuter, SourceOuter, TestDefinition, TransformOuter, compiler, schema, }; /// A complete Vector configuration. diff --git a/src/config/cmd.rs b/src/config/cmd.rs index e2372931087fa..e0b9f7389ec59 100644 --- a/src/config/cmd.rs +++ b/src/config/cmd.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use clap::Parser; use serde_json::Value; -use super::{load_builder_from_paths, load_source_from_paths, process_paths, ConfigBuilder}; +use super::{ConfigBuilder, load_builder_from_paths, load_source_from_paths, process_paths}; use crate::cli::handle_config_errors; use crate::config; @@ -196,8 +196,8 @@ mod tests { use proptest::{num, prelude::*, sample}; use rand::{ - prelude::{SliceRandom, StdRng}, SeedableRng, + prelude::{SliceRandom, StdRng}, }; use serde_json::json; use similar_asserts::assert_eq; @@ -207,9 +207,9 @@ mod tests { use crate::config::Format; use crate::{ - config::{cmd::serialize_to_json, vars, ConfigBuilder}, + config::{ConfigBuilder, cmd::serialize_to_json, vars}, generate, - generate::{generate_example, TransformInputsStrategy}, + generate::{TransformInputsStrategy, generate_example}, }; use super::merge_json; diff --git a/src/config/compiler.rs b/src/config/compiler.rs index bffb51bcaa93a..bc194baa59b45 100644 --- a/src/config/compiler.rs +++ b/src/config/compiler.rs @@ -1,6 +1,6 @@ use super::{ - builder::ConfigBuilder, graph::Graph, transform::get_transform_output_ids, validation, Config, - OutputId, + Config, OutputId, builder::ConfigBuilder, graph::Graph, transform::get_transform_output_ids, + validation, }; use indexmap::{IndexMap, IndexSet}; diff --git a/src/config/enrichment_table.rs b/src/config/enrichment_table.rs index 83b52fc437228..a953dcd7470a6 100644 --- a/src/config/enrichment_table.rs +++ b/src/config/enrichment_table.rs @@ -1,7 +1,7 @@ use enum_dispatch::enum_dispatch; use serde::Serialize; use vector_lib::config::GlobalOptions; -use vector_lib::configurable::{configurable_component, Configurable, NamedComponent, ToValue}; +use vector_lib::configurable::{Configurable, NamedComponent, ToValue, configurable_component}; use vector_lib::id::{ComponentKey, Inputs}; use crate::enrichment_tables::EnrichmentTables; diff --git a/src/config/format.rs b/src/config/format.rs index 32c2bd7b0f12e..dd8ca028d54ca 100644 --- a/src/config/format.rs +++ b/src/config/format.rs @@ -6,7 +6,7 @@ use std::fmt; use std::path::Path; use std::str::FromStr; -use serde::{de, Deserialize, Serialize}; +use serde::{Deserialize, Serialize, de}; use vector_config_macros::Configurable; /// A type alias to better capture the semantics. diff --git a/src/config/graph.rs b/src/config/graph.rs index 989f0a9eaf282..2f22013f4b3eb 100644 --- a/src/config/graph.rs +++ b/src/config/graph.rs @@ -1,8 +1,8 @@ use super::{ - schema, ComponentKey, DataType, OutputId, SinkOuter, SourceOuter, SourceOutput, TransformOuter, - TransformOutput, WildcardMatching, + ComponentKey, DataType, OutputId, SinkOuter, SourceOuter, SourceOutput, TransformOuter, + TransformOutput, WildcardMatching, schema, }; -use indexmap::{set::IndexSet, IndexMap}; +use indexmap::{IndexMap, set::IndexSet}; use std::collections::{HashMap, HashSet, VecDeque}; use std::fmt; @@ -177,7 +177,9 @@ impl Graph { // using value != glob::Pattern::escape(value) to check if value is a glob // TODO: replace with proper check when https://github.com/rust-lang/glob/issues/72 is resolved if from != glob::Pattern::escape(from) { - info!("Input \"{from}\" for {output_type} \"{to}\" didn’t match any components, but this was ignored because `relaxed_wildcard_matching` is enabled."); + info!( + "Input \"{from}\" for {output_type} \"{to}\" didn’t match any components, but this was ignored because `relaxed_wildcard_matching` is enabled." + ); return Ok(()); } } diff --git a/src/config/loading/config_builder.rs b/src/config/loading/config_builder.rs index 4ef0010d6fb20..609cf2f525c43 100644 --- a/src/config/loading/config_builder.rs +++ b/src/config/loading/config_builder.rs @@ -3,8 +3,8 @@ use std::{collections::HashMap, io::Read}; use indexmap::IndexMap; use toml::value::Table; -use super::{deserialize_table, loader, prepare_input, secret}; use super::{ComponentHint, Process}; +use super::{deserialize_table, loader, prepare_input, secret}; use crate::config::{ ComponentKey, ConfigBuilder, EnrichmentTableOuter, SinkOuter, SourceOuter, TestDefinition, TransformOuter, diff --git a/src/config/loading/loader.rs b/src/config/loading/loader.rs index 0fcfeb2545c48..6a89685cef17b 100644 --- a/src/config/loading/loader.rs +++ b/src/config/loading/loader.rs @@ -3,7 +3,7 @@ use std::path::{Path, PathBuf}; use serde_toml_merge::merge_into_table; use toml::value::{Table, Value}; -use super::{component_name, open_file, read_dir, Format}; +use super::{Format, component_name, open_file, read_dir}; use crate::config::format; /// Provides a hint to the loading system of the type of components that should be found diff --git a/src/config/loading/mod.rs b/src/config/loading/mod.rs index 9fbccfd9f9332..2ab4f74c2d79d 100644 --- a/src/config/loading/mod.rs +++ b/src/config/loading/mod.rs @@ -20,7 +20,7 @@ pub use source::*; use vector_lib::configurable::NamedComponent; use super::{ - builder::ConfigBuilder, format, validation, vars, Config, ConfigPath, Format, FormatHint, + Config, ConfigPath, Format, FormatHint, builder::ConfigBuilder, format, validation, vars, }; use crate::{config::ProviderConfig, signal}; @@ -342,15 +342,21 @@ mod tests { .join("success"); let configs = vec![ConfigPath::Dir(path)]; let builder = load_builder_from_paths(&configs).unwrap(); - assert!(builder - .transforms - .contains_key(&ComponentKey::from("apache_parser"))); - assert!(builder - .sources - .contains_key(&ComponentKey::from("apache_logs"))); - assert!(builder - .sinks - .contains_key(&ComponentKey::from("es_cluster"))); + assert!( + builder + .transforms + .contains_key(&ComponentKey::from("apache_parser")) + ); + assert!( + builder + .sources + .contains_key(&ComponentKey::from("apache_logs")) + ); + assert!( + builder + .sinks + .contains_key(&ComponentKey::from("es_cluster")) + ); assert_eq!(builder.tests.len(), 2); } diff --git a/src/config/loading/secret.rs b/src/config/loading/secret.rs index c3a9cf8f86bb8..57fac29238ffd 100644 --- a/src/config/loading/secret.rs +++ b/src/config/loading/secret.rs @@ -13,8 +13,8 @@ use vector_lib::config::ComponentKey; use crate::{ config::{ - loading::{deserialize_table, prepare_input, process::Process, ComponentHint, Loader}, SecretBackend, + loading::{ComponentHint, Loader, deserialize_table, prepare_input, process::Process}, }, secrets::SecretBackends, signal, diff --git a/src/config/loading/secret_backend_example.rs b/src/config/loading/secret_backend_example.rs index 4573df934fb3e..5b6d848c8404a 100644 --- a/src/config/loading/secret_backend_example.rs +++ b/src/config/loading/secret_backend_example.rs @@ -1,6 +1,6 @@ use std::{ collections::HashMap, - io::{stdin, BufReader}, + io::{BufReader, stdin}, }; use serde::{Deserialize, Serialize}; diff --git a/src/config/mod.rs b/src/config/mod.rs index a718df2c4300c..d316245fd7eb5 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -50,29 +50,29 @@ mod vars; pub mod watcher; pub use builder::ConfigBuilder; -pub use cmd::{cmd, Opts}; +pub use cmd::{Opts, cmd}; pub use diff::ConfigDiff; pub use enrichment_table::{EnrichmentTableConfig, EnrichmentTableOuter}; pub use format::{Format, FormatHint}; pub use loading::{ - load, load_builder_from_paths, load_from_paths, load_from_paths_with_provider_and_secrets, - load_from_str, load_source_from_paths, merge_path_lists, process_paths, COLLECTOR, - CONFIG_PATHS, + COLLECTOR, CONFIG_PATHS, load, load_builder_from_paths, load_from_paths, + load_from_paths_with_provider_and_secrets, load_from_str, load_source_from_paths, + merge_path_lists, process_paths, }; pub use provider::ProviderConfig; pub use secret::SecretBackend; pub use sink::{BoxedSink, SinkConfig, SinkContext, SinkHealthcheckOptions, SinkOuter}; pub use source::{BoxedSource, SourceConfig, SourceContext, SourceOuter}; pub use transform::{ - get_transform_output_ids, BoxedTransform, TransformConfig, TransformContext, TransformOuter, + BoxedTransform, TransformConfig, TransformContext, TransformOuter, get_transform_output_ids, }; -pub use unit_test::{build_unit_tests, build_unit_tests_main, UnitTestResult}; +pub use unit_test::{UnitTestResult, build_unit_tests, build_unit_tests_main}; pub use validation::warnings; -pub use vars::{interpolate, ENVIRONMENT_VARIABLE_INTERPOLATION_REGEX}; +pub use vars::{ENVIRONMENT_VARIABLE_INTERPOLATION_REGEX, interpolate}; pub use vector_lib::{ config::{ - init_log_schema, init_telemetry, log_schema, proxy::ProxyConfig, telemetry, ComponentKey, - LogSchema, OutputId, + ComponentKey, LogSchema, OutputId, init_log_schema, init_telemetry, log_schema, + proxy::ProxyConfig, telemetry, }, id::Inputs, }; @@ -584,7 +584,7 @@ mod tests { use crate::{config, topology}; use indoc::indoc; - use super::{builder::ConfigBuilder, format, load_from_str, ComponentKey, ConfigDiff, Format}; + use super::{ComponentKey, ConfigDiff, Format, builder::ConfigBuilder, format, load_from_str}; async fn load(config: &str, format: config::Format) -> Result, Vec> { match config::load_from_str(config, format) { @@ -1334,12 +1334,13 @@ mod resource_config_tests { use indoc::indoc; use vector_lib::configurable::schema::generate_root_schema; - use super::{load_from_str, Format}; + use super::{Format, load_from_str}; #[test] fn config_conflict_detected() { - assert!(load_from_str( - indoc! {r#" + assert!( + load_from_str( + indoc! {r#" [sources.in0] type = "stdin" @@ -1351,9 +1352,10 @@ mod resource_config_tests { inputs = ["in0","in1"] encoding.codec = "json" "#}, - Format::Toml, - ) - .is_err()); + Format::Toml, + ) + .is_err() + ); } #[test] diff --git a/src/config/sink.rs b/src/config/sink.rs index b4b6ac23c085c..7d4f38de6ed94 100644 --- a/src/config/sink.rs +++ b/src/config/sink.rs @@ -10,7 +10,7 @@ use vector_lib::buffers::{BufferConfig, BufferType}; use vector_lib::configurable::attributes::CustomAttribute; use vector_lib::configurable::schema::{SchemaGenerator, SchemaObject}; use vector_lib::configurable::{ - configurable_component, Configurable, GenerateError, Metadata, NamedComponent, + Configurable, GenerateError, Metadata, NamedComponent, configurable_component, }; use vector_lib::{ config::{AcknowledgementsConfig, GlobalOptions, Input}, @@ -18,9 +18,9 @@ use vector_lib::{ sink::VectorSink, }; -use super::{dot_graph::GraphConfig, schema, ComponentKey, ProxyConfig, Resource}; +use super::{ComponentKey, ProxyConfig, Resource, dot_graph::GraphConfig, schema}; use crate::extra_context::ExtraContext; -use crate::sinks::{util::UriSerde, Healthcheck}; +use crate::sinks::{Healthcheck, util::UriSerde}; pub type BoxedSink = Box; @@ -122,7 +122,9 @@ where pub fn healthcheck(&self) -> SinkHealthcheckOptions { if self.healthcheck_uri.is_some() && self.healthcheck.uri.is_some() { - warn!("Both `healthcheck.uri` and `healthcheck_uri` options are specified. Using value of `healthcheck.uri`.") + warn!( + "Both `healthcheck.uri` and `healthcheck_uri` options are specified. Using value of `healthcheck.uri`." + ) } else if self.healthcheck_uri.is_some() { warn!( "The `healthcheck_uri` option has been deprecated, use `healthcheck.uri` instead." diff --git a/src/config/source.rs b/src/config/source.rs index 2c540eeea8a18..1b475192739f4 100644 --- a/src/config/source.rs +++ b/src/config/source.rs @@ -15,8 +15,8 @@ use vector_lib::{ source::Source, }; -use super::{dot_graph::GraphConfig, schema, ComponentKey, ProxyConfig, Resource}; -use crate::{extra_context::ExtraContext, shutdown::ShutdownSignal, SourceSender}; +use super::{ComponentKey, ProxyConfig, Resource, dot_graph::GraphConfig, schema}; +use crate::{SourceSender, extra_context::ExtraContext, shutdown::ShutdownSignal}; pub type BoxedSource = Box; diff --git a/src/config/transform.rs b/src/config/transform.rs index 5471c41b1429e..9f75caf6a9669 100644 --- a/src/config/transform.rs +++ b/src/config/transform.rs @@ -7,9 +7,8 @@ use dyn_clone::DynClone; use serde::Serialize; use vector_lib::configurable::attributes::CustomAttribute; use vector_lib::configurable::{ - configurable_component, + Configurable, GenerateError, Metadata, NamedComponent, configurable_component, schema::{SchemaGenerator, SchemaObject}, - Configurable, GenerateError, Metadata, NamedComponent, }; use vector_lib::{ config::{GlobalOptions, Input, LogNamespace, TransformOutput}, @@ -18,10 +17,10 @@ use vector_lib::{ transform::Transform, }; -use super::dot_graph::GraphConfig; -use super::schema::Options as SchemaOptions; use super::ComponentKey; use super::OutputId; +use super::dot_graph::GraphConfig; +use super::schema::Options as SchemaOptions; use crate::extra_context::ExtraContext; pub type BoxedTransform = Box; diff --git a/src/config/unit_test/mod.rs b/src/config/unit_test/mod.rs index cb967a4de5460..1c5aa2d534bd0 100644 --- a/src/config/unit_test/mod.rs +++ b/src/config/unit_test/mod.rs @@ -16,15 +16,15 @@ use std::{ sync::Arc, }; -use futures_util::{stream::FuturesUnordered, StreamExt}; +use futures_util::{StreamExt, stream::FuturesUnordered}; use indexmap::IndexMap; use tokio::sync::{ - oneshot::{self, Receiver}, Mutex, + oneshot::{self, Receiver}, }; use uuid::Uuid; use vrl::{ - compiler::{state::RuntimeState, Context, TargetValue, TimeZone}, + compiler::{Context, TargetValue, TimeZone, state::RuntimeState}, diagnostic::Formatter, value, }; @@ -33,16 +33,16 @@ pub use self::unit_test_components::{ UnitTestSinkCheck, UnitTestSinkConfig, UnitTestSinkResult, UnitTestSourceConfig, UnitTestStreamSinkConfig, UnitTestStreamSourceConfig, }; -use super::{compiler::expand_globs, graph::Graph, transform::get_transform_output_ids, OutputId}; +use super::{OutputId, compiler::expand_globs, graph::Graph, transform::get_transform_output_ids}; use crate::{ conditions::Condition, config::{ - self, loading, ComponentKey, Config, ConfigBuilder, ConfigPath, SinkOuter, SourceOuter, - TestDefinition, TestInput, TestOutput, + self, ComponentKey, Config, ConfigBuilder, ConfigPath, SinkOuter, SourceOuter, + TestDefinition, TestInput, TestOutput, loading, }, event::{Event, EventMetadata, LogEvent}, signal, - topology::{builder::TopologyPieces, RunningTopology}, + topology::{RunningTopology, builder::TopologyPieces}, }; pub struct UnitTest { diff --git a/src/config/unit_test/tests.rs b/src/config/unit_test/tests.rs index 87a8e2d7c770f..938286ac9ba9f 100644 --- a/src/config/unit_test/tests.rs +++ b/src/config/unit_test/tests.rs @@ -33,10 +33,12 @@ async fn parse_no_input() { let errs = build_unit_tests(config).await.err().unwrap(); assert_eq!( errs, - vec![indoc! {r" + vec![ + indoc! {r" Failed to build test 'broken test': inputs[0]: unable to locate target transform 'foo'"} - .to_owned(),] + .to_owned(), + ] ); let config: ConfigBuilder = toml::from_str(indoc! {r#" @@ -69,10 +71,12 @@ async fn parse_no_input() { let errs = build_unit_tests(config).await.err().unwrap(); assert_eq!( errs, - vec![indoc! {r" + vec![ + indoc! {r" Failed to build test 'broken test': inputs[1]: unable to locate target transform 'foo'"} - .to_owned(),] + .to_owned(), + ] ); } @@ -102,10 +106,12 @@ async fn parse_no_test_input() { let errs = build_unit_tests(config).await.err().unwrap(); assert_eq!( errs, - vec![indoc! {r" + vec![ + indoc! {r" Failed to build test 'broken test': must specify at least one input."} - .to_owned(),] + .to_owned(), + ] ); } @@ -133,10 +139,12 @@ async fn parse_no_outputs() { let errs = build_unit_tests(config).await.err().unwrap(); assert_eq!( errs, - vec![indoc! {r" + vec![ + indoc! {r" Failed to build test 'broken test': unit test must contain at least one of `outputs` or `no_outputs_from`."} - .to_owned(),] + .to_owned(), + ] ); } @@ -170,10 +178,12 @@ async fn parse_invalid_output_targets() { let errs = build_unit_tests(config).await.err().unwrap(); assert_eq!( errs, - vec![indoc! {r" + vec![ + indoc! {r" Failed to build test 'broken test': Invalid extract_from target in test 'broken test': 'nonexistent' does not exist"} - .to_owned(),] + .to_owned(), + ] ); let config: ConfigBuilder = toml::from_str(indoc! {r#" @@ -197,10 +207,12 @@ async fn parse_invalid_output_targets() { let errs = build_unit_tests(config).await.err().unwrap(); assert_eq!( errs, - vec![indoc! {r" + vec![ + indoc! {r" Failed to build test 'broken test': Invalid no_outputs_from target in test 'broken test': 'nonexistent' does not exist"} - .to_owned(),] + .to_owned(), + ] ); } @@ -338,10 +350,12 @@ async fn parse_bad_input_event() { let errs = build_unit_tests(config).await.err().unwrap(); assert_eq!( errs, - vec![indoc! {r" + vec![ + indoc! {r" Failed to build test 'broken test': unrecognized input type 'nah', expected one of: 'raw', 'log' or 'metric'"} - .to_owned(),] + .to_owned(), + ] ); } diff --git a/src/config/unit_test/unit_test_components.rs b/src/config/unit_test/unit_test_components.rs index 8daf82b5029d3..b2887c6414bdd 100644 --- a/src/config/unit_test/unit_test_components.rs +++ b/src/config/unit_test/unit_test_components.rs @@ -1,8 +1,8 @@ use std::sync::Arc; -use futures::{stream, Sink, Stream}; -use futures_util::{future, stream::BoxStream, FutureExt, StreamExt}; -use tokio::sync::{oneshot, Mutex}; +use futures::{Sink, Stream, stream}; +use futures_util::{FutureExt, StreamExt, future, stream::BoxStream}; +use tokio::sync::{Mutex, oneshot}; use vector_lib::configurable::configurable_component; use vector_lib::{ config::{DataType, Input, LogNamespace}, diff --git a/src/config/validation.rs b/src/config/validation.rs index 6cae1ecfbf19a..8011ea41465bb 100644 --- a/src/config/validation.rs +++ b/src/config/validation.rs @@ -1,13 +1,13 @@ use crate::config::schema; -use futures_util::{stream, FutureExt, StreamExt, TryFutureExt, TryStreamExt}; +use futures_util::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, stream}; use heim::{disk::Partition, units::information::byte}; use indexmap::IndexMap; use std::{collections::HashMap, path::PathBuf}; use vector_lib::{buffers::config::DiskUsage, internal_event::DEFAULT_OUTPUT}; use super::{ - builder::ConfigBuilder, transform::get_transform_output_ids, ComponentKey, Config, OutputId, - Resource, + ComponentKey, Config, OutputId, Resource, builder::ConfigBuilder, + transform::get_transform_output_ids, }; /// Check that provide + topology config aren't present in the same builder, which is an error. diff --git a/src/config/watcher.rs b/src/config/watcher.rs index 641c29343121f..26d0133890091 100644 --- a/src/config/watcher.rs +++ b/src/config/watcher.rs @@ -5,11 +5,11 @@ use std::{ time::Duration, }; use std::{ - sync::mpsc::{channel, Receiver}, + sync::mpsc::{Receiver, channel}, thread, }; -use notify::{recommended_watcher, EventKind, RecursiveMode}; +use notify::{EventKind, RecursiveMode, recommended_watcher}; use crate::Error; @@ -89,84 +89,86 @@ pub fn spawn_thread<'a>( info!("Watching configuration files."); - thread::spawn(move || loop { - if let Some((mut watcher, receiver)) = watcher.take() { - while let Ok(Ok(event)) = receiver.recv() { - if matches!( - event.kind, - EventKind::Create(_) | EventKind::Remove(_) | EventKind::Modify(_) - ) { - debug!(message = "Configuration file change detected.", event = ?event); - - // Consume events until delay amount of time has passed since the latest event. - while receiver.recv_timeout(delay).is_ok() {} - - debug!(message = "Consumed file change events for delay.", delay = ?delay); - - let changed_components: HashMap<_, _> = component_configs - .clone() - .into_iter() - .flat_map(|p| p.contains(&event.paths)) - .collect(); - - // We need to read paths to resolve any inode changes that may have happened. - // And we need to do it before raising sighup to avoid missing any change. - if let Err(error) = watcher.add_paths(&config_paths) { - error!(message = "Failed to read files to watch.", %error); - break; - } + thread::spawn(move || { + loop { + if let Some((mut watcher, receiver)) = watcher.take() { + while let Ok(Ok(event)) = receiver.recv() { + if matches!( + event.kind, + EventKind::Create(_) | EventKind::Remove(_) | EventKind::Modify(_) + ) { + debug!(message = "Configuration file change detected.", event = ?event); + + // Consume events until delay amount of time has passed since the latest event. + while receiver.recv_timeout(delay).is_ok() {} + + debug!(message = "Consumed file change events for delay.", delay = ?delay); + + let changed_components: HashMap<_, _> = component_configs + .clone() + .into_iter() + .flat_map(|p| p.contains(&event.paths)) + .collect(); + + // We need to read paths to resolve any inode changes that may have happened. + // And we need to do it before raising sighup to avoid missing any change. + if let Err(error) = watcher.add_paths(&config_paths) { + error!(message = "Failed to read files to watch.", %error); + break; + } + + debug!(message = "Reloaded paths."); - debug!(message = "Reloaded paths."); - - info!("Configuration file changed."); - if !changed_components.is_empty() { - info!( - internal_log_rate_limit = true, - "Component {:?} configuration changed.", - changed_components.keys() - ); - if changed_components - .iter() - .all(|(_, t)| *t == ComponentType::EnrichmentTable) - { + info!("Configuration file changed."); + if !changed_components.is_empty() { info!( internal_log_rate_limit = true, - "Only enrichment tables have changed." + "Component {:?} configuration changed.", + changed_components.keys() ); - _ = signal_tx.send(crate::signal::SignalTo::ReloadEnrichmentTables).map_err(|error| { + if changed_components + .iter() + .all(|(_, t)| *t == ComponentType::EnrichmentTable) + { + info!( + internal_log_rate_limit = true, + "Only enrichment tables have changed." + ); + _ = signal_tx.send(crate::signal::SignalTo::ReloadEnrichmentTables).map_err(|error| { error!(message = "Unable to reload enrichment tables.", cause = %error, internal_log_rate_limit = true) }); - } else { - _ = signal_tx.send(crate::signal::SignalTo::ReloadComponents(changed_components.into_keys().collect())).map_err(|error| { + } else { + _ = signal_tx.send(crate::signal::SignalTo::ReloadComponents(changed_components.into_keys().collect())).map_err(|error| { error!(message = "Unable to reload component configuration. Restart Vector to reload it.", cause = %error, internal_log_rate_limit = true) }); - } - } else { - _ = signal_tx.send(crate::signal::SignalTo::ReloadFromDisk) + } + } else { + _ = signal_tx.send(crate::signal::SignalTo::ReloadFromDisk) .map_err(|error| { error!(message = "Unable to reload configuration file. Restart Vector to reload it.", cause = %error, internal_log_rate_limit = true) }); + } + } else { + debug!(message = "Ignoring event.", event = ?event) } - } else { - debug!(message = "Ignoring event.", event = ?event) } } - } - thread::sleep(RETRY_TIMEOUT); + thread::sleep(RETRY_TIMEOUT); - watcher = create_watcher(&watcher_conf, &config_paths) - .map_err(|error| error!(message = "Failed to create file watcher.", %error)) - .ok(); + watcher = create_watcher(&watcher_conf, &config_paths) + .map_err(|error| error!(message = "Failed to create file watcher.", %error)) + .ok(); - if watcher.is_some() { - // Config files could have changed while we weren't watching, - // so for a good measure raise SIGHUP and let reload logic - // determine if anything changed. - info!("Speculating that configuration files have changed."); - _ = signal_tx.send(crate::signal::SignalTo::ReloadFromDisk).map_err(|error| { + if watcher.is_some() { + // Config files could have changed while we weren't watching, + // so for a good measure raise SIGHUP and let reload logic + // determine if anything changed. + info!("Speculating that configuration files have changed."); + _ = signal_tx.send(crate::signal::SignalTo::ReloadFromDisk).map_err(|error| { error!(message = "Unable to reload configuration file. Restart Vector to reload it.", cause = %error) }); + } } }); @@ -260,7 +262,7 @@ mod tests { if !test_signal( &mut component_files[0], crate::signal::SignalTo::ReloadComponents(HashSet::from_iter(vec![ - http_component.clone() + http_component.clone(), ])), delay * 5, signal_rx, @@ -273,7 +275,7 @@ mod tests { if !test_signal( &mut component_files[1], crate::signal::SignalTo::ReloadComponents(HashSet::from_iter(vec![ - http_component.clone() + http_component.clone(), ])), delay * 5, signal_rx2, diff --git a/src/convert_config.rs b/src/convert_config.rs index 526838b06cd43..a12200c97ef33 100644 --- a/src/convert_config.rs +++ b/src/convert_config.rs @@ -1,4 +1,4 @@ -use crate::config::{format, ConfigBuilder, Format}; +use crate::config::{ConfigBuilder, Format, format}; use clap::Parser; use colored::*; use std::fs; @@ -207,8 +207,8 @@ fn walk_dir_and_convert( feature = "sinks-console" ))] mod tests { - use crate::config::{format, ConfigBuilder, Format}; - use crate::convert_config::{check_paths, walk_dir_and_convert, Opts}; + use crate::config::{ConfigBuilder, Format, format}; + use crate::convert_config::{Opts, check_paths, walk_dir_and_convert}; use std::path::{Path, PathBuf}; use std::str::FromStr; use std::{env, fs}; diff --git a/src/dns.rs b/src/dns.rs index 5886b4a6a938c..0d6aa3eeae8a9 100644 --- a/src/dns.rs +++ b/src/dns.rs @@ -4,7 +4,7 @@ use std::{ task::{Context, Poll}, }; -use futures::{future::BoxFuture, FutureExt}; +use futures::{FutureExt, future::BoxFuture}; use hyper::client::connect::dns::Name; use snafu::ResultExt; use tokio::task::spawn_blocking; diff --git a/src/docker.rs b/src/docker.rs index 24a1fc429748e..3780405056eea 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -2,6 +2,7 @@ use std::{collections::HashMap, env, path::PathBuf}; use bollard::{ + API_DEFAULT_VERSION, Docker, errors::Error as DockerError, models::HostConfig, query_parameters::{ @@ -9,7 +10,6 @@ use bollard::{ RemoveContainerOptions, StartContainerOptions, StopContainerOptions, }, secret::ContainerCreateBody, - Docker, API_DEFAULT_VERSION, }; use futures::StreamExt; use http::uri::Uri; diff --git a/src/encoding_transcode.rs b/src/encoding_transcode.rs index 92a9c88b6e58b..986c8657b8cdd 100644 --- a/src/encoding_transcode.rs +++ b/src/encoding_transcode.rs @@ -186,9 +186,9 @@ mod tests { use std::char::REPLACEMENT_CHARACTER; use bytes::Bytes; - use encoding_rs::{SHIFT_JIS, UTF_16BE, UTF_16LE, UTF_8}; + use encoding_rs::{SHIFT_JIS, UTF_8, UTF_16BE, UTF_16LE}; - use super::{Decoder, Encoder, BOM_UTF8}; + use super::{BOM_UTF8, Decoder, Encoder}; // BOM unicode character (U+FEFF) expressed in utf-16 // http://unicode.org/faq/utf_bom.html#bom4 diff --git a/src/enrichment_tables/file.rs b/src/enrichment_tables/file.rs index ec234ea10e16c..f20331297aa36 100644 --- a/src/enrichment_tables/file.rs +++ b/src/enrichment_tables/file.rs @@ -5,7 +5,7 @@ use bytes::Bytes; use tracing::trace; use vector_lib::configurable::configurable_component; use vector_lib::enrichment::{Case, Condition, IndexHandle, Table}; -use vector_lib::{conversion::Conversion, TimeZone}; +use vector_lib::{TimeZone, conversion::Conversion}; use vrl::value::{ObjectMap, Value}; use crate::config::EnrichmentTableConfig; diff --git a/src/enrichment_tables/geoip.rs b/src/enrichment_tables/geoip.rs index 6e09105a8c2c3..3758331b82e0e 100644 --- a/src/enrichment_tables/geoip.rs +++ b/src/enrichment_tables/geoip.rs @@ -7,8 +7,8 @@ use std::{collections::BTreeMap, fs, net::IpAddr, path::PathBuf, sync::Arc, time::SystemTime}; use maxminddb::{ - geoip2::{AnonymousIp, City, ConnectionType, Isp}, Reader, + geoip2::{AnonymousIp, City, ConnectionType, Isp}, }; use ordered_float::NotNan; use vector_lib::configurable::configurable_component; diff --git a/src/enrichment_tables/memory/config.rs b/src/enrichment_tables/memory/config.rs index b2fed6384f5c6..ea3db29159a46 100644 --- a/src/enrichment_tables/memory/config.rs +++ b/src/enrichment_tables/memory/config.rs @@ -5,7 +5,7 @@ use crate::sinks::Healthcheck; use crate::sources::Source; use crate::{config::SinkContext, enrichment_tables::memory::Memory}; use async_trait::async_trait; -use futures::{future, FutureExt}; +use futures::{FutureExt, future}; use tokio::sync::Mutex; use vector_lib::config::{AcknowledgementsConfig, DataType, Input, LogNamespace}; use vector_lib::enrichment::Table; diff --git a/src/enrichment_tables/memory/source.rs b/src/enrichment_tables/memory/source.rs index 379ae200c00c0..2dfceeff55086 100644 --- a/src/enrichment_tables/memory/source.rs +++ b/src/enrichment_tables/memory/source.rs @@ -7,6 +7,7 @@ use std::{ use tokio::time::interval; use tokio_stream::wrappers::IntervalStream; use vector_lib::{ + ByteSizeOf, EstimatedJsonEncodedSizeOf, config::LogNamespace, configurable::configurable_component, event::{Event, EventMetadata, LogEvent}, @@ -14,10 +15,9 @@ use vector_lib::{ ByteSize, BytesReceived, CountByteSize, EventsReceived, InternalEventHandle, Protocol, }, shutdown::ShutdownSignal, - ByteSizeOf, EstimatedJsonEncodedSizeOf, }; -use crate::{internal_events::StreamClosedError, SourceSender}; +use crate::{SourceSender, internal_events::StreamClosedError}; use super::{Memory, MemoryConfig}; diff --git a/src/enrichment_tables/memory/table.rs b/src/enrichment_tables/memory/table.rs index 068f6630bfb75..b7d9bafb8c696 100644 --- a/src/enrichment_tables/memory/table.rs +++ b/src/enrichment_tables/memory/table.rs @@ -1,9 +1,11 @@ +#![allow(unsafe_op_in_unsafe_fn)] // TODO review ShallowCopy usage code and fix properly. + +use crate::SourceSender; +use crate::enrichment_tables::memory::MemoryConfig; use crate::enrichment_tables::memory::internal_events::{ MemoryEnrichmentTableFlushed, MemoryEnrichmentTableInsertFailed, MemoryEnrichmentTableInserted, MemoryEnrichmentTableRead, MemoryEnrichmentTableReadFailed, MemoryEnrichmentTableTtlExpired, }; -use crate::enrichment_tables::memory::MemoryConfig; -use crate::SourceSender; use std::sync::{Arc, Mutex, MutexGuard}; use std::time::{Duration, Instant}; @@ -371,7 +373,7 @@ impl StreamSink for Memory { #[cfg(test)] mod tests { - use futures::{future::ready, StreamExt}; + use futures::{StreamExt, future::ready}; use futures_util::stream; use std::{num::NonZeroU64, time::Duration}; use tokio::time; @@ -389,8 +391,8 @@ mod tests { }, event::{Event, LogEvent}, test_util::components::{ - run_and_assert_sink_compliance, run_and_assert_source_compliance, SINK_TAGS, - SOURCE_TAGS, + SINK_TAGS, SOURCE_TAGS, run_and_assert_sink_compliance, + run_and_assert_source_compliance, }, }; @@ -489,11 +491,13 @@ mod tests { memory.scan(writer); // The value is not present anymore - assert!(memory - .find_table_rows(Case::Sensitive, &[condition], None, None, None) - .unwrap() - .pop() - .is_none()); + assert!( + memory + .find_table_rows(Case::Sensitive, &[condition], None, None, None) + .unwrap() + .pop() + .is_none() + ); } #[test] @@ -510,11 +514,13 @@ mod tests { value: Value::from("test_key"), }; - assert!(memory - .find_table_rows(Case::Sensitive, &[condition], None, None, None) - .unwrap() - .pop() - .is_none()); + assert!( + memory + .find_table_rows(Case::Sensitive, &[condition], None, None, None) + .unwrap() + .pop() + .is_none() + ); } #[test] @@ -570,11 +576,13 @@ mod tests { value: Value::from("test_key"), }; - assert!(memory - .find_table_rows(Case::Sensitive, &[condition], None, None, None) - .unwrap() - .pop() - .is_none()); + assert!( + memory + .find_table_rows(Case::Sensitive, &[condition], None, None, None) + .unwrap() + .pop() + .is_none() + ); } #[test] @@ -605,20 +613,22 @@ mod tests { ) ); - assert!(memory - .find_table_rows( - Case::Sensitive, - &[Condition::Equals { - field: "key", - value: Value::from("rejected_key") - }], - None, - None, - None - ) - .unwrap() - .pop() - .is_none()); + assert!( + memory + .find_table_rows( + Case::Sensitive, + &[Condition::Equals { + field: "key", + value: Value::from("rejected_key") + }], + None, + None, + None + ) + .unwrap() + .pop() + .is_none() + ); } #[test] @@ -630,11 +640,13 @@ mod tests { value: Value::from("test_key"), }; - assert!(memory - .find_table_rows(Case::Sensitive, &[condition], None, None, None) - .unwrap() - .pop() - .is_none()); + assert!( + memory + .find_table_rows(Case::Sensitive, &[condition], None, None, None) + .unwrap() + .pop() + .is_none() + ); } #[tokio::test] diff --git a/src/expiring_hash_map.rs b/src/expiring_hash_map.rs index 5993ee43513a4..0345e1d483721 100644 --- a/src/expiring_hash_map.rs +++ b/src/expiring_hash_map.rs @@ -10,7 +10,7 @@ use std::{ }; use futures::StreamExt; -use tokio_util::time::{delay_queue, DelayQueue}; +use tokio_util::time::{DelayQueue, delay_queue}; /// An expired item, holding the value and the key with an expiration information. pub type ExpiredItem = (V, delay_queue::Expired); diff --git a/src/gcp.rs b/src/gcp.rs index d484a063ccd35..4643662428721 100644 --- a/src/gcp.rs +++ b/src/gcp.rs @@ -4,14 +4,14 @@ use std::{ time::Duration, }; -use base64::prelude::{Engine as _, BASE64_URL_SAFE}; +use base64::prelude::{BASE64_URL_SAFE, Engine as _}; pub use goauth::scopes::Scope; use goauth::{ + GoErr, auth::{JwtClaims, Token, TokenErr}, credentials::Credentials, - GoErr, }; -use http::{uri::PathAndQuery, Uri}; +use http::{Uri, uri::PathAndQuery}; use hyper::header::AUTHORIZATION; use smpl_jwt::Jwt; use snafu::{ResultExt, Snafu}; diff --git a/src/generate.rs b/src/generate.rs index 1da6c414c7640..282cfce6457c3 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -1,6 +1,6 @@ #![allow(missing_docs)] use std::{ - fs::{create_dir_all, File}, + fs::{File, create_dir_all}, io::Write, path::{Path, PathBuf}, }; @@ -9,13 +9,13 @@ use clap::Parser; use colored::*; use indexmap::IndexMap; use serde::Serialize; -use toml::{map::Map, Value}; +use toml::{Value, map::Map}; use vector_lib::configurable::component::{ SinkDescription, SourceDescription, TransformDescription, }; use vector_lib::{buffers::BufferConfig, config::GlobalOptions, default_data_dir}; -use crate::config::{format, Format, SinkHealthcheckOptions}; +use crate::config::{Format, SinkHealthcheckOptions, format}; #[derive(Parser, Debug)] #[command(rename_all = "kebab-case")] @@ -201,10 +201,12 @@ pub(crate) fn generate_example( if i == 0 { source_names.clone() } else { - vec![transform_names - .get(i - 1) - .unwrap_or(&"component-id".to_owned()) - .to_owned()] + vec![ + transform_names + .get(i - 1) + .unwrap_or(&"component-id".to_owned()) + .to_owned(), + ] } } #[cfg(test)] diff --git a/src/http.rs b/src/http.rs index bbd716a385817..ad485e6df4477 100644 --- a/src/http.rs +++ b/src/http.rs @@ -2,8 +2,8 @@ use futures::future::BoxFuture; use headers::{Authorization, HeaderMapExt}; use http::{ - header::HeaderValue, request::Builder, uri::InvalidUri, HeaderMap, Request, Response, Uri, - Version, + HeaderMap, Request, Response, Uri, Version, header::HeaderValue, request::Builder, + uri::InvalidUri, }; use hyper::{ body::{Body, HttpBody}, @@ -37,8 +37,8 @@ use crate::aws::AwsAuthentication; use crate::{ config::ProxyConfig, - internal_events::{http_client, HttpServerRequestReceived, HttpServerResponseSent}, - tls::{tls_connector_builder, MaybeTlsSettings, TlsError}, + internal_events::{HttpServerRequestReceived, HttpServerResponseSent, http_client}, + tls::{MaybeTlsSettings, TlsError, tls_connector_builder}, }; pub mod status { @@ -682,7 +682,7 @@ pub type QueryParameters = HashMap; mod tests { use std::convert::Infallible; - use hyper::{server::conn::AddrStream, service::make_service_fn, Server}; + use hyper::{Server, server::conn::AddrStream, service::make_service_fn}; use proptest::prelude::*; use tower::ServiceBuilder; diff --git a/src/internal_events/adaptive_concurrency.rs b/src/internal_events/adaptive_concurrency.rs index e5898295ed79d..f815f7d4e2b4b 100644 --- a/src/internal_events/adaptive_concurrency.rs +++ b/src/internal_events/adaptive_concurrency.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use metrics::{histogram, Histogram}; +use metrics::{Histogram, histogram}; #[derive(Clone, Copy)] pub struct AdaptiveConcurrencyLimitData { diff --git a/src/internal_events/aws_cloudwatch_logs.rs b/src/internal_events/aws_cloudwatch_logs.rs index d4bfe0328a53b..b64253f8cc223 100644 --- a/src/internal_events/aws_cloudwatch_logs.rs +++ b/src/internal_events/aws_cloudwatch_logs.rs @@ -1,6 +1,6 @@ use metrics::counter; use vector_lib::internal_event::InternalEvent; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; #[derive(Debug)] pub struct AwsCloudwatchLogsMessageSizeError { diff --git a/src/internal_events/aws_ecs_metrics.rs b/src/internal_events/aws_ecs_metrics.rs index 1a2f7133094ce..37286c9bfb4aa 100644 --- a/src/internal_events/aws_ecs_metrics.rs +++ b/src/internal_events/aws_ecs_metrics.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use metrics::counter; use vector_lib::{ - internal_event::{error_stage, error_type, InternalEvent}, + internal_event::{InternalEvent, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/aws_kinesis.rs b/src/internal_events/aws_kinesis.rs index 332f55d08b25e..adf6a5c0ee28b 100644 --- a/src/internal_events/aws_kinesis.rs +++ b/src/internal_events/aws_kinesis.rs @@ -1,7 +1,7 @@ /// Used in both `aws_kinesis_streams` and `aws_kinesis_firehose` sinks use metrics::counter; use vector_lib::internal_event::InternalEvent; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; #[derive(Debug)] pub struct AwsKinesisStreamNoPartitionKeyError<'a> { diff --git a/src/internal_events/batch.rs b/src/internal_events/batch.rs index 816afa4398d5f..3a9be8fca24c6 100644 --- a/src/internal_events/batch.rs +++ b/src/internal_events/batch.rs @@ -1,6 +1,6 @@ use metrics::counter; use vector_lib::internal_event::InternalEvent; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; #[derive(Debug)] pub struct LargeEventDroppedError { diff --git a/src/internal_events/codecs.rs b/src/internal_events/codecs.rs index 50251bf089cd3..2182b215cffc5 100644 --- a/src/internal_events/codecs.rs +++ b/src/internal_events/codecs.rs @@ -1,6 +1,6 @@ use metrics::counter; use vector_lib::internal_event::InternalEvent; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; #[derive(Debug)] pub struct DecoderFramingError { diff --git a/src/internal_events/common.rs b/src/internal_events/common.rs index 78971840d7dba..c91e980e96315 100644 --- a/src/internal_events/common.rs +++ b/src/internal_events/common.rs @@ -3,7 +3,7 @@ use std::time::Instant; use metrics::{counter, histogram}; pub use vector_lib::internal_event::EventsReceived; use vector_lib::internal_event::InternalEvent; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; #[derive(Debug)] pub struct EndpointBytesReceived<'a> { diff --git a/src/internal_events/datadog_metrics.rs b/src/internal_events/datadog_metrics.rs index 8875b29281ac7..90fe5177a7fb3 100644 --- a/src/internal_events/datadog_metrics.rs +++ b/src/internal_events/datadog_metrics.rs @@ -1,6 +1,6 @@ use metrics::counter; use vector_lib::internal_event::InternalEvent; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; #[derive(Debug)] pub struct DatadogMetricsEncodingError<'a> { diff --git a/src/internal_events/datadog_traces.rs b/src/internal_events/datadog_traces.rs index dd1df213cdf06..e88797ceef2a1 100644 --- a/src/internal_events/datadog_traces.rs +++ b/src/internal_events/datadog_traces.rs @@ -1,6 +1,6 @@ use metrics::counter; use vector_lib::internal_event::InternalEvent; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; #[derive(Debug)] pub struct DatadogTracesEncodingError { diff --git a/src/internal_events/dedupe.rs b/src/internal_events/dedupe.rs index d88930e0b6e49..c4a781de2c10b 100644 --- a/src/internal_events/dedupe.rs +++ b/src/internal_events/dedupe.rs @@ -1,4 +1,4 @@ -use vector_lib::internal_event::{ComponentEventsDropped, InternalEvent, INTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; #[derive(Debug)] pub struct DedupeEventsDropped { diff --git a/src/internal_events/exec.rs b/src/internal_events/exec.rs index fea1f498b725f..d743cbec05201 100644 --- a/src/internal_events/exec.rs +++ b/src/internal_events/exec.rs @@ -4,7 +4,7 @@ use metrics::{counter, histogram}; use tokio::time::error::Elapsed; use vector_lib::internal_event::InternalEvent; use vector_lib::{ - internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}, + internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/expansion.rs b/src/internal_events/expansion.rs index 62a96afca1068..cf24ebd04248e 100644 --- a/src/internal_events/expansion.rs +++ b/src/internal_events/expansion.rs @@ -1,6 +1,6 @@ use metrics::counter; -use vector_lib::internal_event::{error_stage, error_type}; use vector_lib::internal_event::{ComponentEventsDropped, InternalEvent, UNINTENTIONAL}; +use vector_lib::internal_event::{error_stage, error_type}; pub struct PairExpansionError<'a> { pub key: &'a str, diff --git a/src/internal_events/filter.rs b/src/internal_events/filter.rs index cb54a3685284e..0c7fc73930332 100644 --- a/src/internal_events/filter.rs +++ b/src/internal_events/filter.rs @@ -1,4 +1,4 @@ -use vector_lib::internal_event::{ComponentEventsDropped, Count, Registered, INTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, Count, INTENTIONAL, Registered}; vector_lib::registered_event! ( FilterEventsDropped => { diff --git a/src/internal_events/http_client.rs b/src/internal_events/http_client.rs index a35d290395be3..8af9cc974ad3c 100644 --- a/src/internal_events/http_client.rs +++ b/src/internal_events/http_client.rs @@ -1,10 +1,10 @@ use std::time::Duration; use http::{ - header::{self, HeaderMap, HeaderValue}, Request, Response, + header::{self, HeaderMap, HeaderValue}, }; -use hyper::{body::HttpBody, Error}; +use hyper::{Error, body::HttpBody}; use metrics::{counter, histogram}; use vector_lib::internal_event::InternalEvent; use vector_lib::internal_event::{error_stage, error_type}; diff --git a/src/internal_events/influxdb.rs b/src/internal_events/influxdb.rs index 007f5565f1a8f..4b9d0dfa6b3af 100644 --- a/src/internal_events/influxdb.rs +++ b/src/internal_events/influxdb.rs @@ -1,6 +1,6 @@ use metrics::counter; use vector_lib::internal_event::InternalEvent; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; #[derive(Debug)] pub struct InfluxdbEncodingError { diff --git a/src/internal_events/kubernetes_logs.rs b/src/internal_events/kubernetes_logs.rs index 39d27649cef5e..28ed04fd779ac 100644 --- a/src/internal_events/kubernetes_logs.rs +++ b/src/internal_events/kubernetes_logs.rs @@ -1,7 +1,7 @@ use metrics::counter; -use vector_lib::internal_event::{InternalEvent, INTENTIONAL}; +use vector_lib::internal_event::{INTENTIONAL, InternalEvent}; use vector_lib::{ - internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}, + internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}, json_size::JsonSize, }; use vrl::core::Value; diff --git a/src/internal_events/log_to_metric.rs b/src/internal_events/log_to_metric.rs index 0469cdacdd047..0bf851330dade 100644 --- a/src/internal_events/log_to_metric.rs +++ b/src/internal_events/log_to_metric.rs @@ -2,7 +2,7 @@ use std::num::ParseFloatError; use metrics::counter; use vector_lib::internal_event::InternalEvent; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; pub struct LogToMetricFieldNullError<'a> { pub field: &'a str, diff --git a/src/internal_events/loki.rs b/src/internal_events/loki.rs index 2c95d524c655f..d251771994909 100644 --- a/src/internal_events/loki.rs +++ b/src/internal_events/loki.rs @@ -1,6 +1,6 @@ use metrics::counter; +use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; use vector_lib::internal_event::{error_stage, error_type}; -use vector_lib::internal_event::{ComponentEventsDropped, InternalEvent, INTENTIONAL}; #[derive(Debug)] pub struct LokiEventUnlabeledError; diff --git a/src/internal_events/lua.rs b/src/internal_events/lua.rs index 2805b5b57917d..f39070fcb6c64 100644 --- a/src/internal_events/lua.rs +++ b/src/internal_events/lua.rs @@ -1,6 +1,6 @@ use metrics::{counter, gauge}; use vector_lib::internal_event::InternalEvent; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; use crate::transforms::lua::v2::BuildError; diff --git a/src/internal_events/metric_to_log.rs b/src/internal_events/metric_to_log.rs index 79a9d117054a8..a7a3e19253c02 100644 --- a/src/internal_events/metric_to_log.rs +++ b/src/internal_events/metric_to_log.rs @@ -1,7 +1,7 @@ use metrics::counter; use serde_json::Error; use vector_lib::internal_event::InternalEvent; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; #[derive(Debug)] pub struct MetricToLogSerializeError { diff --git a/src/internal_events/open.rs b/src/internal_events/open.rs index b5a58d4011567..ccd9d8cf5411a 100644 --- a/src/internal_events/open.rs +++ b/src/internal_events/open.rs @@ -1,8 +1,8 @@ use std::{ hint, sync::{ - atomic::{AtomicUsize, Ordering}, Arc, + atomic::{AtomicUsize, Ordering}, }, }; diff --git a/src/internal_events/parser.rs b/src/internal_events/parser.rs index 84cd0556b4821..686b55c1356a6 100644 --- a/src/internal_events/parser.rs +++ b/src/internal_events/parser.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use metrics::counter; use vector_lib::internal_event::InternalEvent; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; fn truncate_string_at(s: &str, maxlen: usize) -> Cow { let ellipsis: &str = "[...]"; diff --git a/src/internal_events/prometheus.rs b/src/internal_events/prometheus.rs index 752e8e238fac4..6aebb7deb9e79 100644 --- a/src/internal_events/prometheus.rs +++ b/src/internal_events/prometheus.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use metrics::counter; use vector_lib::internal_event::InternalEvent; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; #[cfg(feature = "sources-prometheus-scrape")] use vector_lib::prometheus::parser::ParserError; diff --git a/src/internal_events/pulsar.rs b/src/internal_events/pulsar.rs index c03dea3870086..62787ed5e58c6 100644 --- a/src/internal_events/pulsar.rs +++ b/src/internal_events/pulsar.rs @@ -1,8 +1,8 @@ -use metrics::counter; #[cfg(feature = "sources-pulsar")] use metrics::Counter; +use metrics::counter; use vector_lib::internal_event::{ - error_stage, error_type, ComponentEventsDropped, InternalEvent, UNINTENTIONAL, + ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; #[derive(Debug)] diff --git a/src/internal_events/reduce.rs b/src/internal_events/reduce.rs index b9887aaf54bb7..87b68b89d423b 100644 --- a/src/internal_events/reduce.rs +++ b/src/internal_events/reduce.rs @@ -1,5 +1,5 @@ use metrics::counter; -use vector_lib::internal_event::{error_stage, error_type, InternalEvent}; +use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; use vrl::path::PathParseError; use vrl::value::KeyString; diff --git a/src/internal_events/remap.rs b/src/internal_events/remap.rs index d05e6dfb9c874..0275262655c76 100644 --- a/src/internal_events/remap.rs +++ b/src/internal_events/remap.rs @@ -1,7 +1,7 @@ use metrics::counter; use vector_lib::internal_event::InternalEvent; use vector_lib::internal_event::{ - error_stage, error_type, ComponentEventsDropped, INTENTIONAL, UNINTENTIONAL, + ComponentEventsDropped, INTENTIONAL, UNINTENTIONAL, error_stage, error_type, }; #[derive(Debug)] diff --git a/src/internal_events/sample.rs b/src/internal_events/sample.rs index c113b2df545f7..c502272908115 100644 --- a/src/internal_events/sample.rs +++ b/src/internal_events/sample.rs @@ -1,4 +1,4 @@ -use vector_lib::internal_event::{ComponentEventsDropped, InternalEvent, INTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; #[derive(Debug)] pub struct SampleEventDiscarded; diff --git a/src/internal_events/sematext_metrics.rs b/src/internal_events/sematext_metrics.rs index b4b5be737fb2e..41ebe60fedd8a 100644 --- a/src/internal_events/sematext_metrics.rs +++ b/src/internal_events/sematext_metrics.rs @@ -1,6 +1,6 @@ use metrics::counter; use vector_lib::internal_event::InternalEvent; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; use crate::event::metric::Metric; diff --git a/src/internal_events/splunk_hec.rs b/src/internal_events/splunk_hec.rs index 4ff5838cdc0b7..52232f36240e5 100644 --- a/src/internal_events/splunk_hec.rs +++ b/src/internal_events/splunk_hec.rs @@ -11,7 +11,7 @@ mod sink { use serde_json::Error; use vector_lib::internal_event::InternalEvent; use vector_lib::internal_event::{ - error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL, + ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type, }; use crate::{ diff --git a/src/internal_events/statsd_sink.rs b/src/internal_events/statsd_sink.rs index 165ef885eabbd..c22af8f6cbf00 100644 --- a/src/internal_events/statsd_sink.rs +++ b/src/internal_events/statsd_sink.rs @@ -2,7 +2,7 @@ use metrics::counter; use vector_lib::internal_event::InternalEvent; use crate::event::metric::{MetricKind, MetricValue}; -use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL, error_stage, error_type}; #[derive(Debug)] pub struct StatsdInvalidMetricError<'a> { diff --git a/src/internal_events/tag_cardinality_limit.rs b/src/internal_events/tag_cardinality_limit.rs index 4c0c315eb11c1..9db97e39f44b9 100644 --- a/src/internal_events/tag_cardinality_limit.rs +++ b/src/internal_events/tag_cardinality_limit.rs @@ -1,5 +1,5 @@ use metrics::counter; -use vector_lib::internal_event::{ComponentEventsDropped, InternalEvent, INTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; pub struct TagCardinalityLimitRejectingEvent<'a> { pub metric_name: &'a str, diff --git a/src/internal_events/tcp.rs b/src/internal_events/tcp.rs index 23ec1fc88e830..5ff074a158172 100644 --- a/src/internal_events/tcp.rs +++ b/src/internal_events/tcp.rs @@ -1,7 +1,7 @@ use std::net::SocketAddr; use metrics::counter; -use vector_lib::internal_event::{error_stage, error_type, InternalEvent}; +use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; use crate::{internal_events::SocketOutgoingConnectionError, tls::TlsError}; diff --git a/src/internal_events/template.rs b/src/internal_events/template.rs index 6ecc62b859363..5d16bc46c7aec 100644 --- a/src/internal_events/template.rs +++ b/src/internal_events/template.rs @@ -1,6 +1,6 @@ use metrics::counter; -use vector_lib::internal_event::{error_stage, error_type}; use vector_lib::internal_event::{ComponentEventsDropped, InternalEvent, UNINTENTIONAL}; +use vector_lib::internal_event::{error_stage, error_type}; pub struct TemplateRenderingError<'a> { pub field: Option<&'a str>, diff --git a/src/internal_events/throttle.rs b/src/internal_events/throttle.rs index 3bbc67be88db8..5999033d4b1fe 100644 --- a/src/internal_events/throttle.rs +++ b/src/internal_events/throttle.rs @@ -1,5 +1,5 @@ use metrics::counter; -use vector_lib::internal_event::{ComponentEventsDropped, InternalEvent, INTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; #[derive(Debug)] pub(crate) struct ThrottleEventDiscarded { diff --git a/src/internal_events/udp.rs b/src/internal_events/udp.rs index 15e9df4c2b07b..26f63aa879065 100644 --- a/src/internal_events/udp.rs +++ b/src/internal_events/udp.rs @@ -1,6 +1,6 @@ use metrics::counter; use vector_lib::internal_event::{ - error_stage, error_type, ComponentEventsDropped, InternalEvent, UNINTENTIONAL, + ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; use crate::internal_events::SocketOutgoingConnectionError; diff --git a/src/internal_events/unix.rs b/src/internal_events/unix.rs index a45777ab8f2e1..90caae1e32274 100644 --- a/src/internal_events/unix.rs +++ b/src/internal_events/unix.rs @@ -2,7 +2,7 @@ use std::{io::Error, path::Path}; use metrics::counter; use vector_lib::internal_event::{ - error_stage, error_type, ComponentEventsDropped, InternalEvent, UNINTENTIONAL, + ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; use crate::internal_events::SocketOutgoingConnectionError; diff --git a/src/internal_events/window.rs b/src/internal_events/window.rs index 5b2f666edcb11..42eb62203ef51 100644 --- a/src/internal_events/window.rs +++ b/src/internal_events/window.rs @@ -1,4 +1,4 @@ -use vector_lib::internal_event::{ComponentEventsDropped, Count, Registered, INTENTIONAL}; +use vector_lib::internal_event::{ComponentEventsDropped, Count, INTENTIONAL, Registered}; vector_lib::registered_event!( WindowEventsDropped => { diff --git a/src/internal_telemetry/allocations/allocator/stack.rs b/src/internal_telemetry/allocations/allocator/stack.rs index 2ac8bab15410a..1772be0125138 100644 --- a/src/internal_telemetry/allocations/allocator/stack.rs +++ b/src/internal_telemetry/allocations/allocator/stack.rs @@ -33,7 +33,9 @@ impl GroupStack { pub fn push(&mut self, group: AllocationGroupId) { self.current_top += 1; if self.current_top >= self.slots.len() { - panic!("tried to push new allocation group to the current stack, but hit the limit of {N} entries"); + panic!( + "tried to push new allocation group to the current stack, but hit the limit of {N} entries" + ); } self.slots[self.current_top] = group; } diff --git a/src/internal_telemetry/allocations/allocator/tracing.rs b/src/internal_telemetry/allocations/allocator/tracing.rs index ba768b8704e98..470424f1da185 100644 --- a/src/internal_telemetry/allocations/allocator/tracing.rs +++ b/src/internal_telemetry/allocations/allocator/tracing.rs @@ -1,7 +1,7 @@ use std::{any::TypeId, marker::PhantomData, ptr::addr_of}; use tracing::{Dispatch, Id, Subscriber}; -use tracing_subscriber::{layer::Context, registry::LookupSpan, Layer}; +use tracing_subscriber::{Layer, layer::Context, registry::LookupSpan}; use super::AllocationGroupToken; diff --git a/src/internal_telemetry/allocations/allocator/tracing_allocator.rs b/src/internal_telemetry/allocations/allocator/tracing_allocator.rs index dc189c35c239e..241c24e583e9e 100644 --- a/src/internal_telemetry/allocations/allocator/tracing_allocator.rs +++ b/src/internal_telemetry/allocations/allocator/tracing_allocator.rs @@ -6,7 +6,7 @@ use std::{ use crate::internal_telemetry::allocations::TRACK_ALLOCATIONS; use super::{ - token::{try_with_suspended_allocation_group, AllocationGroupId}, + token::{AllocationGroupId, try_with_suspended_allocation_group}, tracer::Tracer, }; diff --git a/src/internal_telemetry/allocations/mod.rs b/src/internal_telemetry/allocations/mod.rs index 477afc9b65ed2..481cc80e7ced6 100644 --- a/src/internal_telemetry/allocations/mod.rs +++ b/src/internal_telemetry/allocations/mod.rs @@ -3,8 +3,8 @@ mod allocator; use std::{ sync::{ - atomic::{AtomicBool, AtomicU64, Ordering}, Mutex, + atomic::{AtomicBool, AtomicU64, Ordering}, }, thread, time::Duration, @@ -17,7 +17,7 @@ use rand_distr::num_traits::ToPrimitive; use self::allocator::Tracer; pub(crate) use self::allocator::{ - without_allocation_tracing, AllocationGroupId, AllocationLayer, GroupedTraceableAllocator, + AllocationGroupId, AllocationLayer, GroupedTraceableAllocator, without_allocation_tracing, }; const NUM_GROUPS: usize = 256; @@ -203,6 +203,9 @@ pub fn acquire_allocation_group_id( } } - warn!("Maximum number of registrable allocation group IDs reached ({}). Allocations for component '{}' will be attributed to the root allocation group.", NUM_GROUPS, component_id); + warn!( + "Maximum number of registrable allocation group IDs reached ({}). Allocations for component '{}' will be attributed to the root allocation group.", + NUM_GROUPS, component_id + ); AllocationGroupId::ROOT } diff --git a/src/kafka.rs b/src/kafka.rs index 8567d19a0613d..902129d3ec4c9 100644 --- a/src/kafka.rs +++ b/src/kafka.rs @@ -1,14 +1,14 @@ #![allow(missing_docs)] use std::path::{Path, PathBuf}; -use rdkafka::{consumer::ConsumerContext, ClientConfig, ClientContext, Statistics}; +use rdkafka::{ClientConfig, ClientContext, Statistics, consumer::ConsumerContext}; use snafu::Snafu; use tracing::Span; use vector_lib::configurable::configurable_component; use vector_lib::sensitive_string::SensitiveString; use crate::{ - internal_events::KafkaStatisticsReceived, tls::TlsEnableableConfig, tls::PEM_START_MARKER, + internal_events::KafkaStatisticsReceived, tls::PEM_START_MARKER, tls::TlsEnableableConfig, }; #[derive(Debug, Snafu)] diff --git a/src/kubernetes/reflector.rs b/src/kubernetes/reflector.rs index 14460c73981a6..998b02bd28175 100644 --- a/src/kubernetes/reflector.rs +++ b/src/kubernetes/reflector.rs @@ -5,8 +5,8 @@ use std::{hash::Hash, sync::Arc, time::Duration}; use futures::StreamExt; use futures_util::Stream; use kube::{ - runtime::{reflector::store, watcher}, Resource, + runtime::{reflector::store, watcher}, }; use tokio::pin; use tokio_util::time::DelayQueue; @@ -132,12 +132,12 @@ mod tests { use futures_util::SinkExt; use k8s_openapi::{api::core::v1::ConfigMap, apimachinery::pkg::apis::meta::v1::ObjectMeta}; use kube::runtime::{ - reflector::{store, ObjectRef}, + reflector::{ObjectRef, store}, watcher, }; - use super::custom_reflector; use super::MetaCache; + use super::custom_reflector; #[tokio::test] async fn applied_should_add_object() { diff --git a/src/lib.rs b/src/lib.rs index cc2bb8b59ae54..a1885af68f333 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -130,8 +130,8 @@ pub mod validate; pub mod vector_windows; pub use source_sender::SourceSender; +pub use vector_lib::{Error, Result, shutdown}; pub use vector_lib::{event, metrics, schema, tcp, tls}; -pub use vector_lib::{shutdown, Error, Result}; static APP_NAME_SLUG: std::sync::OnceLock = std::sync::OnceLock::new(); diff --git a/src/line_agg.rs b/src/line_agg.rs index 25693fb21783a..80a4f8c081591 100644 --- a/src/line_agg.rs +++ b/src/line_agg.rs @@ -3,7 +3,7 @@ #![deny(missing_docs)] use std::{ - collections::{hash_map::Entry, HashMap}, + collections::{HashMap, hash_map::Entry}, hash::Hash, pin::Pin, task::{Context, Poll}, diff --git a/src/main.rs b/src/main.rs index eedc25bb43531..6129f1948a488 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ fn main() -> ExitCode { #[cfg(feature = "allocation-tracing")] { use crate::vector::internal_telemetry::allocations::{ - init_allocation_tracing, REPORTING_INTERVAL_MS, TRACK_ALLOCATIONS, + REPORTING_INTERVAL_MS, TRACK_ALLOCATIONS, init_allocation_tracing, }; use std::sync::atomic::Ordering; let opts = vector::cli::Opts::get_matches() diff --git a/src/providers/http.rs b/src/providers/http.rs index d2d5d6a7eb2b5..5f6f6b1d280b8 100644 --- a/src/providers/http.rs +++ b/src/providers/http.rs @@ -8,7 +8,7 @@ use url::Url; use vector_lib::configurable::configurable_component; use crate::{ - config::{self, provider::ProviderConfig, Format, ProxyConfig}, + config::{self, Format, ProxyConfig, provider::ProviderConfig}, http::HttpClient, signal, tls::{TlsConfig, TlsSettings}, diff --git a/src/providers/mod.rs b/src/providers/mod.rs index 1a7f8a1ab97e8..f7896432918cd 100644 --- a/src/providers/mod.rs +++ b/src/providers/mod.rs @@ -1,6 +1,6 @@ #![allow(missing_docs)] use enum_dispatch::enum_dispatch; -use vector_lib::configurable::{configurable_component, NamedComponent}; +use vector_lib::configurable::{NamedComponent, configurable_component}; use crate::{ config::{ConfigBuilder, ProviderConfig}, diff --git a/src/secrets/aws_secrets_manager.rs b/src/secrets/aws_secrets_manager.rs index 3d402536c2754..bf2c6865e1fc7 100644 --- a/src/secrets/aws_secrets_manager.rs +++ b/src/secrets/aws_secrets_manager.rs @@ -1,9 +1,9 @@ use std::collections::{HashMap, HashSet}; -use aws_sdk_secretsmanager::{config, Client}; +use aws_sdk_secretsmanager::{Client, config}; use vector_lib::configurable::{component::GenerateConfig, configurable_component}; -use crate::aws::{create_client, AwsAuthentication, ClientBuilder, RegionOrEndpoint}; +use crate::aws::{AwsAuthentication, ClientBuilder, RegionOrEndpoint, create_client}; use crate::config::ProxyConfig; use crate::tls::TlsConfig; use crate::{config::SecretBackend, signal}; diff --git a/src/serde.rs b/src/serde.rs index 2bee11583e0ad..29b28f732fdd5 100644 --- a/src/serde.rs +++ b/src/serde.rs @@ -2,8 +2,8 @@ use indexmap::map::IndexMap; use serde::{Deserialize, Serialize}; use vector_lib::codecs::{ - decoding::{DeserializerConfig, FramingConfig}, BytesDecoderConfig, BytesDeserializerConfig, + decoding::{DeserializerConfig, FramingConfig}, }; use vector_lib::configurable::configurable_component; pub use vector_lib::serde::{bool_or_struct, is_default}; diff --git a/src/service.rs b/src/service.rs index 7059e424b7840..08283dba9f05b 100644 --- a/src/service.rs +++ b/src/service.rs @@ -200,7 +200,9 @@ pub fn cmd(opts: &Opts) -> exitcode::ExitCode { } }, None => { - error!("You must specify a sub command. Valid sub commands are [start, stop, restart, install, uninstall]."); + error!( + "You must specify a sub command. Valid sub commands are [start, stop, restart, install, uninstall]." + ); exitcode::USAGE } } diff --git a/src/signal.rs b/src/signal.rs index af0d01d1c3d60..6745448caea12 100644 --- a/src/signal.rs +++ b/src/signal.rs @@ -72,7 +72,15 @@ impl SignalPair { /// Create a new signal handler pair, and set them up to receive OS signals. pub fn new(runtime: &Runtime) -> Self { let (handler, receiver) = SignalHandler::new(); + + #[cfg(unix)] let signals = os_signals(runtime); + + // If we passed `runtime` here, we would get the following: + // error[E0521]: borrowed data escapes outside of associated function + #[cfg(windows)] + let signals = os_signals(); + handler.forever(runtime, signals); Self { handler, receiver } } @@ -177,7 +185,7 @@ impl SignalHandler { /// Signals from OS/user. #[cfg(unix)] fn os_signals(runtime: &Runtime) -> impl Stream + use<> { - use tokio::signal::unix::{signal, SignalKind}; + use tokio::signal::unix::{SignalKind, signal}; // The `signal` function must be run within the context of a Tokio runtime. runtime.block_on(async { @@ -215,7 +223,7 @@ fn os_signals(runtime: &Runtime) -> impl Stream + use<> { /// Signals from OS/user. #[cfg(windows)] -fn os_signals(_: &Runtime) -> impl Stream { +fn os_signals() -> impl Stream { use futures::future::FutureExt; async_stream::stream! { diff --git a/src/sink_ext.rs b/src/sink_ext.rs index f1d1ad3ca8656..8267712d5ed20 100644 --- a/src/sink_ext.rs +++ b/src/sink_ext.rs @@ -28,10 +28,10 @@ use std::{ future::Future, pin::Pin, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, }; -use futures::{stream::Peekable, Sink, SinkExt, Stream, StreamExt}; +use futures::{Sink, SinkExt, Stream, StreamExt, stream::Peekable}; impl VecSinkExt for T where T: Sink {} diff --git a/src/sinks/amqp/config.rs b/src/sinks/amqp/config.rs index afca8b47ccae5..5b747d77b4f5a 100644 --- a/src/sinks/amqp/config.rs +++ b/src/sinks/amqp/config.rs @@ -1,7 +1,7 @@ //! Configuration functionality for the `AMQP` sink. use super::channel::AmqpSinkChannels; use crate::{amqp::AmqpConfig, sinks::prelude::*}; -use lapin::{types::ShortString, BasicProperties}; +use lapin::{BasicProperties, types::ShortString}; use vector_lib::{ codecs::TextSerializerConfig, internal_event::{error_stage, error_type}, @@ -164,7 +164,7 @@ pub(super) async fn healthcheck(channels: AmqpSinkChannels) -> crate::Result<()> #[cfg(test)] mod tests { use super::*; - use crate::config::format::{deserialize, Format}; + use crate::config::format::{Format, deserialize}; #[test] pub fn generate_config() { diff --git a/src/sinks/amqp/integration_tests.rs b/src/sinks/amqp/integration_tests.rs index be30e93a6a37b..64acb267ac9aa 100644 --- a/src/sinks/amqp/integration_tests.rs +++ b/src/sinks/amqp/integration_tests.rs @@ -1,15 +1,15 @@ use super::*; use crate::{ + SourceSender, amqp::await_connection, config::{SinkConfig, SinkContext}, shutdown::ShutdownSignal, sinks::amqp::channel::new_channel_pool, template::{Template, UnsignedIntTemplate}, test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, random_lines_with_stream, random_string, }, - SourceSender, }; use config::AmqpPropertiesConfig; use futures::StreamExt; diff --git a/src/sinks/amqp/service.rs b/src/sinks/amqp/service.rs index cee7d20344bd7..3875907d4ce4d 100644 --- a/src/sinks/amqp/service.rs +++ b/src/sinks/amqp/service.rs @@ -3,7 +3,7 @@ use crate::sinks::prelude::*; use bytes::Bytes; use futures::future::BoxFuture; -use lapin::{options::BasicPublishOptions, BasicProperties}; +use lapin::{BasicProperties, options::BasicPublishOptions}; use snafu::Snafu; use std::task::{Context, Poll}; diff --git a/src/sinks/amqp/sink.rs b/src/sinks/amqp/sink.rs index ca40fe46b21e5..17ebbcc68ba78 100644 --- a/src/sinks/amqp/sink.rs +++ b/src/sinks/amqp/sink.rs @@ -6,11 +6,11 @@ use serde::Serialize; use super::channel::AmqpSinkChannels; use super::{ + BuildError, config::{AmqpPropertiesConfig, AmqpSinkConfig}, encoder::AmqpEncoder, request_builder::AmqpRequestBuilder, service::AmqpService, - BuildError, }; /// Stores the event together with the rendered exchange and routing_key values. diff --git a/src/sinks/appsignal/config.rs b/src/sinks/appsignal/config.rs index 0ba840c303da6..c5c80720a37a9 100644 --- a/src/sinks/appsignal/config.rs +++ b/src/sinks/appsignal/config.rs @@ -1,11 +1,11 @@ use futures::FutureExt; -use http::{header::AUTHORIZATION, Request, Uri}; +use http::{Request, Uri, header::AUTHORIZATION}; use hyper::Body; use tower::ServiceBuilder; use vector_lib::configurable::configurable_component; use vector_lib::sensitive_string::SensitiveString; use vector_lib::{ - config::{proxy::ProxyConfig, AcknowledgementsConfig, DataType, Input}, + config::{AcknowledgementsConfig, DataType, Input, proxy::ProxyConfig}, tls::{MaybeTlsSettings, TlsEnableableConfig}, }; @@ -13,12 +13,12 @@ use crate::{ codecs::Transformer, http::HttpClient, sinks::{ + BuildError, Healthcheck, HealthcheckError, VectorSink, prelude::{SinkConfig, SinkContext}, util::{ - http::HttpStatusRetryLogic, BatchConfig, Compression, ServiceBuilderExt, - SinkBatchSettings, TowerRequestConfig, + BatchConfig, Compression, ServiceBuilderExt, SinkBatchSettings, TowerRequestConfig, + http::HttpStatusRetryLogic, }, - BuildError, Healthcheck, HealthcheckError, VectorSink, }, }; @@ -169,7 +169,7 @@ pub fn endpoint_uri(endpoint: &str, path: &str) -> crate::Result { #[cfg(test)] mod test { - use super::{endpoint_uri, AppsignalConfig}; + use super::{AppsignalConfig, endpoint_uri}; #[test] fn generate_config() { diff --git a/src/sinks/appsignal/encoder.rs b/src/sinks/appsignal/encoder.rs index ccd20415acd86..baee19b2f56ff 100644 --- a/src/sinks/appsignal/encoder.rs +++ b/src/sinks/appsignal/encoder.rs @@ -1,10 +1,10 @@ -use serde_json::{json, Value}; +use serde_json::{Value, json}; use vector_lib::request_metadata::GroupedCountByteSize; -use vector_lib::{config::telemetry, event::Event, EstimatedJsonEncodedSizeOf}; +use vector_lib::{EstimatedJsonEncodedSizeOf, config::telemetry, event::Event}; use crate::{ codecs::Transformer, - sinks::util::encoding::{as_tracked_write, Encoder}, + sinks::util::encoding::{Encoder, as_tracked_write}, }; #[derive(Clone)] @@ -31,7 +31,7 @@ impl Encoder> for AppsignalEncoder { _ => { return Err(std::io::Error::other(format!( "The AppSignal sink does not support this type of event: {event:?}" - ))) + ))); } }; if let Value::Array(ref mut array) = result { diff --git a/src/sinks/appsignal/integration_tests.rs b/src/sinks/appsignal/integration_tests.rs index 6509b805c6cde..198e0c6b4379b 100644 --- a/src/sinks/appsignal/integration_tests.rs +++ b/src/sinks/appsignal/integration_tests.rs @@ -1,5 +1,5 @@ use bytes::Bytes; -use futures::{channel::mpsc::Receiver, stream, StreamExt}; +use futures::{StreamExt, channel::mpsc::Receiver, stream}; use http::header::AUTHORIZATION; use hyper::StatusCode; use indoc::indoc; @@ -13,8 +13,8 @@ use crate::{ sinks::util::test::{build_test_server_status, load_sink}, test_util::{ components::{ - assert_sink_compliance, assert_sink_error, run_and_assert_sink_compliance, - COMPONENT_ERROR_TAGS, HTTP_SINK_TAGS, + COMPONENT_ERROR_TAGS, HTTP_SINK_TAGS, assert_sink_compliance, assert_sink_error, + run_and_assert_sink_compliance, }, generate_lines_with_stream, map_event_batch_stream, next_addr, }, diff --git a/src/sinks/appsignal/request_builder.rs b/src/sinks/appsignal/request_builder.rs index 7a2dddd0f9852..328e647d52693 100644 --- a/src/sinks/appsignal/request_builder.rs +++ b/src/sinks/appsignal/request_builder.rs @@ -8,7 +8,7 @@ use vector_lib::{ }; use crate::sinks::util::{ - metadata::RequestMetadataBuilder, request_builder::EncodeResult, Compression, RequestBuilder, + Compression, RequestBuilder, metadata::RequestMetadataBuilder, request_builder::EncodeResult, }; use super::encoder::AppsignalEncoder; diff --git a/src/sinks/appsignal/service.rs b/src/sinks/appsignal/service.rs index 0944eae962dc6..23f80a0323017 100644 --- a/src/sinks/appsignal/service.rs +++ b/src/sinks/appsignal/service.rs @@ -5,7 +5,7 @@ use futures::{ future, future::{BoxFuture, Ready}, }; -use http::{header::AUTHORIZATION, Request, StatusCode, Uri}; +use http::{Request, StatusCode, Uri, header::AUTHORIZATION}; use hyper::Body; use tower::{Service, ServiceExt}; @@ -17,7 +17,7 @@ use vector_lib::{ use crate::{ http::HttpClient, - sinks::util::{http::HttpBatchService, sink::Response, Compression}, + sinks::util::{Compression, http::HttpBatchService, sink::Response}, }; use super::request_builder::AppsignalRequest; diff --git a/src/sinks/appsignal/tests.rs b/src/sinks/appsignal/tests.rs index a93c67ec158b1..69c37c162c734 100644 --- a/src/sinks/appsignal/tests.rs +++ b/src/sinks/appsignal/tests.rs @@ -6,7 +6,7 @@ use vector_lib::event::{Event, LogEvent}; use crate::{ config::{SinkConfig, SinkContext}, test_util::{ - components::{run_and_assert_sink_compliance, HTTP_SINK_TAGS}, + components::{HTTP_SINK_TAGS, run_and_assert_sink_compliance}, http::{always_200_response, spawn_blackhole_http_server}, }, }; diff --git a/src/sinks/aws_cloudwatch_logs/config.rs b/src/sinks/aws_cloudwatch_logs/config.rs index c0f3afcb0e5ee..2822a6fdc03e9 100644 --- a/src/sinks/aws_cloudwatch_logs/config.rs +++ b/src/sinks/aws_cloudwatch_logs/config.rs @@ -1,6 +1,6 @@ use aws_sdk_cloudwatchlogs::Client as CloudwatchLogsClient; use futures::FutureExt; -use serde::{de, Deserialize, Deserializer}; +use serde::{Deserialize, Deserializer, de}; use std::collections::HashMap; use tower::ServiceBuilder; use vector_lib::codecs::JsonSerializerConfig; @@ -9,21 +9,21 @@ use vector_lib::schema; use vrl::value::Kind; use crate::{ - aws::{create_client, AwsAuthentication, ClientBuilder, RegionOrEndpoint}, + aws::{AwsAuthentication, ClientBuilder, RegionOrEndpoint, create_client}, codecs::{Encoder, EncodingConfig}, config::{ AcknowledgementsConfig, DataType, GenerateConfig, Input, ProxyConfig, SinkConfig, SinkContext, }, sinks::{ + Healthcheck, VectorSink, aws_cloudwatch_logs::{ healthcheck::healthcheck, request_builder::CloudwatchRequestBuilder, retry::CloudwatchRetryLogic, service::CloudwatchLogsPartitionSvc, sink::CloudwatchSink, }, util::{ - http::RequestConfig, BatchConfig, Compression, ServiceBuilderExt, SinkBatchSettings, + BatchConfig, Compression, ServiceBuilderExt, SinkBatchSettings, http::RequestConfig, }, - Healthcheck, VectorSink, }, template::Template, tls::TlsConfig, diff --git a/src/sinks/aws_cloudwatch_logs/healthcheck.rs b/src/sinks/aws_cloudwatch_logs/healthcheck.rs index b8a4dd3017d30..965b12ae8baa2 100644 --- a/src/sinks/aws_cloudwatch_logs/healthcheck.rs +++ b/src/sinks/aws_cloudwatch_logs/healthcheck.rs @@ -1,6 +1,6 @@ +use aws_sdk_cloudwatchlogs::Client as CloudwatchLogsClient; use aws_sdk_cloudwatchlogs::error::SdkError; use aws_sdk_cloudwatchlogs::operation::describe_log_groups::DescribeLogGroupsError; -use aws_sdk_cloudwatchlogs::Client as CloudwatchLogsClient; use snafu::Snafu; use crate::sinks::aws_cloudwatch_logs::config::CloudwatchLogsSinkConfig; @@ -58,7 +58,9 @@ pub async fn healthcheck( info!("Skipping healthcheck log group check: `group_name` is dynamic."); Ok(()) } else if config.create_missing_group { - info!("Skipping healthcheck log group check: `group_name` will be created if missing."); + info!( + "Skipping healthcheck log group check: `group_name` will be created if missing." + ); Ok(()) } else { Err(HealthcheckError::NoLogGroup.into()) diff --git a/src/sinks/aws_cloudwatch_logs/integration_tests.rs b/src/sinks/aws_cloudwatch_logs/integration_tests.rs index b365de7d812c1..5e30910e683f0 100644 --- a/src/sinks/aws_cloudwatch_logs/integration_tests.rs +++ b/src/sinks/aws_cloudwatch_logs/integration_tests.rs @@ -5,22 +5,22 @@ use aws_config::Region; use aws_sdk_cloudwatchlogs::Client as CloudwatchLogsClient; use aws_sdk_kms::Client as KMSClient; use chrono::Duration; -use futures::{stream, StreamExt}; +use futures::{StreamExt, stream}; use similar_asserts::assert_eq; use vector_lib::codecs::TextSerializerConfig; use vector_lib::lookup; use super::*; -use crate::aws::{create_client, ClientBuilder}; use crate::aws::{AwsAuthentication, RegionOrEndpoint}; +use crate::aws::{ClientBuilder, create_client}; use crate::sinks::aws_cloudwatch_logs::config::CloudwatchLogsClientBuilder; use crate::{ - config::{log_schema, ProxyConfig, SinkConfig, SinkContext}, + config::{ProxyConfig, SinkConfig, SinkContext, log_schema}, event::{Event, LogEvent, Value}, sinks::util::BatchConfig, template::Template, test_util::{ - components::{run_and_assert_sink_compliance, AWS_SINK_TAGS}, + components::{AWS_SINK_TAGS, run_and_assert_sink_compliance}, random_lines, random_lines_with_stream, random_string, trace_init, }, }; diff --git a/src/sinks/aws_cloudwatch_logs/request.rs b/src/sinks/aws_cloudwatch_logs/request.rs index e052c05d38578..23ea35efe36d0 100644 --- a/src/sinks/aws_cloudwatch_logs/request.rs +++ b/src/sinks/aws_cloudwatch_logs/request.rs @@ -1,4 +1,5 @@ use aws_sdk_cloudwatchlogs::{ + Client as CloudwatchLogsClient, operation::{ create_log_group::CreateLogGroupError, create_log_stream::CreateLogStreamError, @@ -7,17 +8,16 @@ use aws_sdk_cloudwatchlogs::{ put_retention_policy::PutRetentionPolicyError, }, types::InputLogEvent, - Client as CloudwatchLogsClient, }; use aws_smithy_runtime_api::client::{orchestrator::HttpResponse, result::SdkError}; -use futures::{future::BoxFuture, FutureExt}; -use http::{header::HeaderName, HeaderValue}; +use futures::{FutureExt, future::BoxFuture}; +use http::{HeaderValue, header::HeaderName}; use indexmap::IndexMap; use std::collections::HashMap; use std::{ future::Future, pin::Pin, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, }; use tokio::sync::oneshot; @@ -233,7 +233,7 @@ impl Future for CloudwatchFuture { match ready!(fut.poll_unpin(cx)) { Ok(_) => {} Err(error) => { - return Poll::Ready(Err(CloudwatchError::PutRetentionPolicy(error))) + return Poll::Ready(Err(CloudwatchError::PutRetentionPolicy(error))); } } diff --git a/src/sinks/aws_cloudwatch_logs/request_builder.rs b/src/sinks/aws_cloudwatch_logs/request_builder.rs index 88223d78d1c7c..bade11db13c88 100644 --- a/src/sinks/aws_cloudwatch_logs/request_builder.rs +++ b/src/sinks/aws_cloudwatch_logs/request_builder.rs @@ -5,8 +5,8 @@ use chrono::Utc; use tokio_util::codec::Encoder as _; use vector_lib::request_metadata::{MetaDescriptive, RequestMetadata}; use vector_lib::{ - event::{EventFinalizers, Finalizable}, ByteSizeOf, + event::{EventFinalizers, Finalizable}, }; use super::TemplateRenderingError; diff --git a/src/sinks/aws_cloudwatch_logs/retry.rs b/src/sinks/aws_cloudwatch_logs/retry.rs index b2722054de097..19566d63c87e2 100644 --- a/src/sinks/aws_cloudwatch_logs/retry.rs +++ b/src/sinks/aws_cloudwatch_logs/retry.rs @@ -97,7 +97,9 @@ mod test { .message("Rate exceeded for logStreamName log-test-1.us-east-1.compute.internal") .build(); - let body = SdkBody::from("{\"__type\":\"ThrottlingException\",\"message\":\"Rate exceeded for logStreamName log-test-1.us-east-1.compute.internal\"}"); + let body = SdkBody::from( + "{\"__type\":\"ThrottlingException\",\"message\":\"Rate exceeded for logStreamName log-test-1.us-east-1.compute.internal\"}", + ); let raw = HttpResponse::new(StatusCode::try_from(400_u16).unwrap(), body); diff --git a/src/sinks/aws_cloudwatch_logs/service.rs b/src/sinks/aws_cloudwatch_logs/service.rs index 4546aa42b4b71..4384232d7b395 100644 --- a/src/sinks/aws_cloudwatch_logs/service.rs +++ b/src/sinks/aws_cloudwatch_logs/service.rs @@ -1,35 +1,35 @@ use std::{ collections::HashMap, fmt, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, }; use aws_sdk_cloudwatchlogs::{ + Client as CloudwatchLogsClient, operation::{ create_log_group::CreateLogGroupError, create_log_stream::CreateLogStreamError, describe_log_streams::DescribeLogStreamsError, put_log_events::PutLogEventsError, put_retention_policy::PutRetentionPolicyError, }, types::InputLogEvent, - Client as CloudwatchLogsClient, }; use aws_smithy_runtime_api::client::{orchestrator::HttpResponse, result::SdkError}; use chrono::Duration; -use futures::{future::BoxFuture, FutureExt}; +use futures::{FutureExt, future::BoxFuture}; use futures_util::TryFutureExt; use http::{ - header::{HeaderName, InvalidHeaderName, InvalidHeaderValue}, HeaderValue, + header::{HeaderName, InvalidHeaderName, InvalidHeaderValue}, }; use indexmap::IndexMap; use snafu::{ResultExt, Snafu}; use tokio::sync::oneshot; use tower::{ + Service, ServiceBuilder, ServiceExt, buffer::Buffer, limit::{ConcurrencyLimit, RateLimit}, retry::Retry, timeout::Timeout, - Service, ServiceBuilder, ServiceExt, }; use vector_lib::stream::DriverResponse; use vector_lib::{ @@ -39,10 +39,10 @@ use vector_lib::{ use crate::sinks::{ aws_cloudwatch_logs::{ - config::CloudwatchLogsSinkConfig, config::Retention, request, retry::CloudwatchRetryLogic, - sink::BatchCloudwatchRequest, CloudwatchKey, + CloudwatchKey, config::CloudwatchLogsSinkConfig, config::Retention, request, + retry::CloudwatchRetryLogic, sink::BatchCloudwatchRequest, }, - util::{retries::FibonacciRetryPolicy, EncodedLength, TowerRequestSettings}, + util::{EncodedLength, TowerRequestSettings, retries::FibonacciRetryPolicy}, }; type Svc = Buffer< diff --git a/src/sinks/aws_cloudwatch_logs/sink.rs b/src/sinks/aws_cloudwatch_logs/sink.rs index 0624f9f204b17..0a9e947008cb9 100644 --- a/src/sinks/aws_cloudwatch_logs/sink.rs +++ b/src/sinks/aws_cloudwatch_logs/sink.rs @@ -2,7 +2,7 @@ use std::fmt; use async_trait::async_trait; use chrono::{Duration, Utc}; -use futures::{future, stream::BoxStream, StreamExt}; +use futures::{StreamExt, future, stream::BoxStream}; use tower::Service; use vector_lib::request_metadata::{MetaDescriptive, RequestMetadata}; use vector_lib::stream::{BatcherSettings, DriverResponse}; @@ -12,8 +12,8 @@ use crate::{ event::{Event, EventFinalizers, Finalizable}, sinks::{ aws_cloudwatch_logs::{ - request_builder::{CloudwatchRequest, CloudwatchRequestBuilder}, CloudwatchKey, + request_builder::{CloudwatchRequest, CloudwatchRequestBuilder}, }, util::SinkBuilderExt, }, diff --git a/src/sinks/aws_cloudwatch_metrics/integration_tests.rs b/src/sinks/aws_cloudwatch_metrics/integration_tests.rs index c904c527cd6a7..19768b9c1ed82 100644 --- a/src/sinks/aws_cloudwatch_metrics/integration_tests.rs +++ b/src/sinks/aws_cloudwatch_metrics/integration_tests.rs @@ -1,12 +1,12 @@ -use chrono::{offset::TimeZone, Timelike, Utc}; +use chrono::{Timelike, Utc, offset::TimeZone}; use rand::seq::SliceRandom; use vector_lib::metric_tags; use super::*; use crate::{ - event::{metric::StatisticKind, Event, MetricKind}, + event::{Event, MetricKind, metric::StatisticKind}, test_util::{ - components::{run_and_assert_sink_compliance, AWS_SINK_TAGS}, + components::{AWS_SINK_TAGS, run_and_assert_sink_compliance}, random_string, }, }; diff --git a/src/sinks/aws_cloudwatch_metrics/mod.rs b/src/sinks/aws_cloudwatch_metrics/mod.rs index d8f7e35aac1c6..a8502b13f6a1d 100644 --- a/src/sinks/aws_cloudwatch_metrics/mod.rs +++ b/src/sinks/aws_cloudwatch_metrics/mod.rs @@ -4,33 +4,33 @@ mod integration_tests; mod tests; use aws_config::Region; +use aws_sdk_cloudwatch::Client as CloudwatchClient; use aws_sdk_cloudwatch::error::SdkError; use aws_sdk_cloudwatch::operation::put_metric_data::PutMetricDataError; use aws_sdk_cloudwatch::types::{Dimension, MetricDatum}; -use aws_sdk_cloudwatch::Client as CloudwatchClient; use aws_smithy_types::DateTime as AwsDateTime; -use futures::{stream, FutureExt, SinkExt}; +use futures::{FutureExt, SinkExt, stream}; use futures_util::{future, future::BoxFuture}; use std::task::{Context, Poll}; use tower::Service; use vector_lib::configurable::configurable_component; -use vector_lib::{sink::VectorSink, ByteSizeOf, EstimatedJsonEncodedSizeOf}; +use vector_lib::{ByteSizeOf, EstimatedJsonEncodedSizeOf, sink::VectorSink}; use crate::{ aws::{ - auth::AwsAuthentication, create_client, is_retriable_error, ClientBuilder, RegionOrEndpoint, + ClientBuilder, RegionOrEndpoint, auth::AwsAuthentication, create_client, is_retriable_error, }, config::{AcknowledgementsConfig, Input, ProxyConfig, SinkConfig, SinkContext}, event::{ - metric::{Metric, MetricTags, MetricValue}, Event, + metric::{Metric, MetricTags, MetricValue}, }, sinks::util::{ + Compression, EncodedEvent, PartitionBuffer, PartitionInnerBuffer, SinkBatchSettings, + TowerRequestConfig, batch::BatchConfig, buffer::metrics::{MetricNormalize, MetricNormalizer, MetricSet, MetricsBuffer}, retries::RetryLogic, - Compression, EncodedEvent, PartitionBuffer, PartitionInnerBuffer, SinkBatchSettings, - TowerRequestConfig, }, tls::TlsConfig, }; diff --git a/src/sinks/aws_cloudwatch_metrics/tests.rs b/src/sinks/aws_cloudwatch_metrics/tests.rs index 693f60a7f9d18..cbb6bae2c5d25 100644 --- a/src/sinks/aws_cloudwatch_metrics/tests.rs +++ b/src/sinks/aws_cloudwatch_metrics/tests.rs @@ -1,5 +1,5 @@ use aws_smithy_types::DateTime; -use chrono::{offset::TimeZone, Timelike, Utc}; +use chrono::{Timelike, Utc, offset::TimeZone}; use similar_asserts::assert_eq; use vector_lib::metric_tags; @@ -101,10 +101,12 @@ async fn encode_events_absolute_gauge() { assert_eq!( svc().await.encode_events(events), - vec![MetricDatum::builder() - .metric_name("temperature") - .value(10.0) - .build()] + vec![ + MetricDatum::builder() + .metric_name("temperature") + .value(10.0) + .build() + ] ); } @@ -121,11 +123,13 @@ async fn encode_events_distribution() { assert_eq!( svc().await.encode_events(events), - vec![MetricDatum::builder() - .metric_name("latency") - .set_values(Some(vec![11.0, 12.0])) - .set_counts(Some(vec![100.0, 50.0])) - .build()] + vec![ + MetricDatum::builder() + .metric_name("latency") + .set_values(Some(vec![11.0, 12.0])) + .set_counts(Some(vec![100.0, 50.0])) + .build() + ] ); } @@ -141,9 +145,11 @@ async fn encode_events_set() { assert_eq!( svc().await.encode_events(events), - vec![MetricDatum::builder() - .metric_name("users") - .value(2.0) - .build()] + vec![ + MetricDatum::builder() + .metric_name("users") + .value(2.0) + .build() + ] ); } diff --git a/src/sinks/aws_kinesis/config.rs b/src/sinks/aws_kinesis/config.rs index 259129a014a4e..86a93bb3f7b3d 100644 --- a/src/sinks/aws_kinesis/config.rs +++ b/src/sinks/aws_kinesis/config.rs @@ -7,15 +7,15 @@ use crate::{ aws::{AwsAuthentication, RegionOrEndpoint}, sinks::{ prelude::*, - util::{retries::RetryLogic, TowerRequestConfig}, + util::{TowerRequestConfig, retries::RetryLogic}, }, }; use super::{ + KinesisResponse, KinesisService, record::{Record, SendRecord}, request_builder::KinesisRequestBuilder, sink::{BatchKinesisRequest, KinesisSink}, - KinesisResponse, KinesisService, }; /// Base configuration for the `aws_kinesis_` sinks. diff --git a/src/sinks/aws_kinesis/firehose/config.rs b/src/sinks/aws_kinesis/firehose/config.rs index 85ebb6034aa54..534c3f171a400 100644 --- a/src/sinks/aws_kinesis/firehose/config.rs +++ b/src/sinks/aws_kinesis/firehose/config.rs @@ -8,19 +8,18 @@ use vector_lib::configurable::configurable_component; use crate::sinks::util::retries::RetryAction; use crate::{ - aws::{create_client, is_retriable_error, ClientBuilder}, + aws::{ClientBuilder, create_client, is_retriable_error}, config::{AcknowledgementsConfig, GenerateConfig, Input, ProxyConfig, SinkConfig, SinkContext}, sinks::{ - util::{retries::RetryLogic, BatchConfig, SinkBatchSettings}, Healthcheck, VectorSink, + util::{BatchConfig, SinkBatchSettings, retries::RetryLogic}, }, }; use super::sink::BatchKinesisRequest; use super::{ - build_sink, + KinesisClient, KinesisError, KinesisRecord, KinesisResponse, KinesisSinkBaseConfig, build_sink, record::{KinesisFirehoseClient, KinesisFirehoseRecord}, - KinesisClient, KinesisError, KinesisRecord, KinesisResponse, KinesisSinkBaseConfig, }; #[allow(clippy::large_enum_variant)] diff --git a/src/sinks/aws_kinesis/firehose/integration_tests.rs b/src/sinks/aws_kinesis/firehose/integration_tests.rs index e0a452c2a5ec5..810e8a83d1d3b 100644 --- a/src/sinks/aws_kinesis/firehose/integration_tests.rs +++ b/src/sinks/aws_kinesis/firehose/integration_tests.rs @@ -1,15 +1,15 @@ -use aws_sdk_elasticsearch::{types::DomainEndpointOptions, Client as EsClient}; +use aws_sdk_elasticsearch::{Client as EsClient, types::DomainEndpointOptions}; use aws_sdk_firehose::types::ElasticsearchDestinationConfiguration; use futures::StreamExt; use futures::TryFutureExt; -use serde_json::{json, Value}; -use tokio::time::{sleep, Duration}; +use serde_json::{Value, json}; +use tokio::time::{Duration, sleep}; use vector_lib::codecs::JsonSerializerConfig; use vector_lib::lookup::lookup_v2::ConfigValuePath; use super::{config::KinesisFirehoseClientBuilder, *}; use crate::{ - aws::{create_client, AwsAuthentication, ImdsAuthentication, RegionOrEndpoint}, + aws::{AwsAuthentication, ImdsAuthentication, RegionOrEndpoint, create_client}, config::{ProxyConfig, SinkConfig, SinkContext}, sinks::{ elasticsearch::{ @@ -19,7 +19,7 @@ use crate::{ }, template::Template, test_util::{ - components::{run_and_assert_sink_compliance, AWS_SINK_TAGS}, + components::{AWS_SINK_TAGS, run_and_assert_sink_compliance}, random_events_with_stream, random_string, wait_for_duration, }, }; diff --git a/src/sinks/aws_kinesis/firehose/mod.rs b/src/sinks/aws_kinesis/firehose/mod.rs index 28d1162756045..2ce049a7c54f8 100644 --- a/src/sinks/aws_kinesis/firehose/mod.rs +++ b/src/sinks/aws_kinesis/firehose/mod.rs @@ -6,11 +6,11 @@ mod record; mod tests; use aws_sdk_firehose::{ - operation::put_record_batch::PutRecordBatchError, types::Record as FRecord, Client, + Client, operation::put_record_batch::PutRecordBatchError, types::Record as FRecord, }; pub use super::{ - config::{build_sink, KinesisSinkBaseConfig}, + config::{KinesisSinkBaseConfig, build_sink}, record::{Record, SendRecord}, request_builder, service::{KinesisResponse, KinesisService}, diff --git a/src/sinks/aws_kinesis/firehose/tests.rs b/src/sinks/aws_kinesis/firehose/tests.rs index 178850ef84c43..f69bdf21773a3 100644 --- a/src/sinks/aws_kinesis/firehose/tests.rs +++ b/src/sinks/aws_kinesis/firehose/tests.rs @@ -10,7 +10,7 @@ use crate::{ aws_kinesis::firehose::config::{ KinesisFirehoseDefaultBatchSettings, MAX_PAYLOAD_EVENTS, MAX_PAYLOAD_SIZE, }, - util::{batch::BatchError, BatchConfig, Compression}, + util::{BatchConfig, Compression, batch::BatchError}, }, }; diff --git a/src/sinks/aws_kinesis/request_builder.rs b/src/sinks/aws_kinesis/request_builder.rs index b2cfaa202fc90..db6383b8dca55 100644 --- a/src/sinks/aws_kinesis/request_builder.rs +++ b/src/sinks/aws_kinesis/request_builder.rs @@ -1,8 +1,8 @@ use std::{io, marker::PhantomData}; use bytes::Bytes; -use vector_lib::request_metadata::{MetaDescriptive, RequestMetadata}; use vector_lib::ByteSizeOf; +use vector_lib::request_metadata::{MetaDescriptive, RequestMetadata}; use super::{ record::Record, @@ -12,8 +12,8 @@ use crate::{ codecs::{Encoder, Transformer}, event::{Event, EventFinalizers, Finalizable}, sinks::util::{ - metadata::RequestMetadataBuilder, request_builder::EncodeResult, Compression, - RequestBuilder, + Compression, RequestBuilder, metadata::RequestMetadataBuilder, + request_builder::EncodeResult, }, }; diff --git a/src/sinks/aws_kinesis/sink.rs b/src/sinks/aws_kinesis/sink.rs index f29f246a7ffc7..477b6ad4d81d3 100644 --- a/src/sinks/aws_kinesis/sink.rs +++ b/src/sinks/aws_kinesis/sink.rs @@ -8,7 +8,7 @@ use crate::{ internal_events::{AwsKinesisStreamNoPartitionKeyError, SinkRequestBuildError}, sinks::{ prelude::*, - util::{processed_event::ProcessedEvent, StreamSink}, + util::{StreamSink, processed_event::ProcessedEvent}, }, }; diff --git a/src/sinks/aws_kinesis/streams/config.rs b/src/sinks/aws_kinesis/streams/config.rs index 2f42865fe8df8..a63ae778be974 100644 --- a/src/sinks/aws_kinesis/streams/config.rs +++ b/src/sinks/aws_kinesis/streams/config.rs @@ -7,19 +7,18 @@ use vector_lib::configurable::{component::GenerateConfig, configurable_component use crate::sinks::util::retries::RetryAction; use crate::{ - aws::{create_client, is_retriable_error, ClientBuilder}, + aws::{ClientBuilder, create_client, is_retriable_error}, config::{AcknowledgementsConfig, Input, ProxyConfig, SinkConfig, SinkContext}, sinks::{ - util::{retries::RetryLogic, BatchConfig, SinkBatchSettings}, Healthcheck, VectorSink, + util::{BatchConfig, SinkBatchSettings, retries::RetryLogic}, }, }; use super::sink::BatchKinesisRequest; use super::{ - build_sink, + KinesisClient, KinesisError, KinesisRecord, KinesisResponse, KinesisSinkBaseConfig, build_sink, record::{KinesisStreamClient, KinesisStreamRecord}, - KinesisClient, KinesisError, KinesisRecord, KinesisResponse, KinesisSinkBaseConfig, }; #[allow(clippy::large_enum_variant)] diff --git a/src/sinks/aws_kinesis/streams/integration_tests.rs b/src/sinks/aws_kinesis/streams/integration_tests.rs index c46045dd9f83d..e5b7578b7fdd0 100644 --- a/src/sinks/aws_kinesis/streams/integration_tests.rs +++ b/src/sinks/aws_kinesis/streams/integration_tests.rs @@ -5,17 +5,17 @@ use aws_sdk_kinesis::types::{Record, ShardIteratorType}; use aws_smithy_types::DateTime; use futures::StreamExt; -use tokio::time::{sleep, Duration}; +use tokio::time::{Duration, sleep}; use vector_lib::codecs::TextSerializerConfig; use vector_lib::lookup::lookup_v2::ConfigValuePath; use super::{config::KinesisClientBuilder, *}; use crate::{ - aws::{create_client, AwsAuthentication, RegionOrEndpoint}, + aws::{AwsAuthentication, RegionOrEndpoint, create_client}, config::{ProxyConfig, SinkConfig, SinkContext}, sinks::util::{BatchConfig, Compression}, test_util::{ - components::{run_and_assert_sink_compliance, AWS_SINK_TAGS}, + components::{AWS_SINK_TAGS, run_and_assert_sink_compliance}, random_lines_with_stream, random_string, }, }; diff --git a/src/sinks/aws_kinesis/streams/mod.rs b/src/sinks/aws_kinesis/streams/mod.rs index 4410675432cdf..6249e8a92178d 100644 --- a/src/sinks/aws_kinesis/streams/mod.rs +++ b/src/sinks/aws_kinesis/streams/mod.rs @@ -3,11 +3,11 @@ mod integration_tests; mod record; use aws_sdk_kinesis::{ - operation::put_records::PutRecordsError, types::PutRecordsRequestEntry, Client, + Client, operation::put_records::PutRecordsError, types::PutRecordsRequestEntry, }; pub use super::{ - config::{build_sink, KinesisSinkBaseConfig}, + config::{KinesisSinkBaseConfig, build_sink}, record::{Record, SendRecord}, request_builder, service::{KinesisResponse, KinesisService}, diff --git a/src/sinks/aws_s3/config.rs b/src/sinks/aws_s3/config.rs index 06b1148783bf8..0a9c03991eb70 100644 --- a/src/sinks/aws_s3/config.rs +++ b/src/sinks/aws_s3/config.rs @@ -1,10 +1,10 @@ use aws_sdk_s3::Client as S3Client; use tower::ServiceBuilder; use vector_lib::codecs::{ - encoding::{Framer, FramingConfig}, TextSerializerConfig, + encoding::{Framer, FramingConfig}, }; -use vector_lib::{configurable::configurable_component, sink::VectorSink, TimeZone}; +use vector_lib::{TimeZone, configurable::configurable_component, sink::VectorSink}; use super::sink::S3RequestOptions; use crate::{ @@ -12,6 +12,7 @@ use crate::{ codecs::{Encoder, EncodingConfigWithFraming, SinkType}, config::{AcknowledgementsConfig, GenerateConfig, Input, ProxyConfig, SinkConfig, SinkContext}, sinks::{ + Healthcheck, s3_common::{ self, config::{RetryStrategy, S3Options}, @@ -20,10 +21,9 @@ use crate::{ sink::S3Sink, }, util::{ - timezone_to_offset, BatchConfig, BulkSizeBasedDefaultBatchSettings, Compression, - ServiceBuilderExt, TowerRequestConfig, + BatchConfig, BulkSizeBasedDefaultBatchSettings, Compression, ServiceBuilderExt, + TowerRequestConfig, timezone_to_offset, }, - Healthcheck, }, template::Template, tls::TlsConfig, diff --git a/src/sinks/aws_s3/integration_tests.rs b/src/sinks/aws_s3/integration_tests.rs index 1815f5bde2933..bcecb0c32327b 100644 --- a/src/sinks/aws_s3/integration_tests.rs +++ b/src/sinks/aws_s3/integration_tests.rs @@ -6,20 +6,20 @@ use std::{ }; use aws_sdk_s3::{ + Client as S3Client, operation::{create_bucket::CreateBucketError, get_object::GetObjectOutput}, types::{ DefaultRetention, ObjectLockConfiguration, ObjectLockEnabled, ObjectLockRetentionMode, ObjectLockRule, }, - Client as S3Client, }; use aws_smithy_runtime_api::client::result::SdkError; use bytes::Buf; use flate2::read::MultiGzDecoder; -use futures::{stream, Stream}; +use futures::{Stream, stream}; use similar_asserts::assert_eq; use tokio_stream::StreamExt; -use vector_lib::codecs::{encoding::FramingConfig, TextSerializerConfig}; +use vector_lib::codecs::{TextSerializerConfig, encoding::FramingConfig}; use vector_lib::{ config::proxy::ProxyConfig, event::{BatchNotifier, BatchStatus, BatchStatusReceiver, Event, EventArray, LogEvent}, @@ -27,7 +27,7 @@ use vector_lib::{ use super::S3SinkConfig; use crate::{ - aws::{create_client, AwsAuthentication, RegionOrEndpoint}, + aws::{AwsAuthentication, RegionOrEndpoint, create_client}, common::s3::S3ClientBuilder, config::SinkContext, sinks::{ @@ -37,8 +37,8 @@ use crate::{ }, test_util::{ components::{ - run_and_assert_sink_compliance, run_and_assert_sink_error, AWS_SINK_TAGS, - COMPONENT_ERROR_TAGS, + AWS_SINK_TAGS, COMPONENT_ERROR_TAGS, run_and_assert_sink_compliance, + run_and_assert_sink_error, }, random_lines_with_stream, random_string, }, @@ -402,11 +402,13 @@ async fn s3_healthchecks_invalid_bucket() { .create_service(&ProxyConfig::from_env()) .await .unwrap(); - assert!(config - .build_healthcheck(service.client()) - .unwrap() - .await - .is_err()); + assert!( + config + .build_healthcheck(service.client()) + .unwrap() + .await + .is_err() + ); } #[tokio::test] @@ -466,12 +468,14 @@ async fn s3_flush_on_exhaustion() { // outputs for the in-flight batch are flushed. By timing out in 3 seconds with a // flush period of ten seconds, we verify that the flush is triggered *at stream // completion* and not because of periodic flushing. - assert!(tokio::time::timeout( - Duration::from_secs(3), - run_and_assert_sink_compliance(sink, stream::iter(events), &AWS_SINK_TAGS) - ) - .await - .is_ok()); + assert!( + tokio::time::timeout( + Duration::from_secs(3), + run_and_assert_sink_compliance(sink, stream::iter(events), &AWS_SINK_TAGS) + ) + .await + .is_ok() + ); let keys = get_keys(&bucket, prefix).await; assert_eq!(keys.len(), 1); diff --git a/src/sinks/aws_s3/sink.rs b/src/sinks/aws_s3/sink.rs index aee79d00f18aa..edab99b8961bd 100644 --- a/src/sinks/aws_s3/sink.rs +++ b/src/sinks/aws_s3/sink.rs @@ -17,8 +17,8 @@ use crate::{ service::{S3Metadata, S3Request}, }, util::{ - metadata::RequestMetadataBuilder, request_builder::EncodeResult, Compression, - RequestBuilder, + Compression, RequestBuilder, metadata::RequestMetadataBuilder, + request_builder::EncodeResult, }, }, }; diff --git a/src/sinks/aws_s_s/request_builder.rs b/src/sinks/aws_s_s/request_builder.rs index 4d64ebe85f7ea..0d859c64456d5 100644 --- a/src/sinks/aws_s_s/request_builder.rs +++ b/src/sinks/aws_s_s/request_builder.rs @@ -1,6 +1,6 @@ use bytes::Bytes; -use vector_lib::request_metadata::{MetaDescriptive, RequestMetadata}; use vector_lib::ByteSizeOf; +use vector_lib::request_metadata::{MetaDescriptive, RequestMetadata}; use crate::codecs::EncodingConfig; use crate::{ @@ -8,8 +8,8 @@ use crate::{ event::{Event, EventFinalizers, Finalizable}, internal_events::TemplateRenderingError, sinks::util::{ - metadata::RequestMetadataBuilder, request_builder::EncodeResult, Compression, - EncodedLength, RequestBuilder, + Compression, EncodedLength, RequestBuilder, metadata::RequestMetadataBuilder, + request_builder::EncodeResult, }, template::Template, }; diff --git a/src/sinks/aws_s_s/service.rs b/src/sinks/aws_s_s/service.rs index c7aacab5e27e5..18dfa2bf083e4 100644 --- a/src/sinks/aws_s_s/service.rs +++ b/src/sinks/aws_s_s/service.rs @@ -7,7 +7,7 @@ use futures::future::BoxFuture; use tower::Service; use vector_lib::request_metadata::GroupedCountByteSize; use vector_lib::stream::DriverResponse; -use vector_lib::{event::EventStatus, ByteSizeOf}; +use vector_lib::{ByteSizeOf, event::EventStatus}; use super::{client::Client, request_builder::SendMessageEntry}; diff --git a/src/sinks/aws_s_s/sns/config.rs b/src/sinks/aws_s_s/sns/config.rs index c1da2f81112ff..24d06f54a82dd 100644 --- a/src/sinks/aws_s_s/sns/config.rs +++ b/src/sinks/aws_s_s/sns/config.rs @@ -8,11 +8,11 @@ use crate::config::{ use vector_lib::configurable::configurable_component; use super::{ - client::SnsMessagePublisher, message_deduplication_id, message_group_id, BaseSSSinkConfig, - SSRequestBuilder, SSSink, + BaseSSSinkConfig, SSRequestBuilder, SSSink, client::SnsMessagePublisher, + message_deduplication_id, message_group_id, }; -use crate::aws::create_client; use crate::aws::ClientBuilder; +use crate::aws::create_client; /// Configuration for the `aws_sns` sink. #[configurable_component(sink( diff --git a/src/sinks/aws_s_s/sns/integration_tests.rs b/src/sinks/aws_s_s/sns/integration_tests.rs index c97fee30e0318..728d5ba46efcf 100644 --- a/src/sinks/aws_s_s/sns/integration_tests.rs +++ b/src/sinks/aws_s_s/sns/integration_tests.rs @@ -2,22 +2,22 @@ use std::collections::HashMap; use aws_config::Region; use aws_sdk_sns::Client as SnsClient; -use aws_sdk_sqs::{types::QueueAttributeName, Client as SqsClient}; -use tokio::time::{sleep, Duration}; +use aws_sdk_sqs::{Client as SqsClient, types::QueueAttributeName}; +use tokio::time::{Duration, sleep}; use vector_lib::codecs::TextSerializerConfig; use super::{ - config::SnsClientBuilder, - config::{healthcheck, SnsSinkConfig}, BaseSSSinkConfig, + config::SnsClientBuilder, + config::{SnsSinkConfig, healthcheck}, }; use crate::common::sqs::SqsClientBuilder; use crate::config::{SinkConfig, SinkContext}; use crate::{ - aws::{create_client, AwsAuthentication, RegionOrEndpoint}, + aws::{AwsAuthentication, RegionOrEndpoint, create_client}, config::ProxyConfig, test_util::{ - components::{run_and_assert_sink_compliance, AWS_SINK_TAGS}, + components::{AWS_SINK_TAGS, run_and_assert_sink_compliance}, random_lines_with_stream, random_string, }, }; diff --git a/src/sinks/aws_s_s/sns/mod.rs b/src/sinks/aws_s_s/sns/mod.rs index 3d83d21d71216..323bce423f7af 100644 --- a/src/sinks/aws_s_s/sns/mod.rs +++ b/src/sinks/aws_s_s/sns/mod.rs @@ -5,7 +5,7 @@ mod integration_tests; use super::{ client::Client, - config::{message_deduplication_id, message_group_id, BaseSSSinkConfig}, + config::{BaseSSSinkConfig, message_deduplication_id, message_group_id}, request_builder::{SSRequestBuilder, SendMessageEntry}, service::SendMessageResponse, sink::SSSink, diff --git a/src/sinks/aws_s_s/sqs/config.rs b/src/sinks/aws_s_s/sqs/config.rs index 6f7555f6443aa..cbfd0f0d27f27 100644 --- a/src/sinks/aws_s_s/sqs/config.rs +++ b/src/sinks/aws_s_s/sqs/config.rs @@ -8,8 +8,8 @@ use crate::config::{ use vector_lib::configurable::configurable_component; use super::{ - client::SqsMessagePublisher, message_deduplication_id, message_group_id, BaseSSSinkConfig, - SSRequestBuilder, SSSink, + BaseSSSinkConfig, SSRequestBuilder, SSSink, client::SqsMessagePublisher, + message_deduplication_id, message_group_id, }; use crate::{aws::create_client, common::sqs::SqsClientBuilder}; diff --git a/src/sinks/aws_s_s/sqs/integration_tests.rs b/src/sinks/aws_s_s/sqs/integration_tests.rs index 91585c38223f0..1e83eda4991e3 100644 --- a/src/sinks/aws_s_s/sqs/integration_tests.rs +++ b/src/sinks/aws_s_s/sqs/integration_tests.rs @@ -1,21 +1,21 @@ use std::collections::HashMap; use aws_config::Region; -use aws_sdk_sqs::{types::QueueAttributeName, Client as SqsClient}; -use tokio::time::{sleep, Duration}; +use aws_sdk_sqs::{Client as SqsClient, types::QueueAttributeName}; +use tokio::time::{Duration, sleep}; use vector_lib::codecs::TextSerializerConfig; use crate::config::{SinkConfig, SinkContext}; use crate::sinks::aws_s_s::sqs::{ - config::{healthcheck, SqsSinkConfig}, BaseSSSinkConfig, + config::{SqsSinkConfig, healthcheck}, }; use crate::{ - aws::{create_client, AwsAuthentication, RegionOrEndpoint}, + aws::{AwsAuthentication, RegionOrEndpoint, create_client}, common::sqs::SqsClientBuilder, config::ProxyConfig, test_util::{ - components::{run_and_assert_sink_compliance, AWS_SINK_TAGS}, + components::{AWS_SINK_TAGS, run_and_assert_sink_compliance}, random_lines_with_stream, random_string, }, }; diff --git a/src/sinks/aws_s_s/sqs/mod.rs b/src/sinks/aws_s_s/sqs/mod.rs index 943fc8bacb8ab..a56c934c23181 100644 --- a/src/sinks/aws_s_s/sqs/mod.rs +++ b/src/sinks/aws_s_s/sqs/mod.rs @@ -6,7 +6,7 @@ mod integration_tests; use super::{ client::Client, - config::{message_deduplication_id, message_group_id, BaseSSSinkConfig}, + config::{BaseSSSinkConfig, message_deduplication_id, message_group_id}, request_builder::{SSRequestBuilder, SendMessageEntry}, service::SendMessageResponse, sink::SSSink, diff --git a/src/sinks/axiom.rs b/src/sinks/axiom.rs index 6958f2cc137d2..7720819ff87f9 100644 --- a/src/sinks/axiom.rs +++ b/src/sinks/axiom.rs @@ -1,8 +1,8 @@ +use vector_lib::codecs::MetricTagValues; use vector_lib::codecs::encoding::FramingConfig; use vector_lib::codecs::encoding::JsonSerializerConfig; use vector_lib::codecs::encoding::JsonSerializerOptions; use vector_lib::codecs::encoding::SerializerConfig; -use vector_lib::codecs::MetricTagValues; use vector_lib::configurable::configurable_component; use vector_lib::sensitive_string::SensitiveString; @@ -11,11 +11,11 @@ use crate::{ config::{AcknowledgementsConfig, DataType, GenerateConfig, Input, SinkConfig, SinkContext}, http::Auth as HttpAuthConfig, sinks::{ + Healthcheck, VectorSink, http::config::{HttpMethod, HttpSinkConfig}, util::{ - http::RequestConfig, BatchConfig, Compression, RealtimeSizeBasedDefaultBatchSettings, + BatchConfig, Compression, RealtimeSizeBasedDefaultBatchSettings, http::RequestConfig, }, - Healthcheck, VectorSink, }, tls::TlsConfig, }; @@ -196,7 +196,7 @@ mod integration_tests { use crate::{ config::SinkContext, sinks::axiom::AxiomConfig, - test_util::components::{run_and_assert_sink_compliance, HTTP_SINK_TAGS}, + test_util::components::{HTTP_SINK_TAGS, run_and_assert_sink_compliance}, }; #[tokio::test] diff --git a/src/sinks/azure_blob/config.rs b/src/sinks/azure_blob/config.rs index 11f32900d5b32..d3e9eda6fb535 100644 --- a/src/sinks/azure_blob/config.rs +++ b/src/sinks/azure_blob/config.rs @@ -2,27 +2,27 @@ use std::sync::Arc; use azure_storage_blobs::prelude::*; use tower::ServiceBuilder; -use vector_lib::codecs::{encoding::Framer, JsonSerializerConfig, NewlineDelimitedEncoderConfig}; +use vector_lib::codecs::{JsonSerializerConfig, NewlineDelimitedEncoderConfig, encoding::Framer}; use vector_lib::configurable::configurable_component; use vector_lib::sensitive_string::SensitiveString; use super::request_builder::AzureBlobRequestOptions; use crate::sinks::util::service::TowerRequestConfigDefaults; use crate::{ + Result, codecs::{Encoder, EncodingConfigWithFraming, SinkType}, config::{AcknowledgementsConfig, DataType, GenerateConfig, Input, SinkConfig, SinkContext}, sinks::{ + Healthcheck, VectorSink, azure_common::{ self, config::AzureBlobRetryLogic, service::AzureBlobService, sink::AzureBlobSink, }, util::{ - partitioner::KeyPartitioner, BatchConfig, BulkSizeBasedDefaultBatchSettings, - Compression, ServiceBuilderExt, TowerRequestConfig, + BatchConfig, BulkSizeBasedDefaultBatchSettings, Compression, ServiceBuilderExt, + TowerRequestConfig, partitioner::KeyPartitioner, }, - Healthcheck, VectorSink, }, template::Template, - Result, }; #[derive(Clone, Copy, Debug)] diff --git a/src/sinks/azure_blob/integration_tests.rs b/src/sinks/azure_blob/integration_tests.rs index 7318452ff0685..a8315401f8baa 100644 --- a/src/sinks/azure_blob/integration_tests.rs +++ b/src/sinks/azure_blob/integration_tests.rs @@ -7,24 +7,23 @@ use azure_core::{error::HttpError, prelude::Range}; use azure_storage_blobs::prelude::*; use bytes::{Buf, BytesMut}; use flate2::read::GzDecoder; -use futures::{stream, Stream, StreamExt}; +use futures::{Stream, StreamExt, stream}; use http::StatusCode; +use vector_lib::ByteSizeOf; use vector_lib::codecs::{ - encoding::FramingConfig, JsonSerializerConfig, NewlineDelimitedEncoderConfig, - TextSerializerConfig, + JsonSerializerConfig, NewlineDelimitedEncoderConfig, TextSerializerConfig, + encoding::FramingConfig, }; -use vector_lib::ByteSizeOf; use super::config::AzureBlobSinkConfig; use crate::{ event::{Event, EventArray, LogEvent}, sinks::{ - azure_common, + VectorSink, azure_common, util::{Compression, TowerRequestConfig}, - VectorSink, }, test_util::{ - components::{assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, assert_sink_compliance}, random_events_with_stream, random_lines, random_lines_with_stream, random_string, }, }; @@ -281,13 +280,11 @@ impl AzureBlobSinkConfig { .expect("Failed to fetch blobs") .unwrap(); - let blobs = response + response .blobs .blobs() .map(|blob| blob.name.clone()) - .collect::>(); - - blobs + .collect::>() } pub async fn get_blob(&self, blob: String) -> (Blob, Vec) { diff --git a/src/sinks/azure_blob/request_builder.rs b/src/sinks/azure_blob/request_builder.rs index 1e674b41795f6..c5503df308e7b 100644 --- a/src/sinks/azure_blob/request_builder.rs +++ b/src/sinks/azure_blob/request_builder.rs @@ -1,9 +1,9 @@ use bytes::Bytes; use chrono::Utc; use uuid::Uuid; +use vector_lib::EstimatedJsonEncodedSizeOf; use vector_lib::codecs::encoding::Framer; use vector_lib::request_metadata::RequestMetadata; -use vector_lib::EstimatedJsonEncodedSizeOf; use crate::{ codecs::{Encoder, Transformer}, @@ -11,8 +11,8 @@ use crate::{ sinks::{ azure_common::config::{AzureBlobMetadata, AzureBlobRequest}, util::{ - metadata::RequestMetadataBuilder, request_builder::EncodeResult, Compression, - RequestBuilder, + Compression, RequestBuilder, metadata::RequestMetadataBuilder, + request_builder::EncodeResult, }, }, }; diff --git a/src/sinks/azure_blob/test.rs b/src/sinks/azure_blob/test.rs index cca8a744acf9c..bffb2b1d03c8f 100644 --- a/src/sinks/azure_blob/test.rs +++ b/src/sinks/azure_blob/test.rs @@ -1,17 +1,17 @@ use bytes::Bytes; use chrono::Utc; use vector_lib::codecs::{ - encoding::{Framer, FramingConfig}, NewlineDelimitedEncoder, TextSerializerConfig, + encoding::{Framer, FramingConfig}, }; use vector_lib::request_metadata::GroupedCountByteSize; -use vector_lib::{partition::Partitioner, EstimatedJsonEncodedSizeOf}; +use vector_lib::{EstimatedJsonEncodedSizeOf, partition::Partitioner}; use super::config::AzureBlobSinkConfig; use super::request_builder::AzureBlobRequestOptions; use crate::codecs::EncodingConfigWithFraming; use crate::event::{Event, LogEvent}; -use crate::sinks::util::{request_builder::RequestBuilder, Compression}; +use crate::sinks::util::{Compression, request_builder::RequestBuilder}; use crate::{codecs::Encoder, sinks::util::request_builder::EncodeResult}; fn default_config(encoding: EncodingConfigWithFraming) -> AzureBlobSinkConfig { diff --git a/src/sinks/azure_common/config.rs b/src/sinks/azure_common/config.rs index ca6b1c7dd87fc..5f03b87c02b70 100644 --- a/src/sinks/azure_common/config.rs +++ b/src/sinks/azure_common/config.rs @@ -1,8 +1,8 @@ use std::sync::Arc; -use azure_core::{error::HttpError, RetryOptions}; +use azure_core::{RetryOptions, error::HttpError}; use azure_identity::{AutoRefreshingTokenCredential, DefaultAzureCredential}; -use azure_storage::{prelude::*, CloudLocation, ConnectionString}; +use azure_storage::{CloudLocation, ConnectionString, prelude::*}; use azure_storage_blobs::{blob::operations::PutBlockBlobResponse, prelude::*}; use bytes::Bytes; use futures::FutureExt; @@ -16,7 +16,7 @@ use vector_lib::{ use crate::{ event::{EventFinalizers, EventStatus, Finalizable}, - sinks::{util::retries::RetryLogic, Healthcheck}, + sinks::{Healthcheck, util::retries::RetryLogic}, }; #[derive(Debug, Clone)] @@ -130,12 +130,11 @@ pub fn build_client( container_name: String, endpoint: Option, ) -> crate::Result> { - let client; - match (connection_string, storage_account) { + let client = match (connection_string, storage_account) { (Some(connection_string_p), None) => { let connection_string = ConnectionString::new(&connection_string_p)?; - client = match connection_string.blob_endpoint { + match connection_string.blob_endpoint { // When the blob_endpoint is provided, we use the Custom CloudLocation since it is // required to contain the full URI to the blob storage API endpoint, this means // that account_name is not required to exist in the connection_string since @@ -158,14 +157,14 @@ pub fn build_client( ), } .retry(RetryOptions::none()) - .container_client(container_name); + .container_client(container_name) } (None, Some(storage_account_p)) => { let creds = std::sync::Arc::new(DefaultAzureCredential::default()); let auto_creds = std::sync::Arc::new(AutoRefreshingTokenCredential::new(creds)); let storage_credentials = StorageCredentials::token_credential(auto_creds); - client = match endpoint { + match endpoint { // If a blob_endpoint is provided in the configuration, use it with a Custom // CloudLocation, to allow overriding the blob storage API endpoint Some(endpoint) => ClientBuilder::with_location( @@ -178,17 +177,19 @@ pub fn build_client( None => ClientBuilder::new(storage_account_p, storage_credentials), } .retry(RetryOptions::none()) - .container_client(container_name); + .container_client(container_name) } (None, None) => { - return Err("Either `connection_string` or `storage_account` has to be provided".into()) + return Err( + "Either `connection_string` or `storage_account` has to be provided".into(), + ); } (Some(_), Some(_)) => { return Err( "`connection_string` and `storage_account` can't be provided at the same time" .into(), - ) + ); } - } + }; Ok(std::sync::Arc::new(client)) } diff --git a/src/sinks/azure_monitor_logs/config.rs b/src/sinks/azure_monitor_logs/config.rs index cad779f546e7c..0429694f37aa3 100644 --- a/src/sinks/azure_monitor_logs/config.rs +++ b/src/sinks/azure_monitor_logs/config.rs @@ -1,5 +1,5 @@ use openssl::{base64, pkey}; -use vector_lib::lookup::{lookup_v2::OptionalValuePath, OwnedValuePath}; +use vector_lib::lookup::{OwnedValuePath, lookup_v2::OptionalValuePath}; use vector_lib::configurable::configurable_component; use vector_lib::sensitive_string::SensitiveString; @@ -7,10 +7,10 @@ use vector_lib::{config::log_schema, schema}; use vrl::value::Kind; use crate::{ - http::{get_http_scheme_from_uri, HttpClient}, + http::{HttpClient, get_http_scheme_from_uri}, sinks::{ prelude::*, - util::{http::HttpStatusRetryLogic, RealtimeSizeBasedDefaultBatchSettings, UriSerde}, + util::{RealtimeSizeBasedDefaultBatchSettings, UriSerde, http::HttpStatusRetryLogic}, }, }; diff --git a/src/sinks/azure_monitor_logs/service.rs b/src/sinks/azure_monitor_logs/service.rs index 4779a248bc75c..5674434c39db5 100644 --- a/src/sinks/azure_monitor_logs/service.rs +++ b/src/sinks/azure_monitor_logs/service.rs @@ -3,8 +3,8 @@ use std::task::{Context, Poll}; use bytes::Bytes; use http::{ - header::{self, HeaderMap}, HeaderName, HeaderValue, Request, StatusCode, Uri, + header::{self, HeaderMap}, }; use hyper::Body; use openssl::{base64, hash, pkey, sign}; diff --git a/src/sinks/azure_monitor_logs/sink.rs b/src/sinks/azure_monitor_logs/sink.rs index 947256855421b..0e852ba7b1b4a 100644 --- a/src/sinks/azure_monitor_logs/sink.rs +++ b/src/sinks/azure_monitor_logs/sink.rs @@ -1,7 +1,7 @@ use std::{fmt::Debug, io}; use bytes::Bytes; -use vector_lib::codecs::{encoding::Framer, CharacterDelimitedEncoder, JsonSerializerConfig}; +use vector_lib::codecs::{CharacterDelimitedEncoder, JsonSerializerConfig, encoding::Framer}; use vector_lib::lookup::{OwnedValuePath, PathPrefix}; use crate::sinks::prelude::*; diff --git a/src/sinks/azure_monitor_logs/tests.rs b/src/sinks/azure_monitor_logs/tests.rs index 9050297eebc9d..31bfede218356 100644 --- a/src/sinks/azure_monitor_logs/tests.rs +++ b/src/sinks/azure_monitor_logs/tests.rs @@ -8,14 +8,14 @@ use tokio::time::timeout; use vector_lib::config::log_schema; use super::{ - config::{default_host, AzureMonitorLogsConfig}, + config::{AzureMonitorLogsConfig, default_host}, sink::JsonEncoding, }; use crate::{ event::LogEvent, sinks::{prelude::*, util::encoding::Encoder}, test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, http::{always_200_response, spawn_blackhole_http_server}, }, }; diff --git a/src/sinks/blackhole/config.rs b/src/sinks/blackhole/config.rs index bb427602f6fe3..7ca402f112803 100644 --- a/src/sinks/blackhole/config.rs +++ b/src/sinks/blackhole/config.rs @@ -1,12 +1,12 @@ use std::time::Duration; -use futures::{future, FutureExt}; +use futures::{FutureExt, future}; use serde_with::serde_as; use vector_lib::configurable::configurable_component; use crate::{ config::{AcknowledgementsConfig, GenerateConfig, Input, SinkConfig, SinkContext}, - sinks::{blackhole::sink::BlackholeSink, Healthcheck, VectorSink}, + sinks::{Healthcheck, VectorSink, blackhole::sink::BlackholeSink}, }; const fn default_print_interval_secs() -> Duration { diff --git a/src/sinks/blackhole/mod.rs b/src/sinks/blackhole/mod.rs index 94ead51ec7588..9d9046e208fde 100644 --- a/src/sinks/blackhole/mod.rs +++ b/src/sinks/blackhole/mod.rs @@ -10,8 +10,8 @@ mod tests { use crate::{ sinks::{ - blackhole::{config::BlackholeConfig, sink::BlackholeSink}, VectorSink, + blackhole::{config::BlackholeConfig, sink::BlackholeSink}, }, test_util::{ components::run_and_assert_nonsending_sink_compliance, random_events_with_stream, diff --git a/src/sinks/blackhole/sink.rs b/src/sinks/blackhole/sink.rs index 514e3e3071a8d..f5e46f649f655 100644 --- a/src/sinks/blackhole/sink.rs +++ b/src/sinks/blackhole/sink.rs @@ -1,22 +1,22 @@ use std::{ sync::{ - atomic::{AtomicUsize, Ordering}, Arc, + atomic::{AtomicUsize, Ordering}, }, time::{Duration, Instant}, }; use async_trait::async_trait; -use futures::{stream::BoxStream, StreamExt}; +use futures::{StreamExt, stream::BoxStream}; use tokio::{ select, sync::watch, time::{interval, sleep_until}, }; +use vector_lib::EstimatedJsonEncodedSizeOf; use vector_lib::internal_event::{ ByteSize, BytesSent, CountByteSize, EventsSent, InternalEventHandle as _, Output, Protocol, }; -use vector_lib::EstimatedJsonEncodedSizeOf; use crate::{ event::{EventArray, EventContainer}, diff --git a/src/sinks/clickhouse/config.rs b/src/sinks/clickhouse/config.rs index 9a884b53a48dd..cc861c451298d 100644 --- a/src/sinks/clickhouse/config.rs +++ b/src/sinks/clickhouse/config.rs @@ -9,13 +9,13 @@ use crate::{ http::{Auth, HttpClient, MaybeAuth}, sinks::{ prelude::*, - util::{http::HttpService, RealtimeSizeBasedDefaultBatchSettings, UriSerde}, + util::{RealtimeSizeBasedDefaultBatchSettings, UriSerde, http::HttpService}, }, }; use http::{Request, StatusCode, Uri}; use hyper::Body; use std::fmt; -use vector_lib::codecs::{encoding::Framer, JsonSerializerConfig, NewlineDelimitedEncoderConfig}; +use vector_lib::codecs::{JsonSerializerConfig, NewlineDelimitedEncoderConfig, encoding::Framer}; /// Data format. /// diff --git a/src/sinks/clickhouse/integration_tests.rs b/src/sinks/clickhouse/integration_tests.rs index a01e655be412d..b20a3b3442f4c 100644 --- a/src/sinks/clickhouse/integration_tests.rs +++ b/src/sinks/clickhouse/integration_tests.rs @@ -2,8 +2,8 @@ use std::{ convert::Infallible, net::SocketAddr, sync::{ - atomic::{AtomicBool, Ordering}, Arc, + atomic::{AtomicBool, Ordering}, }, }; @@ -14,20 +14,20 @@ use futures::{ use http::StatusCode; use serde::Deserialize; use serde_json::Value; -use tokio::time::{timeout, Duration}; +use tokio::time::{Duration, timeout}; use vector_lib::event::{BatchNotifier, BatchStatus, BatchStatusReceiver, Event, LogEvent}; use vector_lib::lookup::PathPrefix; use warp::Filter; use crate::{ codecs::{TimestampFormat, Transformer}, - config::{log_schema, SinkConfig, SinkContext}, + config::{SinkConfig, SinkContext, log_schema}, sinks::{ clickhouse::config::ClickhouseConfig, util::{BatchConfig, Compression, TowerRequestConfig}, }, test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, random_table_name, trace_init, }, }; diff --git a/src/sinks/clickhouse/service.rs b/src/sinks/clickhouse/service.rs index ca865fa0cf4fd..c3c24bb0ff1a3 100644 --- a/src/sinks/clickhouse/service.rs +++ b/src/sinks/clickhouse/service.rs @@ -5,19 +5,19 @@ use super::sink::PartitionKey; use crate::{ http::{Auth, HttpError}, sinks::{ + HTTPRequestBuilderSnafu, UriParseSnafu, clickhouse::config::Format, prelude::*, util::{ http::{HttpRequest, HttpResponse, HttpRetryLogic, HttpServiceRequestBuilder}, retries::RetryAction, }, - HTTPRequestBuilderSnafu, UriParseSnafu, }, }; use bytes::Bytes; use http::{ - header::{CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE}, Request, StatusCode, Uri, + header::{CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE}, }; use snafu::ResultExt; @@ -216,11 +216,14 @@ mod tests { QuerySettingsConfig::default(), ) .unwrap(); - assert_eq!(uri.to_string(), "http://localhost:80/?\ + assert_eq!( + uri.to_string(), + "http://localhost:80/?\ input_format_import_nested_json=1&\ input_format_skip_unknown_fields=0&\ date_time_input_format=best_effort&\ - query=INSERT+INTO+%22my_database%22.%22my_table%22+FORMAT+JSONEachRow"); + query=INSERT+INTO+%22my_database%22.%22my_table%22+FORMAT+JSONEachRow" + ); let uri = set_uri_query( &"http://localhost:80".parse().unwrap(), @@ -233,10 +236,13 @@ mod tests { QuerySettingsConfig::default(), ) .unwrap(); - assert_eq!(uri.to_string(), "http://localhost:80/?\ + assert_eq!( + uri.to_string(), + "http://localhost:80/?\ input_format_import_nested_json=1&\ input_format_skip_unknown_fields=0&\ - query=INSERT+INTO+%22my_database%22.%22my_%5C%22table%5C%22%22+FORMAT+JSONEachRow"); + query=INSERT+INTO+%22my_database%22.%22my_%5C%22table%5C%22%22+FORMAT+JSONEachRow" + ); let uri = set_uri_query( &"http://localhost:80".parse().unwrap(), @@ -249,11 +255,14 @@ mod tests { QuerySettingsConfig::default(), ) .unwrap(); - assert_eq!(uri.to_string(), "http://localhost:80/?\ + assert_eq!( + uri.to_string(), + "http://localhost:80/?\ input_format_import_nested_json=1&\ input_format_skip_unknown_fields=1&\ date_time_input_format=best_effort&\ - query=INSERT+INTO+%22my_database%22.%22my_%5C%22table%5C%22%22+FORMAT+JSONAsObject"); + query=INSERT+INTO+%22my_database%22.%22my_%5C%22table%5C%22%22+FORMAT+JSONAsObject" + ); let uri = set_uri_query( &"http://localhost:80".parse().unwrap(), @@ -266,10 +275,13 @@ mod tests { QuerySettingsConfig::default(), ) .unwrap(); - assert_eq!(uri.to_string(), "http://localhost:80/?\ + assert_eq!( + uri.to_string(), + "http://localhost:80/?\ input_format_import_nested_json=1&\ date_time_input_format=best_effort&\ - query=INSERT+INTO+%22my_database%22.%22my_%5C%22table%5C%22%22+FORMAT+JSONAsObject"); + query=INSERT+INTO+%22my_database%22.%22my_%5C%22table%5C%22%22+FORMAT+JSONAsObject" + ); let uri = set_uri_query( &"http://localhost:80".parse().unwrap(), @@ -289,13 +301,16 @@ mod tests { }, ) .unwrap(); - assert_eq!(uri.to_string(), "http://localhost:80/?\ + assert_eq!( + uri.to_string(), + "http://localhost:80/?\ input_format_import_nested_json=1&\ date_time_input_format=best_effort&\ async_insert=1&\ wait_for_async_insert=1&\ wait_for_async_insert_timeout=500&\ - query=INSERT+INTO+%22my_database%22.%22my_%5C%22table%5C%22%22+FORMAT+JSONAsObject"); + query=INSERT+INTO+%22my_database%22.%22my_%5C%22table%5C%22%22+FORMAT+JSONAsObject" + ); } #[test] diff --git a/src/sinks/console/config.rs b/src/sinks/console/config.rs index 4bfe81c9435e9..6670786f5847f 100644 --- a/src/sinks/console/config.rs +++ b/src/sinks/console/config.rs @@ -1,15 +1,15 @@ -use futures::{future, FutureExt}; +use futures::{FutureExt, future}; use tokio::io; use vector_lib::codecs::{ - encoding::{Framer, FramingConfig}, JsonSerializerConfig, + encoding::{Framer, FramingConfig}, }; use vector_lib::configurable::configurable_component; use crate::{ codecs::{Encoder, EncodingConfigWithFraming, SinkType}, config::{AcknowledgementsConfig, GenerateConfig, Input, SinkConfig, SinkContext}, - sinks::{console::sink::WriterSink, Healthcheck, VectorSink}, + sinks::{Healthcheck, VectorSink, console::sink::WriterSink}, }; /// The [standard stream][standard_streams] to write to. diff --git a/src/sinks/console/sink.rs b/src/sinks/console/sink.rs index 326942d56e9ae..72d787b9cf86c 100644 --- a/src/sinks/console/sink.rs +++ b/src/sinks/console/sink.rs @@ -1,14 +1,14 @@ use async_trait::async_trait; use bytes::BytesMut; -use futures::{stream::BoxStream, StreamExt}; +use futures::{StreamExt, stream::BoxStream}; use tokio::{io, io::AsyncWriteExt}; use tokio_util::codec::Encoder as _; use vector_lib::codecs::encoding::Framer; use vector_lib::{ + EstimatedJsonEncodedSizeOf, internal_event::{ ByteSize, BytesSent, CountByteSize, EventsSent, InternalEventHandle as _, Output, Protocol, }, - EstimatedJsonEncodedSizeOf, }; use crate::{ @@ -73,7 +73,7 @@ mod test { use super::*; use crate::{ event::{Event, LogEvent}, - test_util::components::{run_and_assert_sink_compliance, SINK_TAGS}, + test_util::components::{SINK_TAGS, run_and_assert_sink_compliance}, }; #[tokio::test] diff --git a/src/sinks/databend/config.rs b/src/sinks/databend/config.rs index 4c4c4566ceafd..92384cbf51a78 100644 --- a/src/sinks/databend/config.rs +++ b/src/sinks/databend/config.rs @@ -12,11 +12,11 @@ use crate::{ config::{AcknowledgementsConfig, Input, SinkConfig, SinkContext}, http::{Auth, MaybeAuth}, sinks::{ + Healthcheck, VectorSink, util::{ BatchConfig, Compression, RealtimeSizeBasedDefaultBatchSettings, ServiceBuilderExt, TowerRequestConfig, UriSerde, }, - Healthcheck, VectorSink, }, tls::TlsConfig, vector_version, diff --git a/src/sinks/databend/encoding.rs b/src/sinks/databend/encoding.rs index 4aba84b7f3c82..bcff2b14c17d1 100644 --- a/src/sinks/databend/encoding.rs +++ b/src/sinks/databend/encoding.rs @@ -1,4 +1,4 @@ -use vector_lib::codecs::{encoding::SerializerConfig, CsvSerializerConfig, JsonSerializerConfig}; +use vector_lib::codecs::{CsvSerializerConfig, JsonSerializerConfig, encoding::SerializerConfig}; use vector_lib::configurable::configurable_component; use crate::codecs::{EncodingConfig, Transformer}; diff --git a/src/sinks/databend/integration_tests.rs b/src/sinks/databend/integration_tests.rs index 8bbf469aff364..74db60ecc0cd2 100644 --- a/src/sinks/databend/integration_tests.rs +++ b/src/sinks/databend/integration_tests.rs @@ -12,7 +12,7 @@ use crate::{ config::{SinkConfig, SinkContext}, sinks::util::UriSerde, test_util::{ - components::{run_and_assert_sink_compliance, HTTP_SINK_TAGS}, + components::{HTTP_SINK_TAGS, run_and_assert_sink_compliance}, random_table_name, trace_init, }, }; diff --git a/src/sinks/databend/request_builder.rs b/src/sinks/databend/request_builder.rs index 5dbc3ecb856ec..11c7c88b84549 100644 --- a/src/sinks/databend/request_builder.rs +++ b/src/sinks/databend/request_builder.rs @@ -10,7 +10,7 @@ use crate::sinks::util::Compression; use crate::{ codecs::{Encoder, Transformer}, sinks::util::{ - metadata::RequestMetadataBuilder, request_builder::EncodeResult, RequestBuilder, + RequestBuilder, metadata::RequestMetadataBuilder, request_builder::EncodeResult, }, }; diff --git a/src/sinks/databend/service.rs b/src/sinks/databend/service.rs index 2069771088fd4..c7f8076d9c9fc 100644 --- a/src/sinks/databend/service.rs +++ b/src/sinks/databend/service.rs @@ -8,7 +8,7 @@ use chrono::Utc; use databend_client::APIClient as DatabendAPIClient; use databend_client::Error as DatabendError; use futures::future::BoxFuture; -use rand::{rng, Rng}; +use rand::{Rng, rng}; use rand_distr::Alphanumeric; use snafu::Snafu; use tower::Service; diff --git a/src/sinks/datadog/events/config.rs b/src/sinks/datadog/events/config.rs index e2a05506d894d..3697e09fd8bd3 100644 --- a/src/sinks/datadog/events/config.rs +++ b/src/sinks/datadog/events/config.rs @@ -14,9 +14,9 @@ use crate::{ config::{AcknowledgementsConfig, GenerateConfig, Input, SinkConfig, SinkContext}, http::HttpClient, sinks::{ - datadog::{DatadogCommonConfig, LocalDatadogCommonConfig}, - util::{http::HttpStatusRetryLogic, ServiceBuilderExt, TowerRequestConfig}, Healthcheck, VectorSink, + datadog::{DatadogCommonConfig, LocalDatadogCommonConfig}, + util::{ServiceBuilderExt, TowerRequestConfig, http::HttpStatusRetryLogic}, }, tls::MaybeTlsSettings, }; diff --git a/src/sinks/datadog/events/request_builder.rs b/src/sinks/datadog/events/request_builder.rs index b2aa8bb1d7067..3e5ce252850fc 100644 --- a/src/sinks/datadog/events/request_builder.rs +++ b/src/sinks/datadog/events/request_builder.rs @@ -1,17 +1,17 @@ use std::{io, sync::Arc}; use bytes::Bytes; +use vector_lib::ByteSizeOf; use vector_lib::codecs::JsonSerializerConfig; use vector_lib::lookup::lookup_v2::ConfigValuePath; use vector_lib::request_metadata::{MetaDescriptive, RequestMetadata}; -use vector_lib::ByteSizeOf; use crate::{ codecs::{Encoder, TimestampFormat, Transformer}, event::{Event, EventFinalizers, Finalizable}, sinks::util::{ - metadata::RequestMetadataBuilder, request_builder::EncodeResult, Compression, ElementCount, - RequestBuilder, + Compression, ElementCount, RequestBuilder, metadata::RequestMetadataBuilder, + request_builder::EncodeResult, }, }; diff --git a/src/sinks/datadog/events/sink.rs b/src/sinks/datadog/events/sink.rs index c2a5b4c018158..38531209fd329 100644 --- a/src/sinks/datadog/events/sink.rs +++ b/src/sinks/datadog/events/sink.rs @@ -3,7 +3,7 @@ use std::fmt; use vector_lib::lookup::event_path; use crate::{ - internal_events::{ParserMissingFieldError, DROP_EVENT}, + internal_events::{DROP_EVENT, ParserMissingFieldError}, sinks::{ datadog::events::request_builder::{DatadogEventsRequest, DatadogEventsRequestBuilder}, prelude::*, diff --git a/src/sinks/datadog/events/tests.rs b/src/sinks/datadog/events/tests.rs index d19e5e87a2443..c3588396c39df 100644 --- a/src/sinks/datadog/events/tests.rs +++ b/src/sinks/datadog/events/tests.rs @@ -2,9 +2,9 @@ use std::sync::Arc; use bytes::Bytes; use futures::{ + StreamExt, channel::mpsc::{Receiver, TryRecvError}, stream::Stream, - StreamExt, }; use hyper::StatusCode; use indoc::indoc; diff --git a/src/sinks/datadog/logs/config.rs b/src/sinks/datadog/logs/config.rs index c848e377ec896..68da21e432b25 100644 --- a/src/sinks/datadog/logs/config.rs +++ b/src/sinks/datadog/logs/config.rs @@ -13,7 +13,7 @@ use crate::{ http::HttpClient, schema, sinks::{ - datadog::{logs::service::LogApiService, DatadogCommonConfig, LocalDatadogCommonConfig}, + datadog::{DatadogCommonConfig, LocalDatadogCommonConfig, logs::service::LogApiService}, prelude::*, util::http::RequestConfig, }, @@ -219,7 +219,7 @@ mod test { use crate::codecs::EncodingConfigWithFraming; use crate::components::validation::prelude::*; use vector_lib::{ - codecs::{encoding::format::JsonSerializerOptions, JsonSerializerConfig, MetricTagValues}, + codecs::{JsonSerializerConfig, MetricTagValues, encoding::format::JsonSerializerOptions}, config::LogNamespace, }; diff --git a/src/sinks/datadog/logs/integration_tests.rs b/src/sinks/datadog/logs/integration_tests.rs index 56d5db161ed59..07d48d7f3d068 100644 --- a/src/sinks/datadog/logs/integration_tests.rs +++ b/src/sinks/datadog/logs/integration_tests.rs @@ -6,7 +6,7 @@ use crate::{ config::SinkConfig, sinks::util::test::load_sink, test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, generate_lines_with_stream, }, }; diff --git a/src/sinks/datadog/logs/service.rs b/src/sinks/datadog/logs/service.rs index 0375708d97ad1..844de5b4265b7 100644 --- a/src/sinks/datadog/logs/service.rs +++ b/src/sinks/datadog/logs/service.rs @@ -6,8 +6,8 @@ use std::{ use bytes::Bytes; use futures::future::BoxFuture; use http::{ - header::{CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE}, HeaderValue, Request, Uri, + header::{CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE}, }; use hyper::Body; use std::collections::BTreeMap; @@ -19,10 +19,10 @@ use vector_lib::stream::DriverResponse; use crate::{ http::HttpClient, - sinks::util::{retries::RetryLogic, Compression}, + sinks::util::{Compression, retries::RetryLogic}, sinks::{ datadog::DatadogApiError, - util::http::{validate_headers, OrderedHeaderName}, + util::http::{OrderedHeaderName, validate_headers}, }, }; diff --git a/src/sinks/datadog/logs/sink.rs b/src/sinks/datadog/logs/sink.rs index 79d873f2044c5..cb6b024da4bbf 100644 --- a/src/sinks/datadog/logs/sink.rs +++ b/src/sinks/datadog/logs/sink.rs @@ -12,10 +12,10 @@ use vrl::path::{OwnedSegment, OwnedTargetPath, PathPrefix}; use super::{config::MAX_PAYLOAD_BYTES, service::LogApiRequest}; use crate::{ - common::datadog::{is_reserved_attribute, DDTAGS, DD_RESERVED_SEMANTIC_ATTRS, MESSAGE}, + common::datadog::{DD_RESERVED_SEMANTIC_ATTRS, DDTAGS, MESSAGE, is_reserved_attribute}, sinks::{ prelude::*, - util::{http::HttpJsonBatchSizer, Compressor}, + util::{Compressor, http::HttpJsonBatchSizer}, }, }; #[derive(Default)] @@ -441,22 +441,23 @@ mod tests { use vector_lib::{ config::{LegacyKey, LogNamespace}, event::{Event, EventMetadata, LogEvent}, - schema::{meaning, Definition}, + schema::{Definition, meaning}, }; use vrl::{ core::Value, event_path, metadata_path, owned_value_path, value, - value::{kind::Collection, Kind}, + value::{Kind, kind::Collection}, }; use super::{normalize_as_agent_event, normalize_event}; use crate::common::datadog::DD_RESERVED_SEMANTIC_ATTRS; fn assert_normalized_log_has_expected_attrs(log: &LogEvent) { - assert!(log - .get(event_path!("timestamp")) - .expect("should have timestamp") - .is_integer()); + assert!( + log.get(event_path!("timestamp")) + .expect("should have timestamp") + .is_integer() + ); for attr in [ "message", diff --git a/src/sinks/datadog/logs/tests.rs b/src/sinks/datadog/logs/tests.rs index 987e27539da84..aa7075b405c10 100644 --- a/src/sinks/datadog/logs/tests.rs +++ b/src/sinks/datadog/logs/tests.rs @@ -5,17 +5,17 @@ use std::sync::Arc; use bytes::Bytes; use chrono::Utc; use futures::{ - channel::mpsc::{Receiver, TryRecvError}, StreamExt, + channel::mpsc::{Receiver, TryRecvError}, }; use http::request::Parts; use indoc::indoc; use vector_lib::{ - config::{init_telemetry, Tags, Telemetry}, + config::{Tags, Telemetry, init_telemetry}, event::{BatchNotifier, BatchStatus, Event, LogEvent}, }; -use crate::sinks::datadog::test_utils::{test_server, ApiStatus}; +use crate::sinks::datadog::test_utils::{ApiStatus, test_server}; use crate::{ common::datadog, config::{SinkConfig, SinkContext}, @@ -27,8 +27,9 @@ use crate::{ }, test_util::{ components::{ + COMPONENT_ERROR_TAGS, DATA_VOLUME_SINK_TAGS, SINK_TAGS, run_and_assert_data_volume_sink_compliance, run_and_assert_sink_compliance, - run_and_assert_sink_error, COMPONENT_ERROR_TAGS, DATA_VOLUME_SINK_TAGS, SINK_TAGS, + run_and_assert_sink_error, }, next_addr, random_lines_with_stream, }, @@ -520,9 +521,10 @@ async fn global_options() { .collect::>() .await; - assert!(keys - .iter() - .all(|value| value.to_str().unwrap() == "global-key")); + assert!( + keys.iter() + .all(|value| value.to_str().unwrap() == "global-key") + ); } #[tokio::test] @@ -566,7 +568,8 @@ async fn override_global_options() { .collect::>() .await; - assert!(keys - .iter() - .all(|value| value.to_str().unwrap() == "local-key")); + assert!( + keys.iter() + .all(|value| value.to_str().unwrap() == "local-key") + ); } diff --git a/src/sinks/datadog/metrics/config.rs b/src/sinks/datadog/metrics/config.rs index 53d59a0e801cc..c3f95ac1048a5 100644 --- a/src/sinks/datadog/metrics/config.rs +++ b/src/sinks/datadog/metrics/config.rs @@ -16,9 +16,9 @@ use crate::{ config::{AcknowledgementsConfig, Input, SinkConfig, SinkContext}, http::HttpClient, sinks::{ - datadog::{DatadogCommonConfig, LocalDatadogCommonConfig}, - util::{batch::BatchConfig, ServiceBuilderExt, SinkBatchSettings, TowerRequestConfig}, Healthcheck, UriParseSnafu, VectorSink, + datadog::{DatadogCommonConfig, LocalDatadogCommonConfig}, + util::{ServiceBuilderExt, SinkBatchSettings, TowerRequestConfig, batch::BatchConfig}, }, tls::{MaybeTlsSettings, TlsEnableableConfig}, }; diff --git a/src/sinks/datadog/metrics/encoder.rs b/src/sinks/datadog/metrics/encoder.rs index 95bf837f4aced..b5ea767c83508 100644 --- a/src/sinks/datadog/metrics/encoder.rs +++ b/src/sinks/datadog/metrics/encoder.rs @@ -10,10 +10,10 @@ use chrono::{DateTime, Utc}; use snafu::{ResultExt, Snafu}; use vector_lib::request_metadata::GroupedCountByteSize; use vector_lib::{ - config::{log_schema, telemetry, LogSchema}, - event::{metric::MetricSketch, DatadogMetricOriginMetadata, Metric, MetricTags, MetricValue}, - metrics::AgentDDSketch, EstimatedJsonEncodedSizeOf, + config::{LogSchema, log_schema, telemetry}, + event::{DatadogMetricOriginMetadata, Metric, MetricTags, MetricValue, metric::MetricSketch}, + metrics::AgentDDSketch, }; use super::config::{DatadogMetricsEndpoint, SeriesApiVersion}; @@ -22,7 +22,7 @@ use crate::{ DatadogMetricType, DatadogPoint, DatadogSeriesMetric, DatadogSeriesMetricMetadata, }, proto::fds::protobuf_descriptors, - sinks::util::{encode_namespace, request_builder::EncodeResult, Compression, Compressor}, + sinks::util::{Compression, Compressor, encode_namespace, request_builder::EncodeResult}, }; const SERIES_PAYLOAD_HEADER: &[u8] = b"{\"series\":["; @@ -285,7 +285,7 @@ impl DatadogMetricsEncoder { return Err(EncoderError::InvalidMetric { expected: "series", metric_value: value.as_name(), - }) + }); } }, // Sketches are encoded via ProtoBuf, also in an incremental fashion. @@ -313,7 +313,7 @@ impl DatadogMetricsEncoder { return Err(EncoderError::InvalidMetric { expected: "sketches", metric_value: value.as_name(), - }) + }); } }, } @@ -742,7 +742,9 @@ fn source_type_to_service(source_type: &str) -> Option { // But if it does occur, by setting the Service value to be undefined, we at least populate the // OriginProduct and OriginCategory. _ => { - debug!("Source {source_type} OriginService value is undefined! This source needs to be properly mapped to a Service value."); + debug!( + "Source {source_type} OriginService value is undefined! This source needs to be properly mapped to a Service value." + ); Some(0) } } @@ -855,7 +857,7 @@ fn generate_series_metrics( return Err(EncoderError::InvalidMetric { expected: "series", metric_value: value.as_name(), - }) + }); } }; @@ -996,22 +998,22 @@ mod tests { }; use prost::Message; use vector_lib::{ - config::{log_schema, LogSchema}, + config::{LogSchema, log_schema}, event::{ - metric::{MetricSketch, TagValue}, DatadogMetricOriginMetadata, EventMetadata, Metric, MetricKind, MetricTags, MetricValue, + metric::{MetricSketch, TagValue}, }, metric_tags, metrics::AgentDDSketch, }; use super::{ - ddmetric_proto, encode_proto_key_and_message, encode_tags, encode_timestamp, - generate_series_metrics, get_compressor, get_sketch_payload_sketches_field_number, - max_compression_overhead_len, max_uncompressed_header_len, series_to_proto_message, - sketch_to_proto_message, validate_payload_size_limits, write_payload_footer, - write_payload_header, DatadogMetricsEncoder, EncoderError, + DatadogMetricsEncoder, EncoderError, ddmetric_proto, encode_proto_key_and_message, + encode_tags, encode_timestamp, generate_series_metrics, get_compressor, + get_sketch_payload_sketches_field_number, max_compression_overhead_len, + max_uncompressed_header_len, series_to_proto_message, sketch_to_proto_message, + validate_payload_size_limits, write_payload_footer, write_payload_header, }; use crate::{ common::datadog::DatadogMetricType, diff --git a/src/sinks/datadog/metrics/integration_tests.rs b/src/sinks/datadog/metrics/integration_tests.rs index 02983a4d6ea36..79608902e5e9c 100644 --- a/src/sinks/datadog/metrics/integration_tests.rs +++ b/src/sinks/datadog/metrics/integration_tests.rs @@ -3,15 +3,15 @@ use std::num::NonZeroU32; use bytes::Bytes; use chrono::{SubsecRound, Utc}; use flate2::read::ZlibDecoder; -use futures::{channel::mpsc::Receiver, stream, StreamExt}; +use futures::{StreamExt, channel::mpsc::Receiver, stream}; use http::request::Parts; use hyper::StatusCode; use indoc::indoc; use prost::Message; -use rand::{rng, Rng}; +use rand::{Rng, rng}; use vector_lib::{ - config::{init_telemetry, Tags, Telemetry}, + config::{Tags, Telemetry, init_telemetry}, event::{BatchNotifier, BatchStatus, Event, Metric, MetricKind, MetricValue}, metric_tags, }; @@ -21,17 +21,17 @@ use crate::{ sinks::util::test::{build_test_server_status, load_sink}, test_util::{ components::{ - assert_data_volume_sink_compliance, assert_sink_compliance, DATA_VOLUME_SINK_TAGS, - SINK_TAGS, + DATA_VOLUME_SINK_TAGS, SINK_TAGS, assert_data_volume_sink_compliance, + assert_sink_compliance, }, map_event_batch_stream, next_addr, }, }; use super::{ + DatadogMetricsConfig, config::{SERIES_V1_PATH, SERIES_V2_PATH}, encoder::{ORIGIN_CATEGORY_VALUE, ORIGIN_PRODUCT_VALUE}, - DatadogMetricsConfig, }; #[allow(warnings, clippy::pedantic, clippy::nursery)] @@ -380,12 +380,14 @@ fn validate_json_counters(request: &(Parts, Bytes)) { assert_eq!(metric_names, sorted_names); let entry = series.first().unwrap().as_object().unwrap(); - assert!(entry - .get("metric") - .unwrap() - .as_str() - .unwrap() - .starts_with("foo.counter_"),); + assert!( + entry + .get("metric") + .unwrap() + .as_str() + .unwrap() + .starts_with("foo.counter_"), + ); assert_eq!(entry.get("type").unwrap().as_str().unwrap(), "count"); let points = entry .get("points") diff --git a/src/sinks/datadog/metrics/normalizer.rs b/src/sinks/datadog/metrics/normalizer.rs index 2c5df07cd108f..9830822421df1 100644 --- a/src/sinks/datadog/metrics/normalizer.rs +++ b/src/sinks/datadog/metrics/normalizer.rs @@ -39,7 +39,7 @@ impl MetricNormalize for DatadogMetricsNormalizer { #[cfg(test)] mod tests { use vector_lib::{ - event::{metric::MetricSketch, Metric, MetricKind, MetricValue}, + event::{Metric, MetricKind, MetricValue, metric::MetricSketch}, metrics::AgentDDSketch, }; diff --git a/src/sinks/datadog/metrics/request_builder.rs b/src/sinks/datadog/metrics/request_builder.rs index 83b53b8d2b6ed..ce3088d9f1f0c 100644 --- a/src/sinks/datadog/metrics/request_builder.rs +++ b/src/sinks/datadog/metrics/request_builder.rs @@ -9,7 +9,7 @@ use super::{ encoder::{CreateError, DatadogMetricsEncoder, EncoderError, FinishError}, service::DatadogMetricsRequest, }; -use crate::sinks::util::{metadata::RequestMetadataBuilder, IncrementalRequestBuilder}; +use crate::sinks::util::{IncrementalRequestBuilder, metadata::RequestMetadataBuilder}; #[derive(Debug, Snafu)] pub enum RequestBuilderError { diff --git a/src/sinks/datadog/metrics/service.rs b/src/sinks/datadog/metrics/service.rs index c1d0d6e52fc69..142d95f2b80cb 100644 --- a/src/sinks/datadog/metrics/service.rs +++ b/src/sinks/datadog/metrics/service.rs @@ -4,8 +4,8 @@ use std::task::{Context, Poll}; use bytes::Bytes; use futures::future::BoxFuture; use http::{ - header::{HeaderValue, CONTENT_ENCODING, CONTENT_TYPE}, Request, StatusCode, Uri, + header::{CONTENT_ENCODING, CONTENT_TYPE, HeaderValue}, }; use hyper::Body; use snafu::ResultExt; diff --git a/src/sinks/datadog/metrics/sink.rs b/src/sinks/datadog/metrics/sink.rs index b5f62d956b18b..51ead4510771d 100644 --- a/src/sinks/datadog/metrics/sink.rs +++ b/src/sinks/datadog/metrics/sink.rs @@ -3,9 +3,9 @@ use std::{fmt, sync::Arc}; use async_trait::async_trait; use chrono::Utc; use futures_util::{ + StreamExt, future::ready, stream::{self, BoxStream}, - StreamExt, }; use tower::Service; use vector_lib::stream::{BatcherSettings, DriverResponse}; @@ -22,9 +22,9 @@ use super::{ use crate::{ internal_events::DatadogMetricsEncodingError, sinks::util::{ + SinkBuilderExt, buffer::metrics::{AggregatedSummarySplitter, MetricSplitter}, request_builder::default_request_builder_concurrency_limit, - SinkBuilderExt, }, }; diff --git a/src/sinks/datadog/metrics/tests.rs b/src/sinks/datadog/metrics/tests.rs index 12575badbe83a..2b42bb1ff6592 100644 --- a/src/sinks/datadog/metrics/tests.rs +++ b/src/sinks/datadog/metrics/tests.rs @@ -2,14 +2,14 @@ use futures::StreamExt; use indoc::indoc; use vector_lib::finalization::{BatchNotifier, BatchStatus}; -use crate::sinks::datadog::test_utils::{test_server, ApiStatus}; +use crate::sinks::datadog::test_utils::{ApiStatus, test_server}; use crate::{ common::datadog, config::{SinkConfig, SinkContext}, extra_context::ExtraContext, sinks::util::test::load_sink_with_context, test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, next_addr, random_metrics_with_stream, }, }; @@ -52,9 +52,10 @@ async fn global_options() { .collect::>() .await; - assert!(keys - .iter() - .all(|value| value.to_str().unwrap() == "global-key")); + assert!( + keys.iter() + .all(|value| value.to_str().unwrap() == "global-key") + ); } #[tokio::test] @@ -97,7 +98,8 @@ async fn override_global_options() { .collect::>() .await; - assert!(keys - .iter() - .all(|value| value.to_str().unwrap() == "local-key")); + assert!( + keys.iter() + .all(|value| value.to_str().unwrap() == "local-key") + ); } diff --git a/src/sinks/datadog/traces/apm_stats/aggregation.rs b/src/sinks/datadog/traces/apm_stats/aggregation.rs index e1897df613233..d4474a7ebe1a3 100644 --- a/src/sinks/datadog/traces/apm_stats/aggregation.rs +++ b/src/sinks/datadog/traces/apm_stats/aggregation.rs @@ -4,8 +4,8 @@ use chrono::Utc; use vrl::event_path; use super::{ - bucket::Bucket, ClientStatsBucket, ClientStatsPayload, PartitionKey, - BUCKET_DURATION_NANOSECONDS, + BUCKET_DURATION_NANOSECONDS, ClientStatsBucket, ClientStatsPayload, PartitionKey, + bucket::Bucket, }; use crate::event::{ObjectMap, TraceEvent, Value}; diff --git a/src/sinks/datadog/traces/apm_stats/bucket.rs b/src/sinks/datadog/traces/apm_stats/bucket.rs index 7dd2334e7fe27..a67140e6feb58 100644 --- a/src/sinks/datadog/traces/apm_stats/bucket.rs +++ b/src/sinks/datadog/traces/apm_stats/bucket.rs @@ -3,8 +3,9 @@ use std::collections::BTreeMap; use prost::Message; use super::{ + ClientGroupedStats, ClientStatsBucket, aggregation::{AggregationKey, PayloadAggregationKey}, - ddsketch_full, ClientGroupedStats, ClientStatsBucket, + ddsketch_full, }; use crate::{event::ObjectMap, event::Value, metrics::AgentDDSketch}; diff --git a/src/sinks/datadog/traces/apm_stats/flusher.rs b/src/sinks/datadog/traces/apm_stats/flusher.rs index d1ee1e73e949b..a82934d3a7900 100644 --- a/src/sinks/datadog/traces/apm_stats/flusher.rs +++ b/src/sinks/datadog/traces/apm_stats/flusher.rs @@ -9,9 +9,9 @@ use tokio::sync::oneshot::{Receiver, Sender}; use vector_lib::{finalization::EventFinalizers, request_metadata::RequestMetadata}; use super::{ - aggregation::Aggregator, build_request, DDTracesMetadata, DatadogTracesEndpoint, - DatadogTracesEndpointConfiguration, RequestBuilderError, StatsPayload, - BUCKET_DURATION_NANOSECONDS, + BUCKET_DURATION_NANOSECONDS, DDTracesMetadata, DatadogTracesEndpoint, + DatadogTracesEndpointConfiguration, RequestBuilderError, StatsPayload, aggregation::Aggregator, + build_request, }; use crate::{ http::{BuildRequestSnafu, HttpClient}, diff --git a/src/sinks/datadog/traces/apm_stats/integration_tests.rs b/src/sinks/datadog/traces/apm_stats/integration_tests.rs index fbd2eb6d19b41..2411d6b2d5470 100644 --- a/src/sinks/datadog/traces/apm_stats/integration_tests.rs +++ b/src/sinks/datadog/traces/apm_stats/integration_tests.rs @@ -1,9 +1,9 @@ use axum::{ + Router, body::Body, extract::Extension, - http::{header::CONTENT_TYPE, Request}, + http::{Request, header::CONTENT_TYPE}, routing::{get, post}, - Router, }; use chrono::Utc; use flate2::read::GzDecoder; @@ -12,11 +12,11 @@ use rmp_serde; use serde::Serialize; use std::{collections::HashMap, io::Read, net::SocketAddr, sync::Arc}; use tokio::sync::mpsc::{self, Receiver, Sender}; -use tokio::time::{sleep, Duration}; +use tokio::time::{Duration, sleep}; use crate::{ config::ConfigBuilder, - sinks::datadog::traces::{apm_stats::StatsPayload, DatadogTracesConfig}, + sinks::datadog::traces::{DatadogTracesConfig, apm_stats::StatsPayload}, sources::datadog_agent::DatadogAgentConfig, test_util::{start_topology, trace_init}, topology::{RunningTopology, ShutdownErrorReceiver}, diff --git a/src/sinks/datadog/traces/apm_stats/mod.rs b/src/sinks/datadog/traces/apm_stats/mod.rs index e778b9af7064a..8e9896b271c19 100644 --- a/src/sinks/datadog/traces/apm_stats/mod.rs +++ b/src/sinks/datadog/traces/apm_stats/mod.rs @@ -14,7 +14,7 @@ pub use self::aggregation::Aggregator; pub use self::flusher::flush_apm_stats_thread; pub(crate) use super::config::{DatadogTracesEndpoint, DatadogTracesEndpointConfiguration}; -pub(crate) use super::request_builder::{build_request, DDTracesMetadata, RequestBuilderError}; +pub(crate) use super::request_builder::{DDTracesMetadata, RequestBuilderError, build_request}; pub(crate) use super::sink::PartitionKey; mod aggregation; diff --git a/src/sinks/datadog/traces/config.rs b/src/sinks/datadog/traces/config.rs index b94a07642290c..c908a1bdd2ff8 100644 --- a/src/sinks/datadog/traces/config.rs +++ b/src/sinks/datadog/traces/config.rs @@ -3,13 +3,13 @@ use std::sync::{Arc, Mutex}; use http::Uri; use indoc::indoc; use snafu::ResultExt; -use tokio::sync::oneshot::{channel, Sender}; +use tokio::sync::oneshot::{Sender, channel}; use tower::ServiceBuilder; -use vector_lib::config::{proxy::ProxyConfig, AcknowledgementsConfig}; +use vector_lib::config::{AcknowledgementsConfig, proxy::ProxyConfig}; use vector_lib::configurable::configurable_component; use super::{ - apm_stats::{flush_apm_stats_thread, Aggregator}, + apm_stats::{Aggregator, flush_apm_stats_thread}, service::TraceApiRetry, }; use crate::common::datadog; @@ -17,18 +17,18 @@ use crate::{ config::{GenerateConfig, Input, SinkConfig, SinkContext}, http::HttpClient, sinks::{ + Healthcheck, UriParseSnafu, VectorSink, datadog::{ + DatadogCommonConfig, LocalDatadogCommonConfig, traces::{ request_builder::DatadogTracesRequestBuilder, service::TraceApiService, sink::TracesSink, }, - DatadogCommonConfig, LocalDatadogCommonConfig, }, util::{ - service::ServiceBuilderExt, BatchConfig, Compression, SinkBatchSettings, - TowerRequestConfig, + BatchConfig, Compression, SinkBatchSettings, TowerRequestConfig, + service::ServiceBuilderExt, }, - Healthcheck, UriParseSnafu, VectorSink, }, tls::{MaybeTlsSettings, TlsEnableableConfig}, }; diff --git a/src/sinks/datadog/traces/integration_tests.rs b/src/sinks/datadog/traces/integration_tests.rs index dbfcbcdc7c691..aecac86af7b7d 100644 --- a/src/sinks/datadog/traces/integration_tests.rs +++ b/src/sinks/datadog/traces/integration_tests.rs @@ -5,11 +5,11 @@ use crate::{ config::SinkConfig, event::Event, sinks::{ - datadog::traces::{tests::simple_trace_event, DatadogTracesConfig}, + datadog::traces::{DatadogTracesConfig, tests::simple_trace_event}, util::test::load_sink, }, test_util::{ - components::{assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, assert_sink_compliance}, map_event_batch_stream, }, }; diff --git a/src/sinks/datadog/traces/request_builder.rs b/src/sinks/datadog/traces/request_builder.rs index 306d67ad17fcf..f230246662563 100644 --- a/src/sinks/datadog/traces/request_builder.rs +++ b/src/sinks/datadog/traces/request_builder.rs @@ -13,7 +13,7 @@ use vector_lib::request_metadata::RequestMetadata; use vrl::event_path; use super::{ - apm_stats::{compute_apm_stats, Aggregator}, + apm_stats::{Aggregator, compute_apm_stats}, config::{DatadogTracesEndpoint, DatadogTracesEndpointConfiguration}, dd_proto, service::TraceApiRequest, @@ -22,7 +22,7 @@ use super::{ use crate::{ event::{Event, ObjectMap, TraceEvent, Value}, sinks::util::{ - metadata::RequestMetadataBuilder, Compression, Compressor, IncrementalRequestBuilder, + Compression, Compressor, IncrementalRequestBuilder, metadata::RequestMetadataBuilder, }, }; @@ -437,7 +437,7 @@ mod test { use proptest::prelude::*; use vrl::event_path; - use super::{encode_traces, PartitionKey}; + use super::{PartitionKey, encode_traces}; use crate::event::{LogEvent, TraceEvent}; proptest! { diff --git a/src/sinks/datadog/traces/sink.rs b/src/sinks/datadog/traces/sink.rs index 25096e26f8d03..bce3f89d6da17 100644 --- a/src/sinks/datadog/traces/sink.rs +++ b/src/sinks/datadog/traces/sink.rs @@ -2,10 +2,10 @@ use std::{fmt::Debug, sync::Arc}; use async_trait::async_trait; use futures_util::{ - stream::{self, BoxStream}, StreamExt, + stream::{self, BoxStream}, }; -use tokio::sync::oneshot::{channel, Sender}; +use tokio::sync::oneshot::{Sender, channel}; use tower::Service; use vector_lib::stream::{BatcherSettings, DriverResponse}; use vector_lib::{config::log_schema, event::Event, partition::Partitioner, sink::StreamSink}; diff --git a/src/sinks/datadog/traces/tests.rs b/src/sinks/datadog/traces/tests.rs index 673f0d2729a27..a93c656fb87d7 100644 --- a/src/sinks/datadog/traces/tests.rs +++ b/src/sinks/datadog/traces/tests.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use bytes::Bytes; use chrono::{TimeZone, Utc}; -use futures::{channel::mpsc::Receiver, stream, StreamExt}; +use futures::{StreamExt, channel::mpsc::Receiver, stream}; use hyper::StatusCode; use indoc::indoc; use ordered_float::NotNan; @@ -11,7 +11,7 @@ use rmp_serde; use vector_lib::event::{BatchNotifier, BatchStatus, Event}; use vrl::event_path; -use super::{apm_stats::StatsPayload, dd_proto, ddsketch_full, DatadogTracesConfig}; +use super::{DatadogTracesConfig, apm_stats::StatsPayload, dd_proto, ddsketch_full}; use crate::{ common::datadog, @@ -20,7 +20,7 @@ use crate::{ extra_context::ExtraContext, sinks::util::test::{build_test_server_status, load_sink, load_sink_with_context}, test_util::{ - components::{assert_sink_compliance, run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, assert_sink_compliance, run_and_assert_sink_compliance}, map_event_batch_stream, next_addr, }, }; @@ -347,9 +347,10 @@ async fn global_options() { .collect::>() .await; - assert!(keys - .iter() - .all(|value| value.to_str().unwrap() == "global-key")); + assert!( + keys.iter() + .all(|value| value.to_str().unwrap() == "global-key") + ); } #[tokio::test] @@ -391,7 +392,8 @@ async fn override_global_options() { .collect::>() .await; - assert!(keys - .iter() - .all(|value| value.to_str().unwrap() == "local-key")); + assert!( + keys.iter() + .all(|value| value.to_str().unwrap() == "local-key") + ); } diff --git a/src/sinks/elasticsearch/common.rs b/src/sinks/elasticsearch/common.rs index 1d346d262cdd8..570339cbfef06 100644 --- a/src/sinks/elasticsearch/common.rs +++ b/src/sinks/elasticsearch/common.rs @@ -1,24 +1,24 @@ use bytes::{Buf, Bytes}; use http::{Response, StatusCode, Uri}; -use hyper::{body, Body}; +use hyper::{Body, body}; use serde::Deserialize; use snafu::ResultExt; -use vector_lib::config::proxy::ProxyConfig; use vector_lib::config::LogNamespace; +use vector_lib::config::proxy::ProxyConfig; use super::{ - request_builder::ElasticsearchRequestBuilder, ElasticsearchApiVersion, ElasticsearchEncoder, - InvalidHostSnafu, Request, VersionType, + ElasticsearchApiVersion, ElasticsearchEncoder, InvalidHostSnafu, Request, VersionType, + request_builder::ElasticsearchRequestBuilder, }; use crate::{ http::{HttpClient, MaybeAuth, ParameterValue, QueryParameterValue, QueryParameters}, sinks::{ + HealthcheckError, elasticsearch::{ ElasticsearchAuthConfig, ElasticsearchCommonMode, ElasticsearchConfig, OpenSearchServiceType, ParseError, }, - util::{auth::Auth, http::RequestConfig, UriSerde}, - HealthcheckError, + util::{UriSerde, auth::Auth, http::RequestConfig}, }, tls::TlsSettings, transforms::metric_to_log::MetricToLog, @@ -196,7 +196,9 @@ impl ElasticsearchCommon { let doc_type = config.doc_type.clone(); let suppress_type_name = if config.suppress_type_name { - warn!(message = "DEPRECATION, use of deprecated option `suppress_type_name`. Please use `api_version` option instead."); + warn!( + message = "DEPRECATION, use of deprecated option `suppress_type_name`. Please use `api_version` option instead." + ); config.suppress_type_name } else { version >= 7 @@ -292,7 +294,9 @@ impl ElasticsearchCommon { ) -> crate::Result> { let mut version = None; if let Some(endpoint) = config.endpoint.as_ref() { - warn!(message = "DEPRECATION, use of deprecated option `endpoint`. Please use `endpoints` option instead."); + warn!( + message = "DEPRECATION, use of deprecated option `endpoint`. Please use `endpoints` option instead." + ); if config.endpoints.is_empty() { Ok(vec![ Self::parse_config(config, endpoint, proxy_config, &mut version).await?, @@ -323,7 +327,9 @@ impl ElasticsearchCommon { pub async fn healthcheck(self, client: HttpClient) -> crate::Result<()> { if self.service_type == OpenSearchServiceType::Serverless { - warn!(message = "Amazon OpenSearch Serverless does not support healthchecks. Skipping healthcheck..."); + warn!( + message = "Amazon OpenSearch Serverless does not support healthchecks. Skipping healthcheck..." + ); Ok(()) } else { match get( diff --git a/src/sinks/elasticsearch/config.rs b/src/sinks/elasticsearch/config.rs index 6b8d633fccf97..4aef55ac5dc73 100644 --- a/src/sinks/elasticsearch/config.rs +++ b/src/sinks/elasticsearch/config.rs @@ -13,19 +13,19 @@ use crate::{ http::{HttpClient, QueryParameters}, internal_events::TemplateRenderingError, sinks::{ + Healthcheck, VectorSink, elasticsearch::{ + ElasticsearchApiVersion, ElasticsearchAuthConfig, ElasticsearchCommon, + ElasticsearchCommonMode, ElasticsearchMode, VersionType, health::ElasticsearchHealthLogic, retry::ElasticsearchRetryLogic, service::{ElasticsearchService, HttpRequestBuilder}, sink::ElasticsearchSink, - ElasticsearchApiVersion, ElasticsearchAuthConfig, ElasticsearchCommon, - ElasticsearchCommonMode, ElasticsearchMode, VersionType, }, util::{ - http::RequestConfig, service::HealthConfig, BatchConfig, Compression, - RealtimeSizeBasedDefaultBatchSettings, + BatchConfig, Compression, RealtimeSizeBasedDefaultBatchSettings, http::RequestConfig, + service::HealthConfig, }, - Healthcheck, VectorSink, }, template::Template, tls::TlsConfig, diff --git a/src/sinks/elasticsearch/encoder.rs b/src/sinks/elasticsearch/encoder.rs index 1e3b4b354c4e4..7cda4fb700ed9 100644 --- a/src/sinks/elasticsearch/encoder.rs +++ b/src/sinks/elasticsearch/encoder.rs @@ -3,7 +3,7 @@ use std::{io, io::Write}; use serde::Serialize; use serde_json::json; use vector_lib::buffers::EventCount; -use vector_lib::{config::telemetry, event::Event, ByteSizeOf, EstimatedJsonEncodedSizeOf}; +use vector_lib::{ByteSizeOf, EstimatedJsonEncodedSizeOf, config::telemetry, event::Event}; use vector_lib::{ internal_event::TaggedEventsSent, json_size::JsonSize, @@ -15,7 +15,7 @@ use crate::{ event::{EventFinalizers, Finalizable, LogEvent}, sinks::{ elasticsearch::{BulkAction, VersionType}, - util::encoding::{as_tracked_write, Encoder}, + util::encoding::{Encoder, as_tracked_write}, }, }; diff --git a/src/sinks/elasticsearch/integration_tests.rs b/src/sinks/elasticsearch/integration_tests.rs index 34f471e8f77c8..1d6626ba5f86e 100644 --- a/src/sinks/elasticsearch/integration_tests.rs +++ b/src/sinks/elasticsearch/integration_tests.rs @@ -6,9 +6,9 @@ use chrono::Utc; use futures::StreamExt; use futures::{future::ready, stream}; use http::{Request, StatusCode}; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use vector_lib::{ - config::{init_telemetry, log_schema, Tags, Telemetry}, + config::{Tags, Telemetry, init_telemetry, log_schema}, event::{BatchNotifier, BatchStatus, Event, LogEvent}, }; @@ -18,13 +18,14 @@ use crate::{ config::{ProxyConfig, SinkConfig, SinkContext}, http::{HttpClient, ParameterValue, QueryParameterValue}, sinks::{ - util::{auth::Auth, BatchConfig, Compression, SinkBatchSettings}, HealthcheckError, + util::{BatchConfig, Compression, SinkBatchSettings, auth::Auth}, }, test_util::{ components::{ + COMPONENT_ERROR_TAGS, DATA_VOLUME_SINK_TAGS, HTTP_SINK_TAGS, run_and_assert_data_volume_sink_compliance, run_and_assert_sink_compliance, - run_and_assert_sink_error, COMPONENT_ERROR_TAGS, DATA_VOLUME_SINK_TAGS, HTTP_SINK_TAGS, + run_and_assert_sink_error, }, random_events_with_stream, random_string, trace_init, }, @@ -91,7 +92,7 @@ impl ElasticsearchCommon { } async fn flush(common: ElasticsearchCommon) -> crate::Result<()> { - use tokio::time::{sleep, Duration}; + use tokio::time::{Duration, sleep}; sleep(Duration::from_secs(2)).await; common.flush_request().await?; sleep(Duration::from_secs(2)).await; diff --git a/src/sinks/elasticsearch/mod.rs b/src/sinks/elasticsearch/mod.rs index 8f9042c9b41e4..4abe69fe08a9f 100644 --- a/src/sinks/elasticsearch/mod.rs +++ b/src/sinks/elasticsearch/mod.rs @@ -19,7 +19,7 @@ use std::{convert::TryFrom, fmt}; pub use common::*; pub use config::*; pub use encoder::ElasticsearchEncoder; -use http::{uri::InvalidUri, Request}; +use http::{Request, uri::InvalidUri}; use snafu::Snafu; use vector_lib::sensitive_string::SensitiveString; use vector_lib::{configurable::configurable_component, internal_event}; diff --git a/src/sinks/elasticsearch/request_builder.rs b/src/sinks/elasticsearch/request_builder.rs index 5314c78527f48..75980c2456f0a 100644 --- a/src/sinks/elasticsearch/request_builder.rs +++ b/src/sinks/elasticsearch/request_builder.rs @@ -10,8 +10,8 @@ use crate::{ service::ElasticsearchRequest, }, util::{ - metadata::RequestMetadataBuilder, request_builder::EncodeResult, Compression, - RequestBuilder, + Compression, RequestBuilder, metadata::RequestMetadataBuilder, + request_builder::EncodeResult, }, }, }; diff --git a/src/sinks/elasticsearch/retry.rs b/src/sinks/elasticsearch/retry.rs index becdcc62ed194..70114b8b564bc 100644 --- a/src/sinks/elasticsearch/retry.rs +++ b/src/sinks/elasticsearch/retry.rs @@ -12,8 +12,8 @@ use crate::{ }; use http::StatusCode; use serde::Deserialize; -use vector_lib::json_size::JsonSize; use vector_lib::EstimatedJsonEncodedSizeOf; +use vector_lib::json_size::JsonSize; #[derive(Deserialize, Debug)] struct EsResultResponse { @@ -154,7 +154,7 @@ impl RetryLogic for ElasticsearchRetryLogic { .clone() .into_iter() .zip(status_codes.iter()) - .filter(|(_, &flag)| flag) + .filter(|&(_, &flag)| flag) .map(|(item, _)| item) .collect(); let finalizers = failed_events.take_finalizers(); @@ -258,7 +258,10 @@ mod tests { Ok(resp) => resp.get_error_reason(json), Err(msg) => msg, }; - assert_eq!(reason, "error type: illegal_argument_exception, reason: mapper [message] of different type, current_type [long], merged_type [text]"); + assert_eq!( + reason, + "error type: illegal_argument_exception, reason: mapper [message] of different type, current_type [long], merged_type [text]" + ); } #[test] @@ -268,6 +271,9 @@ mod tests { Ok(resp) => resp.get_error_reason(json), Err(msg) => msg, }; - assert_eq!(reason, "error type: mapper_parsing_exception, reason: object mapping for [host] tried to parse field [host] as object, but found a concrete value"); + assert_eq!( + reason, + "error type: mapper_parsing_exception, reason: object mapping for [host] tried to parse field [host] as object, but found a concrete value" + ); } } diff --git a/src/sinks/elasticsearch/service.rs b/src/sinks/elasticsearch/service.rs index 61066783335e2..67b28608ef5f9 100644 --- a/src/sinks/elasticsearch/service.rs +++ b/src/sinks/elasticsearch/service.rs @@ -6,10 +6,10 @@ use std::{ use bytes::Bytes; use futures::future::BoxFuture; use http::{Response, Uri}; -use hyper::{service::Service, Body, Request}; +use hyper::{Body, Request, service::Service}; use tower::ServiceExt; -use vector_lib::stream::DriverResponse; use vector_lib::ByteSizeOf; +use vector_lib::stream::DriverResponse; use vector_lib::{ json_size::JsonSize, request_metadata::{GroupedCountByteSize, MetaDescriptive, RequestMetadata}, @@ -22,9 +22,9 @@ use crate::{ sinks::{ elasticsearch::{encoder::ProcessedEvent, request_builder::ElasticsearchRequestBuilder}, util::{ + Compression, ElementCount, auth::Auth, http::{HttpBatchService, RequestConfig}, - Compression, ElementCount, }, }, }; diff --git a/src/sinks/elasticsearch/sink.rs b/src/sinks/elasticsearch/sink.rs index 5c72f3e766419..07d465caaf54b 100644 --- a/src/sinks/elasticsearch/sink.rs +++ b/src/sinks/elasticsearch/sink.rs @@ -6,8 +6,8 @@ use vrl::path::PathPrefix; use crate::{ sinks::{ elasticsearch::{ - encoder::ProcessedEvent, request_builder::ElasticsearchRequestBuilder, - service::ElasticsearchRequest, BulkAction, ElasticsearchCommonMode, + BulkAction, ElasticsearchCommonMode, encoder::ProcessedEvent, + request_builder::ElasticsearchRequestBuilder, service::ElasticsearchRequest, }, prelude::*, }, @@ -15,8 +15,8 @@ use crate::{ }; use super::{ - encoder::{DocumentMetadata, DocumentVersion, DocumentVersionType}, ElasticsearchCommon, ElasticsearchConfig, VersionType, + encoder::{DocumentMetadata, DocumentVersion, DocumentVersionType}, }; #[derive(Clone, Eq, Hash, PartialEq)] diff --git a/src/sinks/elasticsearch/tests.rs b/src/sinks/elasticsearch/tests.rs index fbb95e00dcafe..7e805b4cf1104 100644 --- a/src/sinks/elasticsearch/tests.rs +++ b/src/sinks/elasticsearch/tests.rs @@ -10,8 +10,8 @@ use crate::{ event::{LogEvent, Metric, MetricKind, MetricValue, ObjectMap, Value}, sinks::{ elasticsearch::{ - sink::process_log, BulkAction, BulkConfig, DataStreamConfig, ElasticsearchApiVersion, - ElasticsearchCommon, ElasticsearchConfig, ElasticsearchMode, VersionType, + BulkAction, BulkConfig, DataStreamConfig, ElasticsearchApiVersion, ElasticsearchCommon, + ElasticsearchConfig, ElasticsearchMode, VersionType, sink::process_log, }, util::encoding::Encoder, }, @@ -366,10 +366,12 @@ async fn handle_metrics() { encoded_lines.first().unwrap(), r#"{"create":{"_type":"_doc","_index":"vector"}}"# ); - assert!(encoded_lines - .get(1) - .unwrap() - .starts_with(r#"{"gauge":{"value":42.0},"kind":"absolute","name":"cpu","timestamp""#)); + assert!( + encoded_lines + .get(1) + .unwrap() + .starts_with(r#"{"gauge":{"value":42.0},"kind":"absolute","name":"cpu","timestamp""#) + ); } #[tokio::test] diff --git a/src/sinks/file/mod.rs b/src/sinks/file/mod.rs index 942da67905b3b..23b0cd56c9041 100644 --- a/src/sinks/file/mod.rs +++ b/src/sinks/file/mod.rs @@ -5,9 +5,8 @@ use async_compression::tokio::write::{GzipEncoder, ZstdEncoder}; use async_trait::async_trait; use bytes::{Bytes, BytesMut}; use futures::{ - future, + FutureExt, future, stream::{BoxStream, StreamExt}, - FutureExt, }; use serde_with::serde_as; use tokio::{ @@ -16,13 +15,13 @@ use tokio::{ }; use tokio_util::codec::Encoder as _; use vector_lib::codecs::{ - encoding::{Framer, FramingConfig}, TextSerializerConfig, + encoding::{Framer, FramingConfig}, }; use vector_lib::configurable::configurable_component; use vector_lib::{ - internal_event::{CountByteSize, EventsSent, InternalEventHandle as _, Output, Registered}, EstimatedJsonEncodedSizeOf, TimeZone, + internal_event::{CountByteSize, EventsSent, InternalEventHandle as _, Output, Registered}, }; use crate::{ @@ -33,7 +32,7 @@ use crate::{ internal_events::{ FileBytesSent, FileInternalMetricsConfig, FileIoError, FileOpen, TemplateRenderingError, }, - sinks::util::{timezone_to_offset, StreamSink}, + sinks::util::{StreamSink, timezone_to_offset}, template::Template, }; @@ -444,7 +443,7 @@ mod tests { use std::convert::TryInto; use chrono::{SubsecRound, Utc}; - use futures::{stream, SinkExt}; + use futures::{SinkExt, stream}; use similar_asserts::assert_eq; use vector_lib::{ codecs::JsonSerializerConfig, @@ -456,7 +455,7 @@ mod tests { use crate::{ config::log_schema, test_util::{ - components::{assert_sink_compliance, FILE_SINK_TAGS}, + components::{FILE_SINK_TAGS, assert_sink_compliance}, lines_from_file, lines_from_gzip_file, lines_from_zstd_file, random_events_with_stream, random_lines_with_stream, random_metrics_with_stream, random_metrics_with_stream_timestamp, temp_dir, temp_file, trace_init, diff --git a/src/sinks/gcp/cloud_storage.rs b/src/sinks/gcp/cloud_storage.rs index 4004565fb2e31..cc18a2fa84ffb 100644 --- a/src/sinks/gcp/cloud_storage.rs +++ b/src/sinks/gcp/cloud_storage.rs @@ -2,8 +2,8 @@ use std::{collections::HashMap, convert::TryFrom, io}; use bytes::Bytes; use chrono::{FixedOffset, Utc}; -use http::header::{HeaderName, HeaderValue}; use http::Uri; +use http::header::{HeaderName, HeaderValue}; use indoc::indoc; use snafu::ResultExt; use snafu::Snafu; @@ -12,7 +12,7 @@ use uuid::Uuid; use vector_lib::codecs::encoding::Framer; use vector_lib::configurable::configurable_component; use vector_lib::event::{EventFinalizers, Finalizable}; -use vector_lib::{request_metadata::RequestMetadata, TimeZone}; +use vector_lib::{TimeZone, request_metadata::RequestMetadata}; use crate::sinks::util::metadata::RequestMetadataBuilder; use crate::sinks::util::service::TowerRequestConfigDefaults; @@ -21,23 +21,23 @@ use crate::{ config::{AcknowledgementsConfig, DataType, GenerateConfig, Input, SinkConfig, SinkContext}, event::Event, gcp::{GcpAuthConfig, GcpAuthenticator, Scope}, - http::{get_http_scheme_from_uri, HttpClient}, + http::{HttpClient, get_http_scheme_from_uri}, serde::json::to_string, sinks::{ + Healthcheck, VectorSink, gcs_common::{ config::{ - build_healthcheck, default_endpoint, GcsPredefinedAcl, GcsRetryLogic, - GcsStorageClass, + GcsPredefinedAcl, GcsRetryLogic, GcsStorageClass, build_healthcheck, + default_endpoint, }, service::{GcsRequest, GcsRequestSettings, GcsService}, sink::GcsSink, }, util::{ - batch::BatchConfig, partitioner::KeyPartitioner, request_builder::EncodeResult, - timezone_to_offset, BulkSizeBasedDefaultBatchSettings, Compression, RequestBuilder, - ServiceBuilderExt, TowerRequestConfig, + BulkSizeBasedDefaultBatchSettings, Compression, RequestBuilder, ServiceBuilderExt, + TowerRequestConfig, batch::BatchConfig, partitioner::KeyPartitioner, + request_builder::EncodeResult, timezone_to_offset, }, - Healthcheck, VectorSink, }, template::{Template, TemplateParseError}, tls::{TlsConfig, TlsSettings}, @@ -446,17 +446,17 @@ fn make_header((name, value): (&String, &String)) -> crate::Result<(HeaderName, #[cfg(test)] mod tests { use futures_util::{future::ready, stream}; + use vector_lib::EstimatedJsonEncodedSizeOf; use vector_lib::codecs::encoding::FramingConfig; use vector_lib::codecs::{ JsonSerializerConfig, NewlineDelimitedEncoderConfig, TextSerializerConfig, }; use vector_lib::partition::Partitioner; use vector_lib::request_metadata::GroupedCountByteSize; - use vector_lib::EstimatedJsonEncodedSizeOf; use crate::event::LogEvent; use crate::test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, http::{always_200_response, spawn_blackhole_http_server}, }; diff --git a/src/sinks/gcp/pubsub.rs b/src/sinks/gcp/pubsub.rs index 67c5a8bcfb3fd..54c3d5945f61f 100644 --- a/src/sinks/gcp/pubsub.rs +++ b/src/sinks/gcp/pubsub.rs @@ -1,10 +1,10 @@ -use base64::prelude::{Engine as _, BASE64_STANDARD}; +use base64::prelude::{BASE64_STANDARD, Engine as _}; use bytes::{Bytes, BytesMut}; use futures::{FutureExt, SinkExt}; use http::{Request, Uri}; use hyper::Body; use indoc::indoc; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use snafu::{ResultExt, Snafu}; use tokio_util::codec::Encoder as _; use vector_lib::configurable::configurable_component; @@ -13,15 +13,15 @@ use crate::{ codecs::{Encoder, EncodingConfig, Transformer}, config::{AcknowledgementsConfig, GenerateConfig, Input, SinkConfig, SinkContext}, event::Event, - gcp::{GcpAuthConfig, GcpAuthenticator, Scope, PUBSUB_URL}, + gcp::{GcpAuthConfig, GcpAuthenticator, PUBSUB_URL, Scope}, http::HttpClient, sinks::{ + Healthcheck, UriParseSnafu, VectorSink, gcs_common::config::healthcheck_response, util::{ - http::{BatchedHttpSink, HttpEventEncoder, HttpSink}, BatchConfig, BoxedRawValue, JsonArrayBuffer, SinkBatchSettings, TowerRequestConfig, + http::{BatchedHttpSink, HttpEventEncoder, HttpSink}, }, - Healthcheck, UriParseSnafu, VectorSink, }, tls::{TlsConfig, TlsSettings}, }; @@ -269,15 +269,15 @@ mod tests { mod integration_tests { use reqwest::{Client, Method, Response}; use serde::{Deserialize, Serialize}; - use serde_json::{json, Value}; + use serde_json::{Value, json}; use vector_lib::codecs::JsonSerializerConfig; use vector_lib::event::{BatchNotifier, BatchStatus}; use super::*; use crate::gcp; - use crate::test_util::components::{run_and_assert_sink_error, COMPONENT_ERROR_TAGS}; + use crate::test_util::components::{COMPONENT_ERROR_TAGS, run_and_assert_sink_error}; use crate::test_util::{ - components::{run_and_assert_sink_compliance, HTTP_SINK_TAGS}, + components::{HTTP_SINK_TAGS, run_and_assert_sink_compliance}, random_events_with_stream, random_metrics_with_stream, random_string, trace_init, }; diff --git a/src/sinks/gcp/stackdriver/logs/config.rs b/src/sinks/gcp/stackdriver/logs/config.rs index e04da61ce9c83..ac27aab48eac1 100644 --- a/src/sinks/gcp/stackdriver/logs/config.rs +++ b/src/sinks/gcp/stackdriver/logs/config.rs @@ -8,9 +8,9 @@ use crate::{ gcs_common::config::healthcheck_response, prelude::*, util::{ - http::{http_response_retry_logic, HttpService}, - service::TowerRequestConfigDefaults, BoxedRawValue, RealtimeSizeBasedDefaultBatchSettings, + http::{HttpService, http_response_retry_logic}, + service::TowerRequestConfigDefaults, }, }, }; diff --git a/src/sinks/gcp/stackdriver/logs/encoder.rs b/src/sinks/gcp/stackdriver/logs/encoder.rs index 76359ca5fdd7c..0893e37897185 100644 --- a/src/sinks/gcp/stackdriver/logs/encoder.rs +++ b/src/sinks/gcp/stackdriver/logs/encoder.rs @@ -3,7 +3,7 @@ use std::{collections::HashMap, io}; use bytes::BytesMut; -use serde_json::{json, to_vec, Map}; +use serde_json::{Map, json, to_vec}; use vector_lib::lookup::lookup_v2::ConfigValuePath; use vrl::event_path; use vrl::path::PathPrefix; @@ -14,7 +14,7 @@ use crate::{ }; use super::config::{ - default_labels_key, StackdriverLabelConfig, StackdriverLogName, StackdriverResource, + StackdriverLabelConfig, StackdriverLogName, StackdriverResource, default_labels_key, }; #[derive(Clone, Debug)] diff --git a/src/sinks/gcp/stackdriver/logs/service.rs b/src/sinks/gcp/stackdriver/logs/service.rs index 9a08214fc1959..72d656134d27a 100644 --- a/src/sinks/gcp/stackdriver/logs/service.rs +++ b/src/sinks/gcp/stackdriver/logs/service.rs @@ -1,13 +1,13 @@ //! Service implementation for the `gcp_stackdriver_logs` sink. use bytes::Bytes; -use http::{header::CONTENT_TYPE, Request, Uri}; +use http::{Request, Uri, header::CONTENT_TYPE}; use crate::{ gcp::GcpAuthenticator, sinks::{ - util::http::{HttpRequest, HttpServiceRequestBuilder}, HTTPRequestBuilderSnafu, + util::http::{HttpRequest, HttpServiceRequestBuilder}, }, }; use snafu::ResultExt; diff --git a/src/sinks/gcp/stackdriver/logs/tests.rs b/src/sinks/gcp/stackdriver/logs/tests.rs index cde8fe964206f..757f1edae6f44 100644 --- a/src/sinks/gcp/stackdriver/logs/tests.rs +++ b/src/sinks/gcp/stackdriver/logs/tests.rs @@ -27,13 +27,13 @@ use crate::{ }, }, test_util::{ - components::{run_and_assert_sink_compliance, HTTP_SINK_TAGS}, + components::{HTTP_SINK_TAGS, run_and_assert_sink_compliance}, http::{always_200_response, spawn_blackhole_http_server}, }, }; use super::{ - config::{default_endpoint, StackdriverConfig, StackdriverResource}, + config::{StackdriverConfig, StackdriverResource, default_endpoint}, encoder::StackdriverLogsEncoder, }; diff --git a/src/sinks/gcp/stackdriver/metrics/config.rs b/src/sinks/gcp/stackdriver/metrics/config.rs index 8827db282c000..f379bc800b564 100644 --- a/src/sinks/gcp/stackdriver/metrics/config.rs +++ b/src/sinks/gcp/stackdriver/metrics/config.rs @@ -1,6 +1,6 @@ use bytes::Bytes; use goauth::scopes::Scope; -use http::{header::CONTENT_TYPE, Request, Uri}; +use http::{Request, Uri, header::CONTENT_TYPE}; use super::{ request_builder::{StackdriverMetricsEncoder, StackdriverMetricsRequestBuilder}, @@ -10,15 +10,14 @@ use crate::{ gcp::{GcpAuthConfig, GcpAuthenticator}, http::HttpClient, sinks::{ - gcp, + HTTPRequestBuilderSnafu, gcp, prelude::*, util::{ http::{ - http_response_retry_logic, HttpRequest, HttpService, HttpServiceRequestBuilder, + HttpRequest, HttpService, HttpServiceRequestBuilder, http_response_retry_logic, }, service::TowerRequestConfigDefaults, }, - HTTPRequestBuilderSnafu, }, }; use snafu::ResultExt; diff --git a/src/sinks/gcp/stackdriver/metrics/tests.rs b/src/sinks/gcp/stackdriver/metrics/tests.rs index 9662b749acebe..a5b3a40649d1f 100644 --- a/src/sinks/gcp/stackdriver/metrics/tests.rs +++ b/src/sinks/gcp/stackdriver/metrics/tests.rs @@ -9,7 +9,7 @@ use crate::{ gcp::GcpAuthConfig, sinks::{prelude::*, util::test::build_test_server}, test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, http::{always_200_response, spawn_blackhole_http_server}, next_addr, }, diff --git a/src/sinks/gcp_chronicle/chronicle_unstructured.rs b/src/sinks/gcp_chronicle/chronicle_unstructured.rs index dcd775c87f9f3..2ff5804e3c601 100644 --- a/src/sinks/gcp_chronicle/chronicle_unstructured.rs +++ b/src/sinks/gcp_chronicle/chronicle_unstructured.rs @@ -19,10 +19,10 @@ use tower::{Service, ServiceBuilder}; use vector_lib::configurable::configurable_component; use vector_lib::request_metadata::{GroupedCountByteSize, MetaDescriptive, RequestMetadata}; use vector_lib::{ - config::{telemetry, AcknowledgementsConfig, Input}, + EstimatedJsonEncodedSizeOf, + config::{AcknowledgementsConfig, Input, telemetry}, event::{Event, EventFinalizers, Finalizable}, sink::VectorSink, - EstimatedJsonEncodedSizeOf, }; use vrl::value::Kind; @@ -34,22 +34,22 @@ use crate::{ http::HttpClient, schema, sinks::{ + Healthcheck, gcp_chronicle::{ compression::ChronicleCompression, partitioner::{ChroniclePartitionKey, ChroniclePartitioner}, sink::ChronicleSink, }, gcs_common::{ - config::{healthcheck_response, GcsRetryLogic}, + config::{GcsRetryLogic, healthcheck_response}, service::GcsResponse, }, util::{ - encoding::{as_tracked_write, Encoder}, + BatchConfig, Compression, RequestBuilder, SinkBatchSettings, TowerRequestConfig, + encoding::{Encoder, as_tracked_write}, metadata::RequestMetadataBuilder, request_builder::EncodeResult, - BatchConfig, Compression, RequestBuilder, SinkBatchSettings, TowerRequestConfig, }, - Healthcheck, }, template::{Template, TemplateParseError}, tls::{TlsConfig, TlsSettings}, @@ -678,8 +678,8 @@ mod integration_tests { use super::*; use crate::test_util::{ components::{ - run_and_assert_sink_compliance, run_and_assert_sink_error, COMPONENT_ERROR_TAGS, - SINK_TAGS, + COMPONENT_ERROR_TAGS, SINK_TAGS, run_and_assert_sink_compliance, + run_and_assert_sink_error, }, random_events_with_stream, random_string, trace_init, }; diff --git a/src/sinks/gcp_chronicle/compression.rs b/src/sinks/gcp_chronicle/compression.rs index 3c9eb7a411917..48df83475665a 100644 --- a/src/sinks/gcp_chronicle/compression.rs +++ b/src/sinks/gcp_chronicle/compression.rs @@ -6,17 +6,17 @@ use vector_lib::configurable::ToValue; use indexmap::IndexMap; use vector_lib::configurable::attributes::CustomAttribute; use vector_lib::configurable::{ + Configurable, GenerateError, Metadata, schema::{ - apply_base_metadata, generate_one_of_schema, generate_struct_schema, - get_or_generate_schema, SchemaGenerator, SchemaObject, + SchemaGenerator, SchemaObject, apply_base_metadata, generate_one_of_schema, + generate_struct_schema, get_or_generate_schema, }, - Configurable, GenerateError, Metadata, }; +use crate::sinks::util::Compression; use crate::sinks::util::buffer::compression::{ - generate_string_schema, CompressionLevel, ALGORITHM_NAME, ENUM_TAGGING_MODE, LEVEL_NAME, + ALGORITHM_NAME, CompressionLevel, ENUM_TAGGING_MODE, LEVEL_NAME, generate_string_schema, }; -use crate::sinks::util::Compression; /// Compression configuration. #[derive(Clone, Copy, Debug, Derivative, Eq, PartialEq)] diff --git a/src/sinks/gcs_common/config.rs b/src/sinks/gcs_common/config.rs index 65ee3794cc6ad..2e13fdc899c16 100644 --- a/src/sinks/gcs_common/config.rs +++ b/src/sinks/gcs_common/config.rs @@ -10,9 +10,9 @@ use crate::{ gcp::{GcpAuthenticator, GcpError}, http::HttpClient, sinks::{ + Healthcheck, HealthcheckError, gcs_common::service::GcsResponse, util::retries::{RetryAction, RetryLogic}, - Healthcheck, HealthcheckError, }, }; diff --git a/src/sinks/gcs_common/service.rs b/src/sinks/gcs_common/service.rs index 01f4003e3eaf9..5a1fffd2f8888 100644 --- a/src/sinks/gcs_common/service.rs +++ b/src/sinks/gcs_common/service.rs @@ -3,8 +3,8 @@ use std::task::Poll; use bytes::Bytes; use futures::future::BoxFuture; use http::{ - header::{HeaderName, HeaderValue}, Request, Uri, + header::{HeaderName, HeaderValue}, }; use hyper::Body; use tower::Service; diff --git a/src/sinks/greptimedb/logs/config.rs b/src/sinks/greptimedb/logs/config.rs index 1501a490c5d1f..4a07f0fe43c3c 100644 --- a/src/sinks/greptimedb/logs/config.rs +++ b/src/sinks/greptimedb/logs/config.rs @@ -2,15 +2,14 @@ use crate::{ http::{Auth, HttpClient}, sinks::{ greptimedb::{ - default_dbname_template, default_pipeline_template, + GreptimeDBDefaultBatchSettings, default_dbname_template, default_pipeline_template, logs::{ http_request_builder::{ - http_healthcheck, GreptimeDBHttpRetryLogic, GreptimeDBLogsHttpRequestBuilder, - PartitionKey, + GreptimeDBHttpRetryLogic, GreptimeDBLogsHttpRequestBuilder, PartitionKey, + http_healthcheck, }, sink::{GreptimeDBLogsHttpSink, LogsSinkSetting}, }, - GreptimeDBDefaultBatchSettings, }, prelude::*, util::http::HttpService, @@ -18,7 +17,7 @@ use crate::{ }; use std::collections::HashMap; use vector_lib::{ - codecs::{encoding::Framer, JsonSerializerConfig, NewlineDelimitedEncoderConfig}, + codecs::{JsonSerializerConfig, NewlineDelimitedEncoderConfig, encoding::Framer}, configurable::configurable_component, sensitive_string::SensitiveString, }; diff --git a/src/sinks/greptimedb/logs/http_request_builder.rs b/src/sinks/greptimedb/logs/http_request_builder.rs index 62672e56faf56..746821b3dcc7c 100644 --- a/src/sinks/greptimedb/logs/http_request_builder.rs +++ b/src/sinks/greptimedb/logs/http_request_builder.rs @@ -1,18 +1,18 @@ use crate::{ + Error, codecs::{Encoder, Transformer}, event::{Event, EventFinalizers, Finalizable}, http::{Auth, HttpClient, HttpError}, sinks::{ + HTTPRequestBuilderSnafu, HealthcheckError, prelude::*, util::http::{HttpRequest, HttpResponse, HttpRetryLogic, HttpServiceRequestBuilder}, - HTTPRequestBuilderSnafu, HealthcheckError, }, - Error, }; use bytes::Bytes; use http::{ - header::{CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE}, Request, StatusCode, + header::{CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE}, }; use hyper::Body; use snafu::ResultExt; diff --git a/src/sinks/greptimedb/logs/integration_tests.rs b/src/sinks/greptimedb/logs/integration_tests.rs index bd5c18e92e680..ca12ebd9d8eea 100644 --- a/src/sinks/greptimedb/logs/integration_tests.rs +++ b/src/sinks/greptimedb/logs/integration_tests.rs @@ -6,7 +6,7 @@ use crate::{ config::{SinkConfig, SinkContext}, sinks::util::test::load_sink, test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, trace_init, }, }; diff --git a/src/sinks/greptimedb/metrics/config.rs b/src/sinks/greptimedb/metrics/config.rs index 065a8656829d2..f9a466cc22e1e 100644 --- a/src/sinks/greptimedb/metrics/config.rs +++ b/src/sinks/greptimedb/metrics/config.rs @@ -1,13 +1,12 @@ use crate::sinks::{ greptimedb::{ - default_dbname, + GreptimeDBDefaultBatchSettings, default_dbname, metrics::{ request::GreptimeDBGrpcRetryLogic, request_builder::RequestBuilderOptions, - service::{healthcheck, GreptimeDBGrpcService}, + service::{GreptimeDBGrpcService, healthcheck}, sink, }, - GreptimeDBDefaultBatchSettings, }, prelude::*, }; @@ -31,7 +30,9 @@ impl GenerateConfig for GreptimeDBConfig { #[typetag::serde(name = "greptimedb")] impl SinkConfig for GreptimeDBConfig { async fn build(&self, cx: SinkContext) -> crate::Result<(VectorSink, Healthcheck)> { - warn!("DEPRECATED: The `greptimedb` sink has been renamed. Please use `greptimedb_metrics` instead."); + warn!( + "DEPRECATED: The `greptimedb` sink has been renamed. Please use `greptimedb_metrics` instead." + ); self.0.build(cx).await } diff --git a/src/sinks/greptimedb/metrics/integration_tests.rs b/src/sinks/greptimedb/metrics/integration_tests.rs index f6bb782b2a820..6a984a2a6a71f 100644 --- a/src/sinks/greptimedb/metrics/integration_tests.rs +++ b/src/sinks/greptimedb/metrics/integration_tests.rs @@ -2,7 +2,7 @@ use crate::{ config::{SinkConfig, SinkContext}, sinks::{greptimedb::metrics::config::GreptimeDBMetricsConfig, util::test::load_sink}, test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, trace_init, }, }; diff --git a/src/sinks/greptimedb/metrics/request.rs b/src/sinks/greptimedb/metrics/request.rs index 082c6c6709b54..8ee48907755bf 100644 --- a/src/sinks/greptimedb/metrics/request.rs +++ b/src/sinks/greptimedb/metrics/request.rs @@ -1,11 +1,11 @@ use crate::sinks::{ greptimedb::metrics::{ batch::GreptimeDBBatchSizer, - request_builder::{metric_to_insert_request, RequestBuilderOptions}, + request_builder::{RequestBuilderOptions, metric_to_insert_request}, }, prelude::*, }; -use greptimedb_ingester::{api::v1::*, Error as GreptimeError}; +use greptimedb_ingester::{Error as GreptimeError, api::v1::*}; use std::num::NonZeroUsize; use vector_lib::event::Metric; diff --git a/src/sinks/greptimedb/metrics/request_builder.rs b/src/sinks/greptimedb/metrics/request_builder.rs index bd9bef33d919c..d0f320a56a9c7 100644 --- a/src/sinks/greptimedb/metrics/request_builder.rs +++ b/src/sinks/greptimedb/metrics/request_builder.rs @@ -3,8 +3,8 @@ use chrono::Utc; use greptimedb_ingester::{api::v1::*, helpers::values::*}; use vector_lib::{ event::{ - metric::{Bucket, MetricSketch, Quantile, Sample}, Metric, MetricValue, + metric::{Bucket, MetricSketch, Quantile, Sample}, }, metrics::AgentDDSketch, }; diff --git a/src/sinks/greptimedb/metrics/service.rs b/src/sinks/greptimedb/metrics/service.rs index d33cc3c5b1168..34a7ceb72059b 100644 --- a/src/sinks/greptimedb/metrics/service.rs +++ b/src/sinks/greptimedb/metrics/service.rs @@ -4,8 +4,8 @@ use crate::sinks::{ prelude::*, }; use greptimedb_ingester::{ - api::v1::auth_header::AuthScheme, api::v1::*, channel_manager::*, Client, ClientBuilder, - Compression, Database, Error as GreptimeError, + Client, ClientBuilder, Compression, Database, Error as GreptimeError, + api::v1::auth_header::AuthScheme, api::v1::*, channel_manager::*, }; use std::{sync::Arc, task::Poll}; use vector_lib::sensitive_string::SensitiveString; @@ -50,7 +50,9 @@ fn try_from_tls_config(tls_config: &TlsConfig) -> crate::Result || tls_config.verify_certificate.is_some() || tls_config.verify_hostname.is_some() { - warn!(message = "TlsConfig: key_pass, alpn_protocols, verify_certificate and verify_hostname are not supported by greptimedb client at the moment."); + warn!( + message = "TlsConfig: key_pass, alpn_protocols, verify_certificate and verify_hostname are not supported by greptimedb client at the moment." + ); } Ok(ClientTlsOption { diff --git a/src/sinks/honeycomb/config.rs b/src/sinks/honeycomb/config.rs index 414d698f5a368..c2f877ec04527 100644 --- a/src/sinks/honeycomb/config.rs +++ b/src/sinks/honeycomb/config.rs @@ -12,8 +12,8 @@ use crate::{ sinks::{ prelude::*, util::{ - http::{http_response_retry_logic, HttpService}, BatchConfig, BoxedRawValue, + http::{HttpService, http_response_retry_logic}, }, }, }; diff --git a/src/sinks/honeycomb/encoder.rs b/src/sinks/honeycomb/encoder.rs index 77a773fbd3945..b7f30ad718a71 100644 --- a/src/sinks/honeycomb/encoder.rs +++ b/src/sinks/honeycomb/encoder.rs @@ -7,7 +7,7 @@ use std::io; use crate::sinks::{ prelude::*, - util::encoding::{write_all, Encoder as SinkEncoder}, + util::encoding::{Encoder as SinkEncoder, write_all}, }; pub(super) struct HoneycombEncoder { diff --git a/src/sinks/honeycomb/service.rs b/src/sinks/honeycomb/service.rs index bc7bc341322fd..1d459ed0095a1 100644 --- a/src/sinks/honeycomb/service.rs +++ b/src/sinks/honeycomb/service.rs @@ -5,9 +5,9 @@ use http::{Request, Uri}; use vector_lib::sensitive_string::SensitiveString; use crate::sinks::{ + HTTPRequestBuilderSnafu, util::buffer::compression::Compression, util::http::{HttpRequest, HttpServiceRequestBuilder}, - HTTPRequestBuilderSnafu, }; use snafu::ResultExt; diff --git a/src/sinks/honeycomb/tests.rs b/src/sinks/honeycomb/tests.rs index 76d5ae5ebbbb3..c933ae49e0cbf 100644 --- a/src/sinks/honeycomb/tests.rs +++ b/src/sinks/honeycomb/tests.rs @@ -6,7 +6,7 @@ use serde::Deserialize; use crate::{ sinks::prelude::*, test_util::{ - components::{run_and_assert_sink_compliance, HTTP_SINK_TAGS}, + components::{HTTP_SINK_TAGS, run_and_assert_sink_compliance}, http::{always_200_response, spawn_blackhole_http_server}, }, }; diff --git a/src/sinks/http/batch.rs b/src/sinks/http/batch.rs index deb4b8e0e1d1d..177523209417b 100644 --- a/src/sinks/http/batch.rs +++ b/src/sinks/http/batch.rs @@ -2,7 +2,7 @@ use vector_lib::codecs::encoding::Framer; use vector_lib::stream::batcher::limiter::ItemBatchSize; -use vector_lib::{event::Event, ByteSizeOf, EstimatedJsonEncodedSizeOf}; +use vector_lib::{ByteSizeOf, EstimatedJsonEncodedSizeOf, event::Event}; use crate::codecs::Encoder; diff --git a/src/sinks/http/config.rs b/src/sinks/http/config.rs index e2d5c0840659e..8927d1373cc37 100644 --- a/src/sinks/http/config.rs +++ b/src/sinks/http/config.rs @@ -4,13 +4,13 @@ use aws_config::meta::region::ProvideRegion; #[cfg(feature = "aws-core")] use aws_types::region::Region; -use http::{header::AUTHORIZATION, HeaderName, HeaderValue, Method, Request, StatusCode}; +use http::{HeaderName, HeaderValue, Method, Request, StatusCode, header::AUTHORIZATION}; use hyper::Body; use std::collections::BTreeMap; use std::path::PathBuf; use vector_lib::codecs::{ - encoding::{Framer, Serializer}, CharacterDelimitedEncoder, + encoding::{Framer, Serializer}, }; #[cfg(feature = "aws-core")] use vector_lib::config::proxy::ProxyConfig; @@ -29,8 +29,8 @@ use crate::{ sinks::{ prelude::*, util::{ - http::{http_response_retry_logic, HttpService, OrderedHeaderName, RequestConfig}, RealtimeSizeBasedDefaultBatchSettings, UriSerde, + http::{HttpService, OrderedHeaderName, RequestConfig, http_response_retry_logic}, }, }, }; diff --git a/src/sinks/http/encoder.rs b/src/sinks/http/encoder.rs index a48c1c19151f2..2a033ed1fe6d0 100644 --- a/src/sinks/http/encoder.rs +++ b/src/sinks/http/encoder.rs @@ -2,18 +2,18 @@ use crate::{ event::Event, - sinks::util::encoding::{write_all, Encoder as SinkEncoder}, + sinks::util::encoding::{Encoder as SinkEncoder, write_all}, }; use bytes::{BufMut, BytesMut}; use std::io; use tokio_util::codec::Encoder as _; use vector_lib::codecs::{ + CharacterDelimitedEncoder, encoding::{ Framer, Framer::{CharacterDelimited, NewlineDelimited}, Serializer::Json, }, - CharacterDelimitedEncoder, }; use crate::sinks::prelude::*; diff --git a/src/sinks/http/service.rs b/src/sinks/http/service.rs index 69ce79842bb35..c8832808f8b65 100644 --- a/src/sinks/http/service.rs +++ b/src/sinks/http/service.rs @@ -5,18 +5,18 @@ use std::str::FromStr; use bytes::Bytes; use http::{ - header::{CONTENT_ENCODING, CONTENT_TYPE}, HeaderName, HeaderValue, Method, Request, + header::{CONTENT_ENCODING, CONTENT_TYPE}, }; use crate::{ http::{Auth, MaybeAuth}, sinks::{ + HTTPRequestBuilderSnafu, util::{ - http::{HttpRequest, HttpServiceRequestBuilder, OrderedHeaderName}, UriSerde, + http::{HttpRequest, HttpServiceRequestBuilder, OrderedHeaderName}, }, - HTTPRequestBuilderSnafu, }, }; use snafu::ResultExt; diff --git a/src/sinks/http/tests.rs b/src/sinks/http/tests.rs index 1b96f267093e7..6eaab936b5f53 100644 --- a/src/sinks/http/tests.rs +++ b/src/sinks/http/tests.rs @@ -2,7 +2,7 @@ use std::{ future::ready, - sync::{atomic, Arc}, + sync::{Arc, atomic}, }; use bytes::{Buf, Bytes}; @@ -10,10 +10,10 @@ use flate2::{read::MultiGzDecoder, read::ZlibDecoder}; use futures::stream; use headers::{Authorization, HeaderMapExt}; use hyper::{Body, Method, Response, StatusCode}; -use serde::{de, Deserialize}; +use serde::{Deserialize, de}; use vector_lib::codecs::{ - encoding::{Framer, FramingConfig}, JsonSerializerConfig, NewlineDelimitedEncoderConfig, TextSerializerConfig, + encoding::{Framer, FramingConfig}, }; use vector_lib::event::{BatchNotifier, BatchStatus, Event, LogEvent}; use vector_lib::finalization::AddBatchNotifier; @@ -35,8 +35,8 @@ use crate::{ }, test_util::{ components::{ - self, init_test, run_and_assert_sink_compliance, run_and_assert_sink_error_with_events, - COMPONENT_ERROR_TAGS, HTTP_SINK_TAGS, + self, COMPONENT_ERROR_TAGS, HTTP_SINK_TAGS, init_test, run_and_assert_sink_compliance, + run_and_assert_sink_error_with_events, }, create_events_batch_with_fn, next_addr, random_lines_with_stream, }, diff --git a/src/sinks/humio/logs.rs b/src/sinks/humio/logs.rs index eee9b071e01b4..b4822447fa384 100644 --- a/src/sinks/humio/logs.rs +++ b/src/sinks/humio/logs.rs @@ -9,15 +9,15 @@ use crate::{ codecs::EncodingConfig, config::{AcknowledgementsConfig, DataType, GenerateConfig, Input, SinkConfig, SinkContext}, sinks::{ + Healthcheck, VectorSink, splunk_hec::{ common::{ - acknowledgements::HecClientAcknowledgementsConfig, EndpointTarget, - SplunkHecDefaultBatchSettings, + EndpointTarget, SplunkHecDefaultBatchSettings, + acknowledgements::HecClientAcknowledgementsConfig, }, logs::config::HecLogsSinkConfig, }, util::{BatchConfig, Compression, TowerRequestConfig}, - Healthcheck, VectorSink, }, template::Template, tls::TlsConfig, @@ -230,17 +230,17 @@ mod integration_tests { use futures::{future::ready, stream}; use indoc::indoc; use serde::Deserialize; - use serde_json::{json, Value as JsonValue}; + use serde_json::{Value as JsonValue, json}; use std::{collections::HashMap, convert::TryFrom}; use tokio::time::Duration; use super::*; use crate::{ - config::{log_schema, SinkConfig, SinkContext}, + config::{SinkConfig, SinkContext, log_schema}, event::LogEvent, sinks::util::Compression, test_util::{ - components::{run_and_assert_sink_compliance, HTTP_SINK_TAGS}, + components::{HTTP_SINK_TAGS, run_and_assert_sink_compliance}, random_string, }, }; diff --git a/src/sinks/humio/metrics.rs b/src/sinks/humio/metrics.rs index a4822a88118b0..05cef18edc215 100644 --- a/src/sinks/humio/metrics.rs +++ b/src/sinks/humio/metrics.rs @@ -11,7 +11,7 @@ use vector_lib::sink::StreamSink; use super::{ config_host_key, - logs::{HumioLogsConfig, HOST}, + logs::{HOST, HumioLogsConfig}, }; use crate::{ config::{ @@ -19,15 +19,15 @@ use crate::{ }, event::{Event, EventArray, EventContainer}, sinks::{ + Healthcheck, VectorSink, splunk_hec::common::SplunkHecDefaultBatchSettings, util::{BatchConfig, Compression, TowerRequestConfig}, - Healthcheck, VectorSink, }, template::Template, tls::TlsConfig, transforms::{ - metric_to_log::{MetricToLog, MetricToLogConfig}, FunctionTransform, OutputBuffer, + metric_to_log::{MetricToLog, MetricToLogConfig}, }, }; @@ -229,7 +229,7 @@ impl StreamSink for HumioMetricsSink { #[cfg(test)] mod tests { - use chrono::{offset::TimeZone, Utc}; + use chrono::{Utc, offset::TimeZone}; use futures::stream; use indoc::indoc; use similar_asserts::assert_eq; @@ -238,13 +238,13 @@ mod tests { use super::*; use crate::{ event::{ - metric::{MetricKind, MetricValue, StatisticKind}, Event, Metric, + metric::{MetricKind, MetricValue, StatisticKind}, }, sinks::util::test::{build_test_server, load_sink}, test_util::{ self, - components::{run_and_assert_sink_compliance, HTTP_SINK_TAGS}, + components::{HTTP_SINK_TAGS, run_and_assert_sink_compliance}, }, }; diff --git a/src/sinks/influxdb/logs.rs b/src/sinks/influxdb/logs.rs index 7b4c33c014183..61b5fc10e1836 100644 --- a/src/sinks/influxdb/logs.rs +++ b/src/sinks/influxdb/logs.rs @@ -10,13 +10,13 @@ use vrl::value::Kind; use vector_lib::config::log_schema; use vector_lib::configurable::configurable_component; -use vector_lib::lookup::lookup_v2::OptionalValuePath; use vector_lib::lookup::PathPrefix; +use vector_lib::lookup::lookup_v2::OptionalValuePath; use vector_lib::schema; use super::{ - encode_timestamp, healthcheck, influx_line_protocol, influxdb_settings, Field, - InfluxDb1Settings, InfluxDb2Settings, ProtocolVersion, + Field, InfluxDb1Settings, InfluxDb2Settings, ProtocolVersion, encode_timestamp, healthcheck, + influx_line_protocol, influxdb_settings, }; use crate::{ codecs::Transformer, @@ -25,11 +25,11 @@ use crate::{ http::HttpClient, internal_events::InfluxdbEncodingError, sinks::{ + Healthcheck, VectorSink, util::{ - http::{BatchedHttpSink, HttpEventEncoder, HttpSink}, BatchConfig, Buffer, Compression, SinkBatchSettings, TowerRequestConfig, + http::{BatchedHttpSink, HttpEventEncoder, HttpSink}, }, - Healthcheck, VectorSink, }, tls::{TlsConfig, TlsSettings}, }; @@ -391,9 +391,9 @@ fn to_field(value: &Value) -> Field { #[cfg(test)] mod tests { - use chrono::{offset::TimeZone, Utc}; - use futures::{channel::mpsc, stream, StreamExt}; - use http::{request::Parts, StatusCode}; + use chrono::{Utc, offset::TimeZone}; + use futures::{StreamExt, channel::mpsc, stream}; + use http::{StatusCode, request::Parts}; use indoc::indoc; use vector_lib::event::{BatchNotifier, BatchStatus, Event, LogEvent}; @@ -406,8 +406,8 @@ mod tests { }, test_util::{ components::{ - run_and_assert_sink_compliance, run_and_assert_sink_error, COMPONENT_ERROR_TAGS, - HTTP_SINK_TAGS, + COMPONENT_ERROR_TAGS, HTTP_SINK_TAGS, run_and_assert_sink_compliance, + run_and_assert_sink_error, }, next_addr, }, @@ -882,11 +882,11 @@ mod integration_tests { use crate::{ config::SinkContext, sinks::influxdb::{ - logs::InfluxDbLogsConfig, - test_util::{address_v2, onboarding_v2, BUCKET, ORG, TOKEN}, InfluxDb2Settings, + logs::InfluxDbLogsConfig, + test_util::{BUCKET, ORG, TOKEN, address_v2, onboarding_v2}, }, - test_util::components::{run_and_assert_sink_compliance, HTTP_SINK_TAGS}, + test_util::components::{HTTP_SINK_TAGS, run_and_assert_sink_compliance}, }; use super::*; diff --git a/src/sinks/influxdb/metrics.rs b/src/sinks/influxdb/metrics.rs index 81ad81f4fc1ea..815c031fc4639 100644 --- a/src/sinks/influxdb/metrics.rs +++ b/src/sinks/influxdb/metrics.rs @@ -1,35 +1,35 @@ use std::{collections::HashMap, future::ready, task::Poll}; use bytes::{Bytes, BytesMut}; -use futures::{future::BoxFuture, stream, SinkExt}; +use futures::{SinkExt, future::BoxFuture, stream}; use tower::Service; use vector_lib::configurable::configurable_component; use vector_lib::{ - event::metric::{MetricSketch, MetricTags, Quantile}, ByteSizeOf, EstimatedJsonEncodedSizeOf, + event::metric::{MetricSketch, MetricTags, Quantile}, }; use crate::{ config::{AcknowledgementsConfig, Input, SinkConfig, SinkContext}, event::{ - metric::{Metric, MetricValue, Sample, StatisticKind}, Event, KeyString, + metric::{Metric, MetricValue, Sample, StatisticKind}, }, http::HttpClient, internal_events::InfluxdbEncodingError, sinks::{ + Healthcheck, VectorSink, influxdb::{ - encode_timestamp, healthcheck, influx_line_protocol, influxdb_settings, Field, - InfluxDb1Settings, InfluxDb2Settings, ProtocolVersion, + Field, InfluxDb1Settings, InfluxDb2Settings, ProtocolVersion, encode_timestamp, + healthcheck, influx_line_protocol, influxdb_settings, }, util::{ + BatchConfig, EncodedEvent, SinkBatchSettings, TowerRequestConfig, buffer::metrics::{MetricNormalize, MetricNormalizer, MetricSet, MetricsBuffer}, encode_namespace, http::{HttpBatchService, HttpRetryLogic}, - statistic::{validate_quantiles, DistributionStatistic}, - BatchConfig, EncodedEvent, SinkBatchSettings, TowerRequestConfig, + statistic::{DistributionStatistic, validate_quantiles}, }, - Healthcheck, VectorSink, }, tls::{TlsConfig, TlsSettings}, }; @@ -218,10 +218,10 @@ fn create_build_request( uri: http::Uri, token: &str, ) -> impl Fn(Bytes) -> BoxFuture<'static, crate::Result>> - + Sync - + Send - + 'static - + use<> { ++ Sync ++ Send ++ 'static ++ use<> { let auth = format!("Token {token}"); move |body| { Box::pin(ready( @@ -487,14 +487,16 @@ mod tests { #[test] fn test_encode_gauge() { - let events = vec![Metric::new( - "meter", - MetricKind::Incremental, - MetricValue::Gauge { value: -1.5 }, - ) - .with_namespace(Some("ns")) - .with_tags(Some(tags())) - .with_timestamp(Some(ts()))]; + let events = vec![ + Metric::new( + "meter", + MetricKind::Incremental, + MetricValue::Gauge { value: -1.5 }, + ) + .with_namespace(Some("ns")) + .with_tags(Some(tags())) + .with_timestamp(Some(ts())), + ]; let line_protocols = encode_events(ProtocolVersion::V2, events, None, None, &[]); assert_eq!( @@ -505,16 +507,18 @@ mod tests { #[test] fn test_encode_set() { - let events = vec![Metric::new( - "users", - MetricKind::Incremental, - MetricValue::Set { - values: vec!["alice".into(), "bob".into()].into_iter().collect(), - }, - ) - .with_namespace(Some("ns")) - .with_tags(Some(tags())) - .with_timestamp(Some(ts()))]; + let events = vec![ + Metric::new( + "users", + MetricKind::Incremental, + MetricValue::Set { + values: vec!["alice".into(), "bob".into()].into_iter().collect(), + }, + ) + .with_namespace(Some("ns")) + .with_tags(Some(tags())) + .with_timestamp(Some(ts())), + ]; let line_protocols = encode_events(ProtocolVersion::V2, events, None, None, &[]); assert_eq!( @@ -525,18 +529,20 @@ mod tests { #[test] fn test_encode_histogram_v1() { - let events = vec![Metric::new( - "requests", - MetricKind::Absolute, - MetricValue::AggregatedHistogram { - buckets: vector_lib::buckets![1.0 => 1, 2.1 => 2, 3.0 => 3], - count: 6, - sum: 12.5, - }, - ) - .with_namespace(Some("ns")) - .with_tags(Some(tags())) - .with_timestamp(Some(ts()))]; + let events = vec![ + Metric::new( + "requests", + MetricKind::Absolute, + MetricValue::AggregatedHistogram { + buckets: vector_lib::buckets![1.0 => 1, 2.1 => 2, 3.0 => 3], + count: 6, + sum: 12.5, + }, + ) + .with_namespace(Some("ns")) + .with_tags(Some(tags())) + .with_timestamp(Some(ts())), + ]; let line_protocols = encode_events(ProtocolVersion::V1, events, None, None, &[]); let line_protocols = @@ -566,18 +572,20 @@ mod tests { #[test] fn test_encode_histogram() { - let events = vec![Metric::new( - "requests", - MetricKind::Absolute, - MetricValue::AggregatedHistogram { - buckets: vector_lib::buckets![1.0 => 1, 2.1 => 2, 3.0 => 3], - count: 6, - sum: 12.5, - }, - ) - .with_namespace(Some("ns")) - .with_tags(Some(tags())) - .with_timestamp(Some(ts()))]; + let events = vec![ + Metric::new( + "requests", + MetricKind::Absolute, + MetricValue::AggregatedHistogram { + buckets: vector_lib::buckets![1.0 => 1, 2.1 => 2, 3.0 => 3], + count: 6, + sum: 12.5, + }, + ) + .with_namespace(Some("ns")) + .with_tags(Some(tags())) + .with_timestamp(Some(ts())), + ]; let line_protocols = encode_events(ProtocolVersion::V2, events, None, None, &[]); let line_protocols = @@ -607,18 +615,20 @@ mod tests { #[test] fn test_encode_summary_v1() { - let events = vec![Metric::new( - "requests_sum", - MetricKind::Absolute, - MetricValue::AggregatedSummary { - quantiles: vector_lib::quantiles![0.01 => 1.5, 0.5 => 2.0, 0.99 => 3.0], - count: 6, - sum: 12.0, - }, - ) - .with_namespace(Some("ns")) - .with_tags(Some(tags())) - .with_timestamp(Some(ts()))]; + let events = vec![ + Metric::new( + "requests_sum", + MetricKind::Absolute, + MetricValue::AggregatedSummary { + quantiles: vector_lib::quantiles![0.01 => 1.5, 0.5 => 2.0, 0.99 => 3.0], + count: 6, + sum: 12.0, + }, + ) + .with_namespace(Some("ns")) + .with_tags(Some(tags())) + .with_timestamp(Some(ts())), + ]; let line_protocols = encode_events(ProtocolVersion::V1, events, None, None, &[]); let line_protocols = @@ -648,18 +658,20 @@ mod tests { #[test] fn test_encode_summary() { - let events = vec![Metric::new( - "requests_sum", - MetricKind::Absolute, - MetricValue::AggregatedSummary { - quantiles: vector_lib::quantiles![0.01 => 1.5, 0.5 => 2.0, 0.99 => 3.0], - count: 6, - sum: 12.0, - }, - ) - .with_namespace(Some("ns")) - .with_tags(Some(tags())) - .with_timestamp(Some(ts()))]; + let events = vec![ + Metric::new( + "requests_sum", + MetricKind::Absolute, + MetricValue::AggregatedSummary { + quantiles: vector_lib::quantiles![0.01 => 1.5, 0.5 => 2.0, 0.99 => 3.0], + count: 6, + sum: 12.0, + }, + ) + .with_namespace(Some("ns")) + .with_tags(Some(tags())) + .with_timestamp(Some(ts())), + ]; let line_protocols = encode_events(ProtocolVersion::V2, events, None, None, &[]); let line_protocols = @@ -799,17 +811,19 @@ mod tests { #[test] fn test_encode_distribution_empty_stats() { - let events = vec![Metric::new( - "requests", - MetricKind::Incremental, - MetricValue::Distribution { - samples: vec![], - statistic: StatisticKind::Histogram, - }, - ) - .with_namespace(Some("ns")) - .with_tags(Some(tags())) - .with_timestamp(Some(ts()))]; + let events = vec![ + Metric::new( + "requests", + MetricKind::Incremental, + MetricValue::Distribution { + samples: vec![], + statistic: StatisticKind::Histogram, + }, + ) + .with_namespace(Some("ns")) + .with_tags(Some(tags())) + .with_timestamp(Some(ts())), + ]; let line_protocols = encode_events(ProtocolVersion::V2, events, None, None, &[]); assert_eq!(line_protocols.len(), 0); @@ -817,17 +831,19 @@ mod tests { #[test] fn test_encode_distribution_zero_counts_stats() { - let events = vec![Metric::new( - "requests", - MetricKind::Incremental, - MetricValue::Distribution { - samples: vector_lib::samples![1.0 => 0, 2.0 => 0], - statistic: StatisticKind::Histogram, - }, - ) - .with_namespace(Some("ns")) - .with_tags(Some(tags())) - .with_timestamp(Some(ts()))]; + let events = vec![ + Metric::new( + "requests", + MetricKind::Incremental, + MetricValue::Distribution { + samples: vector_lib::samples![1.0 => 0, 2.0 => 0], + statistic: StatisticKind::Histogram, + }, + ) + .with_namespace(Some("ns")) + .with_tags(Some(tags())) + .with_timestamp(Some(ts())), + ]; let line_protocols = encode_events(ProtocolVersion::V2, events, None, None, &[]); assert_eq!(line_protocols.len(), 0); @@ -835,17 +851,19 @@ mod tests { #[test] fn test_encode_distribution_summary() { - let events = vec![Metric::new( - "requests", - MetricKind::Incremental, - MetricValue::Distribution { - samples: vector_lib::samples![1.0 => 3, 2.0 => 3, 3.0 => 2], - statistic: StatisticKind::Summary, - }, - ) - .with_namespace(Some("ns")) - .with_tags(Some(tags())) - .with_timestamp(Some(ts()))]; + let events = vec![ + Metric::new( + "requests", + MetricKind::Incremental, + MetricValue::Distribution { + samples: vector_lib::samples![1.0 => 3, 2.0 => 3, 3.0 => 2], + statistic: StatisticKind::Summary, + }, + ) + .with_namespace(Some("ns")) + .with_tags(Some(tags())) + .with_timestamp(Some(ts())), + ]; let line_protocols = encode_events( ProtocolVersion::V2, @@ -944,19 +962,19 @@ mod integration_tests { use crate::{ config::{SinkConfig, SinkContext}, event::{ - metric::{Metric, MetricKind, MetricValue}, Event, + metric::{Metric, MetricKind, MetricValue}, }, http::HttpClient, sinks::influxdb::{ - metrics::{default_summary_quantiles, InfluxDbConfig, InfluxDbSvc}, + InfluxDb1Settings, InfluxDb2Settings, + metrics::{InfluxDbConfig, InfluxDbSvc, default_summary_quantiles}, test_util::{ - address_v1, address_v2, cleanup_v1, format_timestamp, onboarding_v1, onboarding_v2, - query_v1, BUCKET, ORG, TOKEN, + BUCKET, ORG, TOKEN, address_v1, address_v2, cleanup_v1, format_timestamp, + onboarding_v1, onboarding_v2, query_v1, }, - InfluxDb1Settings, InfluxDb2Settings, }, - test_util::components::{run_and_assert_sink_compliance, HTTP_SINK_TAGS}, + test_util::components::{HTTP_SINK_TAGS, run_and_assert_sink_compliance}, tls::{self, TlsConfig}, }; diff --git a/src/sinks/influxdb/mod.rs b/src/sinks/influxdb/mod.rs index 2743658c64a29..49d570c857616 100644 --- a/src/sinks/influxdb/mod.rs +++ b/src/sinks/influxdb/mod.rs @@ -379,7 +379,7 @@ pub(in crate::sinks) fn encode_uri( pub mod test_util { use std::{fs::File, io::Read}; - use chrono::{offset::TimeZone, DateTime, SecondsFormat, Timelike, Utc}; + use chrono::{DateTime, SecondsFormat, Timelike, Utc, offset::TimeZone}; use vector_lib::metric_tags; use super::*; @@ -637,7 +637,10 @@ mod tests { let uri = settings .write_uri("http://localhost:8086".to_owned()) .unwrap(); - assert_eq!("http://localhost:8086/write?consistency=quorum&db=vector_db&rp=autogen&p=secret&u=writer&precision=ns", uri.to_string()) + assert_eq!( + "http://localhost:8086/write?consistency=quorum&db=vector_db&rp=autogen&p=secret&u=writer&precision=ns", + uri.to_string() + ) } #[test] @@ -900,9 +903,8 @@ mod integration_tests { config::ProxyConfig, http::HttpClient, sinks::influxdb::{ - healthcheck, - test_util::{address_v1, address_v2, next_database, onboarding_v2, BUCKET, ORG, TOKEN}, - InfluxDb1Settings, InfluxDb2Settings, + InfluxDb1Settings, InfluxDb2Settings, healthcheck, + test_util::{BUCKET, ORG, TOKEN, address_v1, address_v2, next_database, onboarding_v2}, }, }; diff --git a/src/sinks/kafka/config.rs b/src/sinks/kafka/config.rs index 69f3f6b6ec306..1d2d09536e330 100644 --- a/src/sinks/kafka/config.rs +++ b/src/sinks/kafka/config.rs @@ -12,7 +12,7 @@ use crate::{ kafka::{KafkaAuthConfig, KafkaCompression}, serde::json::to_string, sinks::{ - kafka::sink::{healthcheck, KafkaSink}, + kafka::sink::{KafkaSink, healthcheck}, prelude::*, }, }; diff --git a/src/sinks/kafka/service.rs b/src/sinks/kafka/service.rs index 94017e22e7f36..8d770a844ff9c 100644 --- a/src/sinks/kafka/service.rs +++ b/src/sinks/kafka/service.rs @@ -1,7 +1,7 @@ use std::{ sync::{ - atomic::{AtomicUsize, Ordering}, Arc, + atomic::{AtomicUsize, Ordering}, }, task::{Context, Poll}, time::Duration, @@ -196,7 +196,7 @@ impl Service for KafkaService { event_byte_size: config::telemetry().create_request_count_byte_size(), raw_byte_size: 0, event_status: EventStatus::Errored, - }) + }); } }; } diff --git a/src/sinks/kafka/sink.rs b/src/sinks/kafka/sink.rs index e62fe3450a2c2..016f569bb726d 100644 --- a/src/sinks/kafka/sink.rs +++ b/src/sinks/kafka/sink.rs @@ -1,9 +1,9 @@ use std::time::Duration; use rdkafka::{ + ClientConfig, error::KafkaError, producer::{BaseProducer, FutureProducer, Producer}, - ClientConfig, }; use snafu::{ResultExt, Snafu}; use tower::limit::RateLimit; diff --git a/src/sinks/kafka/tests.rs b/src/sinks/kafka/tests.rs index 89760148ee565..044f8e69f3262 100644 --- a/src/sinks/kafka/tests.rs +++ b/src/sinks/kafka/tests.rs @@ -8,14 +8,14 @@ mod integration_test { use bytes::Bytes; use futures::StreamExt; use rdkafka::{ + Message, Offset, TopicPartitionList, consumer::{BaseConsumer, Consumer}, message::Headers, - Message, Offset, TopicPartitionList, }; use vector_lib::codecs::TextSerializerConfig; use vector_lib::lookup::lookup_v2::ConfigTargetPath; use vector_lib::{ - config::{init_telemetry, Tags, Telemetry}, + config::{Tags, Telemetry, init_telemetry}, event::{BatchNotifier, BatchStatus}, }; @@ -26,12 +26,12 @@ mod integration_test { sinks::prelude::*, test_util::{ components::{ - assert_data_volume_sink_compliance, assert_sink_compliance, DATA_VOLUME_SINK_TAGS, - SINK_TAGS, + DATA_VOLUME_SINK_TAGS, SINK_TAGS, assert_data_volume_sink_compliance, + assert_sink_compliance, }, random_lines_with_stream, random_string, wait_for, }, - tls::{TlsConfig, TlsEnableableConfig, TEST_PEM_INTERMEDIATE_CA_PATH}, + tls::{TEST_PEM_INTERMEDIATE_CA_PATH, TlsConfig, TlsEnableableConfig}, }; fn kafka_host() -> String { @@ -207,16 +207,18 @@ mod integration_test { let mut batch = BatchConfig::default(); batch.max_bytes = Some(1000); - assert!(kafka_batch_options_overrides( - batch, - indexmap::indexmap! { - "batch.size".to_string() => 1.to_string(), - } - .into_iter() - .collect() + assert!( + kafka_batch_options_overrides( + batch, + indexmap::indexmap! { + "batch.size".to_string() => 1.to_string(), + } + .into_iter() + .collect() + ) + .await + .is_err() ) - .await - .is_err()) } #[tokio::test] @@ -237,16 +239,18 @@ mod integration_test { let mut batch = BatchConfig::default(); batch.max_events = Some(10); - assert!(kafka_batch_options_overrides( - batch, - indexmap::indexmap! { - "batch.num.messages".to_string() => 1.to_string(), - } - .into_iter() - .collect() + assert!( + kafka_batch_options_overrides( + batch, + indexmap::indexmap! { + "batch.num.messages".to_string() => 1.to_string(), + } + .into_iter() + .collect() + ) + .await + .is_err() ) - .await - .is_err()) } #[tokio::test] @@ -255,16 +259,18 @@ mod integration_test { let mut batch = BatchConfig::default(); batch.timeout_secs = Some(10.0); - assert!(kafka_batch_options_overrides( - batch, - indexmap::indexmap! { - "queue.buffering.max.ms".to_string() => 1.to_string(), - } - .into_iter() - .collect() + assert!( + kafka_batch_options_overrides( + batch, + indexmap::indexmap! { + "queue.buffering.max.ms".to_string() => 1.to_string(), + } + .into_iter() + .collect() + ) + .await + .is_err() ) - .await - .is_err()) } #[tokio::test] diff --git a/src/sinks/keep/config.rs b/src/sinks/keep/config.rs index f7385b5b27cae..c7ce9f19ad77f 100644 --- a/src/sinks/keep/config.rs +++ b/src/sinks/keep/config.rs @@ -12,8 +12,8 @@ use crate::{ sinks::{ prelude::*, util::{ - http::{http_response_retry_logic, HttpService}, BatchConfig, BoxedRawValue, + http::{HttpService, http_response_retry_logic}, }, }, }; diff --git a/src/sinks/keep/encoder.rs b/src/sinks/keep/encoder.rs index 95e44ea170c20..9bada2d2d1c96 100644 --- a/src/sinks/keep/encoder.rs +++ b/src/sinks/keep/encoder.rs @@ -6,7 +6,7 @@ use std::io; use crate::sinks::{ prelude::*, - util::encoding::{write_all, Encoder as SinkEncoder}, + util::encoding::{Encoder as SinkEncoder, write_all}, }; pub(super) struct KeepEncoder { diff --git a/src/sinks/keep/service.rs b/src/sinks/keep/service.rs index 89b9ebaacf7c9..40e2299cc294c 100644 --- a/src/sinks/keep/service.rs +++ b/src/sinks/keep/service.rs @@ -5,8 +5,8 @@ use http::{Request, Uri}; use vector_lib::sensitive_string::SensitiveString; use crate::sinks::{ - util::http::{HttpRequest, HttpServiceRequestBuilder}, HTTPRequestBuilderSnafu, + util::http::{HttpRequest, HttpServiceRequestBuilder}, }; use snafu::ResultExt; diff --git a/src/sinks/loki/event.rs b/src/sinks/loki/event.rs index 58480434a1306..83e9b5b0ca428 100644 --- a/src/sinks/loki/event.rs +++ b/src/sinks/loki/event.rs @@ -2,7 +2,7 @@ use std::{collections::HashMap, io}; use crate::sinks::{prelude::*, util::encoding::Encoder}; use bytes::Bytes; -use serde::{ser::SerializeSeq, Serialize}; +use serde::{Serialize, ser::SerializeSeq}; use vector_lib::config::telemetry; pub type Labels = Vec<(String, String)>; diff --git a/src/sinks/loki/integration_tests.rs b/src/sinks/loki/integration_tests.rs index 87545b4f8b6ab..07d9c6d390c77 100644 --- a/src/sinks/loki/integration_tests.rs +++ b/src/sinks/loki/integration_tests.rs @@ -5,24 +5,24 @@ use bytes::Bytes; use chrono::{DateTime, Duration, Utc}; use futures::stream; use vector_lib::encode_logfmt; -use vector_lib::lookup::{owned_value_path, PathPrefix}; +use vector_lib::lookup::{PathPrefix, owned_value_path}; use vector_lib::{ - config::{init_telemetry, LogNamespace, Tags, Telemetry}, + config::{LogNamespace, Tags, Telemetry, init_telemetry}, event::{BatchNotifier, BatchStatus, Event, LogEvent}, }; -use vrl::value::{kind::Collection, Kind}; +use vrl::value::{Kind, kind::Collection}; use super::config::{LokiConfig, OutOfOrderAction}; use crate::{ - config::{log_schema, SinkConfig}, + config::{SinkConfig, log_schema}, event::Value, schema, - sinks::{util::test::load_sink, VectorSink}, + sinks::{VectorSink, util::test::load_sink}, template::Template, test_util::{ components::{ - run_and_assert_data_volume_sink_compliance, run_and_assert_sink_compliance, - DATA_VOLUME_SINK_TAGS, SINK_TAGS, + DATA_VOLUME_SINK_TAGS, SINK_TAGS, run_and_assert_data_volume_sink_compliance, + run_and_assert_sink_compliance, }, generate_events_with_stream, generate_lines_with_stream, random_lines, }, diff --git a/src/sinks/loki/sink.rs b/src/sinks/loki/sink.rs index 60fd044854095..d206a792b29e4 100644 --- a/src/sinks/loki/sink.rs +++ b/src/sinks/loki/sink.rs @@ -13,7 +13,7 @@ use super::{ use crate::sinks::loki::event::LokiBatchEncoding; use crate::{ common::expansion::pair_expansion, - http::{get_http_scheme_from_uri, HttpClient}, + http::{HttpClient, get_http_scheme_from_uri}, internal_events::{ LokiEventUnlabeledError, LokiOutOfOrderEventDroppedError, LokiOutOfOrderEventRewritten, LokiTimestampNonParsableEventsDropped, SinkRequestBuildError, @@ -595,8 +595,10 @@ mod tests { chrono::Utc::now(), ); let record = encoder.encode_event(event).unwrap(); - assert!(String::from_utf8_lossy(&record.event.event) - .contains(log_schema().timestamp_key().unwrap().to_string().as_str())); + assert!( + String::from_utf8_lossy(&record.event.event) + .contains(log_schema().timestamp_key().unwrap().to_string().as_str()) + ); assert_eq!(record.labels.len(), 1); assert_eq!( record.labels[0], @@ -648,8 +650,10 @@ mod tests { log.insert("dict", Value::from(test_dict)); let record = encoder.encode_event(event).unwrap(); - assert!(String::from_utf8_lossy(&record.event.event) - .contains(log_schema().timestamp_key().unwrap().to_string().as_str())); + assert!( + String::from_utf8_lossy(&record.event.event) + .contains(log_schema().timestamp_key().unwrap().to_string().as_str()) + ); assert_eq!(record.labels.len(), 4); let labels: HashMap = record.labels.into_iter().collect(); @@ -807,8 +811,10 @@ mod tests { chrono::Utc::now(), ); let record = encoder.encode_event(event).unwrap(); - assert!(!String::from_utf8_lossy(&record.event.event) - .contains(log_schema().timestamp_key().unwrap().to_string().as_str())); + assert!( + !String::from_utf8_lossy(&record.event.event) + .contains(log_schema().timestamp_key().unwrap().to_string().as_str()) + ); } #[test] diff --git a/src/sinks/mezmo.rs b/src/sinks/mezmo.rs index 526302675df33..61932c082e889 100644 --- a/src/sinks/mezmo.rs +++ b/src/sinks/mezmo.rs @@ -16,9 +16,9 @@ use crate::{ http::{Auth, HttpClient}, schema, sinks::util::{ - http::{HttpEventEncoder, HttpSink, PartitionHttpSink}, BatchConfig, BoxedRawValue, JsonArrayBuffer, PartitionBuffer, PartitionInnerBuffer, RealtimeSizeBasedDefaultBatchSettings, TowerRequestConfig, UriSerde, + http::{HttpEventEncoder, HttpSink, PartitionHttpSink}, }, template::{Template, TemplateRenderingError}, }; @@ -394,9 +394,9 @@ async fn healthcheck(config: MezmoConfig, client: HttpClient) -> crate::Result<( #[cfg(test)] mod tests { - use futures::{channel::mpsc, StreamExt}; + use futures::{StreamExt, channel::mpsc}; use futures_util::stream; - use http::{request::Parts, StatusCode}; + use http::{StatusCode, request::Parts}; use serde_json::json; use vector_lib::event::{BatchNotifier, BatchStatus, Event, LogEvent}; @@ -405,7 +405,7 @@ mod tests { config::SinkConfig, sinks::util::test::{build_test_server_status, load_sink}, test_util::{ - components::{assert_sink_compliance, HTTP_SINK_TAGS}, + components::{HTTP_SINK_TAGS, assert_sink_compliance}, next_addr, random_lines, }, }; diff --git a/src/sinks/mqtt/config.rs b/src/sinks/mqtt/config.rs index c4cf0225e7417..bf0b86984bad4 100644 --- a/src/sinks/mqtt/config.rs +++ b/src/sinks/mqtt/config.rs @@ -13,7 +13,7 @@ use crate::{ TlsSnafu, }, config::{AcknowledgementsConfig, Input, SinkConfig, SinkContext}, - sinks::{mqtt::sink::MqttSink, prelude::*, Healthcheck, VectorSink}, + sinks::{Healthcheck, VectorSink, mqtt::sink::MqttSink, prelude::*}, tls::MaybeTlsSettings, }; diff --git a/src/sinks/mqtt/integration_tests.rs b/src/sinks/mqtt/integration_tests.rs index 39d93ae6a5b44..2a186aa113b69 100644 --- a/src/sinks/mqtt/integration_tests.rs +++ b/src/sinks/mqtt/integration_tests.rs @@ -1,9 +1,9 @@ use crate::common::mqtt::MqttCommonConfig; use crate::config::{SinkConfig, SinkContext}; -use crate::sinks::mqtt::config::MqttQoS; use crate::sinks::mqtt::MqttSinkConfig; +use crate::sinks::mqtt::config::MqttQoS; use crate::template::Template; -use crate::test_util::components::{run_and_assert_sink_compliance, SINK_TAGS}; +use crate::test_util::components::{SINK_TAGS, run_and_assert_sink_compliance}; use crate::test_util::{random_lines_with_stream, trace_init}; use rumqttc::{AsyncClient, Event, Incoming, MqttOptions, QoS}; use std::time::Duration; diff --git a/src/sinks/mqtt/sink.rs b/src/sinks/mqtt/sink.rs index a0f07e3f97151..1c028b4173164 100644 --- a/src/sinks/mqtt/sink.rs +++ b/src/sinks/mqtt/sink.rs @@ -1,15 +1,15 @@ use async_trait::async_trait; -use futures::{stream::BoxStream, StreamExt}; +use futures::{StreamExt, stream::BoxStream}; use crate::common::mqtt::MqttConnector; use crate::internal_events::MqttConnectionError; use crate::sinks::prelude::*; use super::{ + MqttSinkConfig, config::MqttQoS, request_builder::{MqttEncoder, MqttRequestBuilder}, service::MqttService, - MqttSinkConfig, }; pub struct MqttSink { diff --git a/src/sinks/nats/config.rs b/src/sinks/nats/config.rs index 9082e5123714d..ffec52b3dc5ba 100644 --- a/src/sinks/nats/config.rs +++ b/src/sinks/nats/config.rs @@ -5,9 +5,9 @@ use snafu::ResultExt; use vector_lib::codecs::JsonSerializerConfig; use vector_lib::tls::TlsEnableableConfig; -use super::{sink::NatsSink, ConfigSnafu, ConnectSnafu, NatsError}; +use super::{ConfigSnafu, ConnectSnafu, NatsError, sink::NatsSink}; use crate::{ - nats::{from_tls_auth_config, NatsAuthConfig, NatsConfigError}, + nats::{NatsAuthConfig, NatsConfigError, from_tls_auth_config}, sinks::{prelude::*, util::service::TowerRequestConfigDefaults}, }; use async_nats::HeaderMap; diff --git a/src/sinks/nats/integration_tests.rs b/src/sinks/nats/integration_tests.rs index e506e4a826478..21e743c5633a9 100644 --- a/src/sinks/nats/integration_tests.rs +++ b/src/sinks/nats/integration_tests.rs @@ -1,7 +1,7 @@ use super::{ + ConfigSnafu, NatsError, config::{NatsHeaderConfig, NatsSinkConfig}, sink::NatsSink, - ConfigSnafu, NatsError, }; use crate::{ nats::{ @@ -10,7 +10,7 @@ use crate::{ sinks::nats::config::JetStreamConfig, sinks::prelude::*, test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, random_lines_with_stream, random_string, trace_init, }, tls::TlsEnableableConfig, diff --git a/src/sinks/nats/service.rs b/src/sinks/nats/service.rs index 08b098aae46ff..9747a71a4604c 100644 --- a/src/sinks/nats/service.rs +++ b/src/sinks/nats/service.rs @@ -7,7 +7,7 @@ use futures_util::TryFutureExt; use crate::sinks::prelude::*; -use super::{config::NatsPublisher, request_builder::NatsRequest, NatsError}; +use super::{NatsError, config::NatsPublisher, request_builder::NatsRequest}; #[derive(Clone)] pub(super) struct NatsService { diff --git a/src/sinks/nats/sink.rs b/src/sinks/nats/sink.rs index bb58b58b9192b..64a79d71a1827 100644 --- a/src/sinks/nats/sink.rs +++ b/src/sinks/nats/sink.rs @@ -5,10 +5,10 @@ use snafu::ResultExt; use crate::sinks::prelude::*; use super::{ + EncodingSnafu, NatsError, config::{NatsHeaderConfig, NatsPublisher, NatsSinkConfig, NatsTowerRequestConfigDefaults}, request_builder::{NatsEncoder, NatsRequest, NatsRequestBuilder}, service::{NatsResponse, NatsService}, - EncodingSnafu, NatsError, }; pub(super) struct NatsEvent { diff --git a/src/sinks/new_relic/config.rs b/src/sinks/new_relic/config.rs index bc7a25e141388..dca9454183226 100644 --- a/src/sinks/new_relic/config.rs +++ b/src/sinks/new_relic/config.rs @@ -5,8 +5,8 @@ use tower::ServiceBuilder; use vector_lib::sensitive_string::SensitiveString; use super::{ - healthcheck, service::NewRelicApiRequest, NewRelicApiResponse, NewRelicApiService, - NewRelicEncoder, NewRelicSink, NewRelicSinkError, + NewRelicApiResponse, NewRelicApiService, NewRelicEncoder, NewRelicSink, NewRelicSinkError, + healthcheck, service::NewRelicApiRequest, }; use crate::{http::HttpClient, sinks::prelude::*}; diff --git a/src/sinks/new_relic/encoding.rs b/src/sinks/new_relic/encoding.rs index 12ca89960393a..2cb64fb7680c7 100644 --- a/src/sinks/new_relic/encoding.rs +++ b/src/sinks/new_relic/encoding.rs @@ -2,7 +2,7 @@ use std::{io, sync::Arc}; use serde::Serialize; use vector_lib::request_metadata::GroupedCountByteSize; -use vector_lib::{config::telemetry, event::Event, EstimatedJsonEncodedSizeOf}; +use vector_lib::{EstimatedJsonEncodedSizeOf, config::telemetry, event::Event}; use super::{ EventsApiModel, LogsApiModel, MetricsApiModel, NewRelicApi, NewRelicApiModel, @@ -10,7 +10,7 @@ use super::{ }; use crate::sinks::{ prelude::*, - util::encoding::{as_tracked_write, Encoder}, + util::encoding::{Encoder, as_tracked_write}, }; pub struct NewRelicEncoder { diff --git a/src/sinks/new_relic/service.rs b/src/sinks/new_relic/service.rs index 2b69aae492348..9025791c6af78 100644 --- a/src/sinks/new_relic/service.rs +++ b/src/sinks/new_relic/service.rs @@ -6,8 +6,8 @@ use std::{ use bytes::Bytes; use http::{ - header::{CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE}, Request, + header::{CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE}, }; use hyper::Body; use tracing::Instrument; diff --git a/src/sinks/new_relic/tests.rs b/src/sinks/new_relic/tests.rs index 648c90c5ac067..55f8ef96b6341 100644 --- a/src/sinks/new_relic/tests.rs +++ b/src/sinks/new_relic/tests.rs @@ -4,7 +4,7 @@ use chrono::Utc; use futures::{future::ready, stream}; use serde::Deserialize; use serde_json::{json, to_value}; -use vector_lib::config::{init_telemetry, Tags, Telemetry}; +use vector_lib::config::{Tags, Telemetry, init_telemetry}; use vrl::value; use super::*; @@ -13,8 +13,8 @@ use crate::{ event::{Event, LogEvent, Metric, MetricKind, MetricValue}, test_util::{ components::{ - run_and_assert_data_volume_sink_compliance, run_and_assert_sink_compliance, - DATA_VOLUME_SINK_TAGS, SINK_TAGS, + DATA_VOLUME_SINK_TAGS, SINK_TAGS, run_and_assert_data_volume_sink_compliance, + run_and_assert_sink_compliance, }, http::{always_200_response, spawn_blackhole_http_server}, }, diff --git a/src/sinks/opentelemetry/mod.rs b/src/sinks/opentelemetry/mod.rs index 90d26da27e202..01b8823525fa2 100644 --- a/src/sinks/opentelemetry/mod.rs +++ b/src/sinks/opentelemetry/mod.rs @@ -4,8 +4,8 @@ use crate::sinks::http::config::{HttpMethod, HttpSinkConfig}; use crate::sinks::{Healthcheck, VectorSink}; use indoc::indoc; use vector_config::component::GenerateConfig; -use vector_lib::codecs::encoding::{FramingConfig, SerializerConfig}; use vector_lib::codecs::JsonSerializerConfig; +use vector_lib::codecs::encoding::{FramingConfig, SerializerConfig}; use vector_lib::configurable::configurable_component; /// Configuration for the `OpenTelemetry` sink. diff --git a/src/sinks/papertrail.rs b/src/sinks/papertrail.rs index d74f2a6e0e88b..3d62aa44f5f8b 100644 --- a/src/sinks/papertrail.rs +++ b/src/sinks/papertrail.rs @@ -9,7 +9,7 @@ use crate::{ event::Event, internal_events::TemplateRenderingError, schema, - sinks::util::{tcp::TcpSinkConfig, UriSerde}, + sinks::util::{UriSerde, tcp::TcpSinkConfig}, tcp::TcpKeepaliveConfig, template::Template, tls::TlsEnableableConfig, @@ -192,7 +192,7 @@ mod tests { use vector_lib::event::{Event, LogEvent}; use crate::test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, http::{always_200_response, spawn_blackhole_http_server}, }; diff --git a/src/sinks/postgres/config.rs b/src/sinks/postgres/config.rs index 2a56827cf23e7..3d108bb6fa9ef 100644 --- a/src/sinks/postgres/config.rs +++ b/src/sinks/postgres/config.rs @@ -10,16 +10,16 @@ use super::{ service::{PostgresRetryLogic, PostgresService}, sink::PostgresSink, }; -use sqlx::{postgres::PgPoolOptions, Pool, Postgres}; +use sqlx::{Pool, Postgres, postgres::PgPoolOptions}; use crate::{ config::{Input, SinkConfig, SinkContext}, sinks::{ + Healthcheck, util::{ BatchConfig, RealtimeSizeBasedDefaultBatchSettings, ServiceBuilderExt, TowerRequestConfig, UriSerde, }, - Healthcheck, }, }; diff --git a/src/sinks/postgres/integration_tests.rs b/src/sinks/postgres/integration_tests.rs index 7136da90d81fa..d9f4aff17b6d9 100644 --- a/src/sinks/postgres/integration_tests.rs +++ b/src/sinks/postgres/integration_tests.rs @@ -5,7 +5,7 @@ use crate::{ sinks::{postgres::PostgresConfig, util::test::load_sink}, test_util::{ components::{ - run_and_assert_sink_compliance, run_and_assert_sink_error, COMPONENT_ERROR_TAGS, + COMPONENT_ERROR_TAGS, run_and_assert_sink_compliance, run_and_assert_sink_error, }, next_addr, random_table_name, trace_init, }, @@ -224,8 +224,9 @@ async fn insert_single_event() { let (config, table, mut connection) = prepare_config().await; let (sink, _hc) = config.build(SinkContext::default()).await.unwrap(); - let create_table_sql = - format!("CREATE TABLE {table} (id BIGINT, host TEXT, timestamp TIMESTAMPTZ, message TEXT, payload JSONB)"); + let create_table_sql = format!( + "CREATE TABLE {table} (id BIGINT, host TEXT, timestamp TIMESTAMPTZ, message TEXT, payload JSONB)" + ); sqlx::query(&create_table_sql) .execute(&mut connection) .await @@ -493,8 +494,9 @@ async fn insertion_fails_primary_key_violation() { let (config, table, mut connection) = prepare_config().await; let (sink, _hc) = config.build(SinkContext::default()).await.unwrap(); - let create_table_sql = - format!("CREATE TABLE {table} (id BIGINT PRIMARY KEY, host TEXT, timestamp TIMESTAMPTZ, message TEXT, payload JSONB)"); + let create_table_sql = format!( + "CREATE TABLE {table} (id BIGINT PRIMARY KEY, host TEXT, timestamp TIMESTAMPTZ, message TEXT, payload JSONB)" + ); sqlx::query(&create_table_sql) .execute(&mut connection) .await diff --git a/src/sinks/postgres/service.rs b/src/sinks/postgres/service.rs index 54389d6a66c88..e81ded7d6f392 100644 --- a/src/sinks/postgres/service.rs +++ b/src/sinks/postgres/service.rs @@ -8,11 +8,11 @@ use snafu::{ResultExt, Snafu}; use sqlx::types::Json; use sqlx::{Pool, Postgres}; use tower::Service; +use vector_lib::EstimatedJsonEncodedSizeOf; use vector_lib::codecs::JsonSerializerConfig; use vector_lib::event::{Event, EventFinalizers, EventStatus, Finalizable}; use vector_lib::request_metadata::{GroupedCountByteSize, MetaDescriptive, RequestMetadata}; use vector_lib::stream::DriverResponse; -use vector_lib::EstimatedJsonEncodedSizeOf; const POSTGRES_PROTOCOL: &str = "postgres"; diff --git a/src/sinks/prelude.rs b/src/sinks/prelude.rs index 2f94c65cd653c..c3dd0fa0c6fa6 100644 --- a/src/sinks/prelude.rs +++ b/src/sinks/prelude.rs @@ -2,19 +2,19 @@ //! stream based sinks are likely to use. pub use async_trait::async_trait; -pub use futures::{future, future::BoxFuture, stream::BoxStream, FutureExt, StreamExt}; +pub use futures::{FutureExt, StreamExt, future, future::BoxFuture, stream::BoxStream}; pub use tower::{Service, ServiceBuilder}; pub use vector_lib::buffers::EventCount; pub use vector_lib::configurable::configurable_component; pub use vector_lib::stream::{BatcherSettings, DriverResponse}; pub use vector_lib::{ - config::{telemetry, AcknowledgementsConfig, Input}, + ByteSizeOf, EstimatedJsonEncodedSizeOf, + config::{AcknowledgementsConfig, Input, telemetry}, event::Value, partition::Partitioner, schema::Requirement, sink::{StreamSink, VectorSink}, tls::TlsSettings, - ByteSizeOf, EstimatedJsonEncodedSizeOf, }; pub use vector_lib::{ finalization::{EventFinalizers, EventStatus, Finalizable}, @@ -29,17 +29,17 @@ pub use crate::{ event::{Event, LogEvent}, internal_events::{SinkRequestBuildError, TemplateRenderingError}, sinks::{ + Healthcheck, HealthcheckError, util::{ + BatchConfig, Compression, Concurrency, NoDefaultsBatchSettings, RequestBuilder, + SinkBatchSettings, TowerRequestConfig, builder::SinkBuilderExt, encoding::{self, write_all}, metadata::RequestMetadataBuilder, - request_builder::{default_request_builder_concurrency_limit, EncodeResult}, + request_builder::{EncodeResult, default_request_builder_concurrency_limit}, retries::{RetryAction, RetryLogic}, service::{ServiceBuilderExt, Svc}, - BatchConfig, Compression, Concurrency, NoDefaultsBatchSettings, RequestBuilder, - SinkBatchSettings, TowerRequestConfig, }, - Healthcheck, HealthcheckError, }, template::{Template, TemplateParseError, UnsignedIntTemplate}, tls::TlsConfig, diff --git a/src/sinks/prometheus/collector.rs b/src/sinks/prometheus/collector.rs index 25a042a442084..3b588fdeb7a2c 100644 --- a/src/sinks/prometheus/collector.rs +++ b/src/sinks/prometheus/collector.rs @@ -2,8 +2,8 @@ use std::{collections::BTreeMap, fmt::Write as _}; use chrono::Utc; use indexmap::map::IndexMap; -use vector_lib::event::metric::{samples_to_buckets, MetricSketch, MetricTags, Quantile}; -use vector_lib::prometheus::parser::{proto, METRIC_NAME_LABEL}; +use vector_lib::event::metric::{MetricSketch, MetricTags, Quantile, samples_to_buckets}; +use vector_lib::prometheus::parser::{METRIC_NAME_LABEL, proto}; use crate::{ event::metric::{Metric, MetricKind, MetricValue, StatisticKind}, diff --git a/src/sinks/prometheus/exporter.rs b/src/sinks/prometheus/exporter.rs index 2dafb871b428f..e229e41b7a37a 100644 --- a/src/sinks/prometheus/exporter.rs +++ b/src/sinks/prometheus/exporter.rs @@ -1,22 +1,22 @@ use std::{ convert::Infallible, hash::Hash, - mem::{discriminant, Discriminant}, + mem::{Discriminant, discriminant}, net::{IpAddr, Ipv4Addr, SocketAddr}, sync::{Arc, RwLock}, time::{Duration, Instant}, }; use async_trait::async_trait; -use base64::prelude::{Engine as _, BASE64_STANDARD}; -use futures::{future, stream::BoxStream, FutureExt, StreamExt}; +use base64::prelude::{BASE64_STANDARD, Engine as _}; +use futures::{FutureExt, StreamExt, future, stream::BoxStream}; use hyper::{ + Body, Method, Request, Response, Server, StatusCode, body::HttpBody, header::HeaderValue, service::{make_service_fn, service_fn}, - Body, Method, Request, Response, Server, StatusCode, }; -use indexmap::{map::Entry, IndexMap}; +use indexmap::{IndexMap, map::Entry}; use serde_with::serde_as; use snafu::Snafu; use stream_cancel::{Trigger, Tripwire}; @@ -25,25 +25,25 @@ use tower_http::compression::CompressionLayer; use tracing::{Instrument, Span}; use vector_lib::configurable::configurable_component; use vector_lib::{ + ByteSizeOf, EstimatedJsonEncodedSizeOf, internal_event::{ ByteSize, BytesSent, CountByteSize, EventsSent, InternalEventHandle as _, Output, Protocol, Registered, }, - ByteSizeOf, EstimatedJsonEncodedSizeOf, }; use super::collector::{MetricCollector, StringCollector}; use crate::{ config::{AcknowledgementsConfig, GenerateConfig, Input, Resource, SinkConfig, SinkContext}, event::{ - metric::{Metric, MetricData, MetricKind, MetricSeries, MetricValue}, Event, EventStatus, Finalizable, + metric::{Metric, MetricData, MetricKind, MetricSeries, MetricValue}, }, - http::{build_http_trace_layer, Auth}, + http::{Auth, build_http_trace_layer}, internal_events::PrometheusNormalizationError, sinks::{ - util::{statistic::validate_quantiles, StreamSink}, Healthcheck, VectorSink, + util::{StreamSink, statistic::validate_quantiles}, }, tls::{MaybeTlsSettings, TlsEnableableConfig}, }; @@ -621,7 +621,7 @@ mod tests { http::HttpClient, sinks::prometheus::{distribution_to_agg_histogram, distribution_to_ddsketch}, test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, next_addr, random_string, trace_init, }, tls::MaybeTlsSettings, @@ -951,9 +951,11 @@ mod tests { assert!(result.status().is_success()); if encoding.is_some() { - assert!(result - .headers() - .contains_key(http::header::CONTENT_ENCODING)); + assert!( + result + .headers() + .contains_key(http::header::CONTENT_ENCODING) + ); } let body = result.into_body(); @@ -1462,7 +1464,7 @@ mod integration_tests { config::ProxyConfig, http::HttpClient, test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, trace_init, }, }; diff --git a/src/sinks/prometheus/remote_write/config.rs b/src/sinks/prometheus/remote_write/config.rs index 1ee5d4695301c..f90955b89b9c9 100644 --- a/src/sinks/prometheus/remote_write/config.rs +++ b/src/sinks/prometheus/remote_write/config.rs @@ -4,15 +4,15 @@ use snafu::prelude::*; use crate::{ http::HttpClient, sinks::{ + UriParseSnafu, prelude::*, prometheus::PrometheusRemoteWriteAuth, util::{auth::Auth, http::http_response_retry_logic}, - UriParseSnafu, }, }; use super::{ - service::{build_request, RemoteWriteService}, + service::{RemoteWriteService, build_request}, sink::{PrometheusRemoteWriteDefaultBatchSettings, RemoteWriteSink}, }; diff --git a/src/sinks/prometheus/remote_write/integration_tests.rs b/src/sinks/prometheus/remote_write/integration_tests.rs index cf47ec5270045..4136e900d4321 100644 --- a/src/sinks/prometheus/remote_write/integration_tests.rs +++ b/src/sinks/prometheus/remote_write/integration_tests.rs @@ -5,10 +5,10 @@ use serde_json::Value; use super::tests::*; use crate::{ config::{SinkConfig, SinkContext}, - event::{metric::MetricValue, Event}, + event::{Event, metric::MetricValue}, sinks::influxdb::test_util::{cleanup_v1, format_timestamp, onboarding_v1, query_v1}, sinks::prometheus::remote_write::config::RemoteWriteConfig, - test_util::components::{assert_sink_compliance, HTTP_SINK_TAGS}, + test_util::components::{HTTP_SINK_TAGS, assert_sink_compliance}, tls::{self, TlsConfig}, }; diff --git a/src/sinks/prometheus/remote_write/request_builder.rs b/src/sinks/prometheus/remote_write/request_builder.rs index 716923edd381b..862c763120f7e 100644 --- a/src/sinks/prometheus/remote_write/request_builder.rs +++ b/src/sinks/prometheus/remote_write/request_builder.rs @@ -9,7 +9,7 @@ use crate::sinks::{ prometheus::{collector, collector::MetricCollector as _}, }; -use super::{sink::EventCollection, PartitionKey}; +use super::{PartitionKey, sink::EventCollection}; pub(crate) struct RemoteWriteEncoder { pub(super) default_namespace: Option, diff --git a/src/sinks/prometheus/remote_write/sink.rs b/src/sinks/prometheus/remote_write/sink.rs index 8ce8dfa6a43f3..046e769c0eace 100644 --- a/src/sinks/prometheus/remote_write/sink.rs +++ b/src/sinks/prometheus/remote_write/sink.rs @@ -7,8 +7,8 @@ use vector_lib::stream::batcher::{data::BatchData, limiter::ByteSizeOfItemSize}; use crate::sinks::{prelude::*, util::buffer::metrics::MetricSet}; use super::{ - request_builder::{RemoteWriteEncoder, RemoteWriteRequest, RemoteWriteRequestBuilder}, PartitionKey, PrometheusMetricNormalize, + request_builder::{RemoteWriteEncoder, RemoteWriteRequest, RemoteWriteRequestBuilder}, }; pub(super) struct RemoteWriteMetric { diff --git a/src/sinks/prometheus/remote_write/tests.rs b/src/sinks/prometheus/remote_write/tests.rs index 9bf74c72aee6e..f9ea548e837c8 100644 --- a/src/sinks/prometheus/remote_write/tests.rs +++ b/src/sinks/prometheus/remote_write/tests.rs @@ -13,7 +13,7 @@ use crate::{ sinks::{prometheus::remote_write::config::RemoteWriteConfig, util::test::build_test_server}, test_util::{ self, - components::{assert_sink_compliance, HTTP_SINK_TAGS}, + components::{HTTP_SINK_TAGS, assert_sink_compliance}, }, }; diff --git a/src/sinks/pulsar/config.rs b/src/sinks/pulsar/config.rs index d565b73ae4a24..027d929cf5345 100644 --- a/src/sinks/pulsar/config.rs +++ b/src/sinks/pulsar/config.rs @@ -2,21 +2,21 @@ use crate::{ schema, sinks::{ prelude::*, - pulsar::sink::{healthcheck, PulsarSink}, + pulsar::sink::{PulsarSink, healthcheck}, }, }; use futures_util::{FutureExt, TryFutureExt}; use pulsar::{ + Authentication, ConnectionRetryOptions, Error as PulsarError, ProducerOptions, Pulsar, + TokioExecutor, authentication::oauth2::{OAuth2Authentication, OAuth2Params}, compression, message::proto, - Authentication, ConnectionRetryOptions, Error as PulsarError, ProducerOptions, Pulsar, - TokioExecutor, }; -use pulsar::{error::AuthenticationError, OperationRetryOptions}; +use pulsar::{OperationRetryOptions, error::AuthenticationError}; use std::path::Path; use std::time::Duration; -use vector_lib::codecs::{encoding::SerializerConfig, TextSerializerConfig}; +use vector_lib::codecs::{TextSerializerConfig, encoding::SerializerConfig}; use vector_lib::config::DataType; use vector_lib::lookup::lookup_v2::OptionalTargetPath; use vector_lib::sensitive_string::SensitiveString; diff --git a/src/sinks/pulsar/encoder.rs b/src/sinks/pulsar/encoder.rs index 8fd05ceb14285..18877cd23be4b 100644 --- a/src/sinks/pulsar/encoder.rs +++ b/src/sinks/pulsar/encoder.rs @@ -1,13 +1,13 @@ //! Encoding for the `Pulsar` sink. use crate::{ event::Event, - sinks::util::encoding::{write_all, Encoder}, + sinks::util::encoding::{Encoder, write_all}, }; use bytes::BytesMut; use std::io; use tokio_util::codec::Encoder as _; use vector_lib::request_metadata::GroupedCountByteSize; -use vector_lib::{config::telemetry, EstimatedJsonEncodedSizeOf}; +use vector_lib::{EstimatedJsonEncodedSizeOf, config::telemetry}; #[derive(Clone, Debug)] pub(super) struct PulsarEncoder { diff --git a/src/sinks/pulsar/integration_tests.rs b/src/sinks/pulsar/integration_tests.rs index 5d95ed98b3f86..e7b4d4f54d5f5 100644 --- a/src/sinks/pulsar/integration_tests.rs +++ b/src/sinks/pulsar/integration_tests.rs @@ -6,7 +6,7 @@ use crate::event::{ObjectMap, Value}; use crate::sinks::VectorSink; use crate::template::Template; use crate::test_util::{ - components::{assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, assert_sink_compliance}, random_lines_with_stream, random_string, trace_init, }; use crate::tls::TEST_PEM_INTERMEDIATE_CA_PATH; diff --git a/src/sinks/redis/config.rs b/src/sinks/redis/config.rs index a8a49d01e02fc..d7e4c938bcbeb 100644 --- a/src/sinks/redis/config.rs +++ b/src/sinks/redis/config.rs @@ -1,6 +1,6 @@ use redis::{ - sentinel::{Sentinel, SentinelNodeConnectionInfo}, ProtocolVersion, RedisConnectionInfo, TlsMode, + sentinel::{Sentinel, SentinelNodeConnectionInfo}, }; use snafu::prelude::*; @@ -10,8 +10,8 @@ use crate::{ }; use super::{ - sink::{RedisConnection, RedisSink}, RedisCreateFailedSnafu, + sink::{RedisConnection, RedisSink}, }; #[derive(Clone, Copy, Debug)] diff --git a/src/sinks/redis/integration_tests.rs b/src/sinks/redis/integration_tests.rs index 341e527f69fc3..4bd6c9824c784 100644 --- a/src/sinks/redis/integration_tests.rs +++ b/src/sinks/redis/integration_tests.rs @@ -3,7 +3,7 @@ use rand::Rng; use redis::AsyncCommands; use vector_lib::codecs::JsonSerializerConfig; use vector_lib::{ - config::{init_telemetry, Tags, Telemetry}, + config::{Tags, Telemetry, init_telemetry}, event::LogEvent, }; @@ -19,8 +19,8 @@ use crate::{ sinks::prelude::*, test_util::{ components::{ - assert_data_volume_sink_compliance, assert_sink_compliance, DATA_VOLUME_SINK_TAGS, - SINK_TAGS, + DATA_VOLUME_SINK_TAGS, SINK_TAGS, assert_data_volume_sink_compliance, + assert_sink_compliance, }, map_event_batch_stream, random_lines_with_stream, random_string, trace_init, }, @@ -65,10 +65,12 @@ async fn redis_sink_sentinel_reaches_primary() { .unwrap() .connection; - assert!(redis::cmd("PING") - .query_async::<()>(&mut conn) - .await - .is_ok()); + assert!( + redis::cmd("PING") + .query_async::<()>(&mut conn) + .await + .is_ok() + ); } #[tokio::test] @@ -623,7 +625,7 @@ async fn redis_sink_metrics() { #[tokio::test] async fn redis_sink_traces() { - use crate::test_util::components::{assert_sink_compliance, SINK_TAGS}; + use crate::test_util::components::{SINK_TAGS, assert_sink_compliance}; trace_init(); diff --git a/src/sinks/redis/mod.rs b/src/sinks/redis/mod.rs index 17ef4ec907d5e..5d2587b401a8e 100644 --- a/src/sinks/redis/mod.rs +++ b/src/sinks/redis/mod.rs @@ -33,7 +33,7 @@ pub(super) enum RedisSinkError { RedisCreateFailed { source: RedisError }, #[snafu(display( "Error sending query: {source}{}", - if let Some(gen) = generation { format!(", gen={gen}") } else { String::new() } + if let Some(generation) = generation { format!(", gen={generation}") } else { String::new() } ))] SendError { source: RedisError, diff --git a/src/sinks/redis/service.rs b/src/sinks/redis/service.rs index 935409a10bcd4..d69cebfc9b331 100644 --- a/src/sinks/redis/service.rs +++ b/src/sinks/redis/service.rs @@ -3,9 +3,9 @@ use std::task::{Context, Poll}; use crate::sinks::prelude::*; use super::{ + RedisRequest, RedisSinkError, config::{ListMethod, SortedSetMethod}, sink::{ConnectionState, RedisConnection}, - RedisRequest, RedisSinkError, }; #[derive(Clone)] diff --git a/src/sinks/redis/sink.rs b/src/sinks/redis/sink.rs index 0f17d769268b2..db3b0c8231eac 100644 --- a/src/sinks/redis/sink.rs +++ b/src/sinks/redis/sink.rs @@ -2,9 +2,9 @@ use snafu::prelude::*; use std::{future, sync::Arc, time::Duration}; use redis::{ + RedisResult, aio::ConnectionManager, sentinel::{Sentinel, SentinelNodeConnectionInfo}, - RedisResult, }; use tokio::{ sync::watch::{self, Receiver, Sender}, @@ -15,10 +15,10 @@ use tokio::{ use crate::sinks::{prelude::*, redis::RedisSinkError, util::retries::RetryAction}; use super::{ + RedisEvent, RedisRequest, RepairChannelSnafu, config::{DataTypeConfig, RedisSinkConfig, RedisTowerRequestConfigDefaults}, request_builder::request_builder, service::{RedisResponse, RedisService}, - RedisEvent, RedisRequest, RepairChannelSnafu, }; pub(super) type GenerationCount = u64; @@ -192,7 +192,10 @@ impl RedisConnection { } } Err(error) => { - warn!(internal_log_rate_limit = true, "Failed to repair ConnectionManager via sentinel (gen: {current_generation}): {error:?}."); + warn!( + internal_log_rate_limit = true, + "Failed to repair ConnectionManager via sentinel (gen: {current_generation}): {error:?}." + ); sleep(Duration::from_millis(250)).await; continue; } diff --git a/src/sinks/s3_common/config.rs b/src/sinks/s3_common/config.rs index 3d3caac50fc0d..987c6d8e85d0c 100644 --- a/src/sinks/s3_common/config.rs +++ b/src/sinks/s3_common/config.rs @@ -1,9 +1,9 @@ use std::collections::{BTreeMap, HashMap}; use aws_sdk_s3::{ + Client as S3Client, operation::put_object::PutObjectError, types::{ObjectCannedAcl, ServerSideEncryption, StorageClass}, - Client as S3Client, }; use aws_smithy_runtime_api::{ client::{orchestrator::HttpResponse, result::SdkError}, @@ -15,11 +15,11 @@ use vector_lib::configurable::configurable_component; use super::service::{S3Request, S3Response, S3Service}; use crate::{ - aws::{create_client, is_retriable_error, AwsAuthentication, RegionOrEndpoint}, + aws::{AwsAuthentication, RegionOrEndpoint, create_client, is_retriable_error}, common::s3::S3ClientBuilder, config::ProxyConfig, http::status, - sinks::{util::retries::RetryLogic, Healthcheck}, + sinks::{Healthcheck, util::retries::RetryLogic}, tls::TlsConfig, }; diff --git a/src/sinks/s3_common/service.rs b/src/sinks/s3_common/service.rs index d4ad54378fb09..5f9e49558547d 100644 --- a/src/sinks/s3_common/service.rs +++ b/src/sinks/s3_common/service.rs @@ -1,11 +1,11 @@ use std::task::{Context, Poll}; -use aws_sdk_s3::operation::put_object::PutObjectError; use aws_sdk_s3::Client as S3Client; +use aws_sdk_s3::operation::put_object::PutObjectError; use aws_smithy_runtime_api::client::orchestrator::HttpResponse; use aws_smithy_runtime_api::client::result::SdkError; use aws_smithy_types::byte_stream::ByteStream; -use base64::prelude::{Engine as _, BASE64_STANDARD}; +use base64::prelude::{BASE64_STANDARD, Engine as _}; use bytes::Bytes; use futures::future::BoxFuture; use md5::Digest; diff --git a/src/sinks/sematext/logs.rs b/src/sinks/sematext/logs.rs index 49d4d157bfb1b..c2396f1c5e9a9 100644 --- a/src/sinks/sematext/logs.rs +++ b/src/sinks/sematext/logs.rs @@ -11,12 +11,12 @@ use crate::{ config::{AcknowledgementsConfig, GenerateConfig, Input, SinkConfig, SinkContext}, event::EventArray, sinks::{ + Healthcheck, VectorSink, elasticsearch::{BulkConfig, ElasticsearchApiVersion, ElasticsearchConfig}, util::{ - http::RequestConfig, BatchConfig, Compression, RealtimeSizeBasedDefaultBatchSettings, - StreamSink, TowerRequestConfig, + BatchConfig, Compression, RealtimeSizeBasedDefaultBatchSettings, StreamSink, + TowerRequestConfig, http::RequestConfig, }, - Healthcheck, VectorSink, }, template::Template, }; diff --git a/src/sinks/sematext/metrics.rs b/src/sinks/sematext/metrics.rs index 64941c3571666..e56a2f2812dd6 100644 --- a/src/sinks/sematext/metrics.rs +++ b/src/sinks/sematext/metrics.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, future::ready, task::Poll}; use bytes::{Bytes, BytesMut}; -use futures::{future::BoxFuture, stream, FutureExt, SinkExt}; +use futures::{FutureExt, SinkExt, future::BoxFuture, stream}; use http::{StatusCode, Uri}; use hyper::{Body, Request}; use indoc::indoc; @@ -12,23 +12,24 @@ use vector_lib::{ByteSizeOf, EstimatedJsonEncodedSizeOf}; use super::Region; use crate::{ + Result, config::{AcknowledgementsConfig, GenerateConfig, Input, SinkConfig, SinkContext}, event::{ - metric::{Metric, MetricValue}, Event, KeyString, + metric::{Metric, MetricValue}, }, http::HttpClient, internal_events::{SematextMetricsEncodeEventError, SematextMetricsInvalidMetricError}, sinks::{ - influxdb::{encode_timestamp, encode_uri, influx_line_protocol, Field, ProtocolVersion}, + Healthcheck, HealthcheckError, VectorSink, + influxdb::{Field, ProtocolVersion, encode_timestamp, encode_uri, influx_line_protocol}, util::{ + BatchConfig, EncodedEvent, SinkBatchSettings, TowerRequestConfig, buffer::metrics::{MetricNormalize, MetricNormalizer, MetricSet, MetricsBuffer}, http::{HttpBatchService, HttpRetryLogic}, - BatchConfig, EncodedEvent, SinkBatchSettings, TowerRequestConfig, }, - Healthcheck, HealthcheckError, VectorSink, }, - vector_version, Result, + vector_version, }; #[derive(Clone)] @@ -304,17 +305,17 @@ fn to_fields(label: String, value: f64) -> HashMap { #[cfg(test)] mod tests { - use chrono::{offset::TimeZone, Timelike, Utc}; + use chrono::{Timelike, Utc, offset::TimeZone}; use futures::StreamExt; use indoc::indoc; use vector_lib::metric_tags; use super::*; use crate::{ - event::{metric::MetricKind, Event}, + event::{Event, metric::MetricKind}, sinks::util::test::{build_test_server, load_sink}, test_util::{ - components::{assert_sink_compliance, HTTP_SINK_TAGS}, + components::{HTTP_SINK_TAGS, assert_sink_compliance}, next_addr, test_generate_config, }, }; @@ -326,17 +327,19 @@ mod tests { #[test] fn test_encode_counter_event() { - let events = vec![Metric::new( - "pool.used", - MetricKind::Incremental, - MetricValue::Counter { value: 42.0 }, - ) - .with_namespace(Some("jvm")) - .with_timestamp(Some( - Utc.with_ymd_and_hms(2020, 8, 18, 21, 0, 0) - .single() - .expect("invalid timestamp"), - ))]; + let events = vec![ + Metric::new( + "pool.used", + MetricKind::Incremental, + MetricValue::Counter { value: 42.0 }, + ) + .with_namespace(Some("jvm")) + .with_timestamp(Some( + Utc.with_ymd_and_hms(2020, 8, 18, 21, 0, 0) + .single() + .expect("invalid timestamp"), + )), + ]; assert_eq!( "jvm,metric_type=counter,token=aaa pool.used=42 1597784400000000000", @@ -346,16 +349,18 @@ mod tests { #[test] fn test_encode_counter_event_no_namespace() { - let events = vec![Metric::new( - "used", - MetricKind::Incremental, - MetricValue::Counter { value: 42.0 }, - ) - .with_timestamp(Some( - Utc.with_ymd_and_hms(2020, 8, 18, 21, 0, 0) - .single() - .expect("invalid timestamp"), - ))]; + let events = vec![ + Metric::new( + "used", + MetricKind::Incremental, + MetricValue::Counter { value: 42.0 }, + ) + .with_timestamp(Some( + Utc.with_ymd_and_hms(2020, 8, 18, 21, 0, 0) + .single() + .expect("invalid timestamp"), + )), + ]; assert_eq!( "ns,metric_type=counter,token=aaa used=42 1597784400000000000", diff --git a/src/sinks/socket.rs b/src/sinks/socket.rs index 805fa6354355c..cdc811d4c196a 100644 --- a/src/sinks/socket.rs +++ b/src/sinks/socket.rs @@ -1,6 +1,6 @@ use vector_lib::codecs::{ - encoding::{Framer, FramingConfig}, TextSerializerConfig, + encoding::{Framer, FramingConfig}, }; use vector_lib::configurable::configurable_component; @@ -213,7 +213,7 @@ mod test { use serde_json::Value; use tokio::{ net::TcpListener, - time::{sleep, timeout, Duration}, + time::{Duration, sleep, timeout}, }; use tokio_stream::wrappers::TcpListenerStream; use tokio_util::codec::{FramedRead, LinesCodec}; @@ -235,8 +235,9 @@ mod test { config::SinkContext, event::{Event, LogEvent}, test_util::{ - components::{assert_sink_compliance, run_and_assert_sink_compliance, SINK_TAGS}, - next_addr, next_addr_v6, random_lines_with_stream, trace_init, CountReceiver, + CountReceiver, + components::{SINK_TAGS, assert_sink_compliance, run_and_assert_sink_compliance}, + next_addr, next_addr_v6, random_lines_with_stream, trace_init, }, }; @@ -425,18 +426,18 @@ mod test { use std::{ pin::Pin, sync::{ - atomic::{AtomicUsize, Ordering}, Arc, + atomic::{AtomicUsize, Ordering}, }, task::Poll, }; - use futures::{channel::mpsc, FutureExt, SinkExt, StreamExt}; + use futures::{FutureExt, SinkExt, StreamExt, channel::mpsc}; use tokio::{ io::{AsyncRead, AsyncWriteExt, ReadBuf}, net::TcpStream, task::yield_now, - time::{interval, Duration}, + time::{Duration, interval}, }; use tokio_stream::wrappers::IntervalStream; @@ -504,34 +505,36 @@ mod test { let mut stream: MaybeTlsIncomingStream = connection.unwrap(); - std::future::poll_fn(move |cx| loop { - if let Some(fut) = close_rx.as_mut() { - if let Poll::Ready(()) = fut.poll_unpin(cx) { - stream - .get_mut() - .unwrap() - .shutdown() - .now_or_never() - .unwrap() - .unwrap(); - close_rx = None; + std::future::poll_fn(move |cx| { + loop { + if let Some(fut) = close_rx.as_mut() { + if let Poll::Ready(()) = fut.poll_unpin(cx) { + stream + .get_mut() + .unwrap() + .shutdown() + .now_or_never() + .unwrap() + .unwrap(); + close_rx = None; + } } - } - let mut buf = [0u8; 11]; - let mut buf = ReadBuf::new(&mut buf); - return match Pin::new(&mut stream).poll_read(cx, &mut buf) { - Poll::Ready(Ok(())) => { - if buf.filled().is_empty() { - Poll::Ready(()) - } else { - msg_counter1.fetch_add(1, Ordering::SeqCst); - continue; + let mut buf = [0u8; 11]; + let mut buf = ReadBuf::new(&mut buf); + return match Pin::new(&mut stream).poll_read(cx, &mut buf) { + Poll::Ready(Ok(())) => { + if buf.filled().is_empty() { + Poll::Ready(()) + } else { + msg_counter1.fetch_add(1, Ordering::SeqCst); + continue; + } } - } - Poll::Ready(Err(error)) => panic!("{}", error), - Poll::Pending => Poll::Pending, - }; + Poll::Ready(Err(error)) => panic!("{error}"), + Poll::Pending => Poll::Pending, + }; + } }) }) .await; @@ -622,12 +625,14 @@ mod test { // Second listener // If this doesn't succeed then the sink hanged. - assert!(timeout( - Duration::from_secs(5), - CountReceiver::receive_lines(addr).connected() - ) - .await - .is_ok()); + assert!( + timeout( + Duration::from_secs(5), + CountReceiver::receive_lines(addr).connected() + ) + .await + .is_ok() + ); sink_handle.await.unwrap(); } diff --git a/src/sinks/splunk_hec/common/acknowledgements.rs b/src/sinks/splunk_hec/common/acknowledgements.rs index dfd5ea23b5264..cad9279fa08be 100644 --- a/src/sinks/splunk_hec/common/acknowledgements.rs +++ b/src/sinks/splunk_hec/common/acknowledgements.rs @@ -1,6 +1,6 @@ use std::{ collections::HashMap, - num::{NonZeroU64, NonZeroU8}, + num::{NonZeroU8, NonZeroU64}, sync::Arc, time::Duration, }; @@ -147,8 +147,7 @@ impl HecAckClient { } _ => { emit!(SplunkIndexerAcknowledgementAPIError { - message: - "Unable to send acknowledgement query request. Will retry.", + message: "Unable to send acknowledgement query request. Will retry.", error, }); self.expire_ack_ids_with_status(EventStatus::Errored); @@ -286,7 +285,7 @@ pub async fn run_acknowledgements( mod tests { use std::sync::Arc; - use futures_util::{stream::FuturesUnordered, StreamExt}; + use futures_util::{StreamExt, stream::FuturesUnordered}; use tokio::sync::oneshot::{self, Receiver}; use vector_lib::{config::proxy::ProxyConfig, event::EventStatus}; @@ -295,7 +294,7 @@ mod tests { http::HttpClient, sinks::{ splunk_hec::common::{ - acknowledgements::HecAckStatusRequest, service::HttpRequestBuilder, EndpointTarget, + EndpointTarget, acknowledgements::HecAckStatusRequest, service::HttpRequestBuilder, }, util::Compression, }, diff --git a/src/sinks/splunk_hec/common/request.rs b/src/sinks/splunk_hec/common/request.rs index f644107e46676..d94eacb174d81 100644 --- a/src/sinks/splunk_hec/common/request.rs +++ b/src/sinks/splunk_hec/common/request.rs @@ -3,8 +3,8 @@ use std::sync::Arc; use bytes::Bytes; use vector_lib::request_metadata::{MetaDescriptive, RequestMetadata}; use vector_lib::{ - event::{EventFinalizers, Finalizable}, ByteSizeOf, + event::{EventFinalizers, Finalizable}, }; use crate::sinks::util::ElementCount; diff --git a/src/sinks/splunk_hec/common/service.rs b/src/sinks/splunk_hec/common/service.rs index 71a5d49741ad7..1a81948c854e3 100644 --- a/src/sinks/splunk_hec/common/service.rs +++ b/src/sinks/splunk_hec/common/service.rs @@ -1,7 +1,7 @@ use std::{ fmt, sync::Arc, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, }; use bytes::Bytes; @@ -9,7 +9,7 @@ use futures_util::future::BoxFuture; use http::Request; use serde::{Deserialize, Serialize}; use snafu::ResultExt; -use tokio::sync::{mpsc, oneshot, OwnedSemaphorePermit, Semaphore}; +use tokio::sync::{OwnedSemaphorePermit, Semaphore, mpsc, oneshot}; use tokio_util::sync::PollSemaphore; use tower::Service; use uuid::Uuid; @@ -17,16 +17,16 @@ use vector_lib::event::EventStatus; use vector_lib::request_metadata::MetaDescriptive; use super::{ - acknowledgements::{run_acknowledgements, HecClientAcknowledgementsConfig}, EndpointTarget, + acknowledgements::{HecClientAcknowledgementsConfig, run_acknowledgements}, }; use crate::{ http::HttpClient, internal_events::{SplunkIndexerAcknowledgementUnavailableError, SplunkResponseParseError}, sinks::{ - splunk_hec::common::{build_uri, request::HecRequest, response::HecResponse}, - util::{sink::Response, Compression}, UriParseSnafu, + splunk_hec::common::{build_uri, request::HecRequest, response::HecResponse}, + util::{Compression, sink::Response}, }, }; @@ -271,40 +271,40 @@ mod tests { use std::{ collections::HashMap, future::poll_fn, - num::{NonZeroU64, NonZeroU8, NonZeroUsize}, + num::{NonZeroU8, NonZeroU64, NonZeroUsize}, sync::{ - atomic::{AtomicU64, Ordering}, Arc, + atomic::{AtomicU64, Ordering}, }, task::Poll, }; use bytes::Bytes; - use futures_util::{poll, stream::FuturesUnordered, StreamExt}; - use tower::{util::BoxService, Service, ServiceExt}; + use futures_util::{StreamExt, poll, stream::FuturesUnordered}; + use tower::{Service, ServiceExt, util::BoxService}; use vector_lib::internal_event::CountByteSize; use vector_lib::{ config::proxy::ProxyConfig, event::{EventFinalizers, EventStatus}, }; use wiremock::{ - matchers::{header, header_exists, method, path}, Mock, MockServer, Request, Respond, ResponseTemplate, + matchers::{header, header_exists, method, path}, }; use crate::{ http::HttpClient, sinks::{ splunk_hec::common::{ + EndpointTarget, acknowledgements::{ HecAckStatusRequest, HecAckStatusResponse, HecClientAcknowledgementsConfig, }, build_http_batch_service, request::HecRequest, service::{HecAckResponseBody, HecService, HttpRequestBuilder}, - EndpointTarget, }, - util::{metadata::RequestMetadataBuilder, Compression}, + util::{Compression, metadata::RequestMetadataBuilder}, }, }; diff --git a/src/sinks/splunk_hec/common/util.rs b/src/sinks/splunk_hec/common/util.rs index a94614f10d04c..5ae99e2c54c90 100644 --- a/src/sinks/splunk_hec/common/util.rs +++ b/src/sinks/splunk_hec/common/util.rs @@ -9,17 +9,16 @@ use vector_lib::lookup::lookup_v2::{OptionalTargetPath, OptionalValuePath}; use vector_lib::{config::proxy::ProxyConfig, event::EventRef}; use super::{ + EndpointTarget, request::HecRequest, service::{HttpRequestBuilder, MetadataFields}, - EndpointTarget, }; use crate::{ http::HttpClient, internal_events::TemplateRenderingError, sinks::{ - self, - util::{http::HttpBatchService, SinkBatchSettings}, - UriParseSnafu, + self, UriParseSnafu, + util::{SinkBatchSettings, http::HttpBatchService}, }, template::Template, tls::{TlsConfig, TlsSettings}, @@ -172,15 +171,14 @@ mod tests { use http::{HeaderValue, Uri}; use vector_lib::config::proxy::ProxyConfig; use wiremock::{ - matchers::{header, method, path}, Mock, MockServer, ResponseTemplate, + matchers::{header, method, path}, }; use crate::sinks::{ splunk_hec::common::{ - build_healthcheck, build_uri, create_client, + EndpointTarget, HOST_FIELD, SOURCE_FIELD, build_healthcheck, build_uri, create_client, service::{HttpRequestBuilder, MetadataFields}, - EndpointTarget, HOST_FIELD, SOURCE_FIELD, }, util::Compression, }; diff --git a/src/sinks/splunk_hec/logs/config.rs b/src/sinks/splunk_hec/logs/config.rs index 000b26b21de05..8ffa11ceeb537 100644 --- a/src/sinks/splunk_hec/logs/config.rs +++ b/src/sinks/splunk_hec/logs/config.rs @@ -11,10 +11,10 @@ use crate::{ sinks::{ prelude::*, splunk_hec::common::{ + EndpointTarget, SplunkHecDefaultBatchSettings, acknowledgements::HecClientAcknowledgementsConfig, build_healthcheck, build_http_batch_service, create_client, service::{HecService, HttpRequestBuilder}, - EndpointTarget, SplunkHecDefaultBatchSettings, }, util::http::HttpRetryLogic, }, @@ -286,7 +286,7 @@ mod tests { use super::*; use crate::components::validation::prelude::*; use vector_lib::{ - codecs::{encoding::format::JsonSerializerOptions, JsonSerializerConfig, MetricTagValues}, + codecs::{JsonSerializerConfig, MetricTagValues, encoding::format::JsonSerializerOptions}, config::LogNamespace, }; diff --git a/src/sinks/splunk_hec/logs/encoder.rs b/src/sinks/splunk_hec/logs/encoder.rs index 9f8faa841fde6..79327ceb91167 100644 --- a/src/sinks/splunk_hec/logs/encoder.rs +++ b/src/sinks/splunk_hec/logs/encoder.rs @@ -4,7 +4,7 @@ use bytes::BytesMut; use serde::Serialize; use tokio_util::codec::Encoder as _; use vector_lib::request_metadata::GroupedCountByteSize; -use vector_lib::{config::telemetry, EstimatedJsonEncodedSizeOf}; +use vector_lib::{EstimatedJsonEncodedSizeOf, config::telemetry}; use super::sink::HecProcessedEvent; use crate::{ diff --git a/src/sinks/splunk_hec/logs/integration_tests.rs b/src/sinks/splunk_hec/logs/integration_tests.rs index f26263f19acf1..754621a4543a6 100644 --- a/src/sinks/splunk_hec/logs/integration_tests.rs +++ b/src/sinks/splunk_hec/logs/integration_tests.rs @@ -3,11 +3,11 @@ use std::{convert::TryFrom, iter, num::NonZeroU8}; use chrono::{TimeZone, Timelike, Utc}; use futures::{future::ready, stream}; use serde_json::Value as JsonValue; -use tokio::time::{sleep, Duration}; +use tokio::time::{Duration, sleep}; use vector_lib::codecs::{JsonSerializerConfig, TextSerializerConfig}; use vector_lib::lookup::lookup_v2::{ConfigValuePath, OptionalTargetPath}; use vector_lib::{ - config::{init_telemetry, Tags, Telemetry}, + config::{Tags, Telemetry, init_telemetry}, event::{BatchNotifier, BatchStatus, Event, LogEvent}, lookup, }; @@ -20,9 +20,9 @@ use crate::{ sinks::{ splunk_hec::{ common::{ + EndpointTarget, SOURCE_FIELD, acknowledgements::HecClientAcknowledgementsConfig, integration_test_helpers::{get_token, splunk_api_address, splunk_hec_address}, - EndpointTarget, SOURCE_FIELD, }, logs::config::HecLogsSinkConfig, }, @@ -31,8 +31,8 @@ use crate::{ template::Template, test_util::{ components::{ - run_and_assert_data_volume_sink_compliance, run_and_assert_sink_compliance, - DATA_VOLUME_SINK_TAGS, HTTP_SINK_TAGS, + DATA_VOLUME_SINK_TAGS, HTTP_SINK_TAGS, run_and_assert_data_volume_sink_compliance, + run_and_assert_sink_compliance, }, random_lines_with_stream, random_string, }, diff --git a/src/sinks/splunk_hec/logs/request_builder.rs b/src/sinks/splunk_hec/logs/request_builder.rs index 91d37d7b5ebd1..d357470cc4ce5 100644 --- a/src/sinks/splunk_hec/logs/request_builder.rs +++ b/src/sinks/splunk_hec/logs/request_builder.rs @@ -11,8 +11,8 @@ use super::{ use crate::sinks::{ splunk_hec::common::request::HecRequest, util::{ - metadata::RequestMetadataBuilder, request_builder::EncodeResult, Compression, - RequestBuilder, + Compression, RequestBuilder, metadata::RequestMetadataBuilder, + request_builder::EncodeResult, }, }; diff --git a/src/sinks/splunk_hec/logs/sink.rs b/src/sinks/splunk_hec/logs/sink.rs index 51a3e2d2f9f6b..d78d132911434 100644 --- a/src/sinks/splunk_hec/logs/sink.rs +++ b/src/sinks/splunk_hec/logs/sink.rs @@ -7,15 +7,15 @@ use crate::{ sinks::{ prelude::*, splunk_hec::common::{ - render_template_string, request::HecRequest, EndpointTarget, INDEX_FIELD, - SOURCETYPE_FIELD, SOURCE_FIELD, + EndpointTarget, INDEX_FIELD, SOURCE_FIELD, SOURCETYPE_FIELD, render_template_string, + request::HecRequest, }, util::processed_event::ProcessedEvent, }, }; use vector_lib::{ - config::{log_schema, LogNamespace}, - lookup::{event_path, lookup_v2::OptionalTargetPath, OwnedValuePath, PathPrefix}, + config::{LogNamespace, log_schema}, + lookup::{OwnedValuePath, PathPrefix, event_path, lookup_v2::OptionalTargetPath}, schema::meaning, }; use vrl::path::OwnedTargetPath; diff --git a/src/sinks/splunk_hec/logs/tests.rs b/src/sinks/splunk_hec/logs/tests.rs index c69f231ad50e7..151ca68de3543 100644 --- a/src/sinks/splunk_hec/logs/tests.rs +++ b/src/sinks/splunk_hec/logs/tests.rs @@ -2,12 +2,12 @@ use std::{collections::BTreeMap, sync::Arc}; use chrono::{TimeZone, Utc}; use futures_util::StreamExt; -use serde::{de, Deserialize}; +use serde::{Deserialize, de}; use vector_lib::codecs::{JsonSerializerConfig, TextSerializerConfig}; use vector_lib::config::{LegacyKey, LogNamespace}; use vector_lib::event::EventMetadata; use vector_lib::lookup::lookup_v2::OptionalTargetPath; -use vector_lib::schema::{meaning, Definition}; +use vector_lib::schema::{Definition, meaning}; use vector_lib::{ config::log_schema, event::{Event, LogEvent, Value}, @@ -26,7 +26,7 @@ use crate::{ common::EndpointTarget, logs::{config::HecLogsSinkConfig, encoder::HecLogsEncoder, sink::process_log}, }, - util::{encoding::Encoder as _, test::build_test_server, Compression}, + util::{Compression, encoding::Encoder as _, test::build_test_server}, }, template::Template, test_util::next_addr, diff --git a/src/sinks/splunk_hec/metrics/config.rs b/src/sinks/splunk_hec/metrics/config.rs index 38cb8470d0f90..d05f503efd711 100644 --- a/src/sinks/splunk_hec/metrics/config.rs +++ b/src/sinks/splunk_hec/metrics/config.rs @@ -12,16 +12,16 @@ use crate::{ config::{AcknowledgementsConfig, GenerateConfig, Input, SinkConfig, SinkContext}, http::HttpClient, sinks::{ + Healthcheck, splunk_hec::common::{ + EndpointTarget, SplunkHecDefaultBatchSettings, acknowledgements::HecClientAcknowledgementsConfig, build_healthcheck, build_http_batch_service, config_host_key, create_client, service::{HecService, HttpRequestBuilder}, - EndpointTarget, SplunkHecDefaultBatchSettings, }, util::{ - http::HttpRetryLogic, BatchConfig, Compression, ServiceBuilderExt, TowerRequestConfig, + BatchConfig, Compression, ServiceBuilderExt, TowerRequestConfig, http::HttpRetryLogic, }, - Healthcheck, }, template::Template, tls::TlsConfig, diff --git a/src/sinks/splunk_hec/metrics/encoder.rs b/src/sinks/splunk_hec/metrics/encoder.rs index 9a2430f48bfc9..596ad8fc0d41d 100644 --- a/src/sinks/splunk_hec/metrics/encoder.rs +++ b/src/sinks/splunk_hec/metrics/encoder.rs @@ -2,7 +2,7 @@ use std::{collections::BTreeMap, iter}; use serde::Serialize; use vector_lib::request_metadata::GroupedCountByteSize; -use vector_lib::{config::telemetry, EstimatedJsonEncodedSizeOf}; +use vector_lib::{EstimatedJsonEncodedSizeOf, config::telemetry}; use super::sink::HecProcessedEvent; use crate::{internal_events::SplunkEventEncodeError, sinks::util::encoding::Encoder}; diff --git a/src/sinks/splunk_hec/metrics/integration_tests.rs b/src/sinks/splunk_hec/metrics/integration_tests.rs index 9111cd0a350b4..5044c17e02c26 100644 --- a/src/sinks/splunk_hec/metrics/integration_tests.rs +++ b/src/sinks/splunk_hec/metrics/integration_tests.rs @@ -4,7 +4,7 @@ use futures::{future::ready, stream}; use serde_json::Value as JsonValue; use vector_lib::lookup::lookup_v2::OptionalValuePath; use vector_lib::{ - config::{init_telemetry, Tags, Telemetry}, + config::{Tags, Telemetry, init_telemetry}, event::{BatchNotifier, BatchStatus, Event, MetricValue}, metric_tags, }; @@ -21,8 +21,8 @@ use crate::{ }, template::Template, test_util::components::{ - run_and_assert_data_volume_sink_compliance, run_and_assert_sink_compliance, - DATA_VOLUME_SINK_TAGS, HTTP_SINK_TAGS, + DATA_VOLUME_SINK_TAGS, HTTP_SINK_TAGS, run_and_assert_data_volume_sink_compliance, + run_and_assert_sink_compliance, }, }; diff --git a/src/sinks/splunk_hec/metrics/request_builder.rs b/src/sinks/splunk_hec/metrics/request_builder.rs index d57f4634237ce..2237d49b4eb61 100644 --- a/src/sinks/splunk_hec/metrics/request_builder.rs +++ b/src/sinks/splunk_hec/metrics/request_builder.rs @@ -8,8 +8,8 @@ use super::{encoder::HecMetricsEncoder, sink::HecProcessedEvent}; use crate::sinks::{ splunk_hec::common::request::HecRequest, util::{ - metadata::RequestMetadataBuilder, request_builder::EncodeResult, Compression, - RequestBuilder, + Compression, RequestBuilder, metadata::RequestMetadataBuilder, + request_builder::EncodeResult, }, }; diff --git a/src/sinks/splunk_hec/metrics/tests.rs b/src/sinks/splunk_hec/metrics/tests.rs index 3eccfefe40206..a8529a4f00fbe 100644 --- a/src/sinks/splunk_hec/metrics/tests.rs +++ b/src/sinks/splunk_hec/metrics/tests.rs @@ -2,20 +2,21 @@ use std::{collections::BTreeSet, sync::Arc}; use chrono::{DateTime, Utc}; use futures_util::StreamExt; -use serde_json::{json, Value as JsonValue}; +use serde_json::{Value as JsonValue, json}; use vector_lib::{ + ByteSizeOf, event::{Event, Metric, MetricKind, MetricValue}, - metric_tags, ByteSizeOf, + metric_tags, }; use vrl::owned_value_path; -use super::sink::{process_metric, HecProcessedEvent}; +use super::sink::{HecProcessedEvent, process_metric}; use crate::sinks::splunk_hec::common::config_host_key; use crate::{ config::{SinkConfig, SinkContext}, sinks::{ splunk_hec::metrics::{config::HecMetricsSinkConfig, encoder::HecMetricsEncoder}, - util::{test::build_test_server, Compression}, + util::{Compression, test::build_test_server}, }, template::Template, test_util::next_addr, @@ -130,16 +131,18 @@ fn test_process_metric_unsupported_type_returns_none() { let source = None; let index = None; let default_namespace = None; - assert!(process_metric( - metric, - event_byte_size, - sourcetype, - source, - index, - Some(&owned_value_path!("host_key")), - default_namespace - ) - .is_none()); + assert!( + process_metric( + metric, + event_byte_size, + sourcetype, + source, + index, + Some(&owned_value_path!("host_key")), + default_namespace + ) + .is_none() + ); } #[test] diff --git a/src/sinks/statsd/config.rs b/src/sinks/statsd/config.rs index 98f9d8d4efa1a..d1414508091ca 100644 --- a/src/sinks/statsd/config.rs +++ b/src/sinks/statsd/config.rs @@ -12,11 +12,11 @@ use crate::{ config::{SinkConfig, SinkContext}, internal_events::SocketMode, sinks::{ + Healthcheck, util::{ - service::net::{NetworkConnector, TcpConnectorConfig, UdpConnectorConfig}, BatchConfig, SinkBatchSettings, + service::net::{NetworkConnector, TcpConnectorConfig, UdpConnectorConfig}, }, - Healthcheck, }, }; diff --git a/src/sinks/statsd/encoder.rs b/src/sinks/statsd/encoder.rs index d26dba9fdf6d9..ac1730f74d5df 100644 --- a/src/sinks/statsd/encoder.rs +++ b/src/sinks/statsd/encoder.rs @@ -154,7 +154,7 @@ fn encode_and_write_single_event( #[cfg(test)] mod tests { use vector_lib::{ - event::{metric::TagValue, MetricTags}, + event::{MetricTags, metric::TagValue}, metric_tags, }; @@ -177,7 +177,7 @@ mod tests { #[cfg(feature = "sources-statsd")] fn parse_encoded_metrics(metric: &[u8]) -> Vec { - use crate::sources::statsd::{parser::Parser, ConversionUnit}; + use crate::sources::statsd::{ConversionUnit, parser::Parser}; let statsd_parser = Parser::new(true, ConversionUnit::Seconds); let s = std::str::from_utf8(metric).unwrap().trim(); diff --git a/src/sinks/statsd/request_builder.rs b/src/sinks/statsd/request_builder.rs index a00a59879ad1a..da6dc3762e71a 100644 --- a/src/sinks/statsd/request_builder.rs +++ b/src/sinks/statsd/request_builder.rs @@ -4,16 +4,16 @@ use bytes::BytesMut; use tokio_util::codec::Encoder; use vector_lib::request_metadata::RequestMetadata; use vector_lib::{ + EstimatedJsonEncodedSizeOf, config::telemetry, event::{EventFinalizers, Finalizable, Metric}, - EstimatedJsonEncodedSizeOf, }; use super::{encoder::StatsdEncoder, service::StatsdRequest}; use crate::{ internal_events::SocketMode, sinks::util::{ - metadata::RequestMetadataBuilder, request_builder::EncodeResult, IncrementalRequestBuilder, + IncrementalRequestBuilder, metadata::RequestMetadataBuilder, request_builder::EncodeResult, }, }; diff --git a/src/sinks/statsd/sink.rs b/src/sinks/statsd/sink.rs index dd78f203ef341..26de7bf94f260 100644 --- a/src/sinks/statsd/sink.rs +++ b/src/sinks/statsd/sink.rs @@ -2,8 +2,8 @@ use std::{fmt, future::ready}; use async_trait::async_trait; use futures_util::{ - stream::{self, BoxStream}, StreamExt, + stream::{self, BoxStream}, }; use tower::Service; use vector_lib::internal_event::Protocol; diff --git a/src/sinks/statsd/tests.rs b/src/sinks/statsd/tests.rs index 9284e54d8bd92..68aec116d7331 100644 --- a/src/sinks/statsd/tests.rs +++ b/src/sinks/statsd/tests.rs @@ -5,7 +5,7 @@ use tokio::{net::UdpSocket, sync::mpsc}; use tokio_stream::wrappers::ReceiverStream; use tokio_util::{codec::BytesCodec, udp::UdpFramed}; use vector_lib::{ - event::{metric::TagValue, Event, Metric, MetricKind, MetricTags, MetricValue, StatisticKind}, + event::{Event, Metric, MetricKind, MetricTags, MetricValue, StatisticKind, metric::TagValue}, metric_tags, }; @@ -14,7 +14,7 @@ use crate::{ sinks::{statsd::config::Mode, util::service::net::UdpConnectorConfig}, test_util::{ collect_n, - components::{assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, assert_sink_compliance}, next_addr, trace_init, }, }; @@ -95,6 +95,8 @@ async fn test_send_to_statsd() { let messages = collect_n(ReceiverStream::new(rx), 1).await; assert_eq!( messages[0], - Bytes::from("vector.counter:1.5|c|#bare_tag,multi_value:true,multi_value:false,multi_value,normal_tag:value\nvector.histogram:2|h|@0.01\n"), + Bytes::from( + "vector.counter:1.5|c|#bare_tag,multi_value:true,multi_value:false,multi_value,normal_tag:value\nvector.histogram:2|h|@0.01\n" + ), ); } diff --git a/src/sinks/util/adaptive_concurrency/controller.rs b/src/sinks/util/adaptive_concurrency/controller.rs index ed7fe472cf3f6..4d58e8682080e 100644 --- a/src/sinks/util/adaptive_concurrency/controller.rs +++ b/src/sinks/util/adaptive_concurrency/controller.rs @@ -8,7 +8,7 @@ use tokio::sync::OwnedSemaphorePermit; use tower::timeout::error::Elapsed; use vector_lib::internal_event::{InternalEventHandle as _, Registered}; -use super::{instant_now, semaphore::ShrinkableSemaphore, AdaptiveConcurrencySettings}; +use super::{AdaptiveConcurrencySettings, instant_now, semaphore::ShrinkableSemaphore}; #[cfg(test)] use crate::test_util::stats::{TimeHistogram, TimeWeightedSum}; use crate::{ diff --git a/src/sinks/util/adaptive_concurrency/future.rs b/src/sinks/util/adaptive_concurrency/future.rs index 19268db7f32c7..03e951188e29d 100644 --- a/src/sinks/util/adaptive_concurrency/future.rs +++ b/src/sinks/util/adaptive_concurrency/future.rs @@ -4,7 +4,7 @@ use std::{ future::Future, pin::Pin, sync::Arc, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, time::Instant, }; diff --git a/src/sinks/util/adaptive_concurrency/semaphore.rs b/src/sinks/util/adaptive_concurrency/semaphore.rs index 724ed3e997d2e..f248676b3a7cc 100644 --- a/src/sinks/util/adaptive_concurrency/semaphore.rs +++ b/src/sinks/util/adaptive_concurrency/semaphore.rs @@ -7,7 +7,7 @@ use std::{ mem::{drop, replace}, pin::Pin, sync::{Arc, Mutex}, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, }; use futures::future::{BoxFuture, FutureExt}; diff --git a/src/sinks/util/adaptive_concurrency/service.rs b/src/sinks/util/adaptive_concurrency/service.rs index 5f9861c35ed4a..bd0ed2ed4ff80 100644 --- a/src/sinks/util/adaptive_concurrency/service.rs +++ b/src/sinks/util/adaptive_concurrency/service.rs @@ -3,14 +3,14 @@ use std::{ future::Future, mem, sync::Arc, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, }; use futures::future::BoxFuture; use tokio::sync::OwnedSemaphorePermit; -use tower::{load::Load, Service}; +use tower::{Service, load::Load}; -use super::{controller::Controller, future::ResponseFuture, AdaptiveConcurrencySettings}; +use super::{AdaptiveConcurrencySettings, controller::Controller, future::ResponseFuture}; use crate::sinks::util::retries::RetryLogic; /// Enforces a limit on the concurrent number of requests the underlying @@ -134,14 +134,14 @@ mod tests { use tower_test::{ assert_request_eq, mock::{ - self, future::ResponseFuture as MockResponseFuture, Handle, Mock, SendResponse, Spawn, + self, Handle, Mock, SendResponse, Spawn, future::ResponseFuture as MockResponseFuture, }, }; use super::{ super::{ - controller::{ControllerStatistics, Inner}, AdaptiveConcurrencyLimitLayer, + controller::{ControllerStatistics, Inner}, }, *, }; diff --git a/src/sinks/util/adaptive_concurrency/tests.rs b/src/sinks/util/adaptive_concurrency/tests.rs index e22509b7e73b5..6ecb376453534 100644 --- a/src/sinks/util/adaptive_concurrency/tests.rs +++ b/src/sinks/util/adaptive_concurrency/tests.rs @@ -15,32 +15,33 @@ use std::{ }; use futures::{ + FutureExt, SinkExt, channel::oneshot, future::{self, BoxFuture}, - stream, FutureExt, SinkExt, + stream, }; -use rand::{rng, Rng}; +use rand::{Rng, rng}; use rand_distr::Exp1; use rstest::*; use serde::Deserialize; use snafu::Snafu; -use tokio::time::{self, sleep, Duration, Instant}; +use tokio::time::{self, Duration, Instant, sleep}; use tower::Service; use vector_lib::configurable::configurable_component; use vector_lib::json_size::JsonSize; -use super::controller::ControllerStatistics; use super::AdaptiveConcurrencySettings; +use super::controller::ControllerStatistics; use crate::{ config::{self, AcknowledgementsConfig, Input, SinkConfig, SinkContext}, - event::{metric::MetricValue, Event}, + event::{Event, metric::MetricValue}, metrics, sinks::{ + Healthcheck, VectorSink, util::{ - retries::{JitterMode, RetryLogic}, BatchSettings, Concurrency, EncodedEvent, EncodedLength, TowerRequestConfig, VecBuffer, + retries::{JitterMode, RetryLogic}, }, - Healthcheck, VectorSink, }, sources::demo_logs::DemoLogsConfig, test_util::{ diff --git a/src/sinks/util/buffer/compression.rs b/src/sinks/util/buffer/compression.rs index 6e835c4a9cea8..1af665ef78e03 100644 --- a/src/sinks/util/buffer/compression.rs +++ b/src/sinks/util/buffer/compression.rs @@ -5,12 +5,12 @@ use serde::{de, ser}; use serde_json::Value; use vector_lib::configurable::attributes::CustomAttribute; use vector_lib::configurable::{ + Configurable, GenerateError, Metadata, ToValue, schema::{ - apply_base_metadata, generate_const_string_schema, generate_enum_schema, - generate_one_of_schema, generate_struct_schema, get_or_generate_schema, SchemaGenerator, - SchemaObject, + SchemaGenerator, SchemaObject, apply_base_metadata, generate_const_string_schema, + generate_enum_schema, generate_one_of_schema, generate_struct_schema, + get_or_generate_schema, }, - Configurable, GenerateError, Metadata, ToValue, }; use crate::sinks::util::zstd::ZstdCompressionLevel; diff --git a/src/sinks/util/buffer/json.rs b/src/sinks/util/buffer/json.rs index 0cffdc566c13c..fd6948a08cf9d 100644 --- a/src/sinks/util/buffer/json.rs +++ b/src/sinks/util/buffer/json.rs @@ -1,6 +1,6 @@ -use serde_json::value::{to_raw_value, RawValue, Value}; +use serde_json::value::{RawValue, Value, to_raw_value}; -use super::super::batch::{err_event_too_large, Batch, BatchSize, PushResult}; +use super::super::batch::{Batch, BatchSize, PushResult, err_event_too_large}; pub type BoxedRawValue = Box; diff --git a/src/sinks/util/buffer/metrics/mod.rs b/src/sinks/util/buffer/metrics/mod.rs index 64209ffbaffcc..146eac28ad561 100644 --- a/src/sinks/util/buffer/metrics/mod.rs +++ b/src/sinks/util/buffer/metrics/mod.rs @@ -3,8 +3,8 @@ use std::cmp::Ordering; use vector_lib::event::metric::{Metric, MetricValue, Sample}; use crate::sinks::util::{ - batch::{Batch, BatchConfig, BatchError, BatchSize, PushResult}, Merged, SinkBatchSettings, + batch::{Batch, BatchConfig, BatchError, BatchSize, PushResult}, }; mod normalize; diff --git a/src/sinks/util/buffer/metrics/normalize.rs b/src/sinks/util/buffer/metrics/normalize.rs index 5988a2c19a4a5..11580a74db1db 100644 --- a/src/sinks/util/buffer/metrics/normalize.rs +++ b/src/sinks/util/buffer/metrics/normalize.rs @@ -3,8 +3,8 @@ use indexmap::IndexMap; use std::time::{Duration, Instant}; use vector_lib::event::{ - metric::{MetricData, MetricSeries}, EventMetadata, Metric, MetricKind, + metric::{MetricData, MetricSeries}, }; /// Normalizes metrics according to a set of rules. diff --git a/src/sinks/util/buffer/metrics/split.rs b/src/sinks/util/buffer/metrics/split.rs index fb1a352ab3604..1821c9c135d3e 100644 --- a/src/sinks/util/buffer/metrics/split.rs +++ b/src/sinks/util/buffer/metrics/split.rs @@ -1,6 +1,6 @@ use std::collections::VecDeque; -use vector_lib::event::{metric::MetricData, Metric, MetricValue}; +use vector_lib::event::{Metric, MetricValue, metric::MetricData}; #[allow(clippy::large_enum_variant)] enum SplitState { @@ -190,8 +190,8 @@ mod tests { use std::collections::BTreeSet; use vector_lib::event::{ - metric::{Bucket, MetricTags, Quantile, Sample}, Metric, MetricKind, MetricValue, StatisticKind, + metric::{Bucket, MetricTags, Quantile, Sample}, }; use super::{AggregatedSummarySplitter, MetricSplitter}; diff --git a/src/sinks/util/buffer/mod.rs b/src/sinks/util/buffer/mod.rs index a5797e6eb14f9..e3cfd1dc6d14d 100644 --- a/src/sinks/util/buffer/mod.rs +++ b/src/sinks/util/buffer/mod.rs @@ -4,7 +4,7 @@ use bytes::{BufMut, BytesMut}; use flate2::write::{GzEncoder, ZlibEncoder}; use super::{ - batch::{err_event_too_large, Batch, BatchSize, PushResult}, + batch::{Batch, BatchSize, PushResult, err_event_too_large}, snappy::SnappyEncoder, zstd::ZstdEncoder, }; @@ -168,7 +168,7 @@ mod test { }; use bytes::{Buf, BytesMut}; - use futures::{future, stream, SinkExt, StreamExt}; + use futures::{SinkExt, StreamExt, future, stream}; use tokio::time::Duration; use vector_lib::json_size::JsonSize; @@ -230,10 +230,12 @@ mod test { decompressed }); - assert!(decompressed.eq(std::iter::repeat_n( - b"It's going down, I'm yelling timber, You better move, you better dance".to_vec(), - 100_000 - ) - .flatten())); + assert!( + decompressed.eq(std::iter::repeat_n( + b"It's going down, I'm yelling timber, You better move, you better dance".to_vec(), + 100_000 + ) + .flatten()) + ); } } diff --git a/src/sinks/util/buffer/partition.rs b/src/sinks/util/buffer/partition.rs index 2b673a2101822..82027273d218d 100644 --- a/src/sinks/util/buffer/partition.rs +++ b/src/sinks/util/buffer/partition.rs @@ -1,8 +1,8 @@ use vector_lib::ByteSizeOf; use super::super::{ - batch::{Batch, BatchConfig, BatchError, PushResult}, ElementCount, + batch::{Batch, BatchConfig, BatchError, PushResult}, }; use crate::sinks::util::{Merged, SinkBatchSettings}; diff --git a/src/sinks/util/buffer/vec.rs b/src/sinks/util/buffer/vec.rs index 02796da97245b..5f66cbb56498b 100644 --- a/src/sinks/util/buffer/vec.rs +++ b/src/sinks/util/buffer/vec.rs @@ -1,6 +1,6 @@ use bytes::Bytes; -use super::{err_event_too_large, Batch, BatchSize, PushResult}; +use super::{Batch, BatchSize, PushResult, err_event_too_large}; pub trait EncodedLength { fn encoded_length(&self) -> usize; diff --git a/src/sinks/util/builder.rs b/src/sinks/util/builder.rs index 8750e2ae862a9..5234c3c50d02a 100644 --- a/src/sinks/util/builder.rs +++ b/src/sinks/util/builder.rs @@ -1,4 +1,4 @@ -use futures_util::{stream::Map, Stream, StreamExt}; +use futures_util::{Stream, StreamExt, stream::Map}; use pin_project::pin_project; use std::time::Duration; use std::{ @@ -14,17 +14,17 @@ use std::{ use tower::Service; use tracing::Span; use vector_lib::stream::{ - batcher::{config::BatchConfig, Batcher}, ConcurrentMap, Driver, DriverResponse, ExpirationQueue, PartitionedBatcher, + batcher::{Batcher, config::BatchConfig}, }; use vector_lib::{ + ByteSizeOf, event::{Finalizable, Metric}, partition::Partitioner, - ByteSizeOf, }; use super::{ - buffer::metrics::MetricNormalize, IncrementalRequestBuilder, Normalizer, RequestBuilder, + IncrementalRequestBuilder, Normalizer, RequestBuilder, buffer::metrics::MetricNormalize, }; impl SinkBuilderExt for T where T: Stream {} diff --git a/src/sinks/util/compressor.rs b/src/sinks/util/compressor.rs index 8eeed45c9a1d8..a797d2a04fcc9 100644 --- a/src/sinks/util/compressor.rs +++ b/src/sinks/util/compressor.rs @@ -3,7 +3,7 @@ use std::{io, io::BufWriter}; use bytes::{BufMut, BytesMut}; use flate2::write::{GzEncoder, ZlibEncoder}; -use super::{snappy::SnappyEncoder, zstd::ZstdEncoder, Compression}; +use super::{Compression, snappy::SnappyEncoder, zstd::ZstdEncoder}; const GZIP_INPUT_BUFFER_CAPACITY: usize = 4_096; const ZLIB_INPUT_BUFFER_CAPACITY: usize = 4_096; diff --git a/src/sinks/util/datagram.rs b/src/sinks/util/datagram.rs index c9baf175855e8..665200959f33a 100644 --- a/src/sinks/util/datagram.rs +++ b/src/sinks/util/datagram.rs @@ -2,15 +2,15 @@ use std::path::PathBuf; use bytes::BytesMut; -use futures::{stream::BoxStream, StreamExt}; +use futures::{StreamExt, stream::BoxStream}; use futures_util::stream::Peekable; use tokio::net::UdpSocket; #[cfg(unix)] use tokio::net::UnixDatagram; use tokio_util::codec::Encoder; +use vector_lib::EstimatedJsonEncodedSizeOf; use vector_lib::internal_event::RegisterInternalEvent; use vector_lib::internal_event::{ByteSize, BytesSent, InternalEventHandle}; -use vector_lib::EstimatedJsonEncodedSizeOf; use crate::{ codecs::Transformer, diff --git a/src/sinks/util/encoding.rs b/src/sinks/util/encoding.rs index f7f75be1db4be..c9219e2238270 100644 --- a/src/sinks/util/encoding.rs +++ b/src/sinks/util/encoding.rs @@ -5,7 +5,7 @@ use itertools::{Itertools, Position}; use tokio_util::codec::Encoder as _; use vector_lib::codecs::encoding::Framer; use vector_lib::request_metadata::GroupedCountByteSize; -use vector_lib::{config::telemetry, EstimatedJsonEncodedSizeOf}; +use vector_lib::{EstimatedJsonEncodedSizeOf, config::telemetry}; use crate::{codecs::Transformer, event::Event, internal_events::EncoderWriteError}; diff --git a/src/sinks/util/http.rs b/src/sinks/util/http.rs index 4bbe767a3074d..f85d94b7ab168 100644 --- a/src/sinks/util/http.rs +++ b/src/sinks/util/http.rs @@ -3,9 +3,9 @@ use aws_credential_types::provider::SharedCredentialsProvider; #[cfg(feature = "aws-core")] use aws_types::region::Region; use bytes::{Buf, Bytes}; -use futures::{future::BoxFuture, Sink}; +use futures::{Sink, future::BoxFuture}; use headers::HeaderName; -use http::{header, HeaderValue, Request, Response, StatusCode}; +use http::{HeaderValue, Request, Response, StatusCode, header}; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct OrderedHeaderName(HeaderName); @@ -37,7 +37,7 @@ impl PartialOrd for OrderedHeaderName { Some(self.cmp(other)) } } -use hyper::{body, Body}; +use hyper::{Body, body}; use pin_project::pin_project; use snafu::{ResultExt, Snafu}; use std::{ @@ -48,21 +48,22 @@ use std::{ marker::PhantomData, pin::Pin, sync::Arc, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, time::Duration, }; use tower::{Service, ServiceBuilder}; use tower_http::decompression::DecompressionLayer; use vector_lib::{ - configurable::configurable_component, stream::batcher::limiter::ItemBatchSize, ByteSizeOf, - EstimatedJsonEncodedSizeOf, + ByteSizeOf, EstimatedJsonEncodedSizeOf, configurable::configurable_component, + stream::batcher::limiter::ItemBatchSize, }; use super::{ + Batch, EncodedEvent, Partition, TowerBatchedSink, TowerPartitionSink, TowerRequestConfig, + TowerRequestSettings, retries::{RetryAction, RetryLogic}, sink::{self, Response as _}, - uri, Batch, EncodedEvent, Partition, TowerBatchedSink, TowerPartitionSink, TowerRequestConfig, - TowerRequestSettings, + uri, }; #[cfg(feature = "aws-core")] @@ -942,10 +943,10 @@ where mod test { #![allow(clippy::print_stderr)] //tests - use futures::{future::ready, StreamExt}; + use futures::{StreamExt, future::ready}; use hyper::{ - service::{make_service_fn, service_fn}, Response, Server, Uri, + service::{make_service_fn, service_fn}, }; use super::*; @@ -963,12 +964,16 @@ mod test { assert!(logic.should_retry_response(&response_429).is_retryable()); assert!(logic.should_retry_response(&response_500).is_retryable()); assert!(logic.should_retry_response(&response_408).is_retryable()); - assert!(logic - .should_retry_response(&response_400) - .is_not_retryable()); - assert!(logic - .should_retry_response(&response_501) - .is_not_retryable()); + assert!( + logic + .should_retry_response(&response_400) + .is_not_retryable() + ); + assert!( + logic + .should_retry_response(&response_501) + .is_not_retryable() + ); } #[tokio::test] diff --git a/src/sinks/util/metadata.rs b/src/sinks/util/metadata.rs index 3089799421903..cb483c69a3900 100644 --- a/src/sinks/util/metadata.rs +++ b/src/sinks/util/metadata.rs @@ -1,7 +1,7 @@ use std::num::NonZeroUsize; use vector_lib::request_metadata::{GetEventCountTags, GroupedCountByteSize, RequestMetadata}; -use vector_lib::{config, ByteSizeOf, EstimatedJsonEncodedSizeOf}; +use vector_lib::{ByteSizeOf, EstimatedJsonEncodedSizeOf, config}; use super::request_builder::EncodeResult; diff --git a/src/sinks/util/mod.rs b/src/sinks/util/mod.rs index 82bdf301ae456..5a90ae28a2bfc 100644 --- a/src/sinks/util/mod.rs +++ b/src/sinks/util/mod.rs @@ -37,10 +37,10 @@ pub use batch::{ RealtimeSizeBasedDefaultBatchSettings, SinkBatchSettings, Unmerged, }; pub use buffer::{ + Buffer, Compression, PartitionBuffer, PartitionInnerBuffer, json::{BoxedRawValue, JsonArrayBuffer}, partition::Partition, vec::{EncodedLength, VecBuffer}, - Buffer, Compression, PartitionBuffer, PartitionInnerBuffer, }; pub use builder::SinkBuilderExt; pub use compressor::Compressor; @@ -53,7 +53,7 @@ pub use service::{ pub use sink::{BatchSink, PartitionBatchSink, StreamSink}; use snafu::Snafu; pub use uri::UriSerde; -use vector_lib::{json_size::JsonSize, TimeZone}; +use vector_lib::{TimeZone, json_size::JsonSize}; use crate::event::EventFinalizers; use chrono::{FixedOffset, Offset, Utc}; diff --git a/src/sinks/util/normalizer.rs b/src/sinks/util/normalizer.rs index a8560264e5e3b..4ef398a3f9578 100644 --- a/src/sinks/util/normalizer.rs +++ b/src/sinks/util/normalizer.rs @@ -1,10 +1,10 @@ use std::{ pin::Pin, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, time::Duration, }; -use futures_util::{stream::Fuse, Stream, StreamExt}; +use futures_util::{Stream, StreamExt, stream::Fuse}; use pin_project::pin_project; use vector_lib::event::Metric; diff --git a/src/sinks/util/processed_event.rs b/src/sinks/util/processed_event.rs index 6ee0c30960d94..d15dbaf537000 100644 --- a/src/sinks/util/processed_event.rs +++ b/src/sinks/util/processed_event.rs @@ -1,7 +1,7 @@ use serde::Serialize; use vector_lib::{ - event::{EventFinalizers, Finalizable, LogEvent, MaybeAsLogMut}, ByteSizeOf, EstimatedJsonEncodedSizeOf, + event::{EventFinalizers, Finalizable, LogEvent, MaybeAsLogMut}, }; use vector_lib::{ internal_event::TaggedEventsSent, json_size::JsonSize, request_metadata::GetEventCountTags, diff --git a/src/sinks/util/request_builder.rs b/src/sinks/util/request_builder.rs index efad849867f77..17ff8a327c094 100644 --- a/src/sinks/util/request_builder.rs +++ b/src/sinks/util/request_builder.rs @@ -3,7 +3,7 @@ use std::{io, num::NonZeroUsize}; use bytes::Bytes; use vector_lib::request_metadata::{GroupedCountByteSize, RequestMetadata}; -use super::{encoding::Encoder, metadata::RequestMetadataBuilder, Compression, Compressor}; +use super::{Compression, Compressor, encoding::Encoder, metadata::RequestMetadataBuilder}; pub fn default_request_builder_concurrency_limit() -> NonZeroUsize { if let Some(limit) = std::env::var("VECTOR_EXPERIMENTAL_REQUEST_BUILDER_CONCURRENCY") diff --git a/src/sinks/util/retries.rs b/src/sinks/util/retries.rs index cdb5310d9b361..3d7ac6365a1ea 100644 --- a/src/sinks/util/retries.rs +++ b/src/sinks/util/retries.rs @@ -8,7 +8,7 @@ use std::{ }; use futures::FutureExt; -use tokio::time::{sleep, Sleep}; +use tokio::time::{Sleep, sleep}; use tower::{retry::Policy, timeout::error::Elapsed}; use vector_lib::configurable::configurable_component; diff --git a/src/sinks/util/service.rs b/src/sinks/util/service.rs index 61fa9224a930a..daa97fbc4e13d 100644 --- a/src/sinks/util/service.rs +++ b/src/sinks/util/service.rs @@ -3,14 +3,14 @@ use std::{hash::Hash, marker::PhantomData, num::NonZeroU64, pin::Pin, sync::Arc, use futures_util::stream::{self, BoxStream}; use serde_with::serde_as; use tower::{ + Service, ServiceBuilder, balance::p2c::Balance, buffer::{Buffer, BufferLayer}, discover::Change, - layer::{util::Stack, Layer}, + layer::{Layer, util::Stack}, limit::RateLimit, retry::Retry, timeout::Timeout, - Service, ServiceBuilder, }; use vector_lib::configurable::configurable_component; @@ -22,13 +22,13 @@ pub use crate::sinks::util::service::{ use crate::{ internal_events::OpenGauge, sinks::util::{ + Batch, BatchSink, Partition, PartitionBatchSink, adaptive_concurrency::{ AdaptiveConcurrencyLimit, AdaptiveConcurrencyLimitLayer, AdaptiveConcurrencySettings, }, retries::{FibonacciRetryPolicy, JitterMode, RetryLogic}, service::map::MapLayer, sink::Response, - Batch, BatchSink, Partition, PartitionBatchSink, }, }; @@ -407,18 +407,18 @@ where #[cfg(test)] mod tests { use std::sync::{ - atomic::{AtomicBool, Ordering::AcqRel}, Arc, Mutex, + atomic::{AtomicBool, Ordering::AcqRel}, }; - use futures::{future, stream, FutureExt, SinkExt, StreamExt}; + use futures::{FutureExt, SinkExt, StreamExt, future, stream}; use tokio::time::Duration; use vector_lib::json_size::JsonSize; use super::*; use crate::sinks::util::{ - retries::{RetryAction, RetryLogic}, BatchSettings, EncodedEvent, PartitionBuffer, PartitionInnerBuffer, VecBuffer, + retries::{RetryAction, RetryLogic}, }; const TIMEOUT: Duration = Duration::from_secs(10); diff --git a/src/sinks/util/service/concurrency.rs b/src/sinks/util/service/concurrency.rs index 9fd53bf3f63b2..e6ab56b7217d8 100644 --- a/src/sinks/util/service/concurrency.rs +++ b/src/sinks/util/service/concurrency.rs @@ -4,16 +4,16 @@ use serde::Serializer; use serde_json::Value; use vector_lib::configurable::attributes::CustomAttribute; use vector_lib::configurable::{ + Configurable, GenerateError, Metadata, ToValue, schema::{ - apply_base_metadata, generate_const_string_schema, generate_number_schema, - generate_one_of_schema, SchemaGenerator, SchemaObject, + SchemaGenerator, SchemaObject, apply_base_metadata, generate_const_string_schema, + generate_number_schema, generate_one_of_schema, }, - Configurable, GenerateError, Metadata, ToValue, }; use serde::{ - de::{self, Unexpected, Visitor}, Deserialize, Deserializer, Serialize, + de::{self, Unexpected, Visitor}, }; /// Configuration for outbound request concurrency. diff --git a/src/sinks/util/service/health.rs b/src/sinks/util/service/health.rs index a6864df76309e..88d3e53277f26 100644 --- a/src/sinks/util/service/health.rs +++ b/src/sinks/util/service/health.rs @@ -2,18 +2,18 @@ use std::{ future::Future, pin::Pin, sync::{ - atomic::{AtomicUsize, Ordering}, Arc, + atomic::{AtomicUsize, Ordering}, }, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, }; use futures::FutureExt; -use futures_util::{future::BoxFuture, TryFuture}; +use futures_util::{TryFuture, future::BoxFuture}; use pin_project::pin_project; use serde_with::serde_as; use stream_cancel::{Trigger, Tripwire}; -use tokio::time::{sleep, Duration}; +use tokio::time::{Duration, sleep}; use tower::Service; use vector_lib::{configurable::configurable_component, emit}; diff --git a/src/sinks/util/service/net/mod.rs b/src/sinks/util/service/net/mod.rs index ba1c427ad6957..05c8b4642232b 100644 --- a/src/sinks/util/service/net/mod.rs +++ b/src/sinks/util/service/net/mod.rs @@ -7,7 +7,7 @@ mod unix; use std::{ io, net::SocketAddr, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, time::Duration, }; @@ -36,7 +36,7 @@ use self::udp::UdpConnector; #[cfg(unix)] use self::unix::UnixConnector; -use futures_util::{future::BoxFuture, FutureExt}; +use futures_util::{FutureExt, future::BoxFuture}; use snafu::{ResultExt, Snafu}; use tokio::{ io::AsyncWriteExt, diff --git a/src/sinks/util/service/net/tcp.rs b/src/sinks/util/service/net/tcp.rs index 400c4e9f09558..0394617bd4701 100644 --- a/src/sinks/util/service/net/tcp.rs +++ b/src/sinks/util/service/net/tcp.rs @@ -11,7 +11,7 @@ use vector_lib::{ use crate::dns; -use super::{net_error::*, ConnectorType, HostAndPort, NetError, NetworkConnector}; +use super::{ConnectorType, HostAndPort, NetError, NetworkConnector, net_error::*}; /// TCP configuration. #[configurable_component] diff --git a/src/sinks/util/service/net/udp.rs b/src/sinks/util/service/net/udp.rs index c4cb9c2fa1ff2..88c0324877d09 100644 --- a/src/sinks/util/service/net/udp.rs +++ b/src/sinks/util/service/net/udp.rs @@ -7,7 +7,7 @@ use vector_lib::configurable::configurable_component; use crate::{dns, net}; -use super::{net_error::*, ConnectorType, HostAndPort, NetError, NetworkConnector}; +use super::{ConnectorType, HostAndPort, NetError, NetworkConnector, net_error::*}; /// UDP configuration. #[configurable_component] diff --git a/src/sinks/util/service/net/unix.rs b/src/sinks/util/service/net/unix.rs index 0cae976b04630..1769932508827 100644 --- a/src/sinks/util/service/net/unix.rs +++ b/src/sinks/util/service/net/unix.rs @@ -7,7 +7,7 @@ use vector_lib::configurable::configurable_component; use crate::{net, sinks::util::unix::UnixEither}; -use super::{net_error::*, ConnectorType, NetError, NetworkConnector}; +use super::{ConnectorType, NetError, NetworkConnector, net_error::*}; /// Unix socket modes. #[configurable_component] diff --git a/src/sinks/util/sink.rs b/src/sinks/util/sink.rs index 4c7e9384388f4..f863bb0b4ddfb 100644 --- a/src/sinks/util/sink.rs +++ b/src/sinks/util/sink.rs @@ -37,14 +37,14 @@ use std::{ hash::Hash, marker::PhantomData, pin::Pin, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, }; -use futures::{future::BoxFuture, stream::FuturesUnordered, FutureExt, Sink, Stream, TryFutureExt}; +use futures::{FutureExt, Sink, Stream, TryFutureExt, future::BoxFuture, stream::FuturesUnordered}; use pin_project::pin_project; use tokio::{ sync::oneshot, - time::{sleep, Duration, Sleep}, + time::{Duration, Sleep, sleep}, }; use tower::{Service, ServiceBuilder}; use tracing::Instrument; @@ -55,10 +55,10 @@ use vector_lib::internal_event::{ pub use vector_lib::sink::StreamSink; use super::{ + EncodedEvent, batch::{Batch, EncodedBatch, FinalizersBatch, PushResult, StatefulBatch}, buffer::{Partition, PartitionBuffer, PartitionInnerBuffer}, service::{Map, ServiceBuilderExt}, - EncodedEvent, }; use crate::event::EventStatus; @@ -570,11 +570,11 @@ impl Response for &str {} mod tests { use std::{ convert::Infallible, - sync::{atomic::AtomicUsize, atomic::Ordering::Relaxed, Arc, Mutex}, + sync::{Arc, Mutex, atomic::AtomicUsize, atomic::Ordering::Relaxed}, }; use bytes::Bytes; - use futures::{future, stream, task::noop_waker_ref, SinkExt, StreamExt}; + use futures::{SinkExt, StreamExt, future, stream, task::noop_waker_ref}; use tokio::{task::yield_now, time::Instant}; use vector_lib::{ finalization::{BatchNotifier, BatchStatus, EventFinalizer, EventFinalizers}, diff --git a/src/sinks/util/socket_bytes_sink.rs b/src/sinks/util/socket_bytes_sink.rs index 4c2cd36454692..8a882fda7f1b3 100644 --- a/src/sinks/util/socket_bytes_sink.rs +++ b/src/sinks/util/socket_bytes_sink.rs @@ -2,7 +2,7 @@ use std::{ io::Error as IoError, marker::Unpin, pin::Pin, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, }; use bytes::Bytes; diff --git a/src/sinks/util/tcp.rs b/src/sinks/util/tcp.rs index 1cc7a9cc316cf..434542ed39867 100644 --- a/src/sinks/util/tcp.rs +++ b/src/sinks/util/tcp.rs @@ -8,7 +8,7 @@ use std::{ use async_trait::async_trait; use bytes::{Bytes, BytesMut}; -use futures::{stream::BoxStream, task::noop_waker_ref, SinkExt, StreamExt}; +use futures::{SinkExt, StreamExt, stream::BoxStream, task::noop_waker_ref}; use snafu::{ResultExt, Snafu}; use tokio::{ io::{AsyncRead, ReadBuf}, @@ -31,11 +31,11 @@ use crate::{ }, sink_ext::VecSinkExt, sinks::{ + Healthcheck, VectorSink, util::{ - socket_bytes_sink::{BytesSink, ShutdownCheck}, EncodedEvent, SinkBuildError, StreamSink, + socket_bytes_sink::{BytesSink, ShutdownCheck}, }, - Healthcheck, VectorSink, }, tcp::TcpKeepaliveConfig, tls::{MaybeTlsSettings, MaybeTlsStream, TlsEnableableConfig, TlsError}, @@ -106,10 +106,10 @@ impl TcpSinkConfig { &self, transformer: Transformer, encoder: impl Encoder - + Clone - + Send - + Sync - + 'static, + + Clone + + Send + + Sync + + 'static, ) -> crate::Result<(VectorSink, Healthcheck)> { let uri = self.address.parse::()?; let host = uri.host().ok_or(SinkBuildError::MissingHost)?.to_string(); diff --git a/src/sinks/util/test.rs b/src/sinks/util/test.rs index 23b7a96d82984..4a2aae76315db 100644 --- a/src/sinks/util/test.rs +++ b/src/sinks/util/test.rs @@ -1,12 +1,12 @@ use bytes::{Buf, Bytes}; use flate2::read::{MultiGzDecoder, ZlibDecoder}; -use futures::{channel::mpsc, stream, FutureExt, SinkExt, TryFutureExt}; +use futures::{FutureExt, SinkExt, TryFutureExt, channel::mpsc, stream}; use futures_util::StreamExt; use http::request::Parts; use hyper::{ + Body, Request, Response, Server, StatusCode, body::HttpBody, service::{make_service_fn, service_fn}, - Body, Request, Response, Server, StatusCode, }; use serde::Deserialize; use std::{ @@ -16,8 +16,8 @@ use std::{ use stream_cancel::{Trigger, Tripwire}; use crate::{ - config::{SinkConfig, SinkContext}, Error, + config::{SinkConfig, SinkContext}, }; pub fn load_sink(config: &str) -> crate::Result<(T, SinkContext)> diff --git a/src/sinks/util/udp.rs b/src/sinks/util/udp.rs index db525fa2bb24f..64a2636e4932f 100644 --- a/src/sinks/util/udp.rs +++ b/src/sinks/util/udp.rs @@ -5,7 +5,7 @@ use std::{ }; use async_trait::async_trait; -use futures::{stream::BoxStream, FutureExt, StreamExt}; +use futures::{FutureExt, StreamExt, stream::BoxStream}; use snafu::{ResultExt, Snafu}; use tokio::{net::UdpSocket, time::sleep}; use tokio_util::codec::Encoder; @@ -13,8 +13,8 @@ use vector_lib::configurable::configurable_component; use vector_lib::internal_event::{BytesSent, Protocol, Registered}; use super::{ - datagram::{send_datagrams, DatagramSocket}, SinkBuildError, + datagram::{DatagramSocket, send_datagrams}, }; use crate::{ codecs::Transformer, @@ -23,7 +23,7 @@ use crate::{ event::Event, internal_events::{UdpSocketConnectionEstablished, UdpSocketOutgoingConnectionError}, net, - sinks::{util::StreamSink, Healthcheck, VectorSink}, + sinks::{Healthcheck, VectorSink, util::StreamSink}, }; #[derive(Debug, Snafu)] @@ -78,10 +78,10 @@ impl UdpSinkConfig { &self, transformer: Transformer, encoder: impl Encoder - + Clone - + Send - + Sync - + 'static, + + Clone + + Send + + Sync + + 'static, ) -> crate::Result<(VectorSink, Healthcheck)> { let connector = self.build_connector()?; let sink = UdpSink::new(connector.clone(), transformer, encoder); diff --git a/src/sinks/util/unix.rs b/src/sinks/util/unix.rs index bb09e61997ccd..2ee0cc01edfbf 100644 --- a/src/sinks/util/unix.rs +++ b/src/sinks/util/unix.rs @@ -8,7 +8,7 @@ use std::{ use async_trait::async_trait; use bytes::{Bytes, BytesMut}; -use futures::{stream::BoxStream, SinkExt, StreamExt}; +use futures::{SinkExt, StreamExt, stream::BoxStream}; use snafu::{ResultExt, Snafu}; use tokio::{ io::AsyncWriteExt, @@ -17,11 +17,11 @@ use tokio::{ }; use tokio_util::codec::Encoder; use vector_lib::json_size::JsonSize; +use vector_lib::{ByteSizeOf, EstimatedJsonEncodedSizeOf}; use vector_lib::{ configurable::configurable_component, internal_event::{BytesSent, Protocol}, }; -use vector_lib::{ByteSizeOf, EstimatedJsonEncodedSizeOf}; use crate::{ codecs::Transformer, @@ -33,16 +33,16 @@ use crate::{ }, sink_ext::VecSinkExt, sinks::{ + Healthcheck, VectorSink, util::{ + EncodedEvent, StreamSink, service::net::UnixMode, socket_bytes_sink::{BytesSink, ShutdownCheck}, - EncodedEvent, StreamSink, }, - Healthcheck, VectorSink, }, }; -use super::datagram::{send_datagrams, DatagramSocket}; +use super::datagram::{DatagramSocket, send_datagrams}; #[derive(Debug, Snafu)] pub enum UnixError { @@ -76,10 +76,10 @@ impl UnixSinkConfig { &self, transformer: Transformer, encoder: impl Encoder - + Clone - + Send - + Sync - + 'static, + + Clone + + Send + + Sync + + 'static, unix_mode: UnixMode, ) -> crate::Result<(VectorSink, Healthcheck)> { let connector = UnixConnector::new(self.path.clone(), unix_mode); @@ -302,15 +302,16 @@ where mod tests { use tokio::net::UnixListener; use vector_lib::codecs::{ - encoding::Framer, BytesEncoder, NewlineDelimitedEncoder, TextSerializerConfig, + BytesEncoder, NewlineDelimitedEncoder, TextSerializerConfig, encoding::Framer, }; use super::*; use crate::{ codecs::Encoder, test_util::{ - components::{assert_sink_compliance, SINK_TAGS}, - random_lines_with_stream, CountReceiver, + CountReceiver, + components::{SINK_TAGS, assert_sink_compliance}, + random_lines_with_stream, }, }; @@ -322,16 +323,18 @@ mod tests { async fn unix_sink_healthcheck() { let good_path = temp_uds_path("valid_stream_uds"); let _listener = UnixListener::bind(&good_path).unwrap(); - assert!(UnixSinkConfig::new(good_path.clone()) - .build( - Default::default(), - Encoder::<()>::new(TextSerializerConfig::default().build().into()), - UnixMode::Stream - ) - .unwrap() - .1 - .await - .is_ok()); + assert!( + UnixSinkConfig::new(good_path.clone()) + .build( + Default::default(), + Encoder::<()>::new(TextSerializerConfig::default().build().into()), + UnixMode::Stream + ) + .unwrap() + .1 + .await + .is_ok() + ); assert!( UnixSinkConfig::new(good_path.clone()) .build( @@ -347,26 +350,30 @@ mod tests { ); let bad_path = temp_uds_path("no_one_listening"); - assert!(UnixSinkConfig::new(bad_path.clone()) - .build( - Default::default(), - Encoder::<()>::new(TextSerializerConfig::default().build().into()), - UnixMode::Stream - ) - .unwrap() - .1 - .await - .is_err()); - assert!(UnixSinkConfig::new(bad_path.clone()) - .build( - Default::default(), - Encoder::<()>::new(TextSerializerConfig::default().build().into()), - UnixMode::Datagram - ) - .unwrap() - .1 - .await - .is_err()); + assert!( + UnixSinkConfig::new(bad_path.clone()) + .build( + Default::default(), + Encoder::<()>::new(TextSerializerConfig::default().build().into()), + UnixMode::Stream + ) + .unwrap() + .1 + .await + .is_err() + ); + assert!( + UnixSinkConfig::new(bad_path.clone()) + .build( + Default::default(), + Encoder::<()>::new(TextSerializerConfig::default().build().into()), + UnixMode::Datagram + ) + .unwrap() + .1 + .await + .is_err() + ); } #[tokio::test] diff --git a/src/sinks/vector/config.rs b/src/sinks/vector/config.rs index d35daeb0dd150..35eeac280167a 100644 --- a/src/sinks/vector/config.rs +++ b/src/sinks/vector/config.rs @@ -7,9 +7,9 @@ use tower::ServiceBuilder; use vector_lib::configurable::configurable_component; use super::{ + VectorSinkError, service::{VectorRequest, VectorResponse, VectorService}, sink::VectorSink, - VectorSinkError, }; use crate::{ config::{ @@ -19,11 +19,11 @@ use crate::{ http::build_proxy_connector, proto::vector as proto, sinks::{ + Healthcheck, VectorSink as VectorSinkType, util::{ - retries::RetryLogic, BatchConfig, RealtimeEventBasedDefaultBatchSettings, - ServiceBuilderExt, TowerRequestConfig, + BatchConfig, RealtimeEventBasedDefaultBatchSettings, ServiceBuilderExt, + TowerRequestConfig, retries::RetryLogic, }, - Healthcheck, VectorSink as VectorSinkType, }, tls::{MaybeTlsSettings, TlsEnableableConfig}, }; diff --git a/src/sinks/vector/mod.rs b/src/sinks/vector/mod.rs index 1e9df54b0af9f..deb3aeb13fb32 100644 --- a/src/sinks/vector/mod.rs +++ b/src/sinks/vector/mod.rs @@ -41,12 +41,12 @@ mod test { #[cfg(test)] mod tests { use bytes::{BufMut, Bytes, BytesMut}; - use futures::{channel::mpsc, StreamExt}; + use futures::{StreamExt, channel::mpsc}; use http::request::Parts; use hyper::Method; use prost::Message; use vector_lib::{ - config::{init_telemetry, Tags, Telemetry}, + config::{Tags, Telemetry, init_telemetry}, event::{BatchNotifier, BatchStatus}, }; @@ -59,8 +59,8 @@ mod tests { sinks::util::test::build_test_server_generic, test_util::{ components::{ - run_and_assert_data_volume_sink_compliance, run_and_assert_sink_compliance, - DATA_VOLUME_SINK_TAGS, HTTP_SINK_TAGS, + DATA_VOLUME_SINK_TAGS, HTTP_SINK_TAGS, run_and_assert_data_volume_sink_compliance, + run_and_assert_sink_compliance, }, next_addr, random_lines_with_stream, }, diff --git a/src/sinks/vector/service.rs b/src/sinks/vector/service.rs index 1a0b240e4338d..7a2131c481ea8 100644 --- a/src/sinks/vector/service.rs +++ b/src/sinks/vector/service.rs @@ -1,23 +1,23 @@ use std::task::{Context, Poll}; -use futures::{future::BoxFuture, TryFutureExt}; +use futures::{TryFutureExt, future::BoxFuture}; use http::Uri; use hyper::client::HttpConnector; use hyper_openssl::HttpsConnector; use hyper_proxy::ProxyConnector; use prost::Message; -use tonic::{body::BoxBody, IntoRequest}; +use tonic::{IntoRequest, body::BoxBody}; use tower::Service; use vector_lib::request_metadata::{GroupedCountByteSize, MetaDescriptive, RequestMetadata}; use vector_lib::stream::DriverResponse; use super::VectorSinkError; use crate::{ + Error, event::{EventFinalizers, EventStatus, Finalizable}, internal_events::EndpointBytesSent, proto::vector as proto_vector, sinks::util::uri, - Error, }; #[derive(Clone, Debug)] diff --git a/src/sinks/vector/sink.rs b/src/sinks/vector/sink.rs index b5d97541c74e7..3564f0a2cbf48 100644 --- a/src/sinks/vector/sink.rs +++ b/src/sinks/vector/sink.rs @@ -1,18 +1,18 @@ use std::{fmt, num::NonZeroUsize}; use async_trait::async_trait; -use futures::{stream::BoxStream, StreamExt}; +use futures::{StreamExt, stream::BoxStream}; use prost::Message; use tower::Service; use vector_lib::request_metadata::GroupedCountByteSize; -use vector_lib::stream::{batcher::data::BatchReduce, BatcherSettings, DriverResponse}; -use vector_lib::{config::telemetry, ByteSizeOf, EstimatedJsonEncodedSizeOf}; +use vector_lib::stream::{BatcherSettings, DriverResponse, batcher::data::BatchReduce}; +use vector_lib::{ByteSizeOf, EstimatedJsonEncodedSizeOf, config::telemetry}; use super::service::VectorRequest; use crate::{ - event::{proto::EventWrapper, Event, EventFinalizers, Finalizable}, + event::{Event, EventFinalizers, Finalizable, proto::EventWrapper}, proto::vector as proto_vector, - sinks::util::{metadata::RequestMetadataBuilder, SinkBuilderExt, StreamSink}, + sinks::util::{SinkBuilderExt, StreamSink, metadata::RequestMetadataBuilder}, }; /// Data for a single event. diff --git a/src/sinks/webhdfs/config.rs b/src/sinks/webhdfs/config.rs index 749ba310d97cd..6e5d75a24d5d2 100644 --- a/src/sinks/webhdfs/config.rs +++ b/src/sinks/webhdfs/config.rs @@ -1,6 +1,6 @@ -use opendal::{layers::LoggingLayer, services::Webhdfs, Operator}; +use opendal::{Operator, layers::LoggingLayer, services::Webhdfs}; use tower::ServiceBuilder; -use vector_lib::codecs::{encoding::Framer, JsonSerializerConfig, NewlineDelimitedEncoderConfig}; +use vector_lib::codecs::{JsonSerializerConfig, NewlineDelimitedEncoderConfig, encoding::Framer}; use vector_lib::configurable::configurable_component; use vector_lib::{ config::{AcknowledgementsConfig, DataType, Input}, @@ -11,12 +11,12 @@ use crate::{ codecs::{Encoder, EncodingConfigWithFraming, SinkType}, config::{GenerateConfig, SinkConfig, SinkContext}, sinks::{ + Healthcheck, opendal_common::*, util::{ - partitioner::KeyPartitioner, BatchConfig, BulkSizeBasedDefaultBatchSettings, - Compression, + BatchConfig, BulkSizeBasedDefaultBatchSettings, Compression, + partitioner::KeyPartitioner, }, - Healthcheck, }, }; diff --git a/src/sinks/webhdfs/integration_tests.rs b/src/sinks/webhdfs/integration_tests.rs index 57c212188c0fa..4488544ba7099 100644 --- a/src/sinks/webhdfs/integration_tests.rs +++ b/src/sinks/webhdfs/integration_tests.rs @@ -6,7 +6,7 @@ use std::{ use futures::stream; use opendal::Entry; use similar_asserts::assert_eq; -use vector_lib::codecs::{encoding::FramingConfig, TextSerializerConfig}; +use vector_lib::codecs::{TextSerializerConfig, encoding::FramingConfig}; use vector_lib::event::{Event, LogEvent}; use super::WebHdfsConfig; @@ -14,7 +14,7 @@ use crate::{ config::{SinkConfig, SinkContext}, sinks::util::{BatchConfig, Compression}, test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, random_lines_with_stream, random_string, }, }; diff --git a/src/sinks/webhdfs/test.rs b/src/sinks/webhdfs/test.rs index a2ec07b135a5e..4d59cd57a7b12 100644 --- a/src/sinks/webhdfs/test.rs +++ b/src/sinks/webhdfs/test.rs @@ -1,5 +1,5 @@ use bytes::Bytes; -use vector_lib::codecs::{encoding::Framer, JsonSerializerConfig, NewlineDelimitedEncoderConfig}; +use vector_lib::codecs::{JsonSerializerConfig, NewlineDelimitedEncoderConfig, encoding::Framer}; use vector_lib::partition::Partitioner; use vector_lib::request_metadata::GroupedCountByteSize; @@ -10,8 +10,8 @@ use crate::{ sinks::{ opendal_common::{OpenDalRequest, OpenDalRequestBuilder}, util::{ - request_builder::{EncodeResult, RequestBuilder}, Compression, + request_builder::{EncodeResult, RequestBuilder}, }, }, }; diff --git a/src/sinks/websocket/config.rs b/src/sinks/websocket/config.rs index 7fac1402625f8..afab2b1b3ae62 100644 --- a/src/sinks/websocket/config.rs +++ b/src/sinks/websocket/config.rs @@ -7,7 +7,7 @@ use crate::{ codecs::EncodingConfig, common::websocket::{ConnectSnafu, WebSocketConnector, WebSocketError}, config::{AcknowledgementsConfig, GenerateConfig, Input, SinkConfig, SinkContext}, - sinks::{websocket::sink::WebSocketSink, Healthcheck, VectorSink}, + sinks::{Healthcheck, VectorSink, websocket::sink::WebSocketSink}, tls::MaybeTlsSettings, }; diff --git a/src/sinks/websocket/sink.rs b/src/sinks/websocket/sink.rs index e715bef4a55a2..bbc738c776fba 100644 --- a/src/sinks/websocket/sink.rs +++ b/src/sinks/websocket/sink.rs @@ -6,20 +6,19 @@ use std::{ use async_trait::async_trait; use bytes::BytesMut; -use futures::{pin_mut, sink::SinkExt, stream::BoxStream, Sink, Stream, StreamExt}; +use futures::{Sink, Stream, StreamExt, pin_mut, sink::SinkExt, stream::BoxStream}; use tokio_tungstenite::tungstenite::{error::Error as TungsteniteError, protocol::Message}; use tokio_util::codec::Encoder as _; use vector_lib::{ - emit, + EstimatedJsonEncodedSizeOf, emit, internal_event::{ ByteSize, BytesSent, CountByteSize, EventsSent, InternalEventHandle as _, Output, Protocol, }, - EstimatedJsonEncodedSizeOf, }; use crate::{ codecs::{Encoder, Transformer}, - common::websocket::{is_closed, PingInterval, WebSocketConnector}, + common::websocket::{PingInterval, WebSocketConnector, is_closed}, event::{Event, EventStatus, Finalizable}, internal_events::{ ConnectionOpen, OpenGauge, WebSocketConnectionError, WebSocketConnectionShutdown, @@ -57,8 +56,8 @@ impl WebSocketSink { async fn create_sink_and_stream( &self, ) -> ( - impl Sink, - impl Stream>, + impl Sink + use<>, + impl Stream> + use<>, ) { let ws_stream = self.connector.connect_backoff().await; ws_stream.split() @@ -150,7 +149,7 @@ impl WebSocketSink { let event_byte_size = event.estimated_json_encoded_size_of(); let mut bytes = BytesMut::new(); - let res = match self.encoder.encode(event, &mut bytes) { + match self.encoder.encode(event, &mut bytes) { Ok(()) => { finalizers.update_status(EventStatus::Delivered); @@ -172,9 +171,7 @@ impl WebSocketSink { finalizers.update_status(EventStatus::Errored); Ok(()) } - }; - - res + } }, else => break, }; @@ -223,7 +220,7 @@ impl StreamSink for WebSocketSink { mod tests { use std::net::SocketAddr; - use futures::{future, FutureExt, StreamExt}; + use futures::{FutureExt, StreamExt, future}; use serde_json::Value as JsonValue; use tokio::{time, time::timeout}; use tokio_tungstenite::{ @@ -241,8 +238,9 @@ mod tests { config::{SinkConfig, SinkContext}, http::Auth, test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, - next_addr, random_lines_with_stream, trace_init, CountReceiver, + CountReceiver, + components::{SINK_TAGS, run_and_assert_sink_compliance}, + next_addr, random_lines_with_stream, trace_init, }, tls::{self, MaybeTlsSettings, TlsConfig, TlsEnableableConfig}, }; @@ -359,9 +357,11 @@ mod tests { assert!(!receiver.await.is_empty()); let mut receiver = create_count_receiver(addr, tls, false, None); - assert!(timeout(Duration::from_secs(10), receiver.connected()) - .await - .is_ok()); + assert!( + timeout(Duration::from_secs(10), receiver.connected()) + .await + .is_ok() + ); } async fn send_events_and_assert( diff --git a/src/sinks/websocket_server/buffering.rs b/src/sinks/websocket_server/buffering.rs index 955da32e3ab2a..f307a5adccb01 100644 --- a/src/sinks/websocket_server/buffering.rs +++ b/src/sinks/websocket_server/buffering.rs @@ -3,12 +3,12 @@ use std::{collections::VecDeque, net::SocketAddr, num::NonZeroUsize}; use bytes::Bytes; use derivative::Derivative; -use tokio_tungstenite::tungstenite::{handshake::server::Request, Message}; +use tokio_tungstenite::tungstenite::{Message, handshake::server::Request}; use url::Url; use uuid::Uuid; use vector_config::configurable_component; use vector_lib::{ - codecs::decoding::{format::Deserializer as _, DeserializerConfig}, + codecs::decoding::{DeserializerConfig, format::Deserializer as _}, event::{Event, MaybeAsLogMut}, lookup::lookup_v2::ConfigValuePath, }; @@ -212,7 +212,7 @@ impl WsMessageBufferConfig for Option { { match Uuid::parse_str(&last_received_param_value) { Ok(last_received_val) => { - return BufferReplayRequest::with_replay_from(last_received_val) + return BufferReplayRequest::with_replay_from(last_received_val); } Err(err) => { warn!(message = "Parsing last received message UUID failed.", %err) diff --git a/src/sinks/websocket_server/sink.rs b/src/sinks/websocket_server/sink.rs index 53409aa06c818..0e482a35468fa 100644 --- a/src/sinks/websocket_server/sink.rs +++ b/src/sinks/websocket_server/sink.rs @@ -7,22 +7,23 @@ use std::{ use async_trait::async_trait; use bytes::BytesMut; use futures::{ - channel::mpsc::{unbounded, UnboundedSender}, + StreamExt, TryStreamExt, + channel::mpsc::{UnboundedSender, unbounded}, future, pin_mut, stream::BoxStream, - StreamExt, TryStreamExt, }; use http::StatusCode; use tokio::net::TcpStream; use tokio_tungstenite::tungstenite::{ - handshake::server::{ErrorResponse, Request, Response}, Message, + handshake::server::{ErrorResponse, Request, Response}, }; use tokio_util::codec::Encoder as _; use tracing::Instrument; use url::Url; use uuid::Uuid; use vector_lib::{ + EstimatedJsonEncodedSizeOf, event::{Event, EventStatus}, finalization::Finalizable, internal_event::{ @@ -30,7 +31,6 @@ use vector_lib::{ }, sink::StreamSink, tls::{MaybeTlsIncomingStream, MaybeTlsListener, MaybeTlsSettings}, - EstimatedJsonEncodedSizeOf, }; use crate::{ @@ -48,9 +48,9 @@ use crate::{ }; use super::{ + WebSocketListenerSinkConfig, buffering::MessageBufferingConfig, config::{ExtraMetricTagsConfig, SubProtocolConfig}, - WebSocketListenerSinkConfig, }; pub struct WebSocketListenerSink { @@ -445,7 +445,7 @@ impl StreamSink for WebSocketListenerSink { #[cfg(test)] mod tests { - use futures::{channel::mpsc::UnboundedReceiver, SinkExt, Stream, StreamExt}; + use futures::{SinkExt, Stream, StreamExt, channel::mpsc::UnboundedReceiver}; use futures_util::stream; use std::{future::ready, num::NonZeroUsize}; use tokio_tungstenite::tungstenite::client::IntoClientRequest; @@ -453,8 +453,8 @@ mod tests { use tokio::{task::JoinHandle, time}; use vector_lib::{ codecs::{ - decoding::{DeserializerConfig, JsonDeserializerOptions}, JsonDeserializerConfig, + decoding::{DeserializerConfig, JsonDeserializerOptions}, }, lookup::lookup_v2::ConfigValuePath, metrics::Controller, @@ -470,7 +470,7 @@ mod tests { config::InternalMetricsConfig, }, test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, + components::{SINK_TAGS, run_and_assert_sink_compliance}, next_addr, }, }; diff --git a/src/source_sender/mod.rs b/src/source_sender/mod.rs index c93d316c08f7f..7d6a14c72f771 100644 --- a/src/source_sender/mod.rs +++ b/src/source_sender/mod.rs @@ -3,7 +3,7 @@ use std::{collections::HashMap, fmt, num::NonZeroUsize, sync::Arc, time::Instant use chrono::Utc; use futures::{Stream, StreamExt}; -use metrics::{histogram, Histogram}; +use metrics::{Histogram, histogram}; use tracing::Span; use vector_lib::buffers::EventCount; use vector_lib::buffers::{ @@ -12,17 +12,17 @@ use vector_lib::buffers::{ }; use vector_lib::event::array::EventArrayIntoIter; #[cfg(any(test, feature = "test-utils"))] -use vector_lib::event::{into_event_stream, EventStatus}; +use vector_lib::event::{EventStatus, into_event_stream}; use vector_lib::finalization::{AddBatchNotifier, BatchNotifier}; use vector_lib::internal_event::{ComponentEventsDropped, UNINTENTIONAL}; use vector_lib::json_size::JsonSize; use vector_lib::{ - config::{log_schema, SourceOutput}, - event::{array, Event, EventArray, EventContainer, EventRef}, + ByteSizeOf, EstimatedJsonEncodedSizeOf, + config::{SourceOutput, log_schema}, + event::{Event, EventArray, EventContainer, EventRef, array}, internal_event::{ - self, CountByteSize, EventsSent, InternalEventHandle as _, Registered, DEFAULT_OUTPUT, + self, CountByteSize, DEFAULT_OUTPUT, EventsSent, InternalEventHandle as _, Registered, }, - ByteSizeOf, EstimatedJsonEncodedSizeOf, }; use vrl::value::Value; @@ -531,7 +531,7 @@ const fn get_timestamp_millis(value: &Value) -> Option { #[cfg(test)] mod tests { use chrono::{DateTime, Duration}; - use rand::{rng, Rng}; + use rand::{Rng, rng}; use tokio::time::timeout; use vector_lib::event::{LogEvent, Metric, MetricKind, MetricValue, TraceEvent}; use vrl::event_path; diff --git a/src/sources/amqp.rs b/src/sources/amqp.rs index f65cb7fd53213..8b843fc1f7e6c 100644 --- a/src/sources/amqp.rs +++ b/src/sources/amqp.rs @@ -1,24 +1,24 @@ //! `AMQP` source. //! Handles version AMQP 0.9.1 which is used by RabbitMQ. use crate::{ + SourceSender, amqp::AmqpConfig, codecs::{Decoder, DecodingConfig}, config::{SourceConfig, SourceContext, SourceOutput}, event::{BatchNotifier, BatchStatus}, internal_events::{ - source::{AmqpAckError, AmqpBytesReceived, AmqpEventError, AmqpRejectError}, StreamClosedError, + source::{AmqpAckError, AmqpBytesReceived, AmqpEventError, AmqpRejectError}, }, serde::{bool_or_struct, default_decoding, default_framing_message_based}, shutdown::ShutdownSignal, - SourceSender, }; use async_stream::stream; use bytes::Bytes; use chrono::{TimeZone, Utc}; use futures::{FutureExt, StreamExt}; use futures_util::Stream; -use lapin::{acker::Acker, message::Delivery, Channel}; +use lapin::{Channel, acker::Acker, message::Delivery}; use snafu::Snafu; use std::{io::Cursor, pin::Pin}; use tokio_util::codec::FramedRead; @@ -26,9 +26,9 @@ use vector_lib::codecs::decoding::{DeserializerConfig, FramingConfig}; use vector_lib::configurable::configurable_component; use vector_lib::lookup::{lookup_v2::OptionalValuePath, metadata_path, owned_value_path, path}; use vector_lib::{ - config::{log_schema, LegacyKey, LogNamespace, SourceAcknowledgementsConfig}, - event::{Event, LogEvent}, EstimatedJsonEncodedSizeOf, + config::{LegacyKey, LogNamespace, SourceAcknowledgementsConfig, log_schema}, + event::{Event, LogEvent}, }; use vector_lib::{ finalizer::UnorderedFinalizer, @@ -608,17 +608,17 @@ mod integration_test { use super::test::*; use super::*; use crate::{ + SourceSender, amqp::await_connection, shutdown::ShutdownSignal, test_util::{ - components::{run_and_assert_source_compliance, SOURCE_TAGS}, + components::{SOURCE_TAGS, run_and_assert_source_compliance}, random_string, }, - SourceSender, }; use chrono::Utc; - use lapin::options::*; use lapin::BasicProperties; + use lapin::options::*; use tokio::time::Duration; use vector_lib::config::log_schema; @@ -626,15 +626,17 @@ mod integration_test { async fn amqp_source_create_ok() { let config = make_config(); await_connection(&config.connection).await; - assert!(amqp_source( - &config, - ShutdownSignal::noop(), - SourceSender::new_test().0, - LogNamespace::Legacy, - false, - ) - .await - .is_ok()); + assert!( + amqp_source( + &config, + ShutdownSignal::noop(), + SourceSender::new_test().0, + LogNamespace::Legacy, + false, + ) + .await + .is_ok() + ); } #[tokio::test] @@ -642,15 +644,17 @@ mod integration_test { let config = make_tls_config(); await_connection(&config.connection).await; - assert!(amqp_source( - &config, - ShutdownSignal::noop(), - SourceSender::new_test().0, - LogNamespace::Legacy, - false, - ) - .await - .is_ok()); + assert!( + amqp_source( + &config, + ShutdownSignal::noop(), + SourceSender::new_test().0, + LogNamespace::Legacy, + false, + ) + .await + .is_ok() + ); } async fn send_event( diff --git a/src/sources/apache_metrics/mod.rs b/src/sources/apache_metrics/mod.rs index 0cb82ef08b7c4..c0eb08240cbf0 100644 --- a/src/sources/apache_metrics/mod.rs +++ b/src/sources/apache_metrics/mod.rs @@ -1,16 +1,17 @@ use std::{future::ready, time::Duration}; use chrono::Utc; -use futures::{stream, FutureExt, StreamExt, TryFutureExt}; +use futures::{FutureExt, StreamExt, TryFutureExt, stream}; use http::uri::Scheme; use hyper::{Body, Request}; use serde_with::serde_as; use snafu::ResultExt; use tokio_stream::wrappers::IntervalStream; use vector_lib::configurable::configurable_component; -use vector_lib::{metric_tags, EstimatedJsonEncodedSizeOf}; +use vector_lib::{EstimatedJsonEncodedSizeOf, metric_tags}; use crate::{ + SourceSender, config::{GenerateConfig, ProxyConfig, SourceConfig, SourceContext, SourceOutput}, event::metric::{Metric, MetricKind, MetricValue}, http::HttpClient, @@ -19,7 +20,6 @@ use crate::{ HttpClientHttpError, HttpClientHttpResponseError, StreamClosedError, }, shutdown::ShutdownSignal, - SourceSender, }; mod parser; @@ -229,28 +229,32 @@ fn apache_metrics( code: header.status, url: sanitized_url.to_owned(), }); - Some(stream::iter(vec![Metric::new( - "up", - MetricKind::Absolute, - MetricValue::Gauge { value: 1.0 }, - ) - .with_namespace(namespace.clone()) - .with_tags(Some(tags.clone())) - .with_timestamp(Some(Utc::now()))])) + Some(stream::iter(vec![ + Metric::new( + "up", + MetricKind::Absolute, + MetricValue::Gauge { value: 1.0 }, + ) + .with_namespace(namespace.clone()) + .with_tags(Some(tags.clone())) + .with_timestamp(Some(Utc::now())), + ])) } Err(error) => { emit!(HttpClientHttpError { error, url: sanitized_url.to_owned(), }); - Some(stream::iter(vec![Metric::new( - "up", - MetricKind::Absolute, - MetricValue::Gauge { value: 0.0 }, - ) - .with_namespace(namespace.clone()) - .with_tags(Some(tags.clone())) - .with_timestamp(Some(Utc::now()))])) + Some(stream::iter(vec![ + Metric::new( + "up", + MetricKind::Absolute, + MetricValue::Gauge { value: 0.0 }, + ) + .with_namespace(namespace.clone()) + .with_tags(Some(tags.clone())) + .with_timestamp(Some(Utc::now())), + ])) } }) }) @@ -276,21 +280,21 @@ fn apache_metrics( #[cfg(test)] mod test { use hyper::{ - service::{make_service_fn, service_fn}, Body, Response, Server, + service::{make_service_fn, service_fn}, }; use similar_asserts::assert_eq; - use tokio::time::{sleep, Duration}; + use tokio::time::{Duration, sleep}; use super::*; use crate::{ + Error, config::SourceConfig, test_util::{ collect_ready, - components::{run_and_assert_source_compliance, HTTP_PULL_SOURCE_TAGS}, + components::{HTTP_PULL_SOURCE_TAGS, run_and_assert_source_compliance}, next_addr, wait_for_tcp, }, - Error, }; #[test] diff --git a/src/sources/apache_metrics/parser.rs b/src/sources/apache_metrics/parser.rs index 0b436174bdd44..03ee3dea33ddc 100644 --- a/src/sources/apache_metrics/parser.rs +++ b/src/sources/apache_metrics/parser.rs @@ -936,14 +936,16 @@ ConnsTotal: 1 assert_event_data_eq!( metrics, - vec![Metric::new( - "connections", - MetricKind::Absolute, - MetricValue::Gauge { value: 1.0 }, - ) - .with_namespace(Some("apache")) - .with_tags(Some(metric_tags!("state" => "total"))) - .with_timestamp(Some(now)),] + vec![ + Metric::new( + "connections", + MetricKind::Absolute, + MetricValue::Gauge { value: 1.0 }, + ) + .with_namespace(Some("apache")) + .with_tags(Some(metric_tags!("state" => "total"))) + .with_timestamp(Some(now)), + ] ); assert_eq!(errors.len(), 1); } diff --git a/src/sources/aws_ecs_metrics/mod.rs b/src/sources/aws_ecs_metrics/mod.rs index 1ea24be7ebb8d..0a435e60e04b7 100644 --- a/src/sources/aws_ecs_metrics/mod.rs +++ b/src/sources/aws_ecs_metrics/mod.rs @@ -7,9 +7,10 @@ use tokio::time; use tokio_stream::wrappers::IntervalStream; use vector_lib::configurable::configurable_component; use vector_lib::internal_event::{ByteSize, BytesReceived, InternalEventHandle as _, Protocol}; -use vector_lib::{config::LogNamespace, EstimatedJsonEncodedSizeOf}; +use vector_lib::{EstimatedJsonEncodedSizeOf, config::LogNamespace}; use crate::{ + SourceSender, config::{GenerateConfig, SourceConfig, SourceContext, SourceOutput}, http::HttpClient, internal_events::{ @@ -17,7 +18,6 @@ use crate::{ HttpClientHttpResponseError, StreamClosedError, }, shutdown::ShutdownSignal, - SourceSender, }; mod parser; @@ -246,19 +246,19 @@ async fn aws_ecs_metrics( #[cfg(test)] mod test { use hyper::{ - service::{make_service_fn, service_fn}, Body, Response, Server, + service::{make_service_fn, service_fn}, }; use tokio::time::Duration; use super::*; use crate::{ + Error, event::MetricValue, test_util::{ - components::{run_and_assert_source_compliance, SOURCE_TAGS}, + components::{SOURCE_TAGS, run_and_assert_source_compliance}, next_addr, wait_for_tcp, }, - Error, }; #[tokio::test] @@ -611,7 +611,7 @@ mod integration_tests { use tokio::time::Duration; use super::*; - use crate::test_util::components::{run_and_assert_source_compliance, SOURCE_TAGS}; + use crate::test_util::components::{SOURCE_TAGS, run_and_assert_source_compliance}; fn ecs_address() -> String { env::var("ECS_ADDRESS").unwrap_or_else(|_| "http://localhost:9088".into()) diff --git a/src/sources/aws_ecs_metrics/parser.rs b/src/sources/aws_ecs_metrics/parser.rs index 9fb48318d7de6..a835cf2fdcfb6 100644 --- a/src/sources/aws_ecs_metrics/parser.rs +++ b/src/sources/aws_ecs_metrics/parser.rs @@ -573,7 +573,7 @@ pub(super) fn parse( #[cfg(test)] mod test { - use chrono::{offset::TimeZone, DateTime, Timelike, Utc}; + use chrono::{DateTime, Timelike, Utc, offset::TimeZone}; use vector_lib::assert_event_data_eq; use vector_lib::metric_tags; diff --git a/src/sources/aws_kinesis_firehose/filters.rs b/src/sources/aws_kinesis_firehose/filters.rs index d767f778cc35a..5214ab370418e 100644 --- a/src/sources/aws_kinesis_firehose/filters.rs +++ b/src/sources/aws_kinesis_firehose/filters.rs @@ -6,18 +6,17 @@ use flate2::read::MultiGzDecoder; use snafu::ResultExt; use vector_lib::config::LogNamespace; use vector_lib::internal_event::{BytesReceived, Protocol}; -use warp::{http::StatusCode, Filter}; +use warp::{Filter, http::StatusCode}; use super::{ + Compression, errors::{ParseSnafu, RequestError}, handlers, models::{FirehoseRequest, FirehoseResponse}, - Compression, }; use crate::{ - codecs, + SourceSender, codecs, internal_events::{AwsKinesisFirehoseRequestError, AwsKinesisFirehoseRequestReceived}, - SourceSender, }; /// Handles routing of incoming HTTP requests from AWS Kinesis Firehose diff --git a/src/sources/aws_kinesis_firehose/handlers.rs b/src/sources/aws_kinesis_firehose/handlers.rs index 1e390c38b2a41..89dd47bfa14c5 100644 --- a/src/sources/aws_kinesis_firehose/handlers.rs +++ b/src/sources/aws_kinesis_firehose/handlers.rs @@ -1,6 +1,6 @@ use std::io::Read; -use base64::prelude::{Engine as _, BASE64_STANDARD}; +use base64::prelude::{BASE64_STANDARD, Engine as _}; use bytes::Bytes; use chrono::Utc; use flate2::read::MultiGzDecoder; @@ -9,11 +9,11 @@ use snafu::{ResultExt, Snafu}; use tokio_util::codec::FramedRead; use vector_common::constants::GZIP_MAGIC; use vector_lib::codecs::StreamDecodingError; -use vector_lib::lookup::{metadata_path, path, PathPrefix}; +use vector_lib::lookup::{PathPrefix, metadata_path, path}; use vector_lib::{ + EstimatedJsonEncodedSizeOf, config::{LegacyKey, LogNamespace}, event::BatchNotifier, - EstimatedJsonEncodedSizeOf, }; use vector_lib::{ finalization::AddBatchNotifier, @@ -25,11 +25,12 @@ use vrl::compiler::SecretTarget; use warp::reject; use super::{ + Compression, errors::{ParseRecordsSnafu, RequestError}, models::{EncodedFirehoseRecord, FirehoseRequest, FirehoseResponse}, - Compression, }; use crate::{ + SourceSender, codecs::Decoder, config::log_schema, event::{BatchStatus, Event}, @@ -37,7 +38,6 @@ use crate::{ AwsKinesisFirehoseAutomaticRecordDecodeError, EventsReceived, StreamClosedError, }, sources::aws_kinesis_firehose::AwsKinesisFirehoseConfig, - SourceSender, }; #[derive(Clone)] @@ -258,7 +258,7 @@ fn decode_gzip(data: &[u8]) -> std::io::Result { #[cfg(test)] mod tests { - use flate2::{write::GzEncoder, Compression}; + use flate2::{Compression, write::GzEncoder}; use std::io::Write as _; use super::*; diff --git a/src/sources/aws_kinesis_firehose/mod.rs b/src/sources/aws_kinesis_firehose/mod.rs index 720d4c4d8f0c7..1c338604b1995 100644 --- a/src/sources/aws_kinesis_firehose/mod.rs +++ b/src/sources/aws_kinesis_firehose/mod.rs @@ -2,7 +2,7 @@ use std::time::Duration; use std::{convert::Infallible, fmt, net::SocketAddr}; use futures::FutureExt; -use hyper::{service::make_service_fn, Server}; +use hyper::{Server, service::make_service_fn}; use tokio::net::TcpStream; use tower::ServiceBuilder; use tracing::Span; @@ -275,27 +275,27 @@ mod tests { net::SocketAddr, }; - use base64::prelude::{Engine as _, BASE64_STANDARD}; + use base64::prelude::{BASE64_STANDARD, Engine as _}; use bytes::Bytes; use chrono::{DateTime, SubsecRound, Utc}; use flate2::read::GzEncoder; use futures::Stream; use similar_asserts::assert_eq; - use tokio::time::{sleep, Duration}; + use tokio::time::{Duration, sleep}; use vector_lib::assert_event_data_eq; use vector_lib::lookup::path; use vrl::value; use super::*; use crate::{ + SourceSender, event::{Event, EventStatus}, log_event, test_util::{ collect_ready, - components::{assert_source_compliance, SOURCE_TAGS}, + components::{SOURCE_TAGS, assert_source_compliance}, next_addr, wait_for_tcp, }, - SourceSender, }; const SOURCE_ARN: &str = "arn:aws:firehose:us-east-1:111111111111:deliverystream/test"; @@ -647,11 +647,12 @@ mod tests { meta.value().get(path!("vector", "source_type")).unwrap(), &value!("aws_kinesis_firehose") ); - assert!(meta - .value() - .get(path!("vector", "ingest_timestamp")) - .unwrap() - .is_timestamp()); + assert!( + meta.value() + .get(path!("vector", "ingest_timestamp")) + .unwrap() + .is_timestamp() + ); // source metadata assert_eq!( @@ -931,10 +932,12 @@ mod tests { let events = collect_ready(rx).await; - assert!(events[0] - .metadata() - .secrets() - .get("aws_kinesis_firehose_access_key") - .is_none()); + assert!( + events[0] + .metadata() + .secrets() + .get("aws_kinesis_firehose_access_key") + .is_none() + ); } } diff --git a/src/sources/aws_kinesis_firehose/models.rs b/src/sources/aws_kinesis_firehose/models.rs index 1fdd2a71e77b9..5362844d513ce 100644 --- a/src/sources/aws_kinesis_firehose/models.rs +++ b/src/sources/aws_kinesis_firehose/models.rs @@ -1,4 +1,4 @@ -use chrono::{serde::ts_milliseconds, DateTime, Utc}; +use chrono::{DateTime, Utc, serde::ts_milliseconds}; use serde::{Deserialize, Serialize}; /// Represents an AWS Kinesis Firehose request diff --git a/src/sources/aws_s3/mod.rs b/src/sources/aws_s3/mod.rs index f519ccfb73d9c..fb7670dd26fbd 100644 --- a/src/sources/aws_s3/mod.rs +++ b/src/sources/aws_s3/mod.rs @@ -2,22 +2,22 @@ use std::convert::TryInto; use async_compression::tokio::bufread; use aws_smithy_types::byte_stream::ByteStream; -use futures::{stream, stream::StreamExt, TryStreamExt}; +use futures::{TryStreamExt, stream, stream::StreamExt}; use snafu::Snafu; use tokio_util::io::StreamReader; +use vector_lib::codecs::NewlineDelimitedDecoderConfig; use vector_lib::codecs::decoding::{ DeserializerConfig, FramingConfig, NewlineDelimitedDecoderOptions, }; -use vector_lib::codecs::NewlineDelimitedDecoderConfig; use vector_lib::config::{LegacyKey, LogNamespace}; use vector_lib::configurable::configurable_component; use vector_lib::lookup::owned_value_path; -use vrl::value::{kind::Collection, Kind}; +use vrl::value::{Kind, kind::Collection}; use super::util::MultilineConfig; use crate::codecs::DecodingConfig; use crate::{ - aws::{auth::AwsAuthentication, create_client, create_client_and_region, RegionOrEndpoint}, + aws::{RegionOrEndpoint, auth::AwsAuthentication, create_client, create_client_and_region}, common::{s3::S3ClientBuilder, sqs::SqsClientBuilder}, config::{ ProxyConfig, SourceAcknowledgementsConfig, SourceConfig, SourceContext, SourceOutput, @@ -454,29 +454,29 @@ mod integration_tests { }; use aws_sdk_s3::Client as S3Client; - use aws_sdk_sqs::{types::QueueAttributeName, Client as SqsClient}; + use aws_sdk_sqs::{Client as SqsClient, types::QueueAttributeName}; use similar_asserts::assert_eq; - use vector_lib::codecs::{decoding::DeserializerConfig, JsonDeserializerConfig}; + use vector_lib::codecs::{JsonDeserializerConfig, decoding::DeserializerConfig}; use vector_lib::lookup::path; use vrl::value::Value; use super::*; use crate::{ - aws::{create_client, AwsAuthentication, RegionOrEndpoint}, + SourceSender, + aws::{AwsAuthentication, RegionOrEndpoint, create_client}, common::sqs::SqsClientBuilder, config::{ProxyConfig, SourceConfig, SourceContext}, event::EventStatus::{self, *}, line_agg, sources::{ - aws_s3::{sqs::S3Event, S3ClientBuilder}, + aws_s3::{S3ClientBuilder, sqs::S3Event}, util::MultilineConfig, }, test_util::{ collect_n, - components::{assert_source_compliance, SOURCE_TAGS}, + components::{SOURCE_TAGS, assert_source_compliance}, lines_from_gzip_file, random_lines, trace_init, }, - SourceSender, }; fn lines_from_plaintext>(path: P) -> Vec { diff --git a/src/sources/aws_s3/sqs.rs b/src/sources/aws_s3/sqs.rs index 3c33b7d30a782..5e41a0f81e228 100644 --- a/src/sources/aws_s3/sqs.rs +++ b/src/sources/aws_s3/sqs.rs @@ -1,15 +1,15 @@ use std::collections::HashMap; use std::{future::ready, num::NonZeroUsize, panic, sync::Arc, sync::LazyLock}; -use aws_sdk_s3::operation::get_object::GetObjectError; use aws_sdk_s3::Client as S3Client; +use aws_sdk_s3::operation::get_object::GetObjectError; +use aws_sdk_sqs::Client as SqsClient; use aws_sdk_sqs::operation::delete_message_batch::{ DeleteMessageBatchError, DeleteMessageBatchOutput, }; use aws_sdk_sqs::operation::receive_message::ReceiveMessageError; use aws_sdk_sqs::operation::send_message_batch::{SendMessageBatchError, SendMessageBatchOutput}; use aws_sdk_sqs::types::{DeleteMessageBatchRequestEntry, Message, SendMessageBatchRequestEntry}; -use aws_sdk_sqs::Client as SqsClient; use aws_smithy_runtime_api::client::orchestrator::HttpResponse; use aws_smithy_runtime_api::client::result::SdkError; use aws_types::region::Region; @@ -35,6 +35,7 @@ use crate::internal_events::{ SqsMessageSendBatchError, SqsMessageSentPartialError, SqsMessageSentSucceeded, }; use crate::{ + SourceSender, aws::AwsTimeout, config::{SourceAcknowledgementsConfig, SourceContext}, event::{BatchNotifier, BatchStatus, EstimatedJsonEncodedSizeOf}, @@ -48,11 +49,10 @@ use crate::{ shutdown::ShutdownSignal, sources::aws_s3::AwsS3Config, tls::TlsConfig, - SourceSender, }; -use vector_lib::config::{log_schema, LegacyKey, LogNamespace}; +use vector_lib::config::{LegacyKey, LogNamespace, log_schema}; use vector_lib::event::MaybeAsLogMut; -use vector_lib::lookup::{metadata_path, path, PathPrefix}; +use vector_lib::lookup::{PathPrefix, metadata_path, path}; static SUPPORTED_S3_EVENT_VERSION: LazyLock = LazyLock::new(|| semver::VersionReq::parse("~2").unwrap()); diff --git a/src/sources/aws_sqs/integration_tests.rs b/src/sources/aws_sqs/integration_tests.rs index af9fadaebc4d2..cd5fb765e475d 100644 --- a/src/sources/aws_sqs/integration_tests.rs +++ b/src/sources/aws_sqs/integration_tests.rs @@ -9,15 +9,15 @@ use futures::StreamExt; use tokio::time::timeout; use crate::{ + SourceSender, aws::{auth::AwsAuthentication, region::RegionOrEndpoint}, - config::{log_schema, SourceConfig, SourceContext}, + config::{SourceConfig, SourceContext, log_schema}, event::Event, sources::aws_sqs::config::AwsSqsConfig, test_util::{ - components::{assert_source_compliance, HTTP_PULL_SOURCE_TAGS}, + components::{HTTP_PULL_SOURCE_TAGS, assert_source_compliance}, random_string, }, - SourceSender, }; fn sqs_address() -> String { diff --git a/src/sources/aws_sqs/source.rs b/src/sources/aws_sqs/source.rs index 0efd8721ae199..082e6f06cdf47 100644 --- a/src/sources/aws_sqs/source.rs +++ b/src/sources/aws_sqs/source.rs @@ -1,8 +1,8 @@ use std::{collections::HashMap, panic, str::FromStr, sync::Arc}; use aws_sdk_sqs::{ - types::{DeleteMessageBatchRequestEntry, MessageSystemAttributeName}, Client as SqsClient, + types::{DeleteMessageBatchRequestEntry, MessageSystemAttributeName}, }; use chrono::{DateTime, TimeZone, Utc}; use futures::{FutureExt, StreamExt}; @@ -13,6 +13,7 @@ use vector_lib::finalizer::UnorderedFinalizer; use vector_lib::internal_event::{EventsReceived, Registered}; use crate::{ + SourceSender, codecs::Decoder, event::{BatchNotifier, BatchStatus}, internal_events::{ @@ -20,7 +21,6 @@ use crate::{ }, shutdown::ShutdownSignal, sources::util, - SourceSender, }; // This is the maximum SQS supports in a single batch request @@ -222,7 +222,7 @@ async fn delete_messages(client: SqsClient, receipts: Vec, queue_url: St mod tests { use super::*; use crate::codecs::DecodingConfig; - use crate::config::{log_schema, SourceConfig}; + use crate::config::{SourceConfig, log_schema}; use crate::sources::aws_sqs::AwsSqsConfig; use chrono::SecondsFormat; use vector_lib::lookup::path; diff --git a/src/sources/datadog_agent/integration_tests.rs b/src/sources/datadog_agent/integration_tests.rs index 390e97859f64e..b2ee2779fb425 100644 --- a/src/sources/datadog_agent/integration_tests.rs +++ b/src/sources/datadog_agent/integration_tests.rs @@ -9,11 +9,11 @@ use tokio::{io::AsyncWriteExt, net::TcpStream}; use super::{DatadogAgentConfig, LOGS, METRICS}; use crate::{ + SourceSender, config::{GenerateConfig, SourceConfig, SourceContext}, event::{EventStatus, Value}, schema, test_util::{spawn_collect_n, wait_for_tcp}, - SourceSender, }; fn agent_address() -> String { @@ -52,7 +52,9 @@ async fn wait_for_healthy(address: String) { // wait a second before retry... tokio::time::sleep(Duration::new(1, 0)).await; } - panic!("Unable to reach the Datadog Agent. Check that it's started and that the health endpoint is available at {address}."); + panic!( + "Unable to reach the Datadog Agent. Check that it's started and that the health endpoint is available at {address}." + ); } async fn wait_for_healthy_agent() { diff --git a/src/sources/datadog_agent/logs.rs b/src/sources/datadog_agent/logs.rs index 144949cc775e4..422b62d8ed1fd 100644 --- a/src/sources/datadog_agent/logs.rs +++ b/src/sources/datadog_agent/logs.rs @@ -8,19 +8,19 @@ use vector_lib::codecs::StreamDecodingError; use vector_lib::internal_event::{CountByteSize, InternalEventHandle as _}; use vector_lib::json_size::JsonSize; use vector_lib::lookup::path; -use vector_lib::{config::LegacyKey, EstimatedJsonEncodedSizeOf}; +use vector_lib::{EstimatedJsonEncodedSizeOf, config::LegacyKey}; use vrl::core::Value; -use warp::{filters::BoxedFilter, path as warp_path, path::FullPath, reply::Response, Filter}; +use warp::{Filter, filters::BoxedFilter, path as warp_path, path::FullPath, reply::Response}; use crate::common::datadog::DDTAGS; use crate::common::http::ErrorMessage; use crate::{ + SourceSender, event::Event, internal_events::DatadogAgentJsonParseError, sources::datadog_agent::{ - handle_request, ApiKeyQueryParams, DatadogAgentConfig, DatadogAgentSource, LogMsg, + ApiKeyQueryParams, DatadogAgentConfig, DatadogAgentSource, LogMsg, handle_request, }, - SourceSender, }; pub(crate) fn build_warp_filter( @@ -229,7 +229,9 @@ fn parse_ddtags(ddtags_raw: &Bytes) -> Value { .collect(); if ddtags.is_empty() && !ddtags_str.is_empty() { - warn!(message = "`parse_ddtags` set to true and Agent log contains non-empty ddtags string, but no tag-value pairs were parsed.") + warn!( + message = "`parse_ddtags` set to true and Agent log contains non-empty ddtags string, but no tag-value pairs were parsed." + ) } ddtags.into() diff --git a/src/sources/datadog_agent/metrics.rs b/src/sources/datadog_agent/metrics.rs index 4cac3d47a3026..0c7660d275356 100644 --- a/src/sources/datadog_agent/metrics.rs +++ b/src/sources/datadog_agent/metrics.rs @@ -5,33 +5,34 @@ use chrono::{TimeZone, Utc}; use http::StatusCode; use prost::Message; use serde::{Deserialize, Serialize}; -use warp::{filters::BoxedFilter, path, path::FullPath, reply::Response, Filter}; +use warp::{Filter, filters::BoxedFilter, path, path::FullPath, reply::Response}; use vector_lib::internal_event::{CountByteSize, InternalEventHandle as _, Registered}; use vector_lib::{ + EstimatedJsonEncodedSizeOf, event::{DatadogMetricOriginMetadata, EventMetadata}, metrics::AgentDDSketch, - EstimatedJsonEncodedSizeOf, }; use crate::common::http::ErrorMessage; use crate::{ + SourceSender, common::datadog::{DatadogMetricType, DatadogSeriesMetric}, config::log_schema, event::{ - metric::{Metric, MetricValue}, Event, MetricKind, MetricTags, + metric::{Metric, MetricValue}, }, internal_events::EventsReceived, schema, sources::{ datadog_agent::{ - ddmetric_proto::{metric_payload, Metadata, MetricPayload, SketchPayload}, - handle_request, ApiKeyQueryParams, DatadogAgentSource, + ApiKeyQueryParams, DatadogAgentSource, + ddmetric_proto::{Metadata, MetricPayload, SketchPayload, metric_payload}, + handle_request, }, util::extract_tag_key_and_value, }, - SourceSender, }; #[derive(Deserialize, Serialize)] @@ -241,9 +242,7 @@ fn get_event_metadata(metadata: Option<&Metadata>) -> EventMetadata { .map_or_else(EventMetadata::default, |origin| { trace!( "Deserialized origin_product: `{}` origin_category: `{}` origin_service: `{}`.", - origin.origin_product, - origin.origin_category, - origin.origin_service, + origin.origin_product, origin.origin_category, origin.origin_service, ); EventMetadata::default().with_origin_metadata(DatadogMetricOriginMetadata::new( Some(origin.origin_product), diff --git a/src/sources/datadog_agent/mod.rs b/src/sources/datadog_agent/mod.rs index 18a1d33f42766..523afab45e15b 100644 --- a/src/sources/datadog_agent/mod.rs +++ b/src/sources/datadog_agent/mod.rs @@ -22,12 +22,12 @@ use std::time::Duration; use std::{fmt::Debug, io::Read, net::SocketAddr, sync::Arc}; use bytes::{Buf, Bytes}; -use chrono::{serde::ts_milliseconds, DateTime, Utc}; +use chrono::{DateTime, Utc, serde::ts_milliseconds}; use flate2::read::{MultiGzDecoder, ZlibDecoder}; use futures::FutureExt; use http::StatusCode; -use hyper::service::make_service_fn; use hyper::Server; +use hyper::service::make_service_fn; use regex::Regex; use serde::{Deserialize, Serialize}; use snafu::Snafu; @@ -43,17 +43,18 @@ use vector_lib::lookup::owned_value_path; use vector_lib::schema::meaning; use vector_lib::tls::MaybeTlsIncomingStream; use vrl::path::OwnedTargetPath; -use vrl::value::kind::Collection; use vrl::value::Kind; -use warp::{filters::BoxedFilter, reject::Rejection, reply::Response, Filter, Reply}; +use vrl::value::kind::Collection; +use warp::{Filter, Reply, filters::BoxedFilter, reject::Rejection, reply::Response}; use crate::common::http::ErrorMessage; -use crate::http::{build_http_trace_layer, KeepaliveConfig, MaxConnectionAgeLayer}; +use crate::http::{KeepaliveConfig, MaxConnectionAgeLayer, build_http_trace_layer}; use crate::{ + SourceSender, codecs::{Decoder, DecodingConfig}, config::{ - log_schema, DataType, GenerateConfig, Resource, SourceAcknowledgementsConfig, SourceConfig, - SourceContext, SourceOutput, + DataType, GenerateConfig, Resource, SourceAcknowledgementsConfig, SourceConfig, + SourceContext, SourceOutput, log_schema, }, event::Event, internal_events::{HttpBytesReceived, HttpDecompressError, StreamClosedError}, @@ -61,7 +62,6 @@ use crate::{ serde::{bool_or_struct, default_decoding, default_framing_message_based}, sources::{self}, tls::{MaybeTlsSettings, TlsEnableableConfig}, - SourceSender, }; pub const LOGS: &str = "logs"; @@ -482,7 +482,7 @@ impl DatadogAgentSource { return Err(ErrorMessage::new( StatusCode::UNSUPPORTED_MEDIA_TYPE, format!("Unsupported encoding {encoding}"), - )) + )); } } } diff --git a/src/sources/datadog_agent/tests.rs b/src/sources/datadog_agent/tests.rs index b60965c5cac8a..44272b3bc9890 100644 --- a/src/sources/datadog_agent/tests.rs +++ b/src/sources/datadog_agent/tests.rs @@ -14,20 +14,20 @@ use ordered_float::NotNan; use prost::Message; use quickcheck::{Arbitrary, Gen, QuickCheck, TestResult}; use similar_asserts::assert_eq; -use vector_lib::{ - codecs::{decoding::CharacterDelimitedDecoderOptions, CharacterDelimitedDecoderConfig}, - lookup::{owned_value_path, OwnedTargetPath}, -}; use vector_lib::{ codecs::{ - decoding::{BytesDeserializerConfig, Deserializer, DeserializerConfig, Framer}, BytesDecoder, BytesDeserializer, + decoding::{BytesDeserializerConfig, Deserializer, DeserializerConfig, Framer}, }, config::DataType, }; +use vector_lib::{ + codecs::{CharacterDelimitedDecoderConfig, decoding::CharacterDelimitedDecoderOptions}, + lookup::{OwnedTargetPath, owned_value_path}, +}; use vector_lib::{ config::LogNamespace, - event::{metric::TagValue, MetricTags}, + event::{MetricTags, metric::TagValue}, metric_tags, }; use vrl::compiler::value::Collection; @@ -36,25 +36,24 @@ use vrl::value::{Kind, ObjectMap}; use crate::schema::Definition; use crate::{ + SourceSender, common::datadog::{DatadogMetricType, DatadogPoint, DatadogSeriesMetric}, components::validation::prelude::*, config::{SourceConfig, SourceContext}, event::{ - into_event_stream, + Event, EventStatus, Metric, Value, into_event_stream, metric::{MetricKind, MetricSketch, MetricValue}, - Event, EventStatus, Metric, Value, }, schema, serde::{default_decoding, default_framing_message_based}, sources::datadog_agent::{ - ddmetric_proto, ddtrace_proto, logs::decode_log_body, metrics::DatadogSeriesRequest, - DatadogAgentConfig, DatadogAgentSource, LogMsg, LOGS, METRICS, TRACES, + DatadogAgentConfig, DatadogAgentSource, LOGS, LogMsg, METRICS, TRACES, ddmetric_proto, + ddtrace_proto, logs::decode_log_body, metrics::DatadogSeriesRequest, }, test_util::{ - components::{assert_source_compliance, HTTP_PUSH_SOURCE_TAGS}, + components::{HTTP_PUSH_SOURCE_TAGS, assert_source_compliance}, next_addr, spawn_collect_n, trace_init, wait_for_tcp, }, - SourceSender, }; fn test_logs_schema_definition() -> schema::Definition { diff --git a/src/sources/datadog_agent/traces.rs b/src/sources/datadog_agent/traces.rs index 8ce4d9aff7172..15458634fd009 100644 --- a/src/sources/datadog_agent/traces.rs +++ b/src/sources/datadog_agent/traces.rs @@ -7,18 +7,18 @@ use http::StatusCode; use ordered_float::NotNan; use prost::Message; use vrl::event_path; -use warp::{filters::BoxedFilter, path, path::FullPath, reply::Response, Filter, Rejection, Reply}; +use warp::{Filter, Rejection, Reply, filters::BoxedFilter, path, path::FullPath, reply::Response}; -use vector_lib::internal_event::{CountByteSize, InternalEventHandle as _}; use vector_lib::EstimatedJsonEncodedSizeOf; +use vector_lib::internal_event::{CountByteSize, InternalEventHandle as _}; use crate::common::http::ErrorMessage; use crate::{ + SourceSender, event::{Event, ObjectMap, TraceEvent, Value}, sources::datadog_agent::{ - ddtrace_proto, handle_request, ApiKeyQueryParams, DatadogAgentSource, + ApiKeyQueryParams, DatadogAgentSource, ddtrace_proto, handle_request, }, - SourceSender, }; pub(crate) fn build_warp_filter( diff --git a/src/sources/demo_logs.rs b/src/sources/demo_logs.rs index b5b97a52896c9..6e0de5b7b66e8 100644 --- a/src/sources/demo_logs.rs +++ b/src/sources/demo_logs.rs @@ -12,26 +12,26 @@ use vector_lib::internal_event::{ ByteSize, BytesReceived, CountByteSize, InternalEventHandle as _, Protocol, }; use vector_lib::lookup::{owned_value_path, path}; +use vector_lib::{ + EstimatedJsonEncodedSizeOf, + config::{LegacyKey, LogNamespace}, +}; use vector_lib::{ codecs::{ - decoding::{DeserializerConfig, FramingConfig}, StreamDecodingError, + decoding::{DeserializerConfig, FramingConfig}, }, config::DataType, }; -use vector_lib::{ - config::{LegacyKey, LogNamespace}, - EstimatedJsonEncodedSizeOf, -}; use vrl::value::Kind; use crate::{ + SourceSender, codecs::{Decoder, DecodingConfig}, config::{SourceConfig, SourceContext, SourceOutput}, internal_events::{DemoLogsEventProcessed, EventsReceived, StreamClosedError}, serde::{default_decoding, default_framing_message_based}, shutdown::ShutdownSignal, - SourceSender, }; /// Configuration for the `demo_logs` source. @@ -344,15 +344,15 @@ impl SourceConfig for DemoLogsConfig { mod tests { use std::time::{Duration, Instant}; - use futures::{poll, Stream, StreamExt}; + use futures::{Stream, StreamExt, poll}; use super::*; use crate::{ + SourceSender, config::log_schema, event::Event, shutdown::ShutdownSignal, - test_util::components::{assert_source_compliance, SOURCE_TAGS}, - SourceSender, + test_util::components::{SOURCE_TAGS, assert_source_compliance}, }; #[test] diff --git a/src/sources/dnstap/mod.rs b/src/sources/dnstap/mod.rs index bb20d7560a2b5..5f95c512c8feb 100644 --- a/src/sources/dnstap/mod.rs +++ b/src/sources/dnstap/mod.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use base64::prelude::{Engine as _, BASE64_STANDARD}; +use base64::prelude::{BASE64_STANDARD, Engine as _}; use dnsmsg_parser::dns_message_parser::DnsParserOptions; use dnstap_parser::parser::DnstapParser; use dnstap_parser::schema::DnstapEventSchema; @@ -11,15 +11,15 @@ use vector_lib::internal_event::{ use vector_lib::lookup::{owned_value_path, path}; use vector_lib::{configurable::configurable_component, tls::MaybeTlsSettings}; use vrl::path::{OwnedValuePath, PathPrefix}; -use vrl::value::{kind::Collection, Kind}; +use vrl::value::{Kind, kind::Collection}; use super::util::framestream::{ - build_framestream_tcp_source, build_framestream_unix_source, FrameHandler, + FrameHandler, build_framestream_tcp_source, build_framestream_unix_source, }; use crate::internal_events::DnstapParseError; use crate::{ - config::{log_schema, DataType, SourceConfig, SourceContext, SourceOutput}, Result, + config::{DataType, SourceConfig, SourceContext, SourceOutput, log_schema}, }; use dnstap_parser::schema::DNSTAP_VALUE_PATHS; @@ -414,8 +414,8 @@ mod tests { mod integration_tests { #![allow(clippy::print_stdout)] // tests - use bollard::exec::{CreateExecOptions, StartExecOptions}; use bollard::Docker; + use bollard::exec::{CreateExecOptions, StartExecOptions}; use futures::StreamExt; use serde_json::json; use tokio::time; @@ -426,12 +426,12 @@ mod integration_tests { use super::*; use crate::{ + SourceSender, event::Value, test_util::{ - components::{assert_source_compliance, SOURCE_TAGS}, + components::{SOURCE_TAGS, assert_source_compliance}, wait_for, }, - SourceSender, }; async fn test_dnstap(raw_data: bool, query_type: &'static str) { diff --git a/src/sources/dnstap/tcp.rs b/src/sources/dnstap/tcp.rs index ff8076043dd5a..1840ef91b83e4 100644 --- a/src/sources/dnstap/tcp.rs +++ b/src/sources/dnstap/tcp.rs @@ -3,12 +3,12 @@ use std::time::Duration; use bytes::Bytes; use serde_with::serde_as; +use vector_lib::EstimatedJsonEncodedSizeOf; use vector_lib::configurable::configurable_component; use vector_lib::ipallowlist::IpAllowlistConfig; use vector_lib::lookup::{owned_value_path, path}; use vector_lib::tcp::TcpKeepaliveConfig; use vector_lib::tls::{CertificateMetadata, MaybeTlsSettings, TlsSourceConfig}; -use vector_lib::EstimatedJsonEncodedSizeOf; use vrl::path::OwnedValuePath; use vrl::value::ObjectMap; diff --git a/src/sources/docker_logs/mod.rs b/src/sources/docker_logs/mod.rs index f51f86d4d63bd..37c5d0751e7e5 100644 --- a/src/sources/docker_logs/mod.rs +++ b/src/sources/docker_logs/mod.rs @@ -5,11 +5,11 @@ use bollard::query_parameters::{ EventsOptionsBuilder, ListContainersOptionsBuilder, LogsOptionsBuilder, }; use bollard::{ + Docker, container::LogOutput, errors::Error as DockerError, query_parameters::InspectContainerOptions, service::{ContainerInspectResponse, EventMessage}, - Docker, }; use bytes::{Buf, Bytes}; use chrono::{DateTime, FixedOffset, Local, ParseError, Utc}; @@ -24,16 +24,17 @@ use vector_lib::internal_event::{ ByteSize, BytesReceived, InternalEventHandle as _, Protocol, Registered, }; use vector_lib::lookup::{ - lookup_v2::OptionalValuePath, metadata_path, owned_value_path, path, OwnedValuePath, PathPrefix, + OwnedValuePath, PathPrefix, lookup_v2::OptionalValuePath, metadata_path, owned_value_path, path, }; use vrl::event_path; -use vrl::value::{kind::Collection, Kind}; +use vrl::value::{Kind, kind::Collection}; use super::util::MultilineConfig; use crate::{ - config::{log_schema, DataType, SourceConfig, SourceContext, SourceOutput}, - docker::{docker, DockerTlsConfig}, - event::{self, merge_state::LogEventMergeState, EstimatedJsonEncodedSizeOf, LogEvent, Value}, + SourceSender, + config::{DataType, SourceConfig, SourceContext, SourceOutput, log_schema}, + docker::{DockerTlsConfig, docker}, + event::{self, EstimatedJsonEncodedSizeOf, LogEvent, Value, merge_state::LogEventMergeState}, internal_events::{ DockerLogsCommunicationError, DockerLogsContainerEventReceived, DockerLogsContainerMetadataFetchError, DockerLogsContainerUnwatch, @@ -42,7 +43,6 @@ use crate::{ }, line_agg::{self, LineAgg}, shutdown::ShutdownSignal, - SourceSender, }; #[cfg(test)] diff --git a/src/sources/docker_logs/tests.rs b/src/sources/docker_logs/tests.rs index ab878c0b21590..f4cca7a736d07 100644 --- a/src/sources/docker_logs/tests.rs +++ b/src/sources/docker_logs/tests.rs @@ -39,7 +39,7 @@ mod integration_tests { }, secret::ContainerCreateBody, }; - use futures::{stream::TryStreamExt, FutureExt}; + use futures::{FutureExt, stream::TryStreamExt}; use itertools::Itertools as _; use similar_asserts::assert_eq; use vrl::value; @@ -47,13 +47,13 @@ mod integration_tests { use crate::sources::docker_logs::*; use crate::sources::docker_logs::{CONTAINER, CREATED_AT, IMAGE, NAME}; use crate::{ + SourceSender, event::Event, test_util::{ collect_n, collect_ready, - components::{assert_source_compliance, SOURCE_TAGS}, + components::{SOURCE_TAGS, assert_source_compliance}, trace_init, }, - SourceSender, }; /// None if docker is not present on the system @@ -61,7 +61,7 @@ mod integration_tests { names: &[&str], label: L, log_namespace: Option, - ) -> impl Stream { + ) -> impl Stream + use { source_with_config(DockerLogsConfig { include_containers: Some(names.iter().map(|&s| s.to_owned()).collect()), include_labels: Some(label.into().map(|l| vec![l.to_owned()]).unwrap_or_default()), @@ -396,16 +396,18 @@ mod integration_tests { meta.get(path!(DockerLogsConfig::NAME, CONTAINER)).unwrap(), &value!(id) ); - assert!(meta - .get(path!(DockerLogsConfig::NAME, CREATED_AT)) - .is_some()); + assert!( + meta.get(path!(DockerLogsConfig::NAME, CREATED_AT)) + .is_some() + ); assert_eq!( meta.get(path!(DockerLogsConfig::NAME, IMAGE)).unwrap(), &value!("busybox") ); - assert!(meta - .get(path!(DockerLogsConfig::NAME, "labels", label)) - .is_some()); + assert!( + meta.get(path!(DockerLogsConfig::NAME, "labels", label)) + .is_some() + ); assert_eq!( meta.get(path!(DockerLogsConfig::NAME, NAME)).unwrap(), &value!(name) @@ -414,10 +416,11 @@ mod integration_tests { meta.get(path!("vector", "source_type")).unwrap(), &value!(DockerLogsConfig::NAME) ); - assert!(meta - .get(path!("vector", "ingest_timestamp")) - .unwrap() - .is_timestamp()) + assert!( + meta.get(path!("vector", "ingest_timestamp")) + .unwrap() + .is_timestamp() + ) }) .await; } @@ -785,13 +788,14 @@ mod integration_tests { assert_eq!(log[CONTAINER], id.into()); assert!(log.get(CREATED_AT).is_some()); assert_eq!(log[IMAGE], "busybox".into()); - assert!(log - .get("label") - .unwrap() - .as_object() - .unwrap() - .get(label) - .is_some()); + assert!( + log.get("label") + .unwrap() + .as_object() + .unwrap() + .get(label) + .is_some() + ); assert_eq!(events[0].as_log()[&NAME], name.into()); assert_eq!( events[0].as_log()[log_schema().source_type_key().unwrap().to_string()], diff --git a/src/sources/eventstoredb_metrics/mod.rs b/src/sources/eventstoredb_metrics/mod.rs index f9c860a911327..b2837bdecc397 100644 --- a/src/sources/eventstoredb_metrics/mod.rs +++ b/src/sources/eventstoredb_metrics/mod.rs @@ -5,12 +5,12 @@ use http::Uri; use hyper::{Body, Request}; use serde_with::serde_as; use tokio_stream::wrappers::IntervalStream; +use vector_lib::EstimatedJsonEncodedSizeOf; use vector_lib::config::LogNamespace; use vector_lib::configurable::configurable_component; use vector_lib::internal_event::{ ByteSize, BytesReceived, CountByteSize, InternalEventHandle as _, Protocol, }; -use vector_lib::EstimatedJsonEncodedSizeOf; use self::types::Stats; use crate::{ @@ -157,7 +157,7 @@ mod integration_tests { use tokio::time::Duration; use super::*; - use crate::test_util::components::{run_and_assert_source_compliance, SOURCE_TAGS}; + use crate::test_util::components::{SOURCE_TAGS, run_and_assert_source_compliance}; const EVENTSTOREDB_SCRAPE_ADDRESS: &str = "http://eventstoredb:2113/stats"; diff --git a/src/sources/eventstoredb_metrics/types.rs b/src/sources/eventstoredb_metrics/types.rs index 0255058d34698..6585748d8c6be 100644 --- a/src/sources/eventstoredb_metrics/types.rs +++ b/src/sources/eventstoredb_metrics/types.rs @@ -2,8 +2,8 @@ use std::sync::LazyLock; use regex::Regex; use serde::{ - de::{self, Error, MapAccess, Unexpected, Visitor}, Deserialize, Deserializer, + de::{self, Error, MapAccess, Unexpected, Visitor}, }; use crate::event::{Metric, MetricKind, MetricTags, MetricValue}; diff --git a/src/sources/exec/mod.rs b/src/sources/exec/mod.rs index d3ec9eba03fb8..dd040658e2dba 100644 --- a/src/sources/exec/mod.rs +++ b/src/sources/exec/mod.rs @@ -7,22 +7,23 @@ use snafu::Snafu; use tokio::{ io::{AsyncRead, BufReader}, process::Command, - sync::mpsc::{channel, Sender}, - time::{self, sleep, Duration, Instant}, + sync::mpsc::{Sender, channel}, + time::{self, Duration, Instant, sleep}, }; use tokio_stream::wrappers::IntervalStream; use tokio_util::codec::FramedRead; use vector_lib::codecs::{ - decoding::{DeserializerConfig, FramingConfig}, StreamDecodingError, + decoding::{DeserializerConfig, FramingConfig}, }; use vector_lib::configurable::configurable_component; use vector_lib::internal_event::{ByteSize, BytesReceived, InternalEventHandle as _, Protocol}; -use vector_lib::{config::LegacyKey, EstimatedJsonEncodedSizeOf}; +use vector_lib::{EstimatedJsonEncodedSizeOf, config::LegacyKey}; use vrl::path::OwnedValuePath; use vrl::value::Kind; use crate::{ + SourceSender, codecs::{Decoder, DecodingConfig}, config::{SourceConfig, SourceContext, SourceOutput}, event::Event, @@ -32,9 +33,8 @@ use crate::{ }, serde::default_decoding, shutdown::ShutdownSignal, - SourceSender, }; -use vector_lib::config::{log_schema, LogNamespace}; +use vector_lib::config::{LogNamespace, log_schema}; use vector_lib::lookup::{owned_value_path, path}; #[cfg(test)] diff --git a/src/sources/exec/tests.rs b/src/sources/exec/tests.rs index c070b00a24f3c..5b739597690a9 100644 --- a/src/sources/exec/tests.rs +++ b/src/sources/exec/tests.rs @@ -84,10 +84,11 @@ fn test_scheduled_handle_event_vector_namespace() { meta.get(path!("vector", "source_type")).unwrap(), &value!("exec") ); - assert!(meta - .get(path!("vector", "ingest_timestamp")) - .unwrap() - .is_timestamp()); + assert!( + meta.get(path!("vector", "ingest_timestamp")) + .unwrap() + .is_timestamp() + ); } #[test] @@ -160,10 +161,11 @@ fn test_streaming_create_event_vector_namespace() { meta.get(path!("vector", "source_type")).unwrap(), &value!("exec") ); - assert!(meta - .get(path!("vector", "ingest_timestamp")) - .unwrap() - .is_timestamp()); + assert!( + meta.get(path!("vector", "ingest_timestamp")) + .unwrap() + .is_timestamp() + ); } #[test] diff --git a/src/sources/file.rs b/src/sources/file.rs index 1d946e3e09866..2e429aebd6a67 100644 --- a/src/sources/file.rs +++ b/src/sources/file.rs @@ -11,25 +11,26 @@ use tracing::{Instrument, Span}; use vector_lib::codecs::{BytesDeserializer, BytesDeserializerConfig}; use vector_lib::configurable::configurable_component; use vector_lib::file_source::{ - file_server::{calculate_ignore_before, FileServer, Line}, + file_server::{FileServer, Line, calculate_ignore_before}, paths_provider::{Glob, MatchOptions}, }; use vector_lib::file_source_common::{ Checkpointer, FileFingerprint, FingerprintStrategy, Fingerprinter, ReadFrom, ReadFromConfig, }; use vector_lib::finalizer::OrderedFinalizer; -use vector_lib::lookup::{lookup_v2::OptionalValuePath, owned_value_path, path, OwnedValuePath}; +use vector_lib::lookup::{OwnedValuePath, lookup_v2::OptionalValuePath, owned_value_path, path}; use vector_lib::{ - config::{LegacyKey, LogNamespace}, EstimatedJsonEncodedSizeOf, + config::{LegacyKey, LogNamespace}, }; use vrl::value::Kind; use super::util::{EncodingConfig, MultilineConfig}; use crate::{ + SourceSender, config::{ - log_schema, DataType, SourceAcknowledgementsConfig, SourceConfig, SourceContext, - SourceOutput, + DataType, SourceAcknowledgementsConfig, SourceConfig, SourceContext, SourceOutput, + log_schema, }, encoding_transcode::{Decoder, Encoder}, event::{BatchNotifier, BatchStatus, LogEvent}, @@ -40,7 +41,6 @@ use crate::{ line_agg::{self, LineAgg}, serde::bool_or_struct, shutdown::ShutdownSignal, - SourceSender, }; #[derive(Debug, Snafu)] @@ -353,7 +353,9 @@ impl From for FingerprintStrategy { } => { let bytes = match bytes { Some(bytes) => { - warn!(message = "The `fingerprint.bytes` option will be used to convert old file fingerprints created by vector < v0.11.0, but are not supported for new file fingerprints. The first line will be used instead."); + warn!( + message = "The `fingerprint.bytes` option will be used to convert old file fingerprints created by vector < v0.11.0, but are not supported for new file fingerprints. The first line will be used instead." + ); bytes } None => 256, @@ -725,7 +727,9 @@ fn reconcile_position_options( read_from: Option, ) -> (bool, ReadFrom) { if start_at_beginning.is_some() { - warn!(message = "Use of deprecated option `start_at_beginning`. Please use `ignore_checkpoints` and `read_from` options instead.") + warn!( + message = "Use of deprecated option `start_at_beginning`. Please use `ignore_checkpoints` and `read_from` options instead." + ) } match start_at_beginning { @@ -853,7 +857,7 @@ mod tests { use encoding_rs::UTF_16LE; use similar_asserts::assert_eq; use tempfile::tempdir; - use tokio::time::{sleep, timeout, Duration}; + use tokio::time::{Duration, sleep, timeout}; use vector_lib::schema::Definition; use vrl::value::kind::Collection; @@ -863,7 +867,7 @@ mod tests { event::{Event, EventStatus, Value}, shutdown::ShutdownSignal, sources::file, - test_util::components::{assert_source_compliance, FILE_SOURCE_TAGS}, + test_util::components::{FILE_SOURCE_TAGS, assert_source_compliance}, }; use vrl::value; @@ -1129,12 +1133,13 @@ mod tests { .unwrap(), &value!("file") ); - assert!(log - .metadata() - .value() - .get(path!("vector", "ingest_timestamp")) - .unwrap() - .is_timestamp()); + assert!( + log.metadata() + .value() + .get(path!("vector", "ingest_timestamp")) + .unwrap() + .is_timestamp() + ); assert_eq!( log.metadata() @@ -2362,8 +2367,8 @@ mod tests { Unfinalized, // Acknowledgement handling but no finalization Acks, // Full acknowledgements and proper finalization } - use vector_lib::lookup::OwnedTargetPath; use AckingMode::*; + use vector_lib::lookup::OwnedTargetPath; async fn run_file_source( config: &FileConfig, diff --git a/src/sources/file_descriptors/file_descriptor.rs b/src/sources/file_descriptors/file_descriptor.rs index 00f00f7d72209..1429843aa59b1 100644 --- a/src/sources/file_descriptors/file_descriptor.rs +++ b/src/sources/file_descriptors/file_descriptor.rs @@ -1,7 +1,7 @@ use std::os::fd::{FromRawFd as _, IntoRawFd as _, RawFd}; use std::{fs::File, io}; -use super::{outputs, FileDescriptorConfig}; +use super::{FileDescriptorConfig, outputs}; use vector_lib::codecs::decoding::{DeserializerConfig, FramingConfig}; use vector_lib::config::LogNamespace; use vector_lib::configurable::configurable_component; @@ -119,11 +119,11 @@ mod tests { use super::*; use crate::{ + SourceSender, config::log_schema, test_util::components::{ - assert_source_compliance, assert_source_error, COMPONENT_ERROR_TAGS, SOURCE_TAGS, + COMPONENT_ERROR_TAGS, SOURCE_TAGS, assert_source_compliance, assert_source_error, }, - SourceSender, }; use futures::StreamExt; use vrl::value; @@ -206,10 +206,11 @@ mod tests { meta.get(path!("vector", "source_type")).unwrap(), &value!("file_descriptor") ); - assert!(meta - .get(path!("vector", "ingest_timestamp")) - .unwrap() - .is_timestamp()); + assert!( + meta.get(path!("vector", "ingest_timestamp")) + .unwrap() + .is_timestamp() + ); let event = stream.next().await; let event = event.unwrap(); diff --git a/src/sources/file_descriptors/mod.rs b/src/sources/file_descriptors/mod.rs index 0a36af65aa68c..44633e90d602c 100644 --- a/src/sources/file_descriptors/mod.rs +++ b/src/sources/file_descriptors/mod.rs @@ -3,30 +3,30 @@ use std::io; use async_stream::stream; use bytes::Bytes; use chrono::Utc; -use futures::{channel::mpsc, executor, SinkExt, StreamExt}; +use futures::{SinkExt, StreamExt, channel::mpsc, executor}; use tokio_util::{codec::FramedRead, io::StreamReader}; use vector_lib::codecs::{ - decoding::{DeserializerConfig, FramingConfig}, StreamDecodingError, + decoding::{DeserializerConfig, FramingConfig}, }; use vector_lib::configurable::NamedComponent; use vector_lib::internal_event::{ ByteSize, BytesReceived, CountByteSize, InternalEventHandle as _, Protocol, }; -use vector_lib::lookup::{lookup_v2::OptionalValuePath, owned_value_path, path, OwnedValuePath}; +use vector_lib::lookup::{OwnedValuePath, lookup_v2::OptionalValuePath, owned_value_path, path}; use vector_lib::{ + EstimatedJsonEncodedSizeOf, config::{LegacyKey, LogNamespace}, event::Event, - EstimatedJsonEncodedSizeOf, }; use vrl::value::Kind; use crate::{ + SourceSender, codecs::{Decoder, DecodingConfig}, - config::{log_schema, SourceOutput}, + config::{SourceOutput, log_schema}, internal_events::{EventsReceived, FileDescriptorReadError, StreamClosedError}, shutdown::ShutdownSignal, - SourceSender, }; #[cfg(all(unix, feature = "sources-file_descriptor"))] diff --git a/src/sources/file_descriptors/stdin.rs b/src/sources/file_descriptors/stdin.rs index d659e6ebadc29..3b0f6f5335760 100644 --- a/src/sources/file_descriptors/stdin.rs +++ b/src/sources/file_descriptors/stdin.rs @@ -10,7 +10,7 @@ use crate::{ serde::default_decoding, }; -use super::{outputs, FileDescriptorConfig}; +use super::{FileDescriptorConfig, outputs}; /// Configuration for the `stdin` source. #[configurable_component(source("stdin", "Collect logs sent via stdin."))] @@ -111,9 +111,8 @@ mod tests { use super::*; use crate::{ - config::log_schema, shutdown::ShutdownSignal, - test_util::components::assert_source_compliance, test_util::components::SOURCE_TAGS, - SourceSender, + SourceSender, config::log_schema, shutdown::ShutdownSignal, + test_util::components::SOURCE_TAGS, test_util::components::assert_source_compliance, }; use futures::StreamExt; use vector_lib::lookup::path; @@ -190,10 +189,11 @@ mod tests { meta.get(path!("vector", "source_type")).unwrap(), &value!("stdin") ); - assert!(meta - .get(path!("vector", "ingest_timestamp")) - .unwrap() - .is_timestamp()); + assert!( + meta.get(path!("vector", "ingest_timestamp")) + .unwrap() + .is_timestamp() + ); let event = stream.next().await; let event = event.unwrap(); diff --git a/src/sources/fluent/message.rs b/src/sources/fluent/message.rs index a7e34410d97f1..a096fabbd2c32 100644 --- a/src/sources/fluent/message.rs +++ b/src/sources/fluent/message.rs @@ -1,6 +1,6 @@ use std::{collections::BTreeMap, convert::TryInto}; -use chrono::{serde::ts_seconds, DateTime, TimeZone, Utc}; +use chrono::{DateTime, TimeZone, Utc, serde::ts_seconds}; use ordered_float::NotNan; use serde::{Deserialize, Serialize}; use vector_lib::event::{KeyString, ObjectMap, Value}; diff --git a/src/sources/fluent/mod.rs b/src/sources/fluent/mod.rs index 642940c58a2e9..4a2fefd7ad7a9 100644 --- a/src/sources/fluent/mod.rs +++ b/src/sources/fluent/mod.rs @@ -3,20 +3,20 @@ use std::io::{self, Read}; use std::net::SocketAddr; use std::time::Duration; -use base64::prelude::{Engine as _, BASE64_STANDARD}; +use base64::prelude::{BASE64_STANDARD, Engine as _}; use bytes::{Buf, Bytes, BytesMut}; use chrono::Utc; use flate2::read::MultiGzDecoder; -use rmp_serde::{decode, Deserializer, Serializer}; +use rmp_serde::{Deserializer, Serializer, decode}; use serde::{Deserialize, Serialize}; -use smallvec::{smallvec, SmallVec}; +use smallvec::{SmallVec, smallvec}; use tokio_util::codec::Decoder; use vector_lib::codecs::{BytesDeserializerConfig, StreamDecodingError}; use vector_lib::config::{LegacyKey, LogNamespace}; use vector_lib::configurable::configurable_component; use vector_lib::ipallowlist::IpAllowlistConfig; use vector_lib::lookup::lookup_v2::parse_value_path; -use vector_lib::lookup::{metadata_path, owned_value_path, path, OwnedValuePath}; +use vector_lib::lookup::{OwnedValuePath, metadata_path, owned_value_path, path}; use vector_lib::schema::Definition; use vrl::value::kind::Collection; use vrl::value::{Kind, Value}; @@ -24,8 +24,8 @@ use vrl::value::{Kind, Value}; use super::util::net::{SocketListenAddr, TcpSource, TcpSourceAck, TcpSourceAcker}; use crate::{ config::{ - log_schema, DataType, GenerateConfig, Resource, SourceAcknowledgementsConfig, SourceConfig, - SourceContext, SourceOutput, + DataType, GenerateConfig, Resource, SourceAcknowledgementsConfig, SourceConfig, + SourceContext, SourceOutput, log_schema, }, event::{Event, LogEvent}, internal_events::{FluentMessageDecodeError, FluentMessageReceived}, @@ -832,20 +832,20 @@ mod tests { use serde::Serialize; use tokio::{ io::{AsyncReadExt, AsyncWriteExt}, - time::{error::Elapsed, timeout, Duration}, + time::{Duration, error::Elapsed, timeout}, }; use tokio_util::codec::Decoder; use vector_lib::assert_event_data_eq; use vector_lib::lookup::OwnedTargetPath; use vector_lib::schema::Definition; - use vrl::value::{kind::Collection, ObjectMap, Value}; + use vrl::value::{ObjectMap, Value, kind::Collection}; use super::{message::FluentMessageOptions, *}; use crate::{ + SourceSender, config::{SourceConfig, SourceContext}, event::EventStatus, test_util::{self, next_addr, trace_init, wait_for_tcp}, - SourceSender, }; #[test] @@ -1261,15 +1261,15 @@ mod integration_tests { use crate::sources::fluent::{FluentMode, FluentTcpConfig}; use crate::{ + SourceSender, config::{SourceConfig, SourceContext}, docker::Container, sources::fluent::FluentConfig, test_util::{ collect_ready, - components::{assert_source_compliance, SOCKET_PUSH_SOURCE_TAGS}, + components::{SOCKET_PUSH_SOURCE_TAGS, assert_source_compliance}, next_addr, next_addr_for_ip, random_string, wait_for_tcp, }, - SourceSender, }; const FLUENT_BIT_IMAGE: &str = "fluent/fluent-bit"; diff --git a/src/sources/gcp_pubsub.rs b/src/sources/gcp_pubsub.rs index b175c5e895875..ab972f3fcaf77 100644 --- a/src/sources/gcp_pubsub.rs +++ b/src/sources/gcp_pubsub.rs @@ -4,16 +4,16 @@ use std::{error::Error as _, future::Future, pin::Pin, task::Context, task::Poll use chrono::DateTime; use derivative::Derivative; -use futures::{stream, stream::FuturesUnordered, FutureExt, Stream, StreamExt, TryFutureExt}; +use futures::{FutureExt, Stream, StreamExt, TryFutureExt, stream, stream::FuturesUnordered}; use http::uri::{InvalidUri, Scheme, Uri}; use serde_with::serde_as; use snafu::{ResultExt, Snafu}; use tokio::sync::{mpsc, watch}; use tokio_stream::wrappers::ReceiverStream; use tonic::{ + Code, Request, Status, metadata::MetadataValue, transport::{Certificate, ClientTlsConfig, Endpoint, Identity}, - Code, Request, Status, }; use vector_lib::codecs::decoding::{DeserializerConfig, FramingConfig}; use vector_lib::config::{LegacyKey, LogNamespace}; @@ -24,13 +24,14 @@ use vector_lib::internal_event::{ use vector_lib::lookup::owned_value_path; use vector_lib::{byte_size_of::ByteSizeOf, finalizer::UnorderedFinalizer}; use vrl::path; -use vrl::value::{kind::Collection, Kind}; +use vrl::value::{Kind, kind::Collection}; use crate::{ + SourceSender, codecs::{Decoder, DecodingConfig}, config::{DataType, SourceAcknowledgementsConfig, SourceConfig, SourceContext, SourceOutput}, event::{BatchNotifier, BatchStatus, Event, MaybeAsLogMut, Value}, - gcp::{GcpAuthConfig, GcpAuthenticator, Scope, PUBSUB_URL}, + gcp::{GcpAuthConfig, GcpAuthenticator, PUBSUB_URL, Scope}, internal_events::{ GcpPubsubConnectError, GcpPubsubReceiveError, GcpPubsubStreamingPullError, StreamClosedError, @@ -39,7 +40,6 @@ use crate::{ shutdown::ShutdownSignal, sources::util, tls::{TlsConfig, TlsSettings}, - SourceSender, }; const MIN_ACK_DEADLINE_SECS: u64 = 10; @@ -248,7 +248,9 @@ impl SourceConfig for PubsubConfig { let ack_deadline_secs = match self.ack_deadline_seconds { None => self.ack_deadline_secs, Some(ads) => { - warn!("The `ack_deadline_seconds` setting is deprecated, use `ack_deadline_secs` instead."); + warn!( + "The `ack_deadline_seconds` setting is deprecated, use `ack_deadline_secs` instead." + ); Duration::from_secs(ads as u64) } }; @@ -259,7 +261,9 @@ impl SourceConfig for PubsubConfig { let retry_delay_secs = match self.retry_delay_seconds { None => self.retry_delay_secs, Some(rds) => { - warn!("The `retry_delay_seconds` setting is deprecated, use `retry_delay_secs` instead."); + warn!( + "The `retry_delay_seconds` setting is deprecated, use `retry_delay_secs` instead." + ); Duration::from_secs_f64(rds) } }; @@ -830,20 +834,20 @@ mod integration_tests { use std::collections::{BTreeMap, HashSet}; use std::sync::LazyLock; - use base64::prelude::{Engine as _, BASE64_STANDARD}; + use base64::prelude::{BASE64_STANDARD, Engine as _}; use chrono::{DateTime, Utc}; use futures::{Stream, StreamExt}; use http::method::Method; use hyper::{Request, StatusCode}; - use serde_json::{json, Value}; + use serde_json::{Value, json}; use tokio::time::{Duration, Instant}; use vrl::btreemap; use super::*; use crate::config::{ComponentKey, ProxyConfig}; - use crate::test_util::components::{assert_source_compliance, SOURCE_TAGS}; + use crate::test_util::components::{SOURCE_TAGS, assert_source_compliance}; use crate::test_util::{self, components, random_string}; - use crate::{event::EventStatus, gcp, http::HttpClient, shutdown, SourceSender}; + use crate::{SourceSender, event::EventStatus, gcp, http::HttpClient, shutdown}; const PROJECT: &str = "sourceproject"; static PROJECT_URI: LazyLock = @@ -1034,7 +1038,7 @@ mod integration_tests { &self, status: EventStatus, ) -> ( - impl Stream + Unpin, + impl Stream + Unpin + use<>, shutdown::SourceShutdownCoordinator, ) { let (tx, rx) = SourceSender::new_test_finalize(status); diff --git a/src/sources/heroku_logs.rs b/src/sources/heroku_logs.rs index c2daf516746de..dcfe68270230a 100644 --- a/src/sources/heroku_logs.rs +++ b/src/sources/heroku_logs.rs @@ -12,12 +12,12 @@ use tokio_util::codec::Decoder as _; use vector_lib::lookup::{lookup_v2::parse_value_path, owned_value_path, path}; use vector_lib::{ codecs::{ - decoding::{DeserializerConfig, FramingConfig}, StreamDecodingError, + decoding::{DeserializerConfig, FramingConfig}, }, config::DataType, }; -use vrl::value::{kind::Collection, Kind}; +use vrl::value::{Kind, kind::Collection}; use warp::http::{HeaderMap, StatusCode}; use vector_lib::configurable::configurable_component; @@ -28,27 +28,30 @@ use vector_lib::{ use crate::{ codecs::{Decoder, DecodingConfig}, - common::http::{server_auth::HttpServerAuthConfig, ErrorMessage}, + common::http::{ErrorMessage, server_auth::HttpServerAuthConfig}, config::{ - log_schema, GenerateConfig, Resource, SourceAcknowledgementsConfig, SourceConfig, - SourceContext, SourceOutput, + GenerateConfig, Resource, SourceAcknowledgementsConfig, SourceConfig, SourceContext, + SourceOutput, log_schema, }, event::{Event, LogEvent}, http::KeepaliveConfig, internal_events::{HerokuLogplexRequestReadError, HerokuLogplexRequestReceived}, serde::{bool_or_struct, default_decoding, default_framing_message_based}, sources::{ - http_server::{build_param_matcher, remove_duplicates, HttpConfigParamKind}, + http_server::{HttpConfigParamKind, build_param_matcher, remove_duplicates}, util::{ - http::{add_query_parameters, HttpMethod}, HttpSource, + http::{HttpMethod, add_query_parameters}, }, }, tls::TlsEnableableConfig, }; /// Configuration for `heroku_logs` source. -#[configurable_component(source("heroku_logs", "Collect logs from Heroku's Logplex, the router responsible for receiving logs from your Heroku apps."))] +#[configurable_component(source( + "heroku_logs", + "Collect logs from Heroku's Logplex, the router responsible for receiving logs from your Heroku apps." +))] #[derive(Clone, Debug)] pub struct LogplexConfig { /// The socket address to listen for connections on. @@ -431,24 +434,24 @@ mod tests { use chrono::{DateTime, Utc}; use futures::Stream; use similar_asserts::assert_eq; - use vector_lib::lookup::{owned_value_path, OwnedTargetPath}; + use vector_lib::lookup::{OwnedTargetPath, owned_value_path}; use vector_lib::{ config::LogNamespace, event::{Event, EventStatus, Value}, schema::Definition, }; - use vrl::value::{kind::Collection, Kind}; + use vrl::value::{Kind, kind::Collection}; use super::LogplexConfig; use crate::common::http::server_auth::HttpServerAuthConfig; use crate::{ - config::{log_schema, SourceConfig, SourceContext}, + SourceSender, + config::{SourceConfig, SourceContext, log_schema}, serde::{default_decoding, default_framing_message_based}, test_util::{ - components::{assert_source_compliance, HTTP_PUSH_SOURCE_TAGS}, + components::{HTTP_PUSH_SOURCE_TAGS, assert_source_compliance}, next_addr, random_string, spawn_collect_n, wait_for_tcp, }, - SourceSender, }; #[test] diff --git a/src/sources/host_metrics/cgroups.rs b/src/sources/host_metrics/cgroups.rs index 1ad0bfe2dc137..209714025fc6e 100644 --- a/src/sources/host_metrics/cgroups.rs +++ b/src/sources/host_metrics/cgroups.rs @@ -8,7 +8,7 @@ use tokio::{ }; use vector_lib::metric_tags; -use super::{filter_result_sync, CGroupsConfig, HostMetrics, MetricsBuffer}; +use super::{CGroupsConfig, HostMetrics, MetricsBuffer, filter_result_sync}; use crate::event::MetricTags; const MICROSECONDS: f64 = 1.0 / 1_000_000.0; @@ -455,17 +455,17 @@ mod tests { use std::io::Write; use std::path::{Path, PathBuf}; - use rand::{rngs::ThreadRng, Rng}; + use rand::{Rng, rngs::ThreadRng}; use similar_asserts::assert_eq; use tempfile::TempDir; use vector_lib::event::Metric; use super::{ super::{ - tests::{count_name, count_tag}, HostMetrics, HostMetricsConfig, + tests::{count_name, count_tag}, }, - join_name, join_path, MetricsBuffer, + MetricsBuffer, join_name, join_path, }; #[test] diff --git a/src/sources/host_metrics/cpu.rs b/src/sources/host_metrics/cpu.rs index 1d7a276845b0f..6a4b9b0c7ba88 100644 --- a/src/sources/host_metrics/cpu.rs +++ b/src/sources/host_metrics/cpu.rs @@ -5,7 +5,7 @@ use heim::cpu::os::linux::CpuTimeExt; use heim::units::time::second; use vector_lib::{event::MetricTags, metric_tags}; -use super::{filter_result, HostMetrics}; +use super::{HostMetrics, filter_result}; const MODE: &str = "mode"; const CPU_SECS_TOTAL: &str = "cpu_seconds_total"; diff --git a/src/sources/host_metrics/disk.rs b/src/sources/host_metrics/disk.rs index 03ec6e0b82488..0d6893c77952a 100644 --- a/src/sources/host_metrics/disk.rs +++ b/src/sources/host_metrics/disk.rs @@ -4,7 +4,7 @@ use heim::units::information::byte; use vector_lib::configurable::configurable_component; use vector_lib::metric_tags; -use super::{default_all_devices, example_devices, filter_result, FilterList, HostMetrics}; +use super::{FilterList, HostMetrics, default_all_devices, example_devices, filter_result}; /// Options for the disk metrics collector. #[configurable_component] @@ -76,8 +76,8 @@ impl HostMetrics { mod tests { use super::{ super::{ - tests::{all_counters, assert_filtered_metrics, count_name, count_tag}, HostMetrics, HostMetricsConfig, MetricsBuffer, + tests::{all_counters, assert_filtered_metrics, count_name, count_tag}, }, DiskConfig, }; diff --git a/src/sources/host_metrics/filesystem.rs b/src/sources/host_metrics/filesystem.rs index c093e6797155e..f10fd07a3f8f2 100644 --- a/src/sources/host_metrics/filesystem.rs +++ b/src/sources/host_metrics/filesystem.rs @@ -7,7 +7,7 @@ use vector_lib::metric_tags; use crate::internal_events::{HostMetricsScrapeDetailError, HostMetricsScrapeFilesystemError}; -use super::{default_all_devices, example_devices, filter_result, FilterList, HostMetrics}; +use super::{FilterList, HostMetrics, default_all_devices, example_devices, filter_result}; /// Options for the filesystem metrics collector. #[configurable_component] @@ -148,8 +148,8 @@ impl HostMetrics { mod tests { use super::{ super::{ - tests::{all_gauges, assert_filtered_metrics, count_name, count_tag}, HostMetrics, HostMetricsConfig, MetricsBuffer, + tests::{all_gauges, assert_filtered_metrics, count_name, count_tag}, }, FilesystemConfig, }; diff --git a/src/sources/host_metrics/memory.rs b/src/sources/host_metrics/memory.rs index 3c439113b5a4a..38a46491d7daf 100644 --- a/src/sources/host_metrics/memory.rs +++ b/src/sources/host_metrics/memory.rs @@ -1,9 +1,9 @@ +#[cfg(not(windows))] +use heim::memory::os::SwapExt; #[cfg(target_os = "linux")] use heim::memory::os::linux::MemoryExt; #[cfg(target_os = "macos")] use heim::memory::os::macos::MemoryExt; -#[cfg(not(windows))] -use heim::memory::os::SwapExt; use heim::units::information::byte; use vector_lib::event::MetricTags; diff --git a/src/sources/host_metrics/mod.rs b/src/sources/host_metrics/mod.rs index ac3967b706276..29049946689a8 100644 --- a/src/sources/host_metrics/mod.rs +++ b/src/sources/host_metrics/mod.rs @@ -13,19 +13,19 @@ use serde_with::serde_as; use sysinfo::System; use tokio::time; use tokio_stream::wrappers::IntervalStream; +use vector_lib::EstimatedJsonEncodedSizeOf; use vector_lib::config::LogNamespace; use vector_lib::configurable::configurable_component; use vector_lib::internal_event::{ ByteSize, BytesReceived, CountByteSize, InternalEventHandle as _, Protocol, Registered, }; -use vector_lib::EstimatedJsonEncodedSizeOf; use crate::{ + SourceSender, config::{SourceConfig, SourceContext, SourceOutput}, event::metric::{Metric, MetricKind, MetricTags, MetricValue}, internal_events::{EventsReceived, HostMetricsScrapeDetailError, StreamClosedError}, shutdown::ShutdownSignal, - SourceSender, }; #[cfg(target_os = "linux")] @@ -673,7 +673,7 @@ impl From for String { #[cfg(test)] mod tests { - use crate::test_util::components::{run_and_assert_source_compliance, SOURCE_TAGS}; + use crate::test_util::components::{SOURCE_TAGS, run_and_assert_source_compliance}; use std::{collections::HashSet, future::Future, time::Duration}; use super::*; @@ -781,12 +781,14 @@ mod tests { .capture_metrics() .await; let hostname = crate::get_hostname().expect("Broken hostname"); - assert!(!metrics.into_iter().any(|event| event - .tags() - .expect("Missing tags") - .get("host") - .expect("Missing \"host\" tag") - != hostname)); + assert!(!metrics.into_iter().any(|event| { + event + .tags() + .expect("Missing tags") + .get("host") + .expect("Missing \"host\" tag") + != hostname + })); } #[tokio::test] @@ -798,9 +800,11 @@ mod tests { .capture_metrics() .await; - assert!(metrics - .into_iter() - .all(|event| event.namespace() == Some("other"))); + assert!( + metrics + .into_iter() + .all(|event| event.namespace() == Some("other")) + ); } #[tokio::test] @@ -809,9 +813,11 @@ mod tests { .capture_metrics() .await; - assert!(metrics - .iter() - .all(|event| event.namespace() == Some("host"))); + assert!( + metrics + .iter() + .all(|event| event.namespace() == Some("host")) + ); } // Windows does not produce load average metrics. @@ -827,9 +833,11 @@ mod tests { assert!(all_gauges(&metrics)); // All metrics are named load* - assert!(!metrics - .iter() - .any(|metric| !metric.name().starts_with("load"))); + assert!( + !metrics + .iter() + .any(|metric| !metric.name().starts_with("load")) + ); } #[tokio::test] diff --git a/src/sources/host_metrics/network.rs b/src/sources/host_metrics/network.rs index d97559ad3f9ab..1b0f2b68591a1 100644 --- a/src/sources/host_metrics/network.rs +++ b/src/sources/host_metrics/network.rs @@ -9,7 +9,7 @@ use vector_lib::metric_tags; use crate::internal_events::HostMetricsScrapeDetailError; -use super::{default_all_devices, example_devices, filter_result, FilterList, HostMetrics}; +use super::{FilterList, HostMetrics, default_all_devices, example_devices, filter_result}; /// Options for the network metrics collector. #[configurable_component] @@ -102,8 +102,8 @@ impl HostMetrics { mod tests { use super::{ super::{ - tests::{all_counters, assert_filtered_metrics, count_tag}, HostMetrics, HostMetricsConfig, MetricsBuffer, + tests::{all_counters, assert_filtered_metrics, count_tag}, }, NetworkConfig, }; @@ -119,9 +119,11 @@ mod tests { assert!(all_counters(&metrics)); // All metrics are named network_* - assert!(!metrics - .iter() - .any(|metric| !metric.name().starts_with("network_"))); + assert!( + !metrics + .iter() + .any(|metric| !metric.name().starts_with("network_")) + ); // They should all have a "device" tag assert_eq!(count_tag(&metrics, "device"), metrics.len()); diff --git a/src/sources/host_metrics/process.rs b/src/sources/host_metrics/process.rs index db357062525e5..4c11df93dc3d0 100644 --- a/src/sources/host_metrics/process.rs +++ b/src/sources/host_metrics/process.rs @@ -1,4 +1,4 @@ -use super::{default_all_processes, example_processes, FilterList, HostMetrics}; +use super::{FilterList, HostMetrics, default_all_processes, example_processes}; use std::ffi::OsStr; use sysinfo::{ProcessRefreshKind, ProcessesToUpdate, UpdateKind}; use vector_lib::configurable::configurable_component; @@ -72,9 +72,11 @@ mod tests { assert!(!metrics.is_empty()); // All metrics are named process_* - assert!(!metrics - .iter() - .any(|metric| !metric.name().starts_with("process_"))); + assert!( + !metrics + .iter() + .any(|metric| !metric.name().starts_with("process_")) + ); // They should all have the required tag assert_eq!(count_tag(&metrics, "pid"), metrics.len()); diff --git a/src/sources/host_metrics/tcp.rs b/src/sources/host_metrics/tcp.rs index bde7e0953d7d5..4f402bf591a56 100644 --- a/src/sources/host_metrics/tcp.rs +++ b/src/sources/host_metrics/tcp.rs @@ -4,15 +4,15 @@ use std::{collections::HashMap, io, path::Path}; use vector_lib::event::MetricTags; use netlink_packet_core::{ - NetlinkHeader, NetlinkMessage, NetlinkPayload, NLM_F_ACK, NLM_F_DUMP, NLM_F_REQUEST, + NLM_F_ACK, NLM_F_DUMP, NLM_F_REQUEST, NetlinkHeader, NetlinkMessage, NetlinkPayload, }; use netlink_packet_sock_diag::{ + SockDiagMessage, constants::*, inet::{ExtensionFlags, InetRequest, InetResponseHeader, SocketId, StateFlags}, - SockDiagMessage, }; use netlink_sys::{ - protocols::NETLINK_SOCK_DIAG, AsyncSocket, AsyncSocketExt, SocketAddr, TokioSocket, + AsyncSocket, AsyncSocketExt, SocketAddr, TokioSocket, protocols::NETLINK_SOCK_DIAG, }; use snafu::{ResultExt, Snafu}; @@ -291,13 +291,13 @@ mod tests { use tokio::net::{TcpListener, TcpStream}; use netlink_packet_sock_diag::{ - inet::{InetResponseHeader, SocketId}, AF_INET, + inet::{InetResponseHeader, SocketId}, }; use super::{ - fetch_netlink_inet_headers, parse_nl_inet_hdrs, TcpStats, STATE, TCP_CONNS_TOTAL, - TCP_RX_QUEUED_BYTES_TOTAL, TCP_TX_QUEUED_BYTES_TOTAL, + STATE, TCP_CONNS_TOTAL, TCP_RX_QUEUED_BYTES_TOTAL, TCP_TX_QUEUED_BYTES_TOTAL, TcpStats, + fetch_netlink_inet_headers, parse_nl_inet_hdrs, }; use crate::sources::host_metrics::{HostMetrics, HostMetricsConfig, MetricsBuffer}; use crate::test_util::next_addr; diff --git a/src/sources/http_client/client.rs b/src/sources/http_client/client.rs index 85b792c9ef545..ad98c6acbbec8 100644 --- a/src/sources/http_client/client.rs +++ b/src/sources/http_client/client.rs @@ -4,7 +4,7 @@ use bytes::{Bytes, BytesMut}; use chrono::Utc; use futures_util::FutureExt; -use http::{response::Parts, Uri}; +use http::{Uri, response::Parts}; use serde_with::serde_as; use snafu::ResultExt; use std::{collections::HashMap, time::Duration}; @@ -22,25 +22,24 @@ use crate::{ sources::util::{ http::HttpMethod, http_client::{ - build_url, call, default_interval, default_timeout, warn_if_interval_too_low, - GenericHttpClientInputs, HttpClientBuilder, + GenericHttpClientInputs, HttpClientBuilder, build_url, call, default_interval, + default_timeout, warn_if_interval_too_low, }, }, tls::{TlsConfig, TlsSettings}, }; use vector_lib::codecs::{ - decoding::{DeserializerConfig, FramingConfig}, StreamDecodingError, + decoding::{DeserializerConfig, FramingConfig}, }; -use vector_lib::config::{log_schema, LogNamespace, SourceOutput}; +use vector_lib::config::{LogNamespace, SourceOutput, log_schema}; use vector_lib::configurable::configurable_component; use vector_lib::{ - compile_vrl, + TimeZone, compile_vrl, event::{Event, LogEvent, VrlTarget}, - TimeZone, }; use vrl::{ - compiler::{runtime::Runtime, CompileConfig, Function, Program}, + compiler::{CompileConfig, Function, Program, runtime::Runtime}, prelude::TypeState, }; diff --git a/src/sources/http_client/integration_tests.rs b/src/sources/http_client/integration_tests.rs index a648019000b55..eb28cf339b222 100644 --- a/src/sources/http_client/integration_tests.rs +++ b/src/sources/http_client/integration_tests.rs @@ -7,23 +7,23 @@ use tokio::time::{Duration, Instant}; use crate::sources::util::http::HttpMethod; use crate::{ + SourceSender, config::{ComponentKey, SourceConfig, SourceContext}, http::Auth, serde::default_decoding, serde::default_framing_message_based, tls, tls::TlsConfig, - SourceSender, }; use vector_lib::codecs::decoding::DeserializerConfig; use vector_lib::config::log_schema; use super::{ - tests::{run_compliance, INTERVAL, TIMEOUT}, HttpClientConfig, + tests::{INTERVAL, TIMEOUT, run_compliance}, }; -use crate::test_util::components::{run_and_assert_source_error, COMPONENT_ERROR_TAGS}; +use crate::test_util::components::{COMPONENT_ERROR_TAGS, run_and_assert_source_error}; fn dufs_address() -> String { std::env::var("DUFS_ADDRESS").unwrap_or_else(|_| "http://localhost:5000".into()) diff --git a/src/sources/http_client/tests.rs b/src/sources/http_client/tests.rs index 56df12eac1849..b322dfe83f22e 100644 --- a/src/sources/http_client/tests.rs +++ b/src/sources/http_client/tests.rs @@ -2,21 +2,21 @@ use http::Uri; use std::collections::HashMap; use tokio::time::Duration; use vector_lib::config::LogNamespace; -use warp::{http::HeaderMap, Filter}; +use warp::{Filter, http::HeaderMap}; use crate::components::validation::prelude::*; use crate::http::{ParamType, ParameterValue, QueryParameterValue}; use crate::sources::util::http::HttpMethod; use crate::{serde::default_decoding, serde::default_framing_message_based}; +use vector_lib::codecs::CharacterDelimitedDecoderConfig; use vector_lib::codecs::decoding::{ CharacterDelimitedDecoderOptions, DeserializerConfig, FramingConfig, }; -use vector_lib::codecs::CharacterDelimitedDecoderConfig; use vector_lib::event::Event; use super::HttpClientConfig; use crate::test_util::{ - components::{run_and_assert_source_compliance, HTTP_PULL_SOURCE_TAGS}, + components::{HTTP_PULL_SOURCE_TAGS, run_and_assert_source_compliance}, next_addr, test_generate_config, wait_for_tcp, }; diff --git a/src/sources/http_server.rs b/src/sources/http_server.rs index df5fa30144389..cd7a0a6ae4fc5 100644 --- a/src/sources/http_server.rs +++ b/src/sources/http_server.rs @@ -1,4 +1,4 @@ -use crate::common::http::{server_auth::HttpServerAuthConfig, ErrorMessage}; +use crate::common::http::{ErrorMessage, server_auth::HttpServerAuthConfig}; use std::{collections::HashMap, net::SocketAddr}; use bytes::{Bytes, BytesMut}; @@ -6,13 +6,13 @@ use chrono::Utc; use http::StatusCode; use http_serde; use tokio_util::codec::Decoder as _; -use vrl::value::{kind::Collection, Kind}; +use vrl::value::{Kind, kind::Collection}; use warp::http::HeaderMap; use vector_lib::codecs::{ - decoding::{DeserializerConfig, FramingConfig}, BytesDecoderConfig, BytesDeserializerConfig, JsonDeserializerConfig, NewlineDelimitedDecoderConfig, + decoding::{DeserializerConfig, FramingConfig}, }; use vector_lib::configurable::configurable_component; use vector_lib::lookup::{lookup_v2::OptionalValuePath, owned_value_path, path}; @@ -31,8 +31,8 @@ use crate::{ http::KeepaliveConfig, serde::{bool_or_struct, default_decoding}, sources::util::{ - http::{add_headers, add_query_parameters, HttpMethod}, Encoding, HttpSource, + http::{HttpMethod, add_headers, add_query_parameters}, }, tls::TlsEnableableConfig, }; @@ -529,40 +529,40 @@ mod tests { use std::{io::Write, net::SocketAddr}; use flate2::{ - write::{GzEncoder, ZlibEncoder}, Compression, + write::{GzEncoder, ZlibEncoder}, }; use futures::Stream; - use headers::authorization::Credentials; use headers::Authorization; + use headers::authorization::Credentials; use http::header::AUTHORIZATION; use http::{HeaderMap, Method, StatusCode, Uri}; use similar_asserts::assert_eq; use vector_lib::codecs::{ - decoding::{DeserializerConfig, FramingConfig}, BytesDecoderConfig, JsonDeserializerConfig, + decoding::{DeserializerConfig, FramingConfig}, }; use vector_lib::config::LogNamespace; use vector_lib::event::LogEvent; use vector_lib::lookup::lookup_v2::OptionalValuePath; - use vector_lib::lookup::{event_path, owned_value_path, OwnedTargetPath, PathPrefix}; + use vector_lib::lookup::{OwnedTargetPath, PathPrefix, event_path, owned_value_path}; use vector_lib::schema::Definition; - use vrl::value::{kind::Collection, Kind, ObjectMap}; + use vrl::value::{Kind, ObjectMap, kind::Collection}; use crate::common::http::server_auth::HttpServerAuthConfig; use crate::sources::http_server::HttpMethod; use crate::{ + SourceSender, components::validation::prelude::*, - config::{log_schema, SourceConfig, SourceContext}, + config::{SourceConfig, SourceContext, log_schema}, event::{Event, EventStatus, Value}, test_util::{ - components::{self, assert_source_compliance, HTTP_PUSH_SOURCE_TAGS}, + components::{self, HTTP_PUSH_SOURCE_TAGS, assert_source_compliance}, next_addr, spawn_collect_n, wait_for_tcp, }, - SourceSender, }; - use super::{remove_duplicates, SimpleHttpConfig}; + use super::{SimpleHttpConfig, remove_duplicates}; #[test] fn generate_config() { diff --git a/src/sources/internal_logs.rs b/src/sources/internal_logs.rs index 5a60af1e62809..794c7a6999d87 100644 --- a/src/sources/internal_logs.rs +++ b/src/sources/internal_logs.rs @@ -1,10 +1,10 @@ use chrono::Utc; -use futures::{stream, StreamExt}; +use futures::{StreamExt, stream}; use vector_lib::codecs::BytesDeserializerConfig; use vector_lib::config::log_schema; use vector_lib::configurable::configurable_component; use vector_lib::lookup::lookup_v2::OptionalValuePath; -use vector_lib::lookup::{owned_value_path, path, OwnedValuePath}; +use vector_lib::lookup::{OwnedValuePath, owned_value_path, path}; use vector_lib::{ config::{LegacyKey, LogNamespace}, schema::Definition, @@ -12,12 +12,12 @@ use vector_lib::{ use vrl::value::Kind; use crate::{ + SourceSender, config::{DataType, SourceConfig, SourceContext, SourceOutput}, event::{EstimatedJsonEncodedSizeOf, Event}, internal_events::{InternalLogsBytesReceived, InternalLogsEventsReceived, StreamClosedError}, shutdown::ShutdownSignal, trace::TraceSubscription, - SourceSender, }; /// Configuration for the `internal_logs` source. @@ -211,7 +211,7 @@ async fn run( #[cfg(test)] mod tests { use futures::Stream; - use tokio::time::{sleep, Duration}; + use tokio::time::{Duration, sleep}; use vector_lib::event::Value; use vector_lib::lookup::OwnedTargetPath; use vrl::value::kind::Collection; @@ -221,7 +221,7 @@ mod tests { event::Event, test_util::{ collect_ready, - components::{assert_source_compliance, SOURCE_TAGS}, + components::{SOURCE_TAGS, assert_source_compliance}, }, trace, }; diff --git a/src/sources/internal_metrics.rs b/src/sources/internal_metrics.rs index 4b43c1230186b..4bf005cb3b45f 100644 --- a/src/sources/internal_metrics.rs +++ b/src/sources/internal_metrics.rs @@ -9,14 +9,14 @@ use vector_lib::internal_event::{ ByteSize, BytesReceived, CountByteSize, InternalEventHandle as _, Protocol, }; use vector_lib::lookup::lookup_v2::OptionalValuePath; -use vector_lib::{config::LogNamespace, ByteSizeOf, EstimatedJsonEncodedSizeOf}; +use vector_lib::{ByteSizeOf, EstimatedJsonEncodedSizeOf, config::LogNamespace}; use crate::{ - config::{log_schema, SourceConfig, SourceContext, SourceOutput}, + SourceSender, + config::{SourceConfig, SourceContext, SourceOutput, log_schema}, internal_events::{EventsReceived, StreamClosedError}, metrics::Controller, shutdown::ShutdownSignal, - SourceSender, }; /// Configuration for the `internal_metrics` source. @@ -201,12 +201,12 @@ mod tests { use super::*; use crate::{ event::{ - metric::{Metric, MetricValue}, Event, + metric::{Metric, MetricValue}, }, test_util::{ self, - components::{run_and_assert_source_compliance, SOURCE_TAGS}, + components::{SOURCE_TAGS, run_and_assert_source_compliance}, }, }; diff --git a/src/sources/journald.rs b/src/sources/journald.rs index e5df0dbf68e6a..3887bd46c7374 100644 --- a/src/sources/journald.rs +++ b/src/sources/journald.rs @@ -10,9 +10,9 @@ use std::{ use bytes::Bytes; use chrono::{TimeZone, Utc}; -use futures::{poll, stream::BoxStream, task::Poll, StreamExt}; +use futures::{StreamExt, poll, stream::BoxStream, task::Poll}; use nix::{ - sys::signal::{kill, Signal}, + sys::signal::{Signal, kill}, unistd::Pid, }; use serde_json::{Error as JsonError, Value as JsonValue}; @@ -25,13 +25,13 @@ use tokio::{ time::sleep, }; use tokio_util::codec::FramedRead; -use vector_lib::codecs::{decoding::BoxedFramingError, CharacterDelimitedDecoder}; +use vector_lib::codecs::{CharacterDelimitedDecoder, decoding::BoxedFramingError}; use vector_lib::configurable::configurable_component; use vector_lib::lookup::{metadata_path, owned_value_path, path}; use vector_lib::{ + EstimatedJsonEncodedSizeOf, config::{LegacyKey, LogNamespace}, schema::Definition, - EstimatedJsonEncodedSizeOf, }; use vector_lib::{ finalizer::OrderedFinalizer, @@ -40,12 +40,13 @@ use vector_lib::{ }, }; use vrl::event_path; -use vrl::value::{kind::Collection, Kind, Value}; +use vrl::value::{Kind, Value, kind::Collection}; use crate::{ + SourceSender, config::{ - log_schema, DataType, SourceAcknowledgementsConfig, SourceConfig, SourceContext, - SourceOutput, + DataType, SourceAcknowledgementsConfig, SourceConfig, SourceContext, SourceOutput, + log_schema, }, event::{BatchNotifier, BatchStatus, BatchStatusReceiver, LogEvent}, internal_events::{ @@ -55,7 +56,6 @@ use crate::{ }, serde::bool_or_struct, shutdown::ShutdownSignal, - SourceSender, }; const BATCH_TIMEOUT: Duration = Duration::from_millis(10); @@ -330,7 +330,9 @@ type Record = HashMap; impl SourceConfig for JournaldConfig { async fn build(&self, cx: SourceContext) -> crate::Result { if self.remap_priority { - warn!("DEPRECATION, option `remap_priority` has been deprecated. Please use the `remap` transform and function `to_syslog_level` instead."); + warn!( + "DEPRECATION, option `remap_priority` has been deprecated. Please use the `remap` transform and function `to_syslog_level` instead." + ); } let data_dir = cx @@ -1111,8 +1113,8 @@ mod tests { use std::{fs, path::Path}; use tempfile::tempdir; - use tokio::time::{sleep, timeout, Duration, Instant}; - use vrl::value::{kind::Collection, Value}; + use tokio::time::{Duration, Instant, sleep, timeout}; + use vrl::value::{Value, kind::Collection}; use super::*; use crate::{ diff --git a/src/sources/kafka.rs b/src/sources/kafka.rs index c144841c1be31..65e0501cdbc2a 100644 --- a/src/sources/kafka.rs +++ b/src/sources/kafka.rs @@ -3,8 +3,8 @@ use std::{ io::Cursor, pin::Pin, sync::{ - mpsc::{sync_channel, SyncSender}, Arc, OnceLock, Weak, + mpsc::{SyncSender, sync_channel}, }, time::Duration, }; @@ -15,14 +15,14 @@ use chrono::{DateTime, TimeZone, Utc}; use futures::{Stream, StreamExt}; use futures_util::future::OptionFuture; use rdkafka::{ + ClientConfig, ClientContext, Statistics, TopicPartitionList, consumer::{ - stream_consumer::StreamPartitionQueue, BaseConsumer, CommitMode, Consumer, ConsumerContext, - Rebalance, StreamConsumer, + BaseConsumer, CommitMode, Consumer, ConsumerContext, Rebalance, StreamConsumer, + stream_consumer::StreamPartitionQueue, }, error::KafkaError, message::{BorrowedMessage, Headers as _, Message}, types::RDKafkaErrorCode, - ClientConfig, ClientContext, Statistics, TopicPartitionList, }; use serde_with::serde_as; use snafu::{ResultExt, Snafu}; @@ -38,24 +38,25 @@ use tokio::{ use tokio_util::codec::FramedRead; use tracing::{Instrument, Span}; use vector_lib::codecs::{ - decoding::{DeserializerConfig, FramingConfig}, StreamDecodingError, + decoding::{DeserializerConfig, FramingConfig}, }; -use vector_lib::lookup::{lookup_v2::OptionalValuePath, owned_value_path, path, OwnedValuePath}; +use vector_lib::lookup::{OwnedValuePath, lookup_v2::OptionalValuePath, owned_value_path, path}; use vector_lib::configurable::configurable_component; use vector_lib::finalizer::OrderedFinalizer; use vector_lib::{ - config::{LegacyKey, LogNamespace}, EstimatedJsonEncodedSizeOf, + config::{LegacyKey, LogNamespace}, }; -use vrl::value::{kind::Collection, Kind, ObjectMap}; +use vrl::value::{Kind, ObjectMap, kind::Collection}; use crate::{ + SourceSender, codecs::{Decoder, DecodingConfig}, config::{ - log_schema, LogSchema, SourceAcknowledgementsConfig, SourceConfig, SourceContext, - SourceOutput, + LogSchema, SourceAcknowledgementsConfig, SourceConfig, SourceContext, SourceOutput, + log_schema, }, event::{BatchNotifier, BatchStatus, Event, Value}, internal_events::{ @@ -65,7 +66,6 @@ use crate::{ kafka, serde::{bool_or_struct, default_decoding, default_framing_message_based}, shutdown::ShutdownSignal, - SourceSender, }; #[derive(Debug, Snafu)] @@ -1544,6 +1544,7 @@ mod integration_test { use futures::Stream; use futures_util::stream::FuturesUnordered; use rdkafka::{ + Offset, TopicPartitionList, admin::{AdminClient, AdminOptions, NewTopic, TopicReplication}, client::DefaultClientContext, config::{ClientConfig, FromClientConfig}, @@ -1551,7 +1552,6 @@ mod integration_test { message::{Header, OwnedHeaders}, producer::{FutureProducer, FutureRecord}, util::Timeout, - Offset, TopicPartitionList, }; use stream_cancel::{Trigger, Tripwire}; use tokio::time::sleep; @@ -1560,10 +1560,10 @@ mod integration_test { use super::{test::*, *}; use crate::{ + SourceSender, event::{EventArray, EventContainer}, shutdown::ShutdownSignal, test_util::{collect_n, components::assert_source_compliance, random_string}, - SourceSender, }; const KEY: &str = "my key"; @@ -1733,10 +1733,11 @@ mod integration_test { meta.get(path!("vector", "source_type")).unwrap(), &value!(KafkaSourceConfig::NAME) ); - assert!(meta - .get(path!("vector", "ingest_timestamp")) - .unwrap() - .is_timestamp()); + assert!( + meta.get(path!("vector", "ingest_timestamp")) + .unwrap() + .is_timestamp() + ); assert_eq!( event.as_log().value(), @@ -2023,7 +2024,11 @@ mod integration_test { 0, "First batch of events should be non-zero (increase KAFKA_SHUTDOWN_DELAY?)" ); - assert_ne!(events2.len(), 0, "Second batch of events should be non-zero (decrease KAFKA_SHUTDOWN_DELAY or increase KAFKA_SEND_COUNT?) "); + assert_ne!( + events2.len(), + 0, + "Second batch of events should be non-zero (decrease KAFKA_SHUTDOWN_DELAY or increase KAFKA_SEND_COUNT?) " + ); assert_eq!(total, expect_count); } diff --git a/src/sources/kubernetes_logs/k8s_paths_provider.rs b/src/sources/kubernetes_logs/k8s_paths_provider.rs index 8f65eca7d3a9f..7591828d51abd 100644 --- a/src/sources/kubernetes_logs/k8s_paths_provider.rs +++ b/src/sources/kubernetes_logs/k8s_paths_provider.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; use k8s_openapi::api::core::v1::{Namespace, Pod}; -use kube::runtime::reflector::{store::Store, ObjectRef}; +use kube::runtime::reflector::{ObjectRef, store::Store}; use vector_lib::file_source::paths_provider::PathsProvider; use super::path_helpers::build_pod_logs_directory; @@ -198,11 +198,7 @@ fn filter_paths<'a>( }, ) }); - if include { - m - } else { - !m - } + if include { m } else { !m } }) } diff --git a/src/sources/kubernetes_logs/lifecycle.rs b/src/sources/kubernetes_logs/lifecycle.rs index b82b4640f0e46..162b0ad8fe2eb 100644 --- a/src/sources/kubernetes_logs/lifecycle.rs +++ b/src/sources/kubernetes_logs/lifecycle.rs @@ -1,15 +1,15 @@ use std::{ future::Future, pin::Pin, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, }; use futures::{ + FutureExt, StreamExt, channel::oneshot, - future::{select, BoxFuture, Either}, + future::{BoxFuture, Either, select}, pin_mut, stream::FuturesOrdered, - FutureExt, StreamExt, }; use crate::shutdown::ShutdownSignal; diff --git a/src/sources/kubernetes_logs/mod.rs b/src/sources/kubernetes_logs/mod.rs index 590bb1c9ce55a..e906b357bfeeb 100644 --- a/src/sources/kubernetes_logs/mod.rs +++ b/src/sources/kubernetes_logs/mod.rs @@ -14,37 +14,34 @@ use http_1::{HeaderName, HeaderValue}; use k8s_openapi::api::core::v1::{Namespace, Node, Pod}; use k8s_paths_provider::K8sPathsProvider; use kube::{ + Client, Config as ClientConfig, api::Api, config::{self, KubeConfigOptions}, - runtime::{reflector, watcher, WatchStreamExt}, - Client, Config as ClientConfig, + runtime::{WatchStreamExt, reflector, watcher}, }; use lifecycle::Lifecycle; use serde_with::serde_as; use vector_lib::codecs::{BytesDeserializer, BytesDeserializerConfig}; use vector_lib::configurable::configurable_component; use vector_lib::file_source::file_server::{ - calculate_ignore_before, FileServer, Line, Shutdown as FileServerShutdown, + FileServer, Line, Shutdown as FileServerShutdown, calculate_ignore_before, }; use vector_lib::file_source_common::{ Checkpointer, FingerprintStrategy, Fingerprinter, ReadFrom, ReadFromConfig, }; -use vector_lib::lookup::{lookup_v2::OptionalTargetPath, owned_value_path, path, OwnedTargetPath}; -use vector_lib::{config::LegacyKey, config::LogNamespace, EstimatedJsonEncodedSizeOf}; +use vector_lib::lookup::{OwnedTargetPath, lookup_v2::OptionalTargetPath, owned_value_path, path}; +use vector_lib::{EstimatedJsonEncodedSizeOf, config::LegacyKey, config::LogNamespace}; use vector_lib::{ - internal_event::{ByteSize, BytesReceived, InternalEventHandle as _, Protocol}, TimeZone, + internal_event::{ByteSize, BytesReceived, InternalEventHandle as _, Protocol}, }; -use vrl::value::{kind::Collection, Kind}; +use vrl::value::{Kind, kind::Collection}; use crate::{ - built_info::{PKG_NAME, PKG_VERSION}, - sources::kubernetes_logs::partial_events_merger::merge_partial_events, -}; -use crate::{ + SourceSender, config::{ - log_schema, ComponentKey, DataType, GenerateConfig, GlobalOptions, SourceConfig, - SourceContext, SourceOutput, + ComponentKey, DataType, GenerateConfig, GlobalOptions, SourceConfig, SourceContext, + SourceOutput, log_schema, }, event::Event, internal_events::{ @@ -57,7 +54,10 @@ use crate::{ shutdown::ShutdownSignal, sources, transforms::{FunctionTransform, OutputBuffer}, - SourceSender, +}; +use crate::{ + built_info::{PKG_NAME, PKG_VERSION}, + sources::kubernetes_logs::partial_events_merger::merge_partial_events, }; mod k8s_paths_provider; @@ -1153,9 +1153,9 @@ fn prepare_label_selector(selector: &str) -> String { #[cfg(test)] mod tests { use similar_asserts::assert_eq; - use vector_lib::lookup::{owned_value_path, OwnedTargetPath}; + use vector_lib::lookup::{OwnedTargetPath, owned_value_path}; use vector_lib::{config::LogNamespace, schema::Definition}; - use vrl::value::{kind::Collection, Kind}; + use vrl::value::{Kind, kind::Collection}; use crate::config::SourceConfig; diff --git a/src/sources/kubernetes_logs/namespace_metadata_annotator.rs b/src/sources/kubernetes_logs/namespace_metadata_annotator.rs index d97639ad46cbf..6bc8726c31b78 100644 --- a/src/sources/kubernetes_logs/namespace_metadata_annotator.rs +++ b/src/sources/kubernetes_logs/namespace_metadata_annotator.rs @@ -3,11 +3,11 @@ #![deny(missing_docs)] use k8s_openapi::{api::core::v1::Namespace, apimachinery::pkg::apis::meta::v1::ObjectMeta}; -use kube::runtime::reflector::{store::Store, ObjectRef}; +use kube::runtime::reflector::{ObjectRef, store::Store}; use vector_lib::config::{LegacyKey, LogNamespace}; use vector_lib::configurable::configurable_component; use vector_lib::lookup::lookup_v2::OptionalTargetPath; -use vector_lib::lookup::{lookup_v2::ValuePath, owned_value_path, path, OwnedTargetPath}; +use vector_lib::lookup::{OwnedTargetPath, lookup_v2::ValuePath, owned_value_path, path}; use crate::event::{Event, LogEvent}; diff --git a/src/sources/kubernetes_logs/node_metadata_annotator.rs b/src/sources/kubernetes_logs/node_metadata_annotator.rs index 5342e7ae8caac..ead24e2b0d8be 100644 --- a/src/sources/kubernetes_logs/node_metadata_annotator.rs +++ b/src/sources/kubernetes_logs/node_metadata_annotator.rs @@ -4,11 +4,11 @@ use crate::event::{Event, LogEvent}; use k8s_openapi::{api::core::v1::Node, apimachinery::pkg::apis::meta::v1::ObjectMeta}; -use kube::runtime::reflector::{store::Store, ObjectRef}; +use kube::runtime::reflector::{ObjectRef, store::Store}; use vector_lib::config::{LegacyKey, LogNamespace}; use vector_lib::configurable::configurable_component; use vector_lib::lookup::lookup_v2::OptionalTargetPath; -use vector_lib::lookup::{lookup_v2::ValuePath, owned_value_path, path, OwnedTargetPath}; +use vector_lib::lookup::{OwnedTargetPath, lookup_v2::ValuePath, owned_value_path, path}; use super::Config; diff --git a/src/sources/kubernetes_logs/parser/cri.rs b/src/sources/kubernetes_logs/parser/cri.rs index be334da95b376..4d2f5da464401 100644 --- a/src/sources/kubernetes_logs/parser/cri.rs +++ b/src/sources/kubernetes_logs/parser/cri.rs @@ -1,6 +1,6 @@ use chrono::{DateTime, Utc}; use derivative::Derivative; -use vector_lib::config::{log_schema, LegacyKey, LogNamespace}; +use vector_lib::config::{LegacyKey, LogNamespace, log_schema}; use vector_lib::conversion; use vector_lib::lookup::path; @@ -8,7 +8,7 @@ use crate::sources::kubernetes_logs::transform_utils::get_message_path; use crate::{ event::{self, Event, Value}, internal_events::{ - ParserConversionError, ParserMatchError, ParserMissingFieldError, DROP_EVENT, + DROP_EVENT, ParserConversionError, ParserMatchError, ParserMissingFieldError, }, sources::kubernetes_logs::Config, transforms::{FunctionTransform, OutputBuffer}, diff --git a/src/sources/kubernetes_logs/parser/docker.rs b/src/sources/kubernetes_logs/parser/docker.rs index 118cfbb5d799d..7a6ef10d3b9c7 100644 --- a/src/sources/kubernetes_logs/parser/docker.rs +++ b/src/sources/kubernetes_logs/parser/docker.rs @@ -3,7 +3,7 @@ use chrono::{DateTime, Utc}; use serde_json::Value as JsonValue; use snafu::{OptionExt, ResultExt, Snafu}; use vector_lib::config::{LegacyKey, LogNamespace}; -use vector_lib::lookup::{self, path, OwnedTargetPath}; +use vector_lib::lookup::{self, OwnedTargetPath, path}; use crate::sources::kubernetes_logs::transform_utils::get_message_path; use crate::{ diff --git a/src/sources/kubernetes_logs/partial_events_merger.rs b/src/sources/kubernetes_logs/partial_events_merger.rs index 56752b49454cd..e753ceebd8041 100644 --- a/src/sources/kubernetes_logs/partial_events_merger.rs +++ b/src/sources/kubernetes_logs/partial_events_merger.rs @@ -6,7 +6,7 @@ use std::collections::HashMap; use std::time::{Duration, Instant}; use vector_lib::config::LogNamespace; use vector_lib::lookup::OwnedTargetPath; -use vector_lib::stream::expiration_map::{map_with_expiration, Emitter}; +use vector_lib::stream::expiration_map::{Emitter, map_with_expiration}; use vrl::owned_value_path; use crate::event; diff --git a/src/sources/kubernetes_logs/pod_metadata_annotator.rs b/src/sources/kubernetes_logs/pod_metadata_annotator.rs index 228a4d7d1a37b..fdabe70cef463 100644 --- a/src/sources/kubernetes_logs/pod_metadata_annotator.rs +++ b/src/sources/kubernetes_logs/pod_metadata_annotator.rs @@ -6,17 +6,18 @@ use k8s_openapi::{ api::core::v1::{Container, ContainerStatus, Pod, PodSpec, PodStatus}, apimachinery::pkg::apis::meta::v1::ObjectMeta, }; -use kube::runtime::reflector::{store::Store, ObjectRef}; +use kube::runtime::reflector::{ObjectRef, store::Store}; use vector_lib::config::{LegacyKey, LogNamespace}; use vector_lib::configurable::configurable_component; use vector_lib::lookup::{ + OwnedTargetPath, lookup_v2::{OptionalTargetPath, ValuePath}, - owned_value_path, path, OwnedTargetPath, + owned_value_path, path, }; use super::{ - path_helpers::{parse_log_file_path, LogFileInfo}, Config, + path_helpers::{LogFileInfo, parse_log_file_path}, }; use crate::event::{Event, LogEvent}; diff --git a/src/sources/kubernetes_logs/transform_utils/mod.rs b/src/sources/kubernetes_logs/transform_utils/mod.rs index 307d0f72d6fa8..fe61b49f72a09 100644 --- a/src/sources/kubernetes_logs/transform_utils/mod.rs +++ b/src/sources/kubernetes_logs/transform_utils/mod.rs @@ -1,4 +1,4 @@ -use vector_lib::config::{log_schema, LogNamespace}; +use vector_lib::config::{LogNamespace, log_schema}; use vrl::owned_value_path; use vrl::path::OwnedTargetPath; diff --git a/src/sources/kubernetes_logs/util.rs b/src/sources/kubernetes_logs/util.rs index de17af7f74d30..0c55c845e86d3 100644 --- a/src/sources/kubernetes_logs/util.rs +++ b/src/sources/kubernetes_logs/util.rs @@ -1,8 +1,9 @@ use std::{error::Error, future::Future, time::Duration}; use futures::{ - future::{select, Either}, - pin_mut, FutureExt, Sink, + FutureExt, Sink, + future::{Either, select}, + pin_mut, }; use tokio::task::spawn_blocking; use vector_lib::file_source::{ diff --git a/src/sources/logstash.rs b/src/sources/logstash.rs index 79628f96759a3..0c6ca737ebe6b 100644 --- a/src/sources/logstash.rs +++ b/src/sources/logstash.rs @@ -9,12 +9,12 @@ use vector_lib::ipallowlist::IpAllowlistConfig; use bytes::{Buf, Bytes, BytesMut}; use flate2::read::ZlibDecoder; -use smallvec::{smallvec, SmallVec}; +use smallvec::{SmallVec, smallvec}; use snafu::{ResultExt, Snafu}; use tokio_util::codec::Decoder; use vector_lib::codecs::{BytesDeserializerConfig, StreamDecodingError}; use vector_lib::configurable::configurable_component; -use vector_lib::lookup::{event_path, metadata_path, owned_value_path, path, OwnedValuePath}; +use vector_lib::lookup::{OwnedValuePath, event_path, metadata_path, owned_value_path, path}; use vector_lib::{ config::{LegacyKey, LogNamespace}, schema::Definition, @@ -25,8 +25,8 @@ use vrl::value::{KeyString, Kind}; use super::util::net::{SocketListenAddr, TcpSource, TcpSourceAck, TcpSourceAcker}; use crate::{ config::{ - log_schema, DataType, GenerateConfig, Resource, SourceAcknowledgementsConfig, SourceConfig, - SourceContext, SourceOutput, + DataType, GenerateConfig, Resource, SourceAcknowledgementsConfig, SourceConfig, + SourceContext, SourceOutput, log_schema, }, event::{Event, LogEvent, Value}, serde::bool_or_struct, @@ -712,19 +712,19 @@ impl From for SmallVec<[Event; 1]> { mod test { use bytes::BufMut; use futures::Stream; - use rand::{rng, Rng}; + use rand::{Rng, rng}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use vector_lib::lookup::OwnedTargetPath; use vrl::value::kind::Collection; use super::*; use crate::{ + SourceSender, event::EventStatus, test_util::{ - components::{assert_source_compliance, SOCKET_PUSH_SOURCE_TAGS}, + components::{SOCKET_PUSH_SOURCE_TAGS, assert_source_compliance}, next_addr, spawn_collect_n, wait_for_tcp, }, - SourceSender, }; #[test] @@ -915,15 +915,15 @@ mod integration_tests { use super::*; use crate::{ + SourceSender, config::SourceContext, event::EventStatus, test_util::{ collect_n, - components::{assert_source_compliance, SOCKET_PUSH_SOURCE_TAGS}, + components::{SOCKET_PUSH_SOURCE_TAGS, assert_source_compliance}, wait_for_tcp, }, tls::{TlsConfig, TlsEnableableConfig}, - SourceSender, }; fn heartbeat_address() -> String { @@ -984,11 +984,12 @@ mod integration_tests { assert!(!events.is_empty()); let log = events[0].as_log(); - assert!(log - .get("line") - .unwrap() - .to_string_lossy() - .contains("Hello World")); + assert!( + log.get("line") + .unwrap() + .to_string_lossy() + .contains("Hello World") + ); assert!(log.get("host").is_some()); } diff --git a/src/sources/mongodb_metrics/mod.rs b/src/sources/mongodb_metrics/mod.rs index 021165671a83f..586786a3ecb27 100644 --- a/src/sources/mongodb_metrics/mod.rs +++ b/src/sources/mongodb_metrics/mod.rs @@ -2,21 +2,21 @@ use std::time::{Duration, Instant}; use chrono::Utc; use futures::{ - future::{join_all, try_join_all}, StreamExt, + future::{join_all, try_join_all}, }; use mongodb::{ - bson::{self, doc, from_document, Bson, Document}, + Client, + bson::{self, Bson, Document, doc, from_document}, error::Error as MongoError, options::ClientOptions, - Client, }; use serde_with::serde_as; use snafu::{ResultExt, Snafu}; use tokio::time; use tokio_stream::wrappers::IntervalStream; use vector_lib::configurable::configurable_component; -use vector_lib::{metric_tags, ByteSizeOf, EstimatedJsonEncodedSizeOf}; +use vector_lib::{ByteSizeOf, EstimatedJsonEncodedSizeOf, metric_tags}; use crate::{ config::{SourceConfig, SourceContext, SourceOutput}, @@ -1078,22 +1078,25 @@ mod tests { let endpoint = "mongodb://myDBReader:D1fficultP%40ssw0rd@mongos0.example.com:27017,mongos1.example.com:27017,mongos2.example.com:27017/?authSource=admin&tls=true"; let client_options = ClientOptions::parse(endpoint).await.unwrap(); let endpoint = sanitize_endpoint(endpoint, &client_options); - assert_eq!(&endpoint, "mongodb://mongos0.example.com:27017,mongos1.example.com:27017,mongos2.example.com:27017/?tls=true"); + assert_eq!( + &endpoint, + "mongodb://mongos0.example.com:27017,mongos1.example.com:27017,mongos2.example.com:27017/?tls=true" + ); } } #[cfg(all(test, feature = "mongodb_metrics-integration-tests"))] mod integration_tests { use futures::StreamExt; - use tokio::time::{timeout, Duration}; + use tokio::time::{Duration, timeout}; use super::*; use crate::{ + SourceSender, test_util::{ - components::{assert_source_compliance, PULL_SOURCE_TAGS}, + components::{PULL_SOURCE_TAGS, assert_source_compliance}, trace_init, }, - SourceSender, }; fn primary_mongo_address() -> String { diff --git a/src/sources/mqtt/integration_tests.rs b/src/sources/mqtt/integration_tests.rs index 7ba91d7a1e954..52c3a2e0c00ee 100644 --- a/src/sources/mqtt/integration_tests.rs +++ b/src/sources/mqtt/integration_tests.rs @@ -12,10 +12,10 @@ use tokio::time::timeout; use super::MqttSourceConfig; use crate::{ - config::{log_schema, SourceConfig, SourceContext}, + SourceSender, + config::{SourceConfig, SourceContext, log_schema}, event::Event, test_util::components::assert_source_compliance, - SourceSender, }; fn mqtt_broker_address() -> String { diff --git a/src/sources/mqtt/source.rs b/src/sources/mqtt/source.rs index 5bf8588f263b9..1a70b22ed5208 100644 --- a/src/sources/mqtt/source.rs +++ b/src/sources/mqtt/source.rs @@ -3,6 +3,7 @@ use vector_lib::config::LogNamespace; use vector_lib::internal_event::EventsReceived; use crate::{ + SourceSender, codecs::Decoder, common::mqtt::MqttConnector, event::BatchNotifier, @@ -11,7 +12,6 @@ use crate::{ shutdown::ShutdownSignal, sources::mqtt::MqttSourceConfig, sources::util, - SourceSender, }; use rumqttc::{Event as MqttEvent, Incoming, Publish, QoS}; use vector_lib::config::LegacyKey; diff --git a/src/sources/nats.rs b/src/sources/nats.rs index ece2934af6863..f7058228cfc35 100644 --- a/src/sources/nats.rs +++ b/src/sources/nats.rs @@ -1,5 +1,5 @@ use chrono::Utc; -use futures::{pin_mut, StreamExt}; +use futures::{StreamExt, pin_mut}; use snafu::{ResultExt, Snafu}; use tokio_util::codec::FramedRead; use vector_lib::codecs::decoding::{DeserializerConfig, FramingConfig, StreamDecodingError}; @@ -9,21 +9,21 @@ use vector_lib::internal_event::{ }; use vector_lib::lookup::{lookup_v2::OptionalValuePath, owned_value_path}; use vector_lib::{ - config::{LegacyKey, LogNamespace}, EstimatedJsonEncodedSizeOf, + config::{LegacyKey, LogNamespace}, }; use vrl::value::Kind; use crate::{ + SourceSender, codecs::{Decoder, DecodingConfig}, config::{GenerateConfig, SourceConfig, SourceContext, SourceOutput}, event::Event, internal_events::StreamClosedError, - nats::{from_tls_auth_config, NatsAuthConfig, NatsConfigError}, + nats::{NatsAuthConfig, NatsConfigError, from_tls_auth_config}, serde::{default_decoding, default_framing_message_based}, shutdown::ShutdownSignal, tls::TlsEnableableConfig, - SourceSender, }; #[derive(Debug, Snafu)] @@ -304,9 +304,9 @@ async fn create_subscription( mod tests { #![allow(clippy::print_stdout)] //tests - use vector_lib::lookup::{owned_value_path, OwnedTargetPath}; + use vector_lib::lookup::{OwnedTargetPath, owned_value_path}; use vector_lib::schema::Definition; - use vrl::value::{kind::Collection, Kind}; + use vrl::value::{Kind, kind::Collection}; use super::*; @@ -386,7 +386,7 @@ mod integration_tests { use crate::nats::{NatsAuthCredentialsFile, NatsAuthNKey, NatsAuthToken, NatsAuthUserPassword}; use crate::test_util::{ collect_n, - components::{assert_source_compliance, SOURCE_TAGS}, + components::{SOURCE_TAGS, assert_source_compliance}, random_string, }; use crate::tls::TlsConfig; diff --git a/src/sources/nginx_metrics/mod.rs b/src/sources/nginx_metrics/mod.rs index 9435c0a880451..ea2cf14539dbd 100644 --- a/src/sources/nginx_metrics/mod.rs +++ b/src/sources/nginx_metrics/mod.rs @@ -5,15 +5,15 @@ use std::{ use bytes::Bytes; use chrono::Utc; -use futures::{future::join_all, StreamExt, TryFutureExt}; +use futures::{StreamExt, TryFutureExt, future::join_all}; use http::{Request, StatusCode}; -use hyper::{body::to_bytes as body_to_bytes, Body, Uri}; +use hyper::{Body, Uri, body::to_bytes as body_to_bytes}; use serde_with::serde_as; use snafu::{ResultExt, Snafu}; use tokio::time; use tokio_stream::wrappers::IntervalStream; use vector_lib::configurable::configurable_component; -use vector_lib::{metric_tags, EstimatedJsonEncodedSizeOf}; +use vector_lib::{EstimatedJsonEncodedSizeOf, metric_tags}; use crate::{ config::{SourceConfig, SourceContext, SourceOutput}, @@ -280,7 +280,7 @@ mod integration_tests { use super::*; use crate::{ config::ProxyConfig, - test_util::components::{run_and_assert_source_compliance_advanced, HTTP_PULL_SOURCE_TAGS}, + test_util::components::{HTTP_PULL_SOURCE_TAGS, run_and_assert_source_compliance_advanced}, }; use tokio::time::Duration; diff --git a/src/sources/nginx_metrics/parser.rs b/src/sources/nginx_metrics/parser.rs index 8fda2786f2888..22049597745e2 100644 --- a/src/sources/nginx_metrics/parser.rs +++ b/src/sources/nginx_metrics/parser.rs @@ -1,11 +1,11 @@ use std::convert::TryFrom; use nom::{ + Parser, bytes::complete::{tag, take_while_m_n}, combinator::{all_consuming, map_res}, error::ErrorKind, sequence::{preceded, terminated}, - Parser, }; use snafu::Snafu; diff --git a/src/sources/opentelemetry/config.rs b/src/sources/opentelemetry/config.rs index 6d5c08c0676e9..b3c2ab3a38686 100644 --- a/src/sources/opentelemetry/config.rs +++ b/src/sources/opentelemetry/config.rs @@ -1,15 +1,15 @@ use std::net::SocketAddr; use futures::FutureExt; -use futures_util::{future::join, TryFutureExt}; +use futures_util::{TryFutureExt, future::join}; use tonic::{codec::CompressionEncoding, transport::server::RoutesBuilder}; use vector_lib::{ - config::{log_schema, LegacyKey, LogNamespace}, + config::{LegacyKey, LogNamespace, log_schema}, configurable::configurable_component, internal_event::{BytesReceived, EventsReceived, Protocol}, - lookup::{owned_value_path, OwnedTargetPath}, + lookup::{OwnedTargetPath, owned_value_path}, opentelemetry::{ logs::{ ATTRIBUTES_KEY, DROPPED_ATTRIBUTES_COUNT_KEY, FLAGS_KEY, OBSERVED_TIMESTAMP_KEY, @@ -33,17 +33,17 @@ use crate::{ http::KeepaliveConfig, serde::bool_or_struct, sources::{ + Source, http_server::{build_param_matcher, remove_duplicates}, opentelemetry::{ grpc::Service, http::{build_warp_filter, run_http_server}, }, util::grpc::run_grpc_server_with_routes, - Source, }, }; -use vrl::value::{kind::Collection, Kind}; +use vrl::value::{Kind, kind::Collection}; pub const LOGS: &str = "logs"; pub const METRICS: &str = "metrics"; diff --git a/src/sources/opentelemetry/grpc.rs b/src/sources/opentelemetry/grpc.rs index 6b894b8c626e0..463471626a1c0 100644 --- a/src/sources/opentelemetry/grpc.rs +++ b/src/sources/opentelemetry/grpc.rs @@ -3,26 +3,26 @@ use tonic::{Request, Response, Status}; use vector_lib::internal_event::{CountByteSize, InternalEventHandle as _, Registered}; use vector_lib::opentelemetry::proto::collector::{ logs::v1::{ - logs_service_server::LogsService, ExportLogsServiceRequest, ExportLogsServiceResponse, + ExportLogsServiceRequest, ExportLogsServiceResponse, logs_service_server::LogsService, }, metrics::v1::{ - metrics_service_server::MetricsService, ExportMetricsServiceRequest, - ExportMetricsServiceResponse, + ExportMetricsServiceRequest, ExportMetricsServiceResponse, + metrics_service_server::MetricsService, }, trace::v1::{ - trace_service_server::TraceService, ExportTraceServiceRequest, ExportTraceServiceResponse, + ExportTraceServiceRequest, ExportTraceServiceResponse, trace_service_server::TraceService, }, }; use vector_lib::{ + EstimatedJsonEncodedSizeOf, config::LogNamespace, event::{BatchNotifier, BatchStatus, BatchStatusReceiver, Event}, - EstimatedJsonEncodedSizeOf, }; use crate::{ + SourceSender, internal_events::{EventsReceived, StreamClosedError}, sources::opentelemetry::config::{LOGS, METRICS, TRACES}, - SourceSender, }; #[derive(Clone)] diff --git a/src/sources/opentelemetry/http.rs b/src/sources/opentelemetry/http.rs index c3c9fc51f4ac7..c878cdee2c24f 100644 --- a/src/sources/opentelemetry/http.rs +++ b/src/sources/opentelemetry/http.rs @@ -4,7 +4,7 @@ use std::{convert::Infallible, net::SocketAddr}; use bytes::Bytes; use futures_util::FutureExt; use http::StatusCode; -use hyper::{service::make_service_fn, Server}; +use hyper::{Server, service::make_service_fn}; use prost::Message; use snafu::Snafu; use tokio::net::TcpStream; @@ -20,12 +20,12 @@ use vector_lib::opentelemetry::proto::collector::{ }; use vector_lib::tls::MaybeTlsIncomingStream; use vector_lib::{ + EstimatedJsonEncodedSizeOf, config::LogNamespace, event::{BatchNotifier, BatchStatus}, - EstimatedJsonEncodedSizeOf, }; use warp::{ - filters::BoxedFilter, http::HeaderMap, reject::Rejection, reply::Response, Filter, Reply, + Filter, Reply, filters::BoxedFilter, http::HeaderMap, reject::Rejection, reply::Response, }; use crate::common::http::ErrorMessage; @@ -33,17 +33,17 @@ use crate::http::{KeepaliveConfig, MaxConnectionAgeLayer}; use crate::sources::http_server::HttpConfigParamKind; use crate::sources::util::add_headers; use crate::{ + SourceSender, event::Event, http::build_http_trace_layer, internal_events::{EventsReceived, StreamClosedError}, shutdown::ShutdownSignal, sources::util::decode, tls::MaybeTlsSettings, - SourceSender, }; use super::{reply::protobuf, status::Status}; -use crate::sources::opentelemetry::config::{OpentelemetryConfig, LOGS, METRICS, TRACES}; +use crate::sources::opentelemetry::config::{LOGS, METRICS, OpentelemetryConfig, TRACES}; #[derive(Clone, Copy, Debug, Snafu)] pub(crate) enum ApiError { diff --git a/src/sources/opentelemetry/integration_tests.rs b/src/sources/opentelemetry/integration_tests.rs index 0d6644e9070b7..d45fa5f51778b 100644 --- a/src/sources/opentelemetry/integration_tests.rs +++ b/src/sources/opentelemetry/integration_tests.rs @@ -4,14 +4,14 @@ use itertools::Itertools; use serde_json::json; use crate::{ - config::{log_schema, SourceConfig, SourceContext}, + config::{SourceConfig, SourceContext, log_schema}, event::EventStatus, sources::opentelemetry::config::{ - GrpcConfig, HttpConfig, OpentelemetryConfig, LOGS, METRICS, TRACES, + GrpcConfig, HttpConfig, LOGS, METRICS, OpentelemetryConfig, TRACES, }, test_util::{ collect_n, - components::{assert_source_compliance, SOURCE_TAGS}, + components::{SOURCE_TAGS, assert_source_compliance}, retry_until, wait_for_tcp, }, }; @@ -20,10 +20,10 @@ use prost::Message; use super::tests::new_source; use vector_lib::opentelemetry::proto::{ collector::{metrics::v1::ExportMetricsServiceRequest, trace::v1::ExportTraceServiceRequest}, - common::v1::{any_value::Value::StringValue, AnyValue, InstrumentationScope, KeyValue}, + common::v1::{AnyValue, InstrumentationScope, KeyValue, any_value::Value::StringValue}, metrics::v1::{ - metric::Data, number_data_point::Value, Gauge, Metric, NumberDataPoint, ResourceMetrics, - ScopeMetrics, + Gauge, Metric, NumberDataPoint, ResourceMetrics, ScopeMetrics, metric::Data, + number_data_point::Value, }, resource::v1::Resource, trace::v1::{ResourceSpans, ScopeSpans, Span}, diff --git a/src/sources/opentelemetry/reply.rs b/src/sources/opentelemetry/reply.rs index 25bdd7dd6070b..66697a6571d5f 100644 --- a/src/sources/opentelemetry/reply.rs +++ b/src/sources/opentelemetry/reply.rs @@ -1,7 +1,7 @@ use bytes::BytesMut; -use http::{header::CONTENT_TYPE, HeaderValue}; +use http::{HeaderValue, header::CONTENT_TYPE}; use prost::Message; -use warp::{reply::Response, Reply}; +use warp::{Reply, reply::Response}; use super::status::Status; diff --git a/src/sources/opentelemetry/tests.rs b/src/sources/opentelemetry/tests.rs index f8920cdd3c89e..aaf4126b81469 100644 --- a/src/sources/opentelemetry/tests.rs +++ b/src/sources/opentelemetry/tests.rs @@ -2,17 +2,17 @@ use crate::config::OutputId; use crate::event::metric::{Bucket, Quantile}; use crate::event::{MetricKind, MetricTags, MetricValue}; use crate::{ + SourceSender, config::{SourceConfig, SourceContext}, event::{ - into_event_stream, Event, EventStatus, LogEvent, Metric as MetricEvent, ObjectMap, Value, + Event, EventStatus, LogEvent, Metric as MetricEvent, ObjectMap, Value, into_event_stream, }, - sources::opentelemetry::config::{GrpcConfig, HttpConfig, OpentelemetryConfig, LOGS, METRICS}, + sources::opentelemetry::config::{GrpcConfig, HttpConfig, LOGS, METRICS, OpentelemetryConfig}, test_util::{ self, - components::{assert_source_compliance, SOURCE_TAGS}, + components::{SOURCE_TAGS, assert_source_compliance}, next_addr, }, - SourceSender, }; use chrono::{DateTime, TimeZone, Utc}; use futures::Stream; @@ -26,18 +26,18 @@ use vector_lib::config::LogNamespace; use vector_lib::lookup::path; use vector_lib::opentelemetry::proto::{ collector::{ - logs::v1::{logs_service_client::LogsServiceClient, ExportLogsServiceRequest}, - metrics::v1::{metrics_service_client::MetricsServiceClient, ExportMetricsServiceRequest}, + logs::v1::{ExportLogsServiceRequest, logs_service_client::LogsServiceClient}, + metrics::v1::{ExportMetricsServiceRequest, metrics_service_client::MetricsServiceClient}, }, common::v1::{ - any_value, any_value::Value::StringValue, AnyValue, InstrumentationScope, KeyValue, + AnyValue, InstrumentationScope, KeyValue, any_value, any_value::Value::StringValue, }, logs::v1::{LogRecord, ResourceLogs, ScopeLogs}, metrics::v1::{ - exponential_histogram_data_point::Buckets, metric::Data, - summary_data_point::ValueAtQuantile, AggregationTemporality, ExponentialHistogram, - ExponentialHistogramDataPoint, Gauge, Histogram, HistogramDataPoint, Metric, - NumberDataPoint, ResourceMetrics, ScopeMetrics, Sum, Summary, SummaryDataPoint, + AggregationTemporality, ExponentialHistogram, ExponentialHistogramDataPoint, Gauge, + Histogram, HistogramDataPoint, Metric, NumberDataPoint, ResourceMetrics, ScopeMetrics, Sum, + Summary, SummaryDataPoint, exponential_histogram_data_point::Buckets, metric::Data, + summary_data_point::ValueAtQuantile, }, resource::v1::{Resource, Resource as OtelResource}, }; @@ -129,10 +129,11 @@ async fn receive_grpc_logs_vector_namespace() { meta.get(path!("vector", "source_type")).unwrap(), &value!(OpentelemetryConfig::NAME) ); - assert!(meta - .get(path!("vector", "ingest_timestamp")) - .unwrap() - .is_timestamp()); + assert!( + meta.get(path!("vector", "ingest_timestamp")) + .unwrap() + .is_timestamp() + ); assert_eq!( meta.get(path!("opentelemetry", "resources")).unwrap(), &value!({res_key: "res_val"}) diff --git a/src/sources/postgresql_metrics.rs b/src/sources/postgresql_metrics.rs index 4d670110910d2..85f5fb63af661 100644 --- a/src/sources/postgresql_metrics.rs +++ b/src/sources/postgresql_metrics.rs @@ -8,8 +8,8 @@ use std::{ use chrono::{DateTime, Utc}; use futures::{ - future::{join_all, try_join_all}, FutureExt, StreamExt, + future::{join_all, try_join_all}, }; use openssl::{ error::ErrorStack, @@ -20,18 +20,18 @@ use serde_with::serde_as; use snafu::{ResultExt, Snafu}; use tokio::time; use tokio_postgres::{ + Client, Config, Error as PgError, NoTls, Row, config::{ChannelBinding, Host, SslMode, TargetSessionAttrs}, types::FromSql, - Client, Config, Error as PgError, NoTls, Row, }; use tokio_stream::wrappers::IntervalStream; use vector_lib::config::LogNamespace; use vector_lib::configurable::configurable_component; +use vector_lib::{ByteSizeOf, EstimatedJsonEncodedSizeOf, metric_tags}; use vector_lib::{ internal_event::{CountByteSize, InternalEventHandle as _, Registered}, json_size::JsonSize, }; -use vector_lib::{metric_tags, ByteSizeOf, EstimatedJsonEncodedSizeOf}; use crate::{ config::{SourceConfig, SourceContext, SourceOutput}, @@ -345,7 +345,7 @@ impl PostgresqlClient { Ok(_) | Err(_) => { return Err(ConnectError::InvalidVersion { version: version.to_string(), - }) + }); } }; @@ -517,7 +517,7 @@ impl PostgresqlMetrics { _ => { return Err(BuildError::MultipleHostsNotSupported { hosts: config.get_hosts().to_owned(), - }) + }); } }; @@ -692,17 +692,21 @@ impl PostgresqlMetrics { metrics.extend_from_slice(&[ self.create_metric( "pg_stat_database_checksum_failures_total", - counter!(reader - .read::>(row, "checksum_failures")? - .unwrap_or(0)), + counter!( + reader + .read::>(row, "checksum_failures")? + .unwrap_or(0) + ), tags!(self.tags, "db" => db), ), self.create_metric( "pg_stat_database_checksum_last_failure", - gauge!(reader - .read::>>(row, "checksum_last_failure")? - .map(|t| t.timestamp()) - .unwrap_or(0)), + gauge!( + reader + .read::>>(row, "checksum_last_failure")? + .map(|t| t.timestamp()) + .unwrap_or(0) + ), tags!(self.tags, "db" => db), ), ]); @@ -720,10 +724,12 @@ impl PostgresqlMetrics { ), self.create_metric( "pg_stat_database_stats_reset", - gauge!(reader - .read::>>(row, "stats_reset")? - .map(|t| t.timestamp()) - .unwrap_or(0)), + gauge!( + reader + .read::>>(row, "stats_reset")? + .map(|t| t.timestamp()) + .unwrap_or(0) + ), tags!(self.tags, "db" => db), ), ]); @@ -842,9 +848,11 @@ impl PostgresqlMetrics { ), self.create_metric( "pg_stat_bgwriter_stats_reset", - gauge!(reader - .read::>(&row, "stats_reset")? - .timestamp()), + gauge!( + reader + .read::>(&row, "stats_reset")? + .timestamp() + ), tags!(self.tags), ), ], @@ -997,12 +1005,13 @@ mod tests { mod integration_tests { use super::*; use crate::{ + SourceSender, event::Event, test_util::{ - components::{assert_source_compliance, PULL_SOURCE_TAGS}, + components::{PULL_SOURCE_TAGS, assert_source_compliance}, integration::postgres::{pg_socket, pg_url}, }, - tls, SourceSender, + tls, }; async fn test_postgresql_metrics( diff --git a/src/sources/prometheus/parser.rs b/src/sources/prometheus/parser.rs index b05f98cf99164..c9d3cb38772c2 100644 --- a/src/sources/prometheus/parser.rs +++ b/src/sources/prometheus/parser.rs @@ -6,8 +6,8 @@ use vector_lib::prometheus::parser::proto; use vector_lib::prometheus::parser::{GroupKind, MetricGroup, ParserError}; use crate::event::{ - metric::{Bucket, Metric, MetricKind, MetricTags, MetricValue, Quantile}, Event, + metric::{Bucket, Metric, MetricKind, MetricTags, MetricValue, Quantile}, }; fn utc_timestamp(timestamp: Option, default: DateTime) -> DateTime { @@ -224,12 +224,14 @@ mod test { assert_event_data_eq!( events_to_metrics(parse_text(exp)), - Ok(vec![Metric::new( - "uptime", - MetricKind::Absolute, - MetricValue::Counter { value: 123.0 }, - ) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "uptime", + MetricKind::Absolute, + MetricValue::Counter { value: 123.0 }, + ) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -356,12 +358,14 @@ mod test { assert_event_data_eq!( events_to_metrics(parse_text(exp)), - Ok(vec![Metric::new( - "latency", - MetricKind::Absolute, - MetricValue::Gauge { value: 123.0 }, - ) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "latency", + MetricKind::Absolute, + MetricValue::Gauge { value: 123.0 }, + ) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -373,12 +377,14 @@ mod test { assert_event_data_eq!( events_to_metrics(parse_text(exp)), - Ok(vec![Metric::new( - "metric_without_timestamp_and_labels", - MetricKind::Absolute, - MetricValue::Gauge { value: 12.47 }, - ) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "metric_without_timestamp_and_labels", + MetricKind::Absolute, + MetricValue::Gauge { value: 12.47 }, + ) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -390,12 +396,14 @@ mod test { assert_event_data_eq!( events_to_metrics(parse_text(exp)), - Ok(vec![Metric::new( - "no_labels", - MetricKind::Absolute, - MetricValue::Gauge { value: 3.0 }, - ) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "no_labels", + MetricKind::Absolute, + MetricValue::Gauge { value: 3.0 }, + ) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -407,18 +415,20 @@ mod test { assert_event_data_eq!( events_to_metrics(parse_text(exp)), - Ok(vec![Metric::new( - "msdos_file_access_time_seconds", - MetricKind::Absolute, - MetricValue::Gauge { - value: 1458255915.0 - }, - ) - .with_tags(Some(metric_tags!( - "path" => "C:\\DIR\\FILE.TXT", - "error" => "Cannot find file:\n\"FILE.TXT\"", - ))) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "msdos_file_access_time_seconds", + MetricKind::Absolute, + MetricValue::Gauge { + value: 1458255915.0 + }, + ) + .with_tags(Some(metric_tags!( + "path" => "C:\\DIR\\FILE.TXT", + "error" => "Cannot find file:\n\"FILE.TXT\"", + ))) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -431,13 +441,15 @@ mod test { "#; assert_event_data_eq!( events_to_metrics(parse_text(exp)), - Ok(vec![Metric::new( - "name", - MetricKind::Absolute, - MetricValue::Counter { value: 0.0 }, - ) - .with_tags(Some(metric_tags! { "tag" => "}" })) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "name", + MetricKind::Absolute, + MetricValue::Counter { value: 0.0 }, + ) + .with_tags(Some(metric_tags! { "tag" => "}" })) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -450,13 +462,15 @@ mod test { "#; assert_event_data_eq!( events_to_metrics(parse_text(exp)), - Ok(vec![Metric::new( - "name", - MetricKind::Absolute, - MetricValue::Counter { value: 0.0 }, - ) - .with_tags(Some(metric_tags! { "tag" => "a,b" })) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "name", + MetricKind::Absolute, + MetricValue::Counter { value: 0.0 }, + ) + .with_tags(Some(metric_tags! { "tag" => "a,b" })) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -469,13 +483,15 @@ mod test { "#; assert_event_data_eq!( events_to_metrics(parse_text(exp)), - Ok(vec![Metric::new( - "name", - MetricKind::Absolute, - MetricValue::Counter { value: 0.0 }, - ) - .with_tags(Some(metric_tags! { "tag" => "\\n" })) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "name", + MetricKind::Absolute, + MetricValue::Counter { value: 0.0 }, + ) + .with_tags(Some(metric_tags! { "tag" => "\\n" })) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -488,13 +504,15 @@ mod test { "#; assert_event_data_eq!( events_to_metrics(parse_text(exp)), - Ok(vec![Metric::new( - "name", - MetricKind::Absolute, - MetricValue::Counter { value: 0.0 }, - ) - .with_tags(Some(metric_tags! { "tag" => " * " })) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "name", + MetricKind::Absolute, + MetricValue::Counter { value: 0.0 }, + ) + .with_tags(Some(metric_tags! { "tag" => " * " })) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -506,14 +524,16 @@ mod test { assert_event_data_eq!( events_to_metrics(parse_text(exp)), - Ok(vec![Metric::new( - "telemetry_scrape_size_bytes_count", - MetricKind::Absolute, - MetricValue::Gauge { value: 1890.0 }, - ) - .with_tags(Some(metric_tags!( "registry" => "default", + Ok(vec![ + Metric::new( + "telemetry_scrape_size_bytes_count", + MetricKind::Absolute, + MetricValue::Gauge { value: 1890.0 }, + ) + .with_tags(Some(metric_tags!( "registry" => "default", "content_type" => "text/plain; version=0.0.4" ))) - .with_timestamp(Some(*TIMESTAMP))]), + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -543,17 +563,17 @@ mod test { assert_event_data_eq!( events_to_metrics(parse_text(exp)), - Ok(vec![Metric::new( - "something_weird", - MetricKind::Absolute, - MetricValue::Gauge { - value: f64::INFINITY - }, - ) - .with_timestamp(Utc.timestamp_opt(-3982045, 0).latest()) - .with_tags(Some( - metric_tags!("problem" => "division by zero") - ))]), + Ok(vec![ + Metric::new( + "something_weird", + MetricKind::Absolute, + MetricValue::Gauge { + value: f64::INFINITY + }, + ) + .with_timestamp(Utc.timestamp_opt(-3982045, 0).latest()) + .with_tags(Some(metric_tags!("problem" => "division by zero"))) + ]), ); } @@ -701,18 +721,20 @@ mod test { assert_event_data_eq!( events_to_metrics(parse_text(exp)), - Ok(vec![Metric::new( - "http_request_duration_seconds", - MetricKind::Absolute, - MetricValue::AggregatedHistogram { - buckets: vector_lib::buckets![ - 0.05 => 24054, 0.1 => 9390, 0.2 => 66948, 0.5 => 28997, 1.0 => 4599 - ], - count: 144320, - sum: 53423.0, - }, - ) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "http_request_duration_seconds", + MetricKind::Absolute, + MetricValue::AggregatedHistogram { + buckets: vector_lib::buckets![ + 0.05 => 24054, 0.1 => 9390, 0.2 => 66948, 0.5 => 28997, 1.0 => 4599 + ], + count: 144320, + sum: 53423.0, + }, + ) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -729,16 +751,18 @@ mod test { assert_event_data_eq!( events_to_metrics(parse_text(exp)), - Ok(vec![Metric::new( - "duration", - MetricKind::Absolute, - MetricValue::AggregatedHistogram { - buckets: vector_lib::buckets![1.0 => 133988], - count: 144320, - sum: 53423.0, - }, - ) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "duration", + MetricKind::Absolute, + MetricValue::AggregatedHistogram { + buckets: vector_lib::buckets![1.0 => 133988], + count: 144320, + sum: 53423.0, + }, + ) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -756,16 +780,18 @@ mod test { assert_event_data_eq!( events_to_metrics(parse_text(exp)), - Ok(vec![Metric::new( - "duration", - MetricKind::Absolute, - MetricValue::AggregatedHistogram { - buckets: vector_lib::buckets![1.0 => 2000, 10.0 => 0], - count: 2000, - sum: 2000.0, - }, - ) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "duration", + MetricKind::Absolute, + MetricValue::AggregatedHistogram { + buckets: vector_lib::buckets![1.0 => 2000, 10.0 => 0], + count: 2000, + sum: 2000.0, + }, + ) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -1077,13 +1103,15 @@ mod test { assert_event_data_eq!( events_to_metrics(parse_text_with_overrides(exp, vec![], false)), - Ok(vec![Metric::new( - "jobs_total", - MetricKind::Absolute, - MetricValue::Counter { value: 1.0 }, - ) - .with_tags(Some(metric_tags! { "type" => "a" })) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "jobs_total", + MetricKind::Absolute, + MetricValue::Counter { value: 1.0 }, + ) + .with_tags(Some(metric_tags! { "type" => "a" })) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -1101,13 +1129,15 @@ mod test { vec![("type".to_owned(), "b".to_owned())], false )), - Ok(vec![Metric::new( - "jobs_total", - MetricKind::Absolute, - MetricValue::Counter { value: 1.0 }, - ) - .with_tags(Some(metric_tags! { "type" => "b" })) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "jobs_total", + MetricKind::Absolute, + MetricValue::Counter { value: 1.0 }, + ) + .with_tags(Some(metric_tags! { "type" => "b" })) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } @@ -1130,13 +1160,15 @@ mod test { ], false )), - Ok(vec![Metric::new( - "jobs_total", - MetricKind::Absolute, - MetricValue::Counter { value: 1.0 }, - ) - .with_tags(Some(metric_tags! { "type" => "c" })) - .with_timestamp(Some(*TIMESTAMP))]), + Ok(vec![ + Metric::new( + "jobs_total", + MetricKind::Absolute, + MetricValue::Counter { value: 1.0 }, + ) + .with_tags(Some(metric_tags! { "type" => "c" })) + .with_timestamp(Some(*TIMESTAMP)) + ]), ); } diff --git a/src/sources/prometheus/pushgateway.rs b/src/sources/prometheus/pushgateway.rs index 8a08b126489a0..f5e6f4d8b25d2 100644 --- a/src/sources/prometheus/pushgateway.rs +++ b/src/sources/prometheus/pushgateway.rs @@ -11,8 +11,8 @@ //! - Only counters and histograms can be aggregated as there is no meaningful //! way to aggregate gauges or summaries. -use base64::prelude::BASE64_URL_SAFE; use base64::Engine; +use base64::prelude::BASE64_URL_SAFE; use std::{collections::HashMap, net::SocketAddr}; use bytes::Bytes; @@ -22,8 +22,8 @@ use vector_lib::configurable::configurable_component; use warp::http::HeaderMap; use super::parser; -use crate::common::http::server_auth::HttpServerAuthConfig; use crate::common::http::ErrorMessage; +use crate::common::http::server_auth::HttpServerAuthConfig; use crate::http::KeepaliveConfig; use crate::{ config::{ @@ -33,7 +33,7 @@ use crate::{ serde::bool_or_struct, sources::{ self, - util::{http::HttpMethod, HttpSource}, + util::{HttpSource, http::HttpMethod}, }, tls::TlsEnableableConfig, }; @@ -251,9 +251,9 @@ fn decode_label_pair(k: &str, v: &str) -> Result<(String, String), ErrorMessage> #[cfg(test)] mod test { use super::*; - use crate::test_util::components::{assert_source_compliance, HTTP_PUSH_SOURCE_TAGS}; + use crate::test_util::components::{HTTP_PUSH_SOURCE_TAGS, assert_source_compliance}; use crate::test_util::wait_for_tcp; - use crate::{test_util, SourceSender}; + use crate::{SourceSender, test_util}; use chrono::{TimeZone, Timelike, Utc}; use vector_lib::event::{EventStatus, Metric, MetricKind, MetricValue}; use vector_lib::tls::MaybeTlsSettings; diff --git a/src/sources/prometheus/remote_write.rs b/src/sources/prometheus/remote_write.rs index 9a377ec3ebbc5..6111532ae3397 100644 --- a/src/sources/prometheus/remote_write.rs +++ b/src/sources/prometheus/remote_write.rs @@ -9,7 +9,7 @@ use warp::http::{HeaderMap, StatusCode}; use super::parser; use crate::{ - common::http::{server_auth::HttpServerAuthConfig, ErrorMessage}, + common::http::{ErrorMessage, server_auth::HttpServerAuthConfig}, config::{ GenerateConfig, SourceAcknowledgementsConfig, SourceConfig, SourceContext, SourceOutput, }, @@ -19,7 +19,7 @@ use crate::{ serde::bool_or_struct, sources::{ self, - util::{decode, http::HttpMethod, HttpSource}, + util::{HttpSource, decode, http::HttpMethod}, }, tls::TlsEnableableConfig, }; @@ -158,11 +158,11 @@ mod test { use super::*; use crate::{ + SourceSender, config::{SinkConfig, SinkContext}, sinks::prometheus::remote_write::RemoteWriteConfig, test_util::{self, wait_for_tcp}, tls::MaybeTlsSettings, - SourceSender, }; #[test] @@ -305,28 +305,32 @@ mod test { let timestamp = Utc::now().trunc_subsecs(3); - let events = vec![Metric::new( - "gauge_2", - MetricKind::Absolute, - MetricValue::Gauge { value: 41.0 }, - ) - .with_timestamp(Some(timestamp)) - .with_tags(Some(metric_tags! { - "code" => "200".to_string(), - "code" => "success".to_string(), - })) - .into()]; - - let expected = vec![Metric::new( - "gauge_2", - MetricKind::Absolute, - MetricValue::Gauge { value: 41.0 }, - ) - .with_timestamp(Some(timestamp)) - .with_tags(Some(metric_tags! { - "code" => "success".to_string(), - })) - .into()]; + let events = vec![ + Metric::new( + "gauge_2", + MetricKind::Absolute, + MetricValue::Gauge { value: 41.0 }, + ) + .with_timestamp(Some(timestamp)) + .with_tags(Some(metric_tags! { + "code" => "200".to_string(), + "code" => "success".to_string(), + })) + .into(), + ]; + + let expected = vec![ + Metric::new( + "gauge_2", + MetricKind::Absolute, + MetricValue::Gauge { value: 41.0 }, + ) + .with_timestamp(Some(timestamp)) + .with_tags(Some(metric_tags! { + "code" => "success".to_string(), + })) + .into(), + ]; let output = test_util::spawn_collect_ready( async move { @@ -347,7 +351,7 @@ mod integration_tests { use tokio::time::Duration; use super::*; - use crate::test_util::components::{run_and_assert_source_compliance, HTTP_PUSH_SOURCE_TAGS}; + use crate::test_util::components::{HTTP_PUSH_SOURCE_TAGS, run_and_assert_source_compliance}; fn source_receive_address() -> SocketAddr { let address = std::env::var("REMOTE_WRITE_SOURCE_RECEIVE_ADDRESS") diff --git a/src/sources/prometheus/scrape.rs b/src/sources/prometheus/scrape.rs index 7c6e2a2c43e3a..512fc73421218 100644 --- a/src/sources/prometheus/scrape.rs +++ b/src/sources/prometheus/scrape.rs @@ -3,7 +3,7 @@ use std::time::Duration; use bytes::Bytes; use futures_util::FutureExt; -use http::{response::Parts, Uri}; +use http::{Uri, response::Parts}; use serde_with::serde_as; use snafu::ResultExt; use vector_lib::configurable::configurable_component; @@ -14,18 +14,18 @@ use crate::http::QueryParameters; use crate::sources::util::http::HttpMethod; use crate::sources::util::http_client::{default_timeout, warn_if_interval_too_low}; use crate::{ + Result, config::{GenerateConfig, SourceConfig, SourceContext, SourceOutput}, http::Auth, internal_events::PrometheusParseError, sources::{ self, util::http_client::{ - build_url, call, default_interval, GenericHttpClientInputs, HttpClientBuilder, - HttpClientContext, + GenericHttpClientInputs, HttpClientBuilder, HttpClientContext, build_url, call, + default_interval, }, }, tls::{TlsConfig, TlsSettings}, - Result, }; // pulled up, and split over multiple lines, because the long lines trip up rustfmt such that it @@ -321,23 +321,22 @@ impl HttpClientContext for PrometheusScrapeContext { #[cfg(all(test, feature = "sinks-prometheus"))] mod test { use hyper::{ - service::{make_service_fn, service_fn}, Body, Client, Response, Server, + service::{make_service_fn, service_fn}, }; use similar_asserts::assert_eq; - use tokio::time::{sleep, Duration}; + use tokio::time::{Duration, sleep}; use warp::Filter; use super::*; use crate::{ - config, + Error, config, http::{ParameterValue, QueryParameterValue}, sinks::prometheus::exporter::PrometheusExporterConfig, test_util::{ - components::{run_and_assert_source_compliance, HTTP_PULL_SOURCE_TAGS}, + components::{HTTP_PULL_SOURCE_TAGS, run_and_assert_source_compliance}, next_addr, start_topology, trace_init, wait_for_tcp, }, - Error, }; #[test] @@ -725,7 +724,9 @@ mod test { .lines() .collect::>(); - assert_eq!(lines, vec![ + assert_eq!( + lines, + vec![ "# HELP vector_http_request_duration_seconds http_request_duration_seconds", "# TYPE vector_http_request_duration_seconds histogram", "vector_http_request_duration_seconds_bucket{le=\"0.05\"} 24054 1612411516789", @@ -752,8 +753,8 @@ mod test { "vector_rpc_duration_seconds{code=\"200\",quantile=\"0.99\"} 76656 1612411516789", "vector_rpc_duration_seconds_sum{code=\"200\"} 17560473 1612411516789", "vector_rpc_duration_seconds_count{code=\"200\"} 2693 1612411516789", - ], - ); + ], + ); topology.stop().await; } @@ -766,7 +767,7 @@ mod integration_tests { use super::*; use crate::{ event::{MetricKind, MetricValue}, - test_util::components::{run_and_assert_source_compliance, HTTP_PULL_SOURCE_TAGS}, + test_util::components::{HTTP_PULL_SOURCE_TAGS, run_and_assert_source_compliance}, }; #[tokio::test] diff --git a/src/sources/pulsar.rs b/src/sources/pulsar.rs index 349279667c91e..29b28f88fbef4 100644 --- a/src/sources/pulsar.rs +++ b/src/sources/pulsar.rs @@ -5,18 +5,19 @@ use chrono::TimeZone; use futures_util::StreamExt; use pulsar::{ + Authentication, Consumer, Pulsar, SubType, TokioExecutor, authentication::oauth2::{OAuth2Authentication, OAuth2Params}, consumer::Message, message::proto::MessageIdData, - Authentication, Consumer, Pulsar, SubType, TokioExecutor, }; use std::path::Path; use tokio_util::codec::FramedRead; use vector_lib::{ + EstimatedJsonEncodedSizeOf, codecs::{ - decoding::{DeserializerConfig, FramingConfig}, StreamDecodingError, + decoding::{DeserializerConfig, FramingConfig}, }, config::{LegacyKey, LogNamespace, SourceAcknowledgementsConfig, SourceOutput}, configurable::configurable_component, @@ -29,11 +30,11 @@ use vector_lib::{ }, sensitive_string::SensitiveString, shutdown::ShutdownSignal, - EstimatedJsonEncodedSizeOf, }; use vrl::{owned_value_path, path, value::Kind}; use crate::{ + SourceSender, codecs::{Decoder, DecodingConfig}, config::{SourceConfig, SourceContext}, event::BatchNotifier, @@ -41,7 +42,6 @@ use crate::{ PulsarErrorEvent, PulsarErrorEventData, PulsarErrorEventType, StreamClosedError, }, serde::{bool_or_struct, default_decoding, default_framing_message_based}, - SourceSender, }; /// Configuration for the `pulsar` source. @@ -552,7 +552,7 @@ mod tests { mod integration_tests { use super::*; use crate::config::log_schema; - use crate::test_util::components::{assert_source_compliance, SOURCE_TAGS}; + use crate::test_util::components::{SOURCE_TAGS, assert_source_compliance}; use crate::test_util::{collect_n, random_string, trace_init}; use crate::tls::TEST_PEM_INTERMEDIATE_CA_PATH; diff --git a/src/sources/redis/channel.rs b/src/sources/redis/channel.rs index 0e9089d804a30..2d5998c2a6271 100644 --- a/src/sources/redis/channel.rs +++ b/src/sources/redis/channel.rs @@ -4,8 +4,8 @@ use snafu::{ResultExt, Snafu}; use crate::{ internal_events::RedisReceiveEventError, sources::{ - redis::{ConnectionInfo, InputHandler}, Source, + redis::{ConnectionInfo, InputHandler}, }, }; diff --git a/src/sources/redis/list.rs b/src/sources/redis/list.rs index deed9f34443a7..5fb53a8989df9 100644 --- a/src/sources/redis/list.rs +++ b/src/sources/redis/list.rs @@ -1,4 +1,4 @@ -use redis::{aio::ConnectionManager, AsyncCommands, ErrorKind, RedisError, RedisResult}; +use redis::{AsyncCommands, ErrorKind, RedisError, RedisResult, aio::ConnectionManager}; use snafu::{ResultExt, Snafu}; use std::time::Duration; diff --git a/src/sources/redis/mod.rs b/src/sources/redis/mod.rs index b18c3c2ce12d7..075df94925441 100644 --- a/src/sources/redis/mod.rs +++ b/src/sources/redis/mod.rs @@ -4,23 +4,23 @@ use futures::StreamExt; use snafu::{ResultExt, Snafu}; use tokio_util::codec::FramedRead; use vector_lib::codecs::{ - decoding::{DeserializerConfig, FramingConfig}, StreamDecodingError, + decoding::{DeserializerConfig, FramingConfig}, }; use vector_lib::configurable::configurable_component; use vector_lib::internal_event::{ ByteSize, BytesReceived, CountByteSize, InternalEventHandle as _, Protocol, Registered, }; -use vector_lib::lookup::{lookup_v2::OptionalValuePath, owned_value_path, path, OwnedValuePath}; +use vector_lib::lookup::{OwnedValuePath, lookup_v2::OptionalValuePath, owned_value_path, path}; use vector_lib::{ - config::{LegacyKey, LogNamespace}, EstimatedJsonEncodedSizeOf, + config::{LegacyKey, LogNamespace}, }; use vrl::value::Kind; use crate::{ codecs::{Decoder, DecodingConfig}, - config::{log_schema, GenerateConfig, SourceConfig, SourceContext, SourceOutput}, + config::{GenerateConfig, SourceConfig, SourceContext, SourceOutput, log_schema}, event::Event, internal_events::{EventsReceived, StreamClosedError}, serde::{default_decoding, default_framing_message_based}, @@ -312,13 +312,13 @@ mod integration_test { use super::*; use crate::{ + SourceSender, config::log_schema, test_util::{ collect_n, - components::{run_and_assert_source_compliance_n, SOURCE_TAGS}, + components::{SOURCE_TAGS, run_and_assert_source_compliance_n}, random_string, }, - SourceSender, }; use vrl::value; diff --git a/src/sources/socket/mod.rs b/src/sources/socket/mod.rs index 77ebfa165930d..a8efa39f9fc0b 100644 --- a/src/sources/socket/mod.rs +++ b/src/sources/socket/mod.rs @@ -4,10 +4,10 @@ pub mod udp; mod unix; use vector_lib::codecs::decoding::DeserializerConfig; -use vector_lib::config::{log_schema, LegacyKey, LogNamespace}; +use vector_lib::config::{LegacyKey, LogNamespace, log_schema}; use vector_lib::configurable::configurable_component; use vector_lib::lookup::{lookup_v2::OptionalValuePath, owned_value_path}; -use vrl::value::{kind::Collection, Kind}; +use vrl::value::{Kind, kind::Collection}; use crate::{ codecs::DecodingConfig, @@ -321,25 +321,25 @@ mod test { collections::HashMap, net::{IpAddr, Ipv4Addr, SocketAddr, UdpSocket}, sync::{ - atomic::{AtomicBool, Ordering}, Arc, + atomic::{AtomicBool, Ordering}, }, thread, }; use bytes::{BufMut, Bytes, BytesMut}; - use futures::{stream, StreamExt}; - use rand::{rngs::SmallRng, seq::SliceRandom, SeedableRng}; + use futures::{StreamExt, stream}; + use rand::{SeedableRng, rngs::SmallRng, seq::SliceRandom}; use serde_json::json; use tokio::io::AsyncReadExt; use tokio::net::TcpStream; use tokio::{ task::JoinHandle, - time::{timeout, Duration, Instant}, + time::{Duration, Instant, timeout}, }; #[cfg(unix)] use vector_lib::codecs::{ - decoding::CharacterDelimitedDecoderOptions, CharacterDelimitedDecoderConfig, + CharacterDelimitedDecoderConfig, decoding::CharacterDelimitedDecoderOptions, }; use vector_lib::codecs::{GelfDeserializerConfig, NewlineDelimitedDecoderConfig}; use vector_lib::event::EventContainer; @@ -349,7 +349,7 @@ mod test { #[cfg(unix)] use { - super::{unix::UnixConfig, Mode}, + super::{Mode, unix::UnixConfig}, crate::sources::util::unix::UNNAMED_SOCKET_HOST, crate::test_util::wait_for, futures::{SinkExt, Stream}, @@ -364,9 +364,10 @@ mod test { tokio_util::codec::{FramedWrite, LinesCodec}, }; - use super::{tcp::TcpConfig, udp::UdpConfig, SocketConfig}; + use super::{SocketConfig, tcp::TcpConfig, udp::UdpConfig}; use crate::{ - config::{log_schema, ComponentKey, GlobalOptions, SourceConfig, SourceContext}, + SourceSender, + config::{ComponentKey, GlobalOptions, SourceConfig, SourceContext, log_schema}, event::{Event, LogEvent}, shutdown::{ShutdownSignal, SourceShutdownCoordinator}, sinks::util::tcp::TcpSinkConfig, @@ -374,13 +375,12 @@ mod test { test_util::{ collect_n, collect_n_limited, components::{ - assert_source_compliance, assert_source_error, COMPONENT_ERROR_TAGS, - SOCKET_PUSH_SOURCE_TAGS, + COMPONENT_ERROR_TAGS, SOCKET_PUSH_SOURCE_TAGS, assert_source_compliance, + assert_source_error, }, next_addr, next_addr_any, random_string, send_lines, send_lines_tls, wait_for_tcp, }, tls::{self, TlsConfig, TlsEnableableConfig, TlsSourceConfig}, - SourceSender, }; fn get_gelf_payload(message: &str) -> String { diff --git a/src/sources/socket/tcp.rs b/src/sources/socket/tcp.rs index 4c2a87ba4bf93..f731fbf766d3c 100644 --- a/src/sources/socket/tcp.rs +++ b/src/sources/socket/tcp.rs @@ -18,7 +18,7 @@ use crate::{ tls::TlsSourceConfig, }; -use super::{default_host_key, SocketConfig}; +use super::{SocketConfig, default_host_key}; /// TCP configuration for the `socket` source. #[serde_as] diff --git a/src/sources/socket/udp.rs b/src/sources/socket/udp.rs index c60d32d5abb66..56d54857326c6 100644 --- a/src/sources/socket/udp.rs +++ b/src/sources/socket/udp.rs @@ -7,18 +7,19 @@ use futures::StreamExt; use listenfd::ListenFd; use tokio_util::codec::FramedRead; use vector_lib::codecs::{ - decoding::{DeserializerConfig, FramingConfig}, StreamDecodingError, + decoding::{DeserializerConfig, FramingConfig}, }; use vector_lib::configurable::configurable_component; use vector_lib::internal_event::{ByteSize, BytesReceived, InternalEventHandle as _, Protocol}; use vector_lib::lookup::{lookup_v2::OptionalValuePath, owned_value_path, path}; use vector_lib::{ - config::{LegacyKey, LogNamespace}, EstimatedJsonEncodedSizeOf, + config::{LegacyKey, LogNamespace}, }; use crate::{ + SourceSender, codecs::Decoder, event::Event, internal_events::{ @@ -29,11 +30,10 @@ use crate::{ serde::default_decoding, shutdown::ShutdownSignal, sources::{ - socket::SocketConfig, - util::net::{try_bind_udp_socket, SocketListenAddr}, Source, + socket::SocketConfig, + util::net::{SocketListenAddr, try_bind_udp_socket}, }, - SourceSender, }; /// UDP configuration for the `socket` source. diff --git a/src/sources/socket/unix.rs b/src/sources/socket/unix.rs index 2ad3e695372a5..a51c5a8e6d7f0 100644 --- a/src/sources/socket/unix.rs +++ b/src/sources/socket/unix.rs @@ -9,17 +9,17 @@ use vector_lib::lookup::{lookup_v2::OptionalValuePath, path}; use vector_lib::shutdown::ShutdownSignal; use crate::{ + SourceSender, codecs::Decoder, event::Event, serde::default_decoding, sources::{ - util::{build_unix_datagram_source, build_unix_stream_source}, Source, + util::{build_unix_datagram_source, build_unix_stream_source}, }, - SourceSender, }; -use super::{default_host_key, SocketConfig}; +use super::{SocketConfig, default_host_key}; /// Unix domain socket configuration for the `socket` source. #[configurable_component] diff --git a/src/sources/splunk_hec/acknowledgements.rs b/src/sources/splunk_hec/acknowledgements.rs index 2e261582afaf5..9900d07aad7ca 100644 --- a/src/sources/splunk_hec/acknowledgements.rs +++ b/src/sources/splunk_hec/acknowledgements.rs @@ -2,8 +2,8 @@ use std::{ collections::HashMap, num::NonZeroU64, sync::{ - atomic::{AtomicU64, Ordering}, Arc, Mutex, RwLock, + atomic::{AtomicU64, Ordering}, }, time::{Duration, Instant}, }; @@ -311,10 +311,12 @@ mod tests { } // Let the ack finalizer task run sleep(time::Duration::from_secs(1)).await; - assert!(channel - .get_acks_status(&expected_ack_ids) - .values() - .all(|&status| status == result)); + assert!( + channel + .get_acks_status(&expected_ack_ids) + .values() + .all(|&status| status == result) + ); } #[tokio::test] @@ -330,15 +332,19 @@ mod tests { } // Let the ack finalizer task run sleep(time::Duration::from_secs(1)).await; - assert!(channel - .get_acks_status(&expected_ack_ids) - .values() - .all(|status| *status)); + assert!( + channel + .get_acks_status(&expected_ack_ids) + .values() + .all(|status| *status) + ); // Subsequent queries for the same ackId's should result in false - assert!(channel - .get_acks_status(&expected_ack_ids) - .values() - .all(|status| !*status)); + assert!( + channel + .get_acks_status(&expected_ack_ids) + .values() + .all(|status| !*status) + ); } #[tokio::test] @@ -359,15 +365,19 @@ mod tests { // Let the ack finalizer task run sleep(time::Duration::from_secs(1)).await; // The first 10 pending ack ids are dropped - assert!(channel - .get_acks_status(&dropped_pending_ack_ids) - .values() - .all(|status| !*status)); + assert!( + channel + .get_acks_status(&dropped_pending_ack_ids) + .values() + .all(|status| !*status) + ); // The second 10 pending ack ids can be queried - assert!(channel - .get_acks_status(&expected_ack_ids) - .values() - .all(|status| *status)); + assert!( + channel + .get_acks_status(&expected_ack_ids) + .values() + .all(|status| *status) + ); } #[tokio::test] @@ -399,18 +409,22 @@ mod tests { sleep(time::Duration::from_millis(100)).await; } sleep(time::Duration::from_secs(1)).await; - assert!(idx_ack - .get_acks_status_from_channel(channel.clone(), &dropped_pending_ack_ids) - .await - .unwrap() - .values() - .all(|status| !*status)); - assert!(idx_ack - .get_acks_status_from_channel(channel, &expected_ack_ids) - .await - .unwrap() - .values() - .all(|status| *status)); + assert!( + idx_ack + .get_acks_status_from_channel(channel.clone(), &dropped_pending_ack_ids) + .await + .unwrap() + .values() + .all(|status| !*status) + ); + assert!( + idx_ack + .get_acks_status_from_channel(channel, &expected_ack_ids) + .await + .unwrap() + .values() + .all(|status| *status) + ); } #[tokio::test] @@ -431,10 +445,12 @@ mod tests { .unwrap(); let (_tx, batch_rx) = BatchNotifier::new_with_receiver(); - assert!(idx_ack - .get_ack_id_from_channel(channel.clone(), batch_rx) - .await - .is_err()); + assert!( + idx_ack + .get_ack_id_from_channel(channel.clone(), batch_rx) + .await + .is_err() + ); } #[tokio::test] @@ -481,10 +497,12 @@ mod tests { .await .unwrap(); - assert!(idx_ack - .create_or_get_channel(String::from("channel-id-2")) - .await - .is_err()); + assert!( + idx_ack + .create_or_get_channel(String::from("channel-id-2")) + .await + .is_err() + ); } #[tokio::test] @@ -504,10 +522,12 @@ mod tests { .unwrap(); // Allow channel to expire and free up the max channel limit of 1 sleep(time::Duration::from_secs(3)).await; - assert!(idx_ack - .create_or_get_channel(String::from("channel-id-2")) - .await - .is_ok()); + assert!( + idx_ack + .create_or_get_channel(String::from("channel-id-2")) + .await + .is_ok() + ); } #[tokio::test] @@ -534,11 +554,13 @@ mod tests { ); } sleep(time::Duration::from_secs(2)).await; - assert!(idx_ack - .get_acks_status_from_channel(channel.clone(), &expected_ack_ids) - .await - .unwrap() - .values() - .all(|status| *status)); + assert!( + idx_ack + .get_acks_status_from_channel(channel.clone(), &expected_ack_ids) + .await + .unwrap() + .values() + .all(|status| *status) + ); } } diff --git a/src/sources/splunk_hec/mod.rs b/src/sources/splunk_hec/mod.rs index d1b2af8a801db..81b219921069e 100644 --- a/src/sources/splunk_hec/mod.rs +++ b/src/sources/splunk_hec/mod.rs @@ -12,12 +12,12 @@ use chrono::{DateTime, TimeZone, Utc}; use flate2::read::MultiGzDecoder; use futures::FutureExt; use http::StatusCode; -use hyper::{service::make_service_fn, Server}; -use serde::de::DeserializeOwned; +use hyper::{Server, service::make_service_fn}; use serde::Serialize; +use serde::de::DeserializeOwned; use serde_json::{ - de::{Read as JsonRead, StrRead}, Deserializer, Value as JsonValue, + de::{Read as JsonRead, StrRead}, }; use snafu::Snafu; use tokio::net::TcpStream; @@ -28,16 +28,16 @@ use vector_lib::lookup::lookup_v2::OptionalValuePath; use vector_lib::lookup::{self, event_path, owned_value_path}; use vector_lib::sensitive_string::SensitiveString; use vector_lib::{ + EstimatedJsonEncodedSizeOf, config::{LegacyKey, LogNamespace}, event::BatchNotifier, schema::meaning, - EstimatedJsonEncodedSizeOf, }; use vector_lib::{configurable::configurable_component, tls::MaybeTlsIncomingStream}; use vrl::path::OwnedTargetPath; -use vrl::value::{kind::Collection, Kind}; -use warp::http::header::{HeaderValue, CONTENT_TYPE}; -use warp::{filters::BoxedFilter, path, reject::Rejection, reply::Response, Filter, Reply}; +use vrl::value::{Kind, kind::Collection}; +use warp::http::header::{CONTENT_TYPE, HeaderValue}; +use warp::{Filter, Reply, filters::BoxedFilter, path, reject::Rejection, reply::Response}; use self::{ acknowledgements::{ @@ -47,16 +47,16 @@ use self::{ splunk_response::{HecResponse, HecResponseMetadata, HecStatusCode}, }; use crate::{ - config::{log_schema, DataType, Resource, SourceConfig, SourceContext, SourceOutput}, + SourceSender, + config::{DataType, Resource, SourceConfig, SourceContext, SourceOutput, log_schema}, event::{Event, LogEvent, Value}, - http::{build_http_trace_layer, KeepaliveConfig, MaxConnectionAgeLayer}, + http::{KeepaliveConfig, MaxConnectionAgeLayer, build_http_trace_layer}, internal_events::{ EventsReceived, HttpBytesReceived, SplunkHecRequestBodyInvalidError, SplunkHecRequestError, }, serde::bool_or_struct, source_sender::ClosedError, tls::{MaybeTlsSettings, TlsEnableableConfig}, - SourceSender, }; mod acknowledgements; @@ -1296,8 +1296,8 @@ mod tests { use reqwest::{RequestBuilder, Response}; use serde::Deserialize; use vector_lib::codecs::{ - decoding::DeserializerConfig, BytesDecoderConfig, JsonSerializerConfig, - TextSerializerConfig, + BytesDecoderConfig, JsonSerializerConfig, TextSerializerConfig, + decoding::DeserializerConfig, }; use vector_lib::sensitive_string::SensitiveString; use vector_lib::{event::EventStatus, schema::Definition}; @@ -1305,25 +1305,25 @@ mod tests { use super::*; use crate::{ + SourceSender, codecs::{DecodingConfig, EncodingConfig}, components::validation::prelude::*, - config::{log_schema, SinkConfig, SinkContext, SourceConfig, SourceContext}, + config::{SinkConfig, SinkContext, SourceConfig, SourceContext, log_schema}, event::{Event, LogEvent}, sinks::{ + Healthcheck, VectorSink, splunk_hec::logs::config::HecLogsSinkConfig, util::{BatchConfig, Compression, TowerRequestConfig}, - Healthcheck, VectorSink, }, sources::splunk_hec::acknowledgements::{HecAckStatusRequest, HecAckStatusResponse}, test_util::{ collect_n, components::{ - assert_source_compliance, assert_source_error, COMPONENT_ERROR_TAGS, - HTTP_PUSH_SOURCE_TAGS, + COMPONENT_ERROR_TAGS, HTTP_PUSH_SOURCE_TAGS, assert_source_compliance, + assert_source_error, }, next_addr, wait_for_tcp, }, - SourceSender, }; #[test] @@ -2252,10 +2252,12 @@ mod tests { event.as_log()[log_schema().message_key().unwrap().to_string()], message.into() ); - assert!(event - .as_log() - .get((PathPrefix::Event, log_schema().host_key().unwrap())) - .is_none()); + assert!( + event + .as_log() + .get((PathPrefix::Event, log_schema().host_key().unwrap())) + .is_none() + ); }) .await; } diff --git a/src/sources/static_metrics.rs b/src/sources/static_metrics.rs index 110aad634abfd..d0cbbba1de06d 100644 --- a/src/sources/static_metrics.rs +++ b/src/sources/static_metrics.rs @@ -11,17 +11,17 @@ use vector_lib::configurable::configurable_component; use vector_lib::internal_event::{ ByteSize, BytesReceived, CountByteSize, InternalEventHandle as _, Protocol, }; -use vector_lib::{config::LogNamespace, ByteSizeOf, EstimatedJsonEncodedSizeOf}; +use vector_lib::{ByteSizeOf, EstimatedJsonEncodedSizeOf, config::LogNamespace}; use crate::{ + SourceSender, config::{SourceConfig, SourceContext, SourceOutput}, event::{ - metric::{MetricData, MetricName, MetricSeries, MetricTime, MetricValue}, EventMetadata, Metric, MetricKind, + metric::{MetricData, MetricName, MetricSeries, MetricTime, MetricValue}, }, internal_events::{EventsReceived, StreamClosedError}, shutdown::ShutdownSignal, - SourceSender, }; /// Configuration for the `static_metrics` source. @@ -203,7 +203,7 @@ mod tests { event::Event, test_util::{ self, - components::{run_and_assert_source_compliance, SOURCE_TAGS}, + components::{SOURCE_TAGS, run_and_assert_source_compliance}, }, }; diff --git a/src/sources/statsd/mod.rs b/src/sources/statsd/mod.rs index b77ecaeca7a13..1d0ba532cc6f3 100644 --- a/src/sources/statsd/mod.rs +++ b/src/sources/statsd/mod.rs @@ -8,19 +8,20 @@ use bytes::Bytes; use futures::{StreamExt, TryFutureExt}; use listenfd::ListenFd; use serde_with::serde_as; -use smallvec::{smallvec, SmallVec}; +use smallvec::{SmallVec, smallvec}; use tokio_util::udp::UdpFramed; +use vector_lib::EstimatedJsonEncodedSizeOf; use vector_lib::codecs::{ - decoding::{self, Deserializer, Framer}, NewlineDelimitedDecoder, + decoding::{self, Deserializer, Framer}, }; use vector_lib::configurable::configurable_component; use vector_lib::internal_event::{CountByteSize, InternalEventHandle as _, Registered}; -use vector_lib::EstimatedJsonEncodedSizeOf; use self::parser::ParseError; -use super::util::net::{try_bind_udp_socket, SocketListenAddr, TcpNullAcker, TcpSource}; +use super::util::net::{SocketListenAddr, TcpNullAcker, TcpSource, try_bind_udp_socket}; use crate::{ + SourceSender, codecs::Decoder, config::{GenerateConfig, Resource, SourceConfig, SourceContext, SourceOutput}, event::Event, @@ -32,7 +33,6 @@ use crate::{ shutdown::ShutdownSignal, tcp::TcpKeepaliveConfig, tls::{MaybeTlsSettings, TlsSourceConfig}, - SourceSender, }; pub mod parser; @@ -42,7 +42,7 @@ mod unix; use parser::Parser; #[cfg(unix)] -use unix::{statsd_unix, UnixConfig}; +use unix::{UnixConfig, statsd_unix}; use vector_lib::config::LogNamespace; /// Configuration for the `statsd` source. @@ -409,19 +409,19 @@ mod test { use tokio::{ io::AsyncWriteExt, net::UdpSocket, - time::{sleep, Duration, Instant}, + time::{Duration, Instant, sleep}, }; use vector_lib::{ config::ComponentKey, - event::{metric::TagValue, EventContainer}, + event::{EventContainer, metric::TagValue}, }; use super::*; use crate::test_util::{ collect_limited, components::{ - assert_source_compliance, assert_source_error, COMPONENT_ERROR_TAGS, - SOCKET_PUSH_SOURCE_TAGS, + COMPONENT_ERROR_TAGS, SOCKET_PUSH_SOURCE_TAGS, assert_source_compliance, + assert_source_error, }, metrics::{assert_counter, assert_distribution, assert_gauge, assert_set}, next_addr, diff --git a/src/sources/statsd/parser.rs b/src/sources/statsd/parser.rs index ebe2a0fe8df10..b08df28a6dcc8 100644 --- a/src/sources/statsd/parser.rs +++ b/src/sources/statsd/parser.rs @@ -191,11 +191,7 @@ fn sanitize_key(key: &str, sanitize: bool) -> String { } fn sanitize_sampling(sampling: f64) -> f64 { - if sampling == 0.0 { - 1.0 - } else { - sampling - } + if sampling == 0.0 { 1.0 } else { sampling } } fn convert_to_statistic(unit: &str) -> StatisticKind { @@ -241,7 +237,7 @@ mod test { use vector_lib::assert_event_data_eq; use vector_lib::{event::metric::TagValue, metric_tags}; - use super::{sanitize_key, sanitize_sampling, ParseError, Parser}; + use super::{ParseError, Parser, sanitize_key, sanitize_sampling}; use crate::event::metric::{Metric, MetricKind, MetricValue, StatisticKind}; use crate::sources::statsd::ConversionUnit; diff --git a/src/sources/statsd/unix.rs b/src/sources/statsd/unix.rs index 0819c78948856..5b99715385912 100644 --- a/src/sources/statsd/unix.rs +++ b/src/sources/statsd/unix.rs @@ -1,17 +1,17 @@ use std::path::PathBuf; use vector_lib::codecs::{ - decoding::{Deserializer, Framer}, NewlineDelimitedDecoder, + decoding::{Deserializer, Framer}, }; use vector_lib::configurable::configurable_component; -use super::{default_convert_to, default_sanitize, ConversionUnit, StatsdDeserializer}; +use super::{ConversionUnit, StatsdDeserializer, default_convert_to, default_sanitize}; use crate::{ + SourceSender, codecs::Decoder, shutdown::ShutdownSignal, - sources::{util::build_unix_stream_source, Source}, - SourceSender, + sources::{Source, util::build_unix_stream_source}, }; /// Unix domain socket configuration for the `statsd` source. diff --git a/src/sources/syslog.rs b/src/sources/syslog.rs index 4a25a2aae0125..8d5e1401bdbee 100644 --- a/src/sources/syslog.rs +++ b/src/sources/syslog.rs @@ -10,30 +10,30 @@ use listenfd::ListenFd; use smallvec::SmallVec; use tokio_util::udp::UdpFramed; use vector_lib::codecs::{ - decoding::{Deserializer, Framer}, BytesDecoder, OctetCountingDecoder, SyslogDeserializerConfig, + decoding::{Deserializer, Framer}, }; use vector_lib::config::{LegacyKey, LogNamespace}; use vector_lib::configurable::configurable_component; -use vector_lib::lookup::{lookup_v2::OptionalValuePath, path, OwnedValuePath}; +use vector_lib::lookup::{OwnedValuePath, lookup_v2::OptionalValuePath, path}; use vrl::event_path; #[cfg(unix)] use crate::sources::util::build_unix_stream_source; use crate::{ + SourceSender, codecs::Decoder, config::{ - log_schema, DataType, GenerateConfig, Resource, SourceConfig, SourceContext, SourceOutput, + DataType, GenerateConfig, Resource, SourceConfig, SourceContext, SourceOutput, log_schema, }, event::Event, internal_events::StreamClosedError, internal_events::{SocketBindError, SocketMode, SocketReceiveError}, net, shutdown::ShutdownSignal, - sources::util::net::{try_bind_udp_socket, SocketListenAddr, TcpNullAcker, TcpSource}, + sources::util::net::{SocketListenAddr, TcpNullAcker, TcpSource, try_bind_udp_socket}, tcp::TcpKeepaliveConfig, tls::{MaybeTlsSettings, TlsSourceConfig}, - SourceSender, }; /// Configuration for the `syslog` source. @@ -449,27 +449,27 @@ fn enrich_syslog_event( #[cfg(test)] mod test { use std::{collections::HashMap, fmt, str::FromStr}; - use vector_lib::lookup::{event_path, owned_value_path, OwnedTargetPath}; + use vector_lib::lookup::{OwnedTargetPath, event_path, owned_value_path}; use chrono::prelude::*; - use rand::{rng, Rng}; + use rand::{Rng, rng}; use serde::Deserialize; - use tokio::time::{sleep, Duration, Instant}; + use tokio::time::{Duration, Instant, sleep}; use tokio_util::codec::BytesCodec; use vector_lib::assert_event_data_eq; use vector_lib::codecs::decoding::format::Deserializer; use vector_lib::lookup::PathPrefix; use vector_lib::{config::ComponentKey, schema::Definition}; - use vrl::value::{kind::Collection, Kind, ObjectMap, Value}; + use vrl::value::{Kind, ObjectMap, Value, kind::Collection}; use super::*; use crate::{ config::log_schema, event::{Event, LogEvent}, test_util::{ - components::{assert_source_compliance, SOCKET_PUSH_SOURCE_TAGS}, - next_addr, random_maps, random_string, send_encodable, send_lines, wait_for_tcp, CountReceiver, + components::{SOCKET_PUSH_SOURCE_TAGS, assert_source_compliance}, + next_addr, random_maps, random_string, send_encodable, send_lines, wait_for_tcp, }, }; @@ -1185,7 +1185,7 @@ mod test { #[tokio::test] async fn test_unix_stream_syslog() { use crate::test_util::components::SOCKET_PUSH_SOURCE_TAGS; - use futures_util::{stream, SinkExt}; + use futures_util::{SinkExt, stream}; use std::os::unix::net::UnixStream as StdUnixStream; use tokio::io::AsyncWriteExt; use tokio::net::UnixStream; diff --git a/src/sources/util/framestream.rs b/src/sources/util/framestream.rs index a864d42d193a5..ac9051d8aee67 100644 --- a/src/sources/util/framestream.rs +++ b/src/sources/util/framestream.rs @@ -8,8 +8,8 @@ use std::{ net::SocketAddr, path::PathBuf, sync::{ - atomic::{AtomicUsize, Ordering}, Arc, Mutex, + atomic::{AtomicUsize, Ordering}, }, time::Duration, }; @@ -21,7 +21,7 @@ use futures::{ sink::{Sink, SinkExt}, stream::{self, StreamExt, TryStreamExt}, }; -use futures_util::{future::BoxFuture, Future, FutureExt}; +use futures_util::{Future, FutureExt, future::BoxFuture}; use listenfd::ListenFd; use tokio::{ self, @@ -31,8 +31,8 @@ use tokio::{ time::sleep, }; use tokio_stream::wrappers::UnixListenerStream; -use tokio_util::codec::{length_delimited, Framed}; -use tracing::{field, Instrument, Span}; +use tokio_util::codec::{Framed, length_delimited}; +use tracing::{Instrument, Span, field}; use vector_lib::{ lookup::OwnedValuePath, tcp::TcpKeepaliveConfig, @@ -40,6 +40,7 @@ use vector_lib::{ }; use crate::{ + SourceSender, event::Event, internal_events::{ ConnectionOpen, OpenGauge, SocketBindError, SocketMode, SocketReceiveError, @@ -48,13 +49,12 @@ use crate::{ }, shutdown::ShutdownSignal, sources::{ + Source, util::{ - net::{try_bind_tcp_listener, MAX_IN_FLIGHT_EVENTS_TARGET}, AfterReadExt, + net::{MAX_IN_FLIGHT_EVENTS_TARGET, try_bind_tcp_listener}, }, - Source, }, - SourceSender, }; use super::net::{RequestLimiter, SocketListenAddr}; @@ -943,14 +943,14 @@ mod test { use std::{ path::PathBuf, sync::{ - atomic::{AtomicUsize, Ordering}, Arc, + atomic::{AtomicUsize, Ordering}, }, thread, }; use tokio::net::TcpStream; - use bytes::{buf::Buf, Bytes, BytesMut}; + use bytes::{Bytes, BytesMut, buf::Buf}; use futures::{ future, sink::{Sink, SinkExt}, @@ -963,28 +963,28 @@ mod test { task::JoinHandle, time::{Duration, Instant}, }; - use tokio_util::codec::{length_delimited, Framed}; + use tokio_util::codec::{Framed, length_delimited}; use vector_lib::{ config::{LegacyKey, LogNamespace}, tcp::TcpKeepaliveConfig, tls::{CertificateMetadata, MaybeTls}, }; use vector_lib::{ - lookup::{owned_value_path, path, OwnedValuePath}, + lookup::{OwnedValuePath, owned_value_path, path}, tls::MaybeTlsSettings, }; use super::{ - build_framestream_tcp_source, build_framestream_unix_source, spawn_event_handling_tasks, ControlField, ControlHeader, FrameHandler, TcpFrameHandler, UnixFrameHandler, + build_framestream_tcp_source, build_framestream_unix_source, spawn_event_handling_tasks, }; use crate::{ - config::{log_schema, ComponentKey}, + SourceSender, + config::{ComponentKey, log_schema}, event::{Event, LogEvent}, shutdown::SourceShutdownCoordinator, sources::util::net::SocketListenAddr, test_util::{collect_n, collect_n_stream, next_addr}, - SourceSender, }; #[derive(Clone)] @@ -1431,12 +1431,16 @@ mod test { send_control_frame(&mut sock_sink, create_control_frame(ControlHeader::Stop)).await; let message_key = log_schema().message_key().unwrap().to_string(); - assert!(events - .iter() - .any(|e| e.as_log()[&message_key] == "hello".into())); - assert!(events - .iter() - .any(|e| e.as_log()[&message_key] == "world".into())); + assert!( + events + .iter() + .any(|e| e.as_log()[&message_key] == "hello".into()) + ); + assert!( + events + .iter() + .any(|e| e.as_log()[&message_key] == "world".into()) + ); drop(sock_stream); //explicitly drop the stream so we don't get warnings about not using it @@ -1805,6 +1809,9 @@ mod test { max_task_nums_reached_value > 1, "MultiThreaded mode does NOT work" ); - assert!((max_task_nums_reached_value - max_frame_handling_tasks) < 2, "Max number of tasks at any given time should NOT Exceed max_frame_handling_tasks too much"); + assert!( + (max_task_nums_reached_value - max_frame_handling_tasks) < 2, + "Max number of tasks at any given time should NOT Exceed max_frame_handling_tasks too much" + ); } } diff --git a/src/sources/util/grpc/decompression.rs b/src/sources/util/grpc/decompression.rs index cb87986ce0208..f34041934ead5 100644 --- a/src/sources/util/grpc/decompression.rs +++ b/src/sources/util/grpc/decompression.rs @@ -11,12 +11,12 @@ use flate2::write::GzDecoder; use futures_util::FutureExt; use http::{Request, Response}; use hyper::{ - body::{HttpBody, Sender}, Body, + body::{HttpBody, Sender}, }; use std::future::Future; use tokio::{pin, select}; -use tonic::{body::BoxBody, metadata::AsciiMetadataValue, Status}; +use tonic::{Status, body::BoxBody, metadata::AsciiMetadataValue}; use tower::{Layer, Service}; use vector_lib::internal_event::{ ByteSize, BytesReceived, InternalEventHandle as _, Protocol, Registered, diff --git a/src/sources/util/http/encoding.rs b/src/sources/util/http/encoding.rs index 47e2bf72315ac..4360fc42829f1 100644 --- a/src/sources/util/http/encoding.rs +++ b/src/sources/util/http/encoding.rs @@ -37,7 +37,7 @@ pub fn decode(header: Option<&str>, mut body: Bytes) -> Result( buffer.extend_from_slice(message); let now = Utc::now(); - iter::from_fn(move || loop { - break match decoder.decode_eof(&mut buffer) { - Ok(Some((events, _))) => Some(events.into_iter().map(move |mut event| { - if let Event::Log(ref mut log) = event { - log_namespace.insert_vector_metadata( - log, - schema.source_type_key(), - path!("source_type"), - Bytes::from(source_type), - ); - match log_namespace { - LogNamespace::Vector => { - if let Some(timestamp) = timestamp { - log.try_insert(metadata_path!(source_type, "timestamp"), timestamp); - } + iter::from_fn(move || { + loop { + break match decoder.decode_eof(&mut buffer) { + Ok(Some((events, _))) => Some(events.into_iter().map(move |mut event| { + if let Event::Log(ref mut log) = event { + log_namespace.insert_vector_metadata( + log, + schema.source_type_key(), + path!("source_type"), + Bytes::from(source_type), + ); + match log_namespace { + LogNamespace::Vector => { + if let Some(timestamp) = timestamp { + log.try_insert( + metadata_path!(source_type, "timestamp"), + timestamp, + ); + } - log.insert(metadata_path!("vector", "ingest_timestamp"), now); - } - LogNamespace::Legacy => { - if let Some(timestamp) = timestamp { - if let Some(timestamp_key) = schema.timestamp_key() { - log.try_insert((PathPrefix::Event, timestamp_key), timestamp); + log.insert(metadata_path!("vector", "ingest_timestamp"), now); + } + LogNamespace::Legacy => { + if let Some(timestamp) = timestamp { + if let Some(timestamp_key) = schema.timestamp_key() { + log.try_insert( + (PathPrefix::Event, timestamp_key), + timestamp, + ); + } } } } } + events_received.emit(CountByteSize(1, event.estimated_json_encoded_size_of())); + event + })), + Err(error) => { + // Error is logged by `crate::codecs::Decoder`, no further handling + // is needed here. + if error.can_continue() { + continue; + } + None } - events_received.emit(CountByteSize(1, event.estimated_json_encoded_size_of())); - event - })), - Err(error) => { - // Error is logged by `crate::codecs::Decoder`, no further handling - // is needed here. - if error.can_continue() { - continue; - } - None - } - Ok(None) => None, - }; + Ok(None) => None, + }; + } }) .flatten() .map(move |event| event.with_batch_notifier_option(batch)) diff --git a/src/sources/util/mod.rs b/src/sources/util/mod.rs index f7e103d2dd848..1b4ef805fd1a5 100644 --- a/src/sources/util/mod.rs +++ b/src/sources/util/mod.rs @@ -52,6 +52,8 @@ pub use wrappers::{AfterRead, AfterReadExt}; #[cfg(feature = "sources-http_server")] pub use self::body_decoding::Encoding; +#[cfg(feature = "sources-utils-http-prelude")] +pub use self::http::HttpSource; #[cfg(feature = "sources-utils-http-headers")] pub use self::http::add_headers; #[cfg(feature = "sources-utils-http-query")] @@ -62,8 +64,6 @@ pub use self::http::add_query_parameters; feature = "sources-utils-http-encoding" ))] pub use self::http::decode; -#[cfg(feature = "sources-utils-http-prelude")] -pub use self::http::HttpSource; #[cfg(any( feature = "sources-aws_sqs", feature = "sources-gcp_pubsub", diff --git a/src/sources/util/net/mod.rs b/src/sources/util/net/mod.rs index 1317948dfd349..434fc82c92d0e 100644 --- a/src/sources/util/net/mod.rs +++ b/src/sources/util/net/mod.rs @@ -12,8 +12,8 @@ use crate::config::{Protocol, Resource}; #[cfg(feature = "sources-utils-net-tcp")] pub use self::tcp::{ - request_limiter::RequestLimiter, try_bind_tcp_listener, TcpNullAcker, TcpSource, TcpSourceAck, - TcpSourceAcker, MAX_IN_FLIGHT_EVENTS_TARGET, + MAX_IN_FLIGHT_EVENTS_TARGET, TcpNullAcker, TcpSource, TcpSourceAck, TcpSourceAcker, + request_limiter::RequestLimiter, try_bind_tcp_listener, }; #[cfg(feature = "sources-utils-net-udp")] pub use self::udp::try_bind_udp_socket; diff --git a/src/sources/util/net/tcp/mod.rs b/src/sources/util/net/tcp/mod.rs index f29a8df4e6b32..85daa62cc7d54 100644 --- a/src/sources/util/net/tcp/mod.rs +++ b/src/sources/util/net/tcp/mod.rs @@ -3,7 +3,7 @@ pub mod request_limiter; use std::{io, mem::drop, net::SocketAddr, time::Duration}; use bytes::Bytes; -use futures::{future::BoxFuture, FutureExt, StreamExt}; +use futures::{FutureExt, StreamExt, future::BoxFuture}; use futures_util::future::OptionFuture; use ipnet::IpNet; use listenfd::ListenFd; @@ -18,16 +18,17 @@ use tokio_util::codec::{Decoder, FramedRead}; use tracing::Instrument; use vector_lib::codecs::StreamDecodingError; use vector_lib::finalization::AddBatchNotifier; -use vector_lib::lookup::{path, OwnedValuePath}; +use vector_lib::lookup::{OwnedValuePath, path}; use vector_lib::{ - config::{LegacyKey, LogNamespace, SourceAcknowledgementsConfig}, EstimatedJsonEncodedSizeOf, + config::{LegacyKey, LogNamespace, SourceAcknowledgementsConfig}, }; use vrl::value::ObjectMap; use self::request_limiter::RequestLimiter; use super::SocketListenAddr; use crate::{ + SourceSender, codecs::ReadyFrames, config::SourceContext, event::{BatchNotifier, BatchStatus, Event}, @@ -40,7 +41,6 @@ use crate::{ sources::util::AfterReadExt, tcp::TcpKeepaliveConfig, tls::{CertificateMetadata, MaybeTlsIncomingStream, MaybeTlsListener, MaybeTlsSettings}, - SourceSender, }; pub const MAX_IN_FLIGHT_EVENTS_TARGET: usize = 100_000; diff --git a/src/sources/util/unix_datagram.rs b/src/sources/util/unix_datagram.rs index 20be4c474c2e0..c19ab6c3784ed 100644 --- a/src/sources/util/unix_datagram.rs +++ b/src/sources/util/unix_datagram.rs @@ -5,11 +5,12 @@ use futures::StreamExt; use tokio::net::UnixDatagram; use tokio_util::codec::FramedRead; use tracing::field; +use vector_lib::EstimatedJsonEncodedSizeOf; use vector_lib::codecs::StreamDecodingError; use vector_lib::internal_event::{ByteSize, BytesReceived, InternalEventHandle as _, Protocol}; -use vector_lib::EstimatedJsonEncodedSizeOf; use crate::{ + SourceSender, codecs::Decoder, event::Event, internal_events::{ @@ -17,10 +18,9 @@ use crate::{ UnixSocketFileDeleteError, }, shutdown::ShutdownSignal, + sources::Source, sources::util::change_socket_permissions, sources::util::unix::UNNAMED_SOCKET_HOST, - sources::Source, - SourceSender, }; /// Returns a `Source` object corresponding to a Unix domain datagram socket. diff --git a/src/sources/util/unix_stream.rs b/src/sources/util/unix_stream.rs index 7c1f5d151ae20..daa9aaa553d63 100644 --- a/src/sources/util/unix_stream.rs +++ b/src/sources/util/unix_stream.rs @@ -10,13 +10,14 @@ use tokio::{ }; use tokio_stream::wrappers::UnixListenerStream; use tokio_util::codec::FramedRead; -use tracing::{field, Instrument}; +use tracing::{Instrument, field}; +use vector_lib::EstimatedJsonEncodedSizeOf; use vector_lib::codecs::StreamDecodingError; use vector_lib::internal_event::{ByteSize, BytesReceived, InternalEventHandle as _, Protocol}; -use vector_lib::EstimatedJsonEncodedSizeOf; use super::AfterReadExt; use crate::{ + SourceSender, async_read::VecAsyncReadExt, event::Event, internal_events::{ @@ -24,10 +25,9 @@ use crate::{ UnixSocketError, UnixSocketFileDeleteError, }, shutdown::ShutdownSignal, + sources::Source, sources::util::change_socket_permissions, sources::util::unix::UNNAMED_SOCKET_HOST, - sources::Source, - SourceSender, }; /// Returns a `Source` object corresponding to a Unix domain stream socket. diff --git a/src/sources/vector/mod.rs b/src/sources/vector/mod.rs index ead1dc64ea754..1c6c109634281 100644 --- a/src/sources/vector/mod.rs +++ b/src/sources/vector/mod.rs @@ -8,12 +8,13 @@ use vector_lib::codecs::NativeDeserializerConfig; use vector_lib::configurable::configurable_component; use vector_lib::internal_event::{CountByteSize, InternalEventHandle as _}; use vector_lib::{ + EstimatedJsonEncodedSizeOf, config::LogNamespace, event::{BatchNotifier, BatchStatus, BatchStatusReceiver, Event}, - EstimatedJsonEncodedSizeOf, }; use crate::{ + SourceSender, config::{ DataType, GenerateConfig, Resource, SourceAcknowledgementsConfig, SourceConfig, SourceContext, SourceOutput, @@ -21,9 +22,8 @@ use crate::{ internal_events::{EventsReceived, StreamClosedError}, proto::vector as proto, serde::bool_or_struct, - sources::{util::grpc::run_grpc_server, Source}, + sources::{Source, util::grpc::run_grpc_server}, tls::{MaybeTlsSettings, TlsEnableableConfig}, - SourceSender, }; /// Marker type for version two of the configuration for the `vector` source. @@ -219,7 +219,7 @@ impl SourceConfig for VectorConfig { mod test { use vector_lib::lookup::owned_value_path; use vector_lib::{config::LogNamespace, schema::Definition}; - use vrl::value::{kind::Collection, Kind}; + use vrl::value::{Kind, kind::Collection}; use crate::config::SourceConfig; @@ -280,9 +280,10 @@ mod test { mod tests { use super::*; use crate::{ + SourceSender, config::{SinkConfig as _, SinkContext}, sinks::vector::VectorConfig as SinkConfig, - test_util, SourceSender, + test_util, }; use vector_lib::assert_event_data_eq; use vector_lib::config::log_schema; diff --git a/src/sources/websocket/source.rs b/src/sources/websocket/source.rs index c54f4cb717365..b3fa450af8940 100644 --- a/src/sources/websocket/source.rs +++ b/src/sources/websocket/source.rs @@ -1,34 +1,34 @@ use crate::vector_lib::codecs::StreamDecodingError; use crate::{ + SourceSender, codecs::Decoder, - common::websocket::{is_closed, PingInterval, WebSocketConnector}, + common::websocket::{PingInterval, WebSocketConnector, is_closed}, config::SourceContext, internal_events::{ - ConnectionOpen, OpenGauge, WebSocketBytesReceived, WebSocketConnectionError, + ConnectionOpen, OpenGauge, PROTOCOL, WebSocketBytesReceived, WebSocketConnectionError, WebSocketConnectionEstablished, WebSocketConnectionFailedError, WebSocketConnectionShutdown, WebSocketKind, WebSocketMessageReceived, - WebSocketReceiveError, WebSocketSendError, PROTOCOL, + WebSocketReceiveError, WebSocketSendError, }, sources::websocket::config::WebSocketConfig, - SourceSender, }; use chrono::Utc; -use futures::{pin_mut, sink::SinkExt, Sink, Stream, StreamExt}; +use futures::{Sink, Stream, StreamExt, pin_mut, sink::SinkExt}; use snafu::Snafu; use std::pin::Pin; use tokio::time; use tokio_tungstenite::tungstenite::protocol::CloseFrame; -use tokio_tungstenite::tungstenite::{error::Error as TungsteniteError, Message}; +use tokio_tungstenite::tungstenite::{Message, error::Error as TungsteniteError}; use tokio_util::codec::FramedRead; use vector_lib::internal_event::{CountByteSize, EventsReceived, InternalEventHandle as _}; use vector_lib::{ + EstimatedJsonEncodedSizeOf, config::LogNamespace, event::{Event, LogEvent}, - EstimatedJsonEncodedSizeOf, }; macro_rules! fail_with_event { - ($context:expr) => {{ + ($context:expr_2021) => {{ emit!(WebSocketConnectionFailedError { error: Box::new($context.build()) }); @@ -460,16 +460,16 @@ mod tests { sources::websocket::config::PongMessage, sources::websocket::config::WebSocketConfig, test_util::{ - components::{run_and_assert_source_compliance, SOURCE_TAGS}, + components::{SOURCE_TAGS, run_and_assert_source_compliance}, next_addr, }, }; - use futures::{sink::SinkExt, StreamExt}; + use futures::{StreamExt, sink::SinkExt}; use std::borrow::Cow; use std::num::NonZeroU64; use tokio::{net::TcpListener, time::Duration}; use tokio_tungstenite::tungstenite::{ - protocol::frame::coding::CloseCode, protocol::frame::CloseFrame, + protocol::frame::CloseFrame, protocol::frame::coding::CloseCode, }; use tokio_tungstenite::{accept_async, tungstenite::Message}; use url::Url; diff --git a/src/template.rs b/src/template.rs index 8db1a74f6f92d..512b3df681d5a 100644 --- a/src/template.rs +++ b/src/template.rs @@ -3,13 +3,13 @@ use std::{borrow::Cow, convert::TryFrom, fmt, hash::Hash, path::PathBuf, sync::L use bytes::Bytes; use chrono::{ - format::{strftime::StrftimeItems, Item}, FixedOffset, Utc, + format::{Item, strftime::StrftimeItems}, }; use regex::Regex; use snafu::Snafu; use vector_lib::configurable::{ - configurable_component, ConfigurableNumber, ConfigurableString, NumberClass, + ConfigurableNumber, ConfigurableString, NumberClass, configurable_component, }; use vector_lib::lookup::lookup_v2::parse_target_path; @@ -26,7 +26,10 @@ static RE: LazyLock = LazyLock::new(|| Regex::new(r"\{\{(?P[^\}]+)\} pub enum TemplateParseError { #[snafu(display("Invalid strftime item"))] StrftimeError, - #[snafu(display("Invalid field path in template {:?} (see https://vector.dev/docs/reference/configuration/template-syntax/)", path))] + #[snafu(display( + "Invalid field path in template {:?} (see https://vector.dev/docs/reference/configuration/template-syntax/)", + path + ))] InvalidPathSyntax { path: String }, #[snafu(display("Invalid numeric template"))] InvalidNumericTemplate { template: String }, @@ -616,7 +619,7 @@ mod tests { use chrono::{Offset, TimeZone, Utc}; use chrono_tz::Tz; use vector_lib::config::LogNamespace; - use vector_lib::lookup::{metadata_path, PathPrefix}; + use vector_lib::lookup::{PathPrefix, metadata_path}; use vector_lib::metric_tags; use vrl::event_path; @@ -655,12 +658,16 @@ mod tests { fn is_dynamic() { assert!(Template::try_from("/kube-demo/%F").unwrap().is_dynamic()); assert!(!Template::try_from("/kube-demo/echo").unwrap().is_dynamic()); - assert!(Template::try_from("/kube-demo/{{ foo }}") - .unwrap() - .is_dynamic()); - assert!(Template::try_from("/kube-demo/{{ foo }}/%F") - .unwrap() - .is_dynamic()); + assert!( + Template::try_from("/kube-demo/{{ foo }}") + .unwrap() + .is_dynamic() + ); + assert!( + Template::try_from("/kube-demo/{{ foo }}/%F") + .unwrap() + .is_dynamic() + ); } #[test] diff --git a/src/test_util/components.rs b/src/test_util/components.rs index 613ec8ce73d48..cf4b4a18cc693 100644 --- a/src/test_util/components.rs +++ b/src/test_util/components.rs @@ -9,17 +9,17 @@ use std::{env, sync::LazyLock, time::Duration}; -use futures::{stream, SinkExt, Stream, StreamExt}; +use futures::{SinkExt, Stream, StreamExt, stream}; use futures_util::Future; use tokio::{pin, select, time::sleep}; use vector_lib::event_test_util; use crate::{ + SourceSender, config::{SourceConfig, SourceContext}, event::{Event, EventArray, Metric, MetricValue}, metrics::Controller, sinks::VectorSink, - SourceSender, }; /// The most basic set of tags for sources, regardless of whether or not they pull data or have it pushed in. diff --git a/src/test_util/http.rs b/src/test_util/http.rs index c0f552efb734d..592557168d41b 100644 --- a/src/test_util/http.rs +++ b/src/test_util/http.rs @@ -1,9 +1,9 @@ use std::{convert::Infallible, future::Future}; -use http::{uri::Scheme, Request, Response, Uri}; +use http::{Request, Response, Uri, uri::Scheme}; use hyper::{ - service::{make_service_fn, service_fn}, Body, Server, + service::{make_service_fn, service_fn}, }; use super::{next_addr, wait_for_tcp}; diff --git a/src/test_util/metrics.rs b/src/test_util/metrics.rs index 1e393e15ba2af..9bc470aab3c71 100644 --- a/src/test_util/metrics.rs +++ b/src/test_util/metrics.rs @@ -3,8 +3,8 @@ use std::collections::{HashMap, HashSet}; use std::fmt::Display; use vector_lib::event::{ - metric::{Bucket, MetricData, MetricSeries, Sample}, Event, EventMetadata, Metric, MetricValue, StatisticKind, + metric::{Bucket, MetricData, MetricSeries, Sample}, }; use crate::event::MetricKind; diff --git a/src/test_util/mock/mod.rs b/src/test_util/mock/mod.rs index 04781e08e43fe..af824289645cc 100644 --- a/src/test_util/mock/mod.rs +++ b/src/test_util/mock/mod.rs @@ -1,11 +1,11 @@ -use std::sync::{atomic::AtomicUsize, Arc}; +use std::sync::{Arc, atomic::AtomicUsize}; use futures_util::Stream; use stream_cancel::Trigger; use tokio::sync::oneshot::Sender; use vector_lib::event::EventArray; -use crate::{source_sender::SourceSenderItem, SourceSender}; +use crate::{SourceSender, source_sender::SourceSenderItem}; use self::{ sinks::{ diff --git a/src/test_util/mock/sinks/basic.rs b/src/test_util/mock/sinks/basic.rs index d6af6ac66aaaa..00150b398bf11 100644 --- a/src/test_util/mock/sinks/basic.rs +++ b/src/test_util/mock/sinks/basic.rs @@ -1,5 +1,5 @@ use async_trait::async_trait; -use futures_util::{stream::BoxStream, FutureExt, StreamExt}; +use futures_util::{FutureExt, StreamExt, stream::BoxStream}; use snafu::Snafu; use tokio::sync::oneshot; use vector_lib::configurable::configurable_component; @@ -11,9 +11,9 @@ use vector_lib::{ }; use crate::{ + SourceSender, config::{SinkConfig, SinkContext}, sinks::Healthcheck, - SourceSender, }; /// Configuration for the `test_basic` sink. diff --git a/src/test_util/mock/sinks/error.rs b/src/test_util/mock/sinks/error.rs index 8b7bb585fbc4f..e644c3857837c 100644 --- a/src/test_util/mock/sinks/error.rs +++ b/src/test_util/mock/sinks/error.rs @@ -4,7 +4,7 @@ use std::{ }; use async_trait::async_trait; -use futures_util::{future::ok, FutureExt, Sink}; +use futures_util::{FutureExt, Sink, future::ok}; use vector_lib::configurable::configurable_component; use vector_lib::{ config::{AcknowledgementsConfig, Input}, diff --git a/src/test_util/mock/sinks/oneshot.rs b/src/test_util/mock/sinks/oneshot.rs index 81a6089f0c1a6..4fe193d13df0b 100644 --- a/src/test_util/mock/sinks/oneshot.rs +++ b/src/test_util/mock/sinks/oneshot.rs @@ -1,7 +1,7 @@ use std::sync::{Arc, Mutex}; use async_trait::async_trait; -use futures_util::{stream::BoxStream, StreamExt}; +use futures_util::{StreamExt, stream::BoxStream}; use tokio::sync::oneshot::Sender; use vector_lib::configurable::configurable_component; use vector_lib::{ diff --git a/src/test_util/mock/sinks/panic.rs b/src/test_util/mock/sinks/panic.rs index 4da861033ef27..57b99e68e4c6a 100644 --- a/src/test_util/mock/sinks/panic.rs +++ b/src/test_util/mock/sinks/panic.rs @@ -4,7 +4,7 @@ use std::{ }; use async_trait::async_trait; -use futures_util::{future::ok, FutureExt, Sink}; +use futures_util::{FutureExt, Sink, future::ok}; use vector_lib::configurable::configurable_component; use vector_lib::{ config::{AcknowledgementsConfig, Input}, diff --git a/src/test_util/mock/sources/backpressure.rs b/src/test_util/mock/sources/backpressure.rs index fa154da5134e3..a211a492571c7 100644 --- a/src/test_util/mock/sources/backpressure.rs +++ b/src/test_util/mock/sources/backpressure.rs @@ -1,6 +1,6 @@ use std::sync::{ - atomic::{AtomicUsize, Ordering}, Arc, + atomic::{AtomicUsize, Ordering}, }; use async_trait::async_trait; diff --git a/src/test_util/mock/sources/basic.rs b/src/test_util/mock/sources/basic.rs index 1a432d98affc4..a0988c71f551f 100644 --- a/src/test_util/mock/sources/basic.rs +++ b/src/test_util/mock/sources/basic.rs @@ -1,15 +1,15 @@ use std::{ num::NonZeroUsize, sync::{ - atomic::{AtomicUsize, Ordering}, Arc, Mutex, + atomic::{AtomicUsize, Ordering}, }, }; use async_trait::async_trait; use vector_lib::buffers::{ config::MemoryBufferSize, - topology::channel::{limited, LimitedReceiver}, + topology::channel::{LimitedReceiver, limited}, }; use vector_lib::configurable::configurable_component; use vector_lib::{config::LogNamespace, schema::Definition}; diff --git a/src/test_util/mock/sources/error.rs b/src/test_util/mock/sources/error.rs index 878e79d83add9..1e292a9a05d3f 100644 --- a/src/test_util/mock/sources/error.rs +++ b/src/test_util/mock/sources/error.rs @@ -1,5 +1,5 @@ use async_trait::async_trait; -use futures_util::{future::err, FutureExt}; +use futures_util::{FutureExt, future::err}; use vector_lib::config::LogNamespace; use vector_lib::configurable::configurable_component; use vector_lib::schema::Definition; diff --git a/src/test_util/mock/sources/tripwire.rs b/src/test_util/mock/sources/tripwire.rs index ee0a1bfe6c67e..e135df21f80a1 100644 --- a/src/test_util/mock/sources/tripwire.rs +++ b/src/test_util/mock/sources/tripwire.rs @@ -1,7 +1,7 @@ use std::sync::{Arc, Mutex}; use async_trait::async_trait; -use futures_util::{future, FutureExt}; +use futures_util::{FutureExt, future}; use stream_cancel::{Trigger, Tripwire}; use vector_lib::config::LogNamespace; use vector_lib::configurable::configurable_component; diff --git a/src/test_util/mock/transforms/basic.rs b/src/test_util/mock/transforms/basic.rs index a8481d87ec186..c4ba9ce4acadf 100644 --- a/src/test_util/mock/transforms/basic.rs +++ b/src/test_util/mock/transforms/basic.rs @@ -6,8 +6,8 @@ use vector_lib::configurable::configurable_component; use vector_lib::{ config::{DataType, Input, TransformOutput}, event::{ - metric::{MetricData, Sample}, Event, MetricValue, + metric::{MetricData, Sample}, }, schema, transform::{FunctionTransform, OutputBuffer, Transform}, diff --git a/src/test_util/mod.rs b/src/test_util/mod.rs index c920303ae87d0..5181c88cc4048 100644 --- a/src/test_util/mod.rs +++ b/src/test_util/mod.rs @@ -3,25 +3,25 @@ use std::{ collections::HashMap, convert::Infallible, fs::File, - future::{ready, Future}, + future::{Future, ready}, io::Read, iter, net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}, path::{Path, PathBuf}, pin::Pin, sync::{ - atomic::{AtomicUsize, Ordering}, Arc, + atomic::{AtomicUsize, Ordering}, }, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, }; use chrono::{DateTime, SubsecRound, Utc}; use flate2::read::MultiGzDecoder; -use futures::{stream, task::noop_waker_ref, FutureExt, SinkExt, Stream, StreamExt, TryStreamExt}; +use futures::{FutureExt, SinkExt, Stream, StreamExt, TryStreamExt, stream, task::noop_waker_ref}; use openssl::ssl::{SslConnector, SslFiletype, SslMethod, SslVerifyMode}; use portpicker::pick_unused_port; -use rand::{rng, Rng}; +use rand::{Rng, rng}; use rand_distr::Alphanumeric; use tokio::{ io::{AsyncRead, AsyncWrite, AsyncWriteExt, Result as IoResult}, @@ -29,7 +29,7 @@ use tokio::{ runtime, sync::oneshot, task::JoinHandle, - time::{sleep, Duration, Instant}, + time::{Duration, Instant, sleep}, }; use tokio_stream::wrappers::TcpListenerStream; #[cfg(unix)] diff --git a/src/top/cmd.rs b/src/top/cmd.rs index f58c15fb9f101..a6cca42ef4027 100644 --- a/src/top/cmd.rs +++ b/src/top/cmd.rs @@ -3,7 +3,7 @@ use std::time::Duration; use chrono::Local; use futures_util::future::join_all; use tokio::sync::{mpsc, oneshot}; -use vector_lib::api_client::{connect_subscription_client, Client}; +use vector_lib::api_client::{Client, connect_subscription_client}; use super::{ dashboard::{init_dashboard, is_tty}, diff --git a/src/top/dashboard.rs b/src/top/dashboard.rs index 36567247d990c..46c68fcf2b264 100644 --- a/src/top/dashboard.rs +++ b/src/top/dashboard.rs @@ -1,21 +1,21 @@ use crate::internal_telemetry::is_allocation_tracking_enabled; use crossterm::{ + ExecutableCommand, cursor::Show, event::{DisableMouseCapture, EnableMouseCapture, KeyCode}, execute, - terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, + terminal::{EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode}, tty::IsTty, - ExecutableCommand, }; use num_format::{Locale, ToFormattedString}; use number_prefix::NumberPrefix; use ratatui::{ + Frame, Terminal, backend::CrosstermBackend, layout::{Alignment, Constraint, Layout, Rect}, style::{Color, Modifier, Style}, text::{Line, Span}, widgets::{Block, Borders, Cell, Paragraph, Row, Table, Wrap}, - Frame, Terminal, }; use std::{io::stdout, time::Duration}; use tokio::sync::oneshot; diff --git a/src/top/metrics.rs b/src/top/metrics.rs index c2a8ef02e762a..5351bdafb6af5 100644 --- a/src/top/metrics.rs +++ b/src/top/metrics.rs @@ -7,8 +7,8 @@ use glob::Pattern; use tokio::task::JoinHandle; use tokio_stream::StreamExt; use vector_lib::api_client::{ - gql::{ComponentsQueryExt, ComponentsSubscriptionExt, MetricsSubscriptionExt}, Client, SubscriptionClient, + gql::{ComponentsQueryExt, ComponentsSubscriptionExt, MetricsSubscriptionExt}, }; use super::state::{self, OutputMetrics}; diff --git a/src/topology/builder.rs b/src/topology/builder.rs index a872435e968e4..14c1c90efc55e 100644 --- a/src/topology/builder.rs +++ b/src/topology/builder.rs @@ -6,7 +6,7 @@ use std::{ time::Instant, }; -use futures::{stream::FuturesOrdered, FutureExt, StreamExt, TryStreamExt}; +use futures::{FutureExt, StreamExt, TryStreamExt, stream::FuturesOrdered}; use futures_util::stream::FuturesUnordered; use metrics::gauge; use stream_cancel::{StreamExt as StreamCancelExt, Trigger, Tripwire}; @@ -22,24 +22,25 @@ use vector_lib::internal_event::{ }; use vector_lib::transform::update_runtime_schema_definition; use vector_lib::{ + EstimatedJsonEncodedSizeOf, buffers::{ + BufferType, WhenFull, topology::{ builder::TopologyBuilder, channel::{BufferReceiver, BufferSender}, }, - BufferType, WhenFull, }, schema::Definition, - EstimatedJsonEncodedSizeOf, }; use super::{ + BuiltBuffer, ConfigDiff, fanout::{self, Fanout}, schema, task::{Task, TaskOutput, TaskResult}, - BuiltBuffer, ConfigDiff, }; use crate::{ + SourceSender, config::{ ComponentKey, Config, DataType, EnrichmentTableConfig, Input, Inputs, OutputId, ProxyConfig, SinkContext, SourceContext, TransformContext, TransformOuter, TransformOutput, @@ -48,12 +49,11 @@ use crate::{ extra_context::ExtraContext, internal_events::EventsReceived, shutdown::SourceShutdownCoordinator, - source_sender::{SourceSenderItem, CHUNK_SIZE}, + source_sender::{CHUNK_SIZE, SourceSenderItem}, spawn_named, topology::task::TaskError, transforms::{SyncTransform, TaskTransform, Transform, TransformOutputs, TransformOutputsBuf}, - utilization::{wrap, UtilizationComponentSender, UtilizationEmitter}, - SourceSender, + utilization::{UtilizationComponentSender, UtilizationEmitter, wrap}, }; static ENRICHMENT_TABLES: LazyLock = diff --git a/src/topology/running.rs b/src/topology/running.rs index 419c8880673d7..00d40f49810b7 100644 --- a/src/topology/running.rs +++ b/src/topology/running.rs @@ -1,17 +1,17 @@ use std::{ collections::{HashMap, HashSet}, sync::{ - atomic::{AtomicBool, Ordering}, Arc, Mutex, + atomic::{AtomicBool, Ordering}, }, }; use super::{ - builder::{self, reload_enrichment_tables, TopologyPieces}, + BuiltBuffer, TaskHandle, + builder::{self, TopologyPieces, reload_enrichment_tables}, fanout::{ControlChannel, ControlMessage}, handle_errors, retain, take_healthchecks, task::{Task, TaskOutput}, - BuiltBuffer, TaskHandle, }; use crate::{ config::{ComponentKey, Config, ConfigDiff, HealthcheckOptions, Inputs, OutputId, Resource}, @@ -21,11 +21,11 @@ use crate::{ signal::ShutdownError, spawn_named, }; -use futures::{future, Future, FutureExt}; +use futures::{Future, FutureExt, future}; use stream_cancel::Trigger; use tokio::{ sync::{mpsc, watch}, - time::{interval, sleep_until, Duration, Instant}, + time::{Duration, Instant, interval, sleep_until}, }; use tracing::Instrument; use vector_lib::tap::topology::{TapOutput, TapResource, WatchRx, WatchTx}; @@ -195,18 +195,29 @@ impl RunningTopology { .collect::>() .join(", "); - let time_remaining = deadline - .map(|d| match d.checked_duration_since(Instant::now()) { - Some(remaining) => format!("{} seconds left", remaining.as_secs()), - None => "overdue".to_string(), - }) - .unwrap_or("no time limit".to_string()); + let (deadline_passed, time_remaining) = match deadline { + Some(d) => match d.checked_duration_since(Instant::now()) { + Some(remaining) => (false, format!("{} seconds left", remaining.as_secs())), + None => (true, "overdue".to_string()), + }, + None => (false, "no time limit".to_string()), + }; info!( remaining_components = ?remaining_components, time_remaining = ?time_remaining, "Shutting down... Waiting on running components." ); + + let all_done = check_handles.is_empty(); + + if all_done { + info!("Shutdown reporter exiting: all components shut down."); + break; + } else if deadline_passed { + error!(remaining_components = ?remaining_components, "Shutdown reporter: deadline exceeded."); + break; + } } }; @@ -253,8 +264,7 @@ impl RunningTopology { if self.config.global != new_config.global { error!( - message = - "Global options can't be changed while reloading config file; reload aborted. Please restart Vector to reload the configuration file." + message = "Global options can't be changed while reloading config file; reload aborted. Please restart Vector to reload the configuration file." ); return Ok(false); } @@ -1201,8 +1211,8 @@ impl RunningTopology { ) { (Some(e), None) => { warn!( - "DEPRECATED: `expire_metrics` setting is deprecated and will be removed in a future version. Use `expire_metrics_secs` instead." - ); + "DEPRECATED: `expire_metrics` setting is deprecated and will be removed in a future version. Use `expire_metrics_secs` instead." + ); if e < Duration::from_secs(0) { None } else { diff --git a/src/topology/task.rs b/src/topology/task.rs index 2db88e1f48fbe..a78327245f8b7 100644 --- a/src/topology/task.rs +++ b/src/topology/task.rs @@ -5,7 +5,7 @@ use std::{ task::{Context, Poll}, }; -use futures::{future::BoxFuture, FutureExt}; +use futures::{FutureExt, future::BoxFuture}; use pin_project::pin_project; use snafu::Snafu; use tokio::task::JoinError; diff --git a/src/topology/test/backpressure.rs b/src/topology/test/backpressure.rs index 52c472e183566..07ff064d5273b 100644 --- a/src/topology/test/backpressure.rs +++ b/src/topology/test/backpressure.rs @@ -1,5 +1,5 @@ -use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; +use std::sync::atomic::{AtomicUsize, Ordering}; use tokio::time::Duration; use vector_lib::buffers::{BufferConfig, BufferType, MemoryBufferSize, WhenFull}; diff --git a/src/topology/test/compliance.rs b/src/topology/test/compliance.rs index 537418d155878..c1461fbcfda96 100644 --- a/src/topology/test/compliance.rs +++ b/src/topology/test/compliance.rs @@ -1,13 +1,13 @@ use std::sync::Arc; -use tokio::sync::oneshot::{channel, Receiver}; +use tokio::sync::oneshot::{Receiver, channel}; use vector_lib::config::ComponentKey; use vector_lib::config::OutputId; use vector_lib::event::{Event, EventArray, EventContainer, LogEvent}; use crate::config::schema::Definition; use crate::{ - config::{unit_test::UnitTestSourceConfig, ConfigBuilder}, + config::{ConfigBuilder, unit_test::UnitTestSourceConfig}, test_util::{ components::assert_transform_compliance, mock::{ diff --git a/src/topology/test/crash.rs b/src/topology/test/crash.rs index 21ce692d1a89c..387ec0410fb32 100644 --- a/src/topology/test/crash.rs +++ b/src/topology/test/crash.rs @@ -3,13 +3,13 @@ use crate::{ sinks::socket::SocketSinkConfig, sources::socket::SocketConfig, test_util::{ + CountReceiver, mock::{error_sink, error_source, panic_sink, panic_source}, next_addr, random_lines, send_lines, start_topology, trace_init, wait_for_tcp, - CountReceiver, }, }; use futures_util::StreamExt; -use tokio::time::{sleep, Duration}; +use tokio::time::{Duration, sleep}; use tokio_stream::wrappers::UnboundedReceiverStream; /// Ensures that an unrelated source completing immediately with an error does not prematurely terminate the topology. diff --git a/src/topology/test/end_to_end.rs b/src/topology/test/end_to_end.rs index 06703d06116d7..8644be8eb793e 100644 --- a/src/topology/test/end_to_end.rs +++ b/src/topology/test/end_to_end.rs @@ -1,19 +1,20 @@ use std::{collections::HashMap, net::SocketAddr, sync::Arc}; use hyper::{ - service::{make_service_fn, service_fn}, Body, Request, Response, Server, StatusCode, + service::{make_service_fn, service_fn}, }; use tokio::{ - sync::{mpsc, oneshot, Mutex}, + sync::{Mutex, mpsc, oneshot}, task::JoinHandle, - time::{timeout, Duration}, + time::{Duration, timeout}, }; use super::{RunningTopology, TopologyPieces}; use crate::{ + Error, config::{self, ConfigDiff, Format}, - test_util, Error, + test_util, }; type Lock = Arc>; diff --git a/src/topology/test/mod.rs b/src/topology/test/mod.rs index 18c8af61c8eb7..ba5e0aaa04197 100644 --- a/src/topology/test/mod.rs +++ b/src/topology/test/mod.rs @@ -2,14 +2,14 @@ use std::{ collections::HashMap, iter, sync::{ - atomic::{AtomicBool, AtomicUsize, Ordering}, Arc, + atomic::{AtomicBool, AtomicUsize, Ordering}, }, }; use crate::{ config::{Config, ConfigDiff, SinkOuter}, - event::{into_event_stream, Event, EventArray, EventContainer, LogEvent}, + event::{Event, EventArray, EventContainer, LogEvent, into_event_stream}, test_util::{ mock::{ basic_sink, basic_sink_failing_healthcheck, basic_sink_with_data, basic_source, @@ -21,10 +21,10 @@ use crate::{ topology::{RunningTopology, TopologyPieces}, }; use crate::{schema::Definition, source_sender::SourceSenderItem}; -use futures::{future, stream, StreamExt}; +use futures::{StreamExt, future, stream}; use tokio::{ task::yield_now, - time::{sleep, Duration}, + time::{Duration, sleep}, }; use vector_lib::buffers::{BufferConfig, BufferType, WhenFull}; use vector_lib::config::ComponentKey; @@ -300,10 +300,12 @@ async fn topology_remove_one_source() { config.add_source("in1", basic_source().1); config.add_sink("out1", &["in1"], sink1); - assert!(topology - .reload_config_and_respawn(config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(config.build().unwrap(), Default::default()) + .await + .unwrap() + ); // Send an event into both source #1 and source #2: let mut event1 = Event::Log(LogEvent::from("this")); @@ -349,10 +351,12 @@ async fn topology_remove_one_sink() { config.add_source("in1", basic_source().1); config.add_sink("out1", &["in1"], basic_sink(10).1); - assert!(topology - .reload_config_and_respawn(config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(config.build().unwrap(), Default::default()) + .await + .unwrap() + ); let mut event = Event::Log(LogEvent::from("this")); @@ -402,10 +406,12 @@ async fn topology_remove_one_transform() { config.add_transform("t2", &["in1"], transform2); config.add_sink("out1", &["t2"], sink2); - assert!(topology - .reload_config_and_respawn(config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(config.build().unwrap(), Default::default()) + .await + .unwrap() + ); // Send the same event to both sources: let event = Event::Log(LogEvent::from("this")); @@ -451,10 +457,12 @@ async fn topology_swap_source() { config.add_source("in2", source2); config.add_sink("out1", &["in2"], sink2); - assert!(topology - .reload_config_and_respawn(config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(config.build().unwrap(), Default::default()) + .await + .unwrap() + ); // Send an event into both source #1 and source #2: let event1 = Event::Log(LogEvent::from("this")); @@ -516,10 +524,12 @@ async fn topology_swap_transform() { config.add_transform("t1", &["in1"], transform2); config.add_sink("out1", &["t1"], sink2); - assert!(topology - .reload_config_and_respawn(config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(config.build().unwrap(), Default::default()) + .await + .unwrap() + ); // Send an event into both source #1 and source #2: let event1 = Event::Log(LogEvent::from("this")); @@ -568,10 +578,12 @@ async fn topology_swap_sink() { config.add_source("in1", source2); config.add_sink("out1", &["in1"], sink2); - assert!(topology - .reload_config_and_respawn(config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(config.build().unwrap(), Default::default()) + .await + .unwrap() + ); // Send an event into both source #1 and source #2: let mut event1 = Event::Log(LogEvent::from("this")); @@ -656,10 +668,12 @@ async fn topology_swap_transform_is_atomic() { config.add_transform("t1", &["in1"], transform1v2); config.add_sink("out1", &["t1"], basic_sink(10).1); - assert!(topology - .reload_config_and_respawn(config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(config.build().unwrap(), Default::default()) + .await + .unwrap() + ); run_control.store(false, Ordering::Release); h_in.await.unwrap(); @@ -692,10 +706,12 @@ async fn topology_rebuild_connected() { config.add_source("in1", source1); config.add_sink("out1", &["in1"], sink1); - assert!(topology - .reload_config_and_respawn(config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(config.build().unwrap(), Default::default()) + .await + .unwrap() + ); let mut event1 = Event::Log(LogEvent::from("this")); let mut event2 = Event::Log(LogEvent::from("that")); @@ -751,10 +767,12 @@ async fn topology_rebuild_connected_transform() { config.add_transform("t2", &["t1"], transform2); config.add_sink("out1", &["t2"], sink2); - assert!(topology - .reload_config_and_respawn(config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(config.build().unwrap(), Default::default()) + .await + .unwrap() + ); let mut event = Event::Log(LogEvent::from("this")); let h_out1 = tokio::spawn(out1.flat_map(into_event_stream).collect::>()); @@ -806,10 +824,12 @@ async fn topology_optional_healthcheck_does_not_fail_reload() { let config = basic_config(); let (mut topology, _) = start_topology(config, false).await; let config = basic_config_with_sink_failing_healthcheck(); - assert!(topology - .reload_config_and_respawn(config, Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(config, Default::default()) + .await + .unwrap() + ); } #[tokio::test] @@ -819,10 +839,12 @@ async fn topology_healthcheck_not_run_on_unchanged_reload() { let (mut topology, _) = start_topology(config, false).await; let mut config = basic_config_with_sink_failing_healthcheck(); config.healthchecks.require_healthy = true; - assert!(topology - .reload_config_and_respawn(config, Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(config, Default::default()) + .await + .unwrap() + ); } #[tokio::test] @@ -845,10 +867,12 @@ async fn topology_healthcheck_run_for_changes_on_reload() { let mut config = config.build().unwrap(); config.healthchecks.require_healthy = true; - assert!(!topology - .reload_config_and_respawn(config, Default::default()) - .await - .unwrap()); + assert!( + !topology + .reload_config_and_respawn(config, Default::default()) + .await + .unwrap() + ); } #[tokio::test] diff --git a/src/topology/test/reload.rs b/src/topology/test/reload.rs index c2f540cecd667..0f58982180313 100644 --- a/src/topology/test/reload.rs +++ b/src/topology/test/reload.rs @@ -65,10 +65,12 @@ async fn topology_reuse_old_port() { new_config.add_sink("out", &["in2"], basic_sink(1).1); let (mut topology, _) = start_topology(old_config.build().unwrap(), false).await; - assert!(topology - .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) + .await + .unwrap() + ); } #[tokio::test] @@ -90,10 +92,12 @@ async fn topology_rebuild_old() { let _bind = TcpListener::bind(address_1).unwrap(); let (mut topology, _) = start_topology(old_config.build().unwrap(), false).await; - assert!(!topology - .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + !topology + .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) + .await + .unwrap() + ); } #[tokio::test] @@ -107,10 +111,12 @@ async fn topology_old() { old_config.add_sink("out", &["in"], basic_sink(1).1); let (mut topology, _) = start_topology(old_config.clone().build().unwrap(), false).await; - assert!(topology - .reload_config_and_respawn(old_config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(old_config.build().unwrap(), Default::default()) + .await + .unwrap() + ); } #[tokio::test] @@ -258,29 +264,35 @@ async fn topology_readd_input() { new_config.add_source("in1", internal_metrics_source()); new_config.add_source("in2", internal_metrics_source()); new_config.add_sink("out", &["in1"], prom_exporter_sink(address_0, 1)); - assert!(topology - .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) + .await + .unwrap() + ); // re-add in2 let mut new_config = Config::builder(); new_config.add_source("in1", internal_metrics_source()); new_config.add_source("in2", internal_metrics_source()); new_config.add_sink("out", &["in1", "in2"], prom_exporter_sink(address_0, 1)); - assert!(topology - .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) + .await + .unwrap() + ); sleep(Duration::from_secs(1)).await; topology.stop().await; // sink should not crash - assert!(UnboundedReceiverStream::new(crash) - .collect::>() - .await - .is_empty()); + assert!( + UnboundedReceiverStream::new(crash) + .collect::>() + .await + .is_empty() + ); } #[tokio::test] @@ -298,10 +310,12 @@ async fn topology_reload_component() { topology.extend_reload_set(HashSet::from_iter(vec![ComponentKey::from("out")])); - assert!(topology - .reload_config_and_respawn(old_config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(old_config.build().unwrap(), Default::default()) + .await + .unwrap() + ); // TODO: Implement notification to avoid the sleep() // Give the old topology configuration a chance to shutdown cleanly, etc. @@ -329,10 +343,12 @@ async fn reload_sink_test( sleep(Duration::from_secs(1)).await; // Now reload the topology with the "new" configuration, and make sure that a component is now listening on `new_address`. - assert!(topology - .reload_config_and_respawn(new_config, Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(new_config, Default::default()) + .await + .unwrap() + ); // Give the old topology configuration a chance to shutdown cleanly, etc. sleep(Duration::from_secs(2)).await; diff --git a/src/topology/test/source_finished.rs b/src/topology/test/source_finished.rs index 7fcba3a3ade16..2e1495dc4223c 100644 --- a/src/topology/test/source_finished.rs +++ b/src/topology/test/source_finished.rs @@ -1,5 +1,5 @@ -use tokio::time::{timeout, Duration}; -use vector_lib::codecs::{encoding::FramingConfig, TextSerializerConfig}; +use tokio::time::{Duration, timeout}; +use vector_lib::codecs::{TextSerializerConfig, encoding::FramingConfig}; use crate::{ config::Config, diff --git a/src/topology/test/transient_state.rs b/src/topology/test/transient_state.rs index 514f9dc86457b..ed5daca4c0f62 100644 --- a/src/topology/test/transient_state.rs +++ b/src/topology/test/transient_state.rs @@ -29,10 +29,12 @@ async fn closed_source() { topology.sources_finished().await; - assert!(topology - .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) + .await + .unwrap() + ); } #[tokio::test] @@ -51,10 +53,12 @@ async fn remove_sink() { new_config.add_sink("out1", &["trans"], basic_sink(1).1); let (mut topology, _) = start_topology(old_config.build().unwrap(), false).await; - assert!(topology - .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) + .await + .unwrap() + ); } #[tokio::test] @@ -74,10 +78,12 @@ async fn remove_transform() { new_config.add_sink("out1", &["trans1"], basic_sink(1).1); let (mut topology, _) = start_topology(old_config.build().unwrap(), false).await; - assert!(topology - .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) + .await + .unwrap() + ); } #[tokio::test] @@ -98,8 +104,10 @@ async fn replace_transform() { new_config.add_sink("out1", &["trans1"], basic_sink(1).1); let (mut topology, _) = start_topology(old_config.build().unwrap(), false).await; - assert!(topology - .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) - .await - .unwrap()); + assert!( + topology + .reload_config_and_respawn(new_config.build().unwrap(), Default::default()) + .await + .unwrap() + ); } diff --git a/src/trace.rs b/src/trace.rs index 9ee5c97350205..eb8cd7dbc3f04 100644 --- a/src/trace.rs +++ b/src/trace.rs @@ -4,12 +4,12 @@ use std::{ marker::PhantomData, str::FromStr, sync::{ - atomic::{AtomicBool, Ordering}, Mutex, MutexGuard, OnceLock, + atomic::{AtomicBool, Ordering}, }, }; -use futures_util::{future::ready, Stream, StreamExt}; +use futures_util::{Stream, StreamExt, future::ready}; use metrics_tracing_context::MetricsLayer; use tokio::sync::{ broadcast::{self, Receiver, Sender}, @@ -19,11 +19,11 @@ use tokio_stream::wrappers::BroadcastStream; use tracing::{Event, Subscriber}; use tracing_limit::RateLimitedLayer; use tracing_subscriber::{ + Layer, filter::LevelFilter, layer::{Context, SubscriberExt}, registry::LookupSpan, util::SubscriberInitExt, - Layer, }; pub use tracing_tower::{InstrumentableService, InstrumentedService}; use vector_lib::lookup::event_path; diff --git a/src/transforms/aggregate.rs b/src/transforms/aggregate.rs index 377edc3ec67bc..b1e008cd997ae 100644 --- a/src/transforms/aggregate.rs +++ b/src/transforms/aggregate.rs @@ -1,5 +1,5 @@ use std::{ - collections::{hash_map::Entry, HashMap}, + collections::{HashMap, hash_map::Entry}, pin::Pin, time::Duration, }; @@ -370,8 +370,8 @@ mod tests { use crate::schema::Definition; use crate::{ event::{ - metric::{MetricKind, MetricValue}, Event, Metric, + metric::{MetricKind, MetricValue}, }, test_util::components::assert_transform_compliance, transforms::test::create_topology, diff --git a/src/transforms/aws_ec2_metadata.rs b/src/transforms/aws_ec2_metadata.rs index 226e34f831517..9c0f75f3af4b0 100644 --- a/src/transforms/aws_ec2_metadata.rs +++ b/src/transforms/aws_ec2_metadata.rs @@ -4,20 +4,20 @@ use std::{collections::HashSet, error, fmt, future::ready, pin::Pin}; use arc_swap::ArcSwap; use bytes::Bytes; use futures::{Stream, StreamExt}; -use http::{uri::PathAndQuery, Request, StatusCode, Uri}; -use hyper::{body::to_bytes as body_to_bytes, Body}; +use http::{Request, StatusCode, Uri, uri::PathAndQuery}; +use hyper::{Body, body::to_bytes as body_to_bytes}; use serde::Deserialize; use serde_with::serde_as; use snafu::ResultExt as _; -use tokio::time::{sleep, Duration, Instant}; +use tokio::time::{Duration, Instant, sleep}; use tracing::Instrument; use vector_lib::config::LogNamespace; use vector_lib::configurable::configurable_component; +use vector_lib::lookup::OwnedTargetPath; use vector_lib::lookup::lookup_v2::{OptionalTargetPath, OwnedSegment}; use vector_lib::lookup::owned_value_path; -use vector_lib::lookup::OwnedTargetPath; -use vrl::value::kind::Collection; use vrl::value::Kind; +use vrl::value::kind::Collection; use crate::config::OutputId; use crate::{ @@ -744,11 +744,11 @@ mod integration_tests { use tokio::sync::mpsc; use tokio_stream::wrappers::ReceiverStream; use vector_lib::lookup::lookup_v2::{OwnedSegment, OwnedValuePath}; - use vector_lib::lookup::{event_path, PathPrefix}; + use vector_lib::lookup::{PathPrefix, event_path}; use super::*; use crate::{ - event::{metric, LogEvent, Metric}, + event::{LogEvent, Metric, metric}, test_util::{components::assert_transform_compliance, next_addr}, transforms::test::create_topology, }; diff --git a/src/transforms/dedupe/config.rs b/src/transforms/dedupe/config.rs index 57ac09cb342cb..920c0ea98668c 100644 --- a/src/transforms/dedupe/config.rs +++ b/src/transforms/dedupe/config.rs @@ -1,5 +1,5 @@ use vector_lib::{ - config::{clone_input_definitions, LogNamespace}, + config::{LogNamespace, clone_input_definitions}, configurable::configurable_component, }; @@ -14,8 +14,8 @@ use crate::{ use super::{ common::{ - default_cache_config, fill_default_fields_match, CacheConfig, FieldMatchConfig, - TimedCacheConfig, + CacheConfig, FieldMatchConfig, TimedCacheConfig, default_cache_config, + fill_default_fields_match, }, timed_transform::TimedDedupe, transform::Dedupe, diff --git a/src/transforms/dedupe/timed_transform.rs b/src/transforms/dedupe/timed_transform.rs index a092971a46ab3..9095ecfc6ad68 100644 --- a/src/transforms/dedupe/timed_transform.rs +++ b/src/transforms/dedupe/timed_transform.rs @@ -7,7 +7,7 @@ use crate::{event::Event, internal_events::DedupeEventsDropped, transforms::Task use super::{ common::{FieldMatchConfig, TimedCacheConfig}, - transform::{build_cache_entry, CacheEntry}, + transform::{CacheEntry, build_cache_entry}, }; #[derive(Clone)] diff --git a/src/transforms/exclusive_route/config.rs b/src/transforms/exclusive_route/config.rs index 374dd53ae6cd8..71820d895114c 100644 --- a/src/transforms/exclusive_route/config.rs +++ b/src/transforms/exclusive_route/config.rs @@ -5,8 +5,8 @@ use crate::config::{ }; use crate::schema; use crate::sinks::prelude::configurable_component; -use crate::transforms::exclusive_route::transform::ExclusiveRoute; use crate::transforms::Transform; +use crate::transforms::exclusive_route::transform::ExclusiveRoute; use std::hash::{Hash, Hasher}; use vector_lib::config::clone_input_definitions; diff --git a/src/transforms/exclusive_route/tests.rs b/src/transforms/exclusive_route/tests.rs index 8a63632599499..5a7c29591723e 100644 --- a/src/transforms/exclusive_route/tests.rs +++ b/src/transforms/exclusive_route/tests.rs @@ -5,12 +5,12 @@ use std::collections::HashMap; use indoc::indoc; use vector_lib::transform::TransformOutputsBuf; +use crate::transforms::SyncTransform; use crate::transforms::exclusive_route::config::{ExclusiveRouteConfig, UNMATCHED_ROUTE}; use crate::transforms::exclusive_route::transform::ExclusiveRoute; -use crate::transforms::SyncTransform; use crate::{ - config::{build_unit_tests, ConfigBuilder}, - test_util::components::{init_test, COMPONENT_MULTIPLE_OUTPUTS_TESTS}, + config::{ConfigBuilder, build_unit_tests}, + test_util::components::{COMPONENT_MULTIPLE_OUTPUTS_TESTS, init_test}, }; fn get_outputs_buf() -> (Vec<&'static str>, TransformOutputsBuf) { diff --git a/src/transforms/exclusive_route/transform.rs b/src/transforms/exclusive_route/transform.rs index 56a85a248bea4..b9296bc520098 100644 --- a/src/transforms/exclusive_route/transform.rs +++ b/src/transforms/exclusive_route/transform.rs @@ -1,8 +1,8 @@ use vector_lib::transform::SyncTransform; use crate::conditions::Condition; -use crate::transforms::exclusive_route::config::{ExclusiveRouteConfig, UNMATCHED_ROUTE}; use crate::transforms::TransformOutputsBuf; +use crate::transforms::exclusive_route::config::{ExclusiveRouteConfig, UNMATCHED_ROUTE}; use crate::{config::TransformContext, event::Event}; #[derive(Clone)] diff --git a/src/transforms/filter.rs b/src/transforms/filter.rs index cf98c5a45ffec..f36e2134ccd9d 100644 --- a/src/transforms/filter.rs +++ b/src/transforms/filter.rs @@ -1,4 +1,4 @@ -use vector_lib::config::{clone_input_definitions, LogNamespace}; +use vector_lib::config::{LogNamespace, clone_input_definitions}; use vector_lib::configurable::configurable_component; use vector_lib::internal_event::{Count, InternalEventHandle as _, Registered}; diff --git a/src/transforms/log_to_metric.rs b/src/transforms/log_to_metric.rs index f8566b47fc6d6..02f084e55f0f5 100644 --- a/src/transforms/log_to_metric.rs +++ b/src/transforms/log_to_metric.rs @@ -13,7 +13,7 @@ use vector_lib::{ metric::{Bucket, Quantile}, }, }; -use vrl::path::{parse_target_path, PathParseError}; +use vrl::path::{PathParseError, parse_target_path}; use vrl::{event_path, path}; use crate::config::schema::Definition; @@ -25,13 +25,13 @@ use crate::{ TransformOutput, }, event::{ - metric::{Metric, MetricKind, MetricTags, MetricValue, StatisticKind, TagValue}, Event, Value, + metric::{Metric, MetricKind, MetricTags, MetricValue, StatisticKind, TagValue}, }, internal_events::{ - LogToMetricFieldNullError, LogToMetricParseFloatError, + DROP_EVENT, LogToMetricFieldNullError, LogToMetricParseFloatError, MetricMetadataInvalidFieldValueError, MetricMetadataMetricDetailsNotFoundError, - MetricMetadataParseError, ParserMissingFieldError, DROP_EVENT, + MetricMetadataParseError, ParserMissingFieldError, }, schema, template::{Template, TemplateRenderingError}, @@ -621,7 +621,7 @@ fn get_distribution_value(log: &LogEvent) -> Result None => { return Err(TransformError::PathNotFound { path: "distribution.statistic".to_string(), - }) + }); } }; let statistic_kind = match statistic_str.as_str() { @@ -794,7 +794,7 @@ fn to_metrics(event: &Event) -> Result { None => { return Err(TransformError::PathNotFound { path: "name".to_string(), - }) + }); } }; @@ -814,7 +814,7 @@ fn to_metrics(event: &Event) -> Result { None => { return Err(TransformError::PathNotFound { path: "kind".to_string(), - }) + }); } }; @@ -965,11 +965,11 @@ mod tests { use crate::{ config::log_schema, event::{ - metric::{Metric, MetricKind, MetricValue, StatisticKind}, Event, LogEvent, + metric::{Metric, MetricKind, MetricValue, StatisticKind}, }, }; - use chrono::{offset::TimeZone, DateTime, Timelike, Utc}; + use chrono::{DateTime, Timelike, Utc, offset::TimeZone}; use std::sync::Arc; use std::time::Duration; use tokio::sync::mpsc; diff --git a/src/transforms/lua/v1/mod.rs b/src/transforms/lua/v1/mod.rs index 8f8817bedb5c8..d5aa57af083ed 100644 --- a/src/transforms/lua/v1/mod.rs +++ b/src/transforms/lua/v1/mod.rs @@ -1,6 +1,6 @@ use std::{future::ready, pin::Pin}; -use futures::{stream, Stream, StreamExt}; +use futures::{Stream, StreamExt, stream}; use mlua::ExternalError; use mlua::FromLua; use ordered_float::NotNan; diff --git a/src/transforms/lua/v2/mod.rs b/src/transforms/lua/v2/mod.rs index 71c4a4f008e0d..911cec65af842 100644 --- a/src/transforms/lua/v2/mod.rs +++ b/src/transforms/lua/v2/mod.rs @@ -11,7 +11,7 @@ use crate::config::{ComponentKey, OutputId}; use crate::event::lua::event::LuaEvent; use crate::schema::Definition; use crate::{ - config::{self, DataType, Input, TransformOutput, CONFIG_PATHS}, + config::{self, CONFIG_PATHS, DataType, Input, TransformOutput}, event::Event, internal_events::{LuaBuildError, LuaGcTriggered}, schema, @@ -461,8 +461,8 @@ mod tests { use std::{future::Future, sync::Arc}; use similar_asserts::assert_eq; - use tokio::sync::mpsc::{self, Receiver, Sender}; use tokio::sync::Mutex; + use tokio::sync::mpsc::{self, Receiver, Sender}; use tokio_stream::wrappers::ReceiverStream; use super::*; @@ -470,8 +470,8 @@ mod tests { use crate::transforms::test::create_topology; use crate::{ event::{ - metric::{Metric, MetricKind, MetricValue}, Event, LogEvent, Value, + metric::{Metric, MetricKind, MetricValue}, }, test_util, }; diff --git a/src/transforms/metric_to_log.rs b/src/transforms/metric_to_log.rs index 5cbde65f812c5..a3b92c79149c8 100644 --- a/src/transforms/metric_to_log.rs +++ b/src/transforms/metric_to_log.rs @@ -1,20 +1,20 @@ use chrono::Utc; use serde_json::Value; use std::collections::{BTreeMap, BTreeSet}; +use vector_lib::TimeZone; use vector_lib::codecs::MetricTagValues; use vector_lib::config::LogNamespace; use vector_lib::configurable::configurable_component; -use vector_lib::lookup::{event_path, owned_value_path, path, PathPrefix}; -use vector_lib::TimeZone; +use vector_lib::lookup::{PathPrefix, event_path, owned_value_path, path}; use vrl::path::OwnedValuePath; -use vrl::value::kind::Collection; use vrl::value::Kind; +use vrl::value::kind::Collection; use crate::config::OutputId; use crate::{ config::{ - log_schema, DataType, GenerateConfig, Input, TransformConfig, TransformContext, - TransformOutput, + DataType, GenerateConfig, Input, TransformConfig, TransformContext, TransformOutput, + log_schema, }, event::{self, Event, LogEvent, Metric}, internal_events::MetricToLogSerializeError, @@ -347,7 +347,7 @@ impl FunctionTransform for MetricToLog { mod tests { use std::sync::Arc; - use chrono::{offset::TimeZone, DateTime, Timelike, Utc}; + use chrono::{DateTime, Timelike, Utc, offset::TimeZone}; use futures::executor::block_on; use proptest::prelude::*; use similar_asserts::assert_eq; @@ -358,8 +358,8 @@ mod tests { use super::*; use crate::event::{ - metric::{MetricKind, MetricTags, MetricValue, StatisticKind, TagValue, TagValueSet}, KeyString, Metric, Value, + metric::{MetricKind, MetricTags, MetricValue, StatisticKind, TagValue, TagValueSet}, }; use crate::test_util::{components::assert_transform_compliance, random_string}; use crate::transforms::test::create_topology; diff --git a/src/transforms/mod.rs b/src/transforms/mod.rs index 0247897ee295a..6dd7e74a1e873 100644 --- a/src/transforms/mod.rs +++ b/src/transforms/mod.rs @@ -47,8 +47,8 @@ mod test { use crate::{ config::{ - unit_test::{UnitTestStreamSinkConfig, UnitTestStreamSourceConfig}, ConfigBuilder, TransformConfig, + unit_test::{UnitTestStreamSinkConfig, UnitTestStreamSourceConfig}, }, event::Event, test_util::start_topology, diff --git a/src/transforms/reduce/config.rs b/src/transforms/reduce/config.rs index 3f2f1c967bccb..a71a5405b306a 100644 --- a/src/transforms/reduce/config.rs +++ b/src/transforms/reduce/config.rs @@ -4,25 +4,25 @@ use std::time::Duration; use indexmap::IndexMap; use serde_with::serde_as; -use vrl::path::{parse_target_path, PathPrefix}; +use vrl::path::{PathPrefix, parse_target_path}; use vrl::prelude::{Collection, KeyString, Kind}; use vector_lib::configurable::configurable_component; use crate::conditions::AnyCondition; use crate::config::{ - schema, DataType, Input, LogNamespace, OutputId, TransformConfig, TransformContext, - TransformOutput, + DataType, Input, LogNamespace, OutputId, TransformConfig, TransformContext, TransformOutput, + schema, }; use crate::schema::Definition; use crate::transforms::reduce::merge_strategy::MergeStrategy; -use crate::transforms::{reduce::transform::Reduce, Transform}; +use crate::transforms::{Transform, reduce::transform::Reduce}; /// Configuration for the `reduce` transform. #[serde_as] #[configurable_component(transform( -"reduce", -"Collapse multiple log events into a single event based on a set of conditions and merge strategies.", + "reduce", + "Collapse multiple log events into a single event based on a set of conditions and merge strategies.", ))] #[derive(Clone, Debug, Derivative)] #[derivative(Default)] diff --git a/src/transforms/reduce/merge_strategy.rs b/src/transforms/reduce/merge_strategy.rs index df50942ba7f86..7804f21763b4a 100644 --- a/src/transforms/reduce/merge_strategy.rs +++ b/src/transforms/reduce/merge_strategy.rs @@ -570,7 +570,7 @@ impl ReduceValueMerger for MinNumberMerger { pub trait ReduceValueMerger: std::fmt::Debug + Send + Sync + DynClone { fn add(&mut self, v: Value) -> Result<(), String>; fn insert_into(self: Box, path: &OwnedTargetPath, v: &mut LogEvent) - -> Result<(), String>; + -> Result<(), String>; } dyn_clone::clone_trait_object!(ReduceValueMerger); diff --git a/src/transforms/reduce/transform.rs b/src/transforms/reduce/transform.rs index f216e524fd8e3..a38a9417cb954 100644 --- a/src/transforms/reduce/transform.rs +++ b/src/transforms/reduce/transform.rs @@ -1,22 +1,22 @@ -use std::collections::hash_map::Entry; use std::collections::HashMap; +use std::collections::hash_map::Entry; use std::pin::Pin; use std::time::{Duration, Instant}; use crate::internal_events::ReduceAddEventError; use crate::transforms::reduce::merge_strategy::{ - get_value_merger, MergeStrategy, ReduceValueMerger, + MergeStrategy, ReduceValueMerger, get_value_merger, }; use crate::{ conditions::Condition, - event::{discriminant::Discriminant, Event, EventMetadata, LogEvent}, + event::{Event, EventMetadata, LogEvent, discriminant::Discriminant}, internal_events::ReduceStaleEventFlushed, - transforms::{reduce::config::ReduceConfig, TaskTransform}, + transforms::{TaskTransform, reduce::config::ReduceConfig}, }; use futures::Stream; use indexmap::IndexMap; -use vector_lib::stream::expiration_map::{map_with_expiration, Emitter}; -use vrl::path::{parse_target_path, OwnedTargetPath}; +use vector_lib::stream::expiration_map::{Emitter, map_with_expiration}; +use vrl::path::{OwnedTargetPath, parse_target_path}; use vrl::prelude::KeyString; #[derive(Clone, Debug)] @@ -358,7 +358,7 @@ mod test { use vector_lib::lookup::owned_value_path; use crate::config::schema::Definition; - use crate::config::{schema, LogNamespace, OutputId, TransformConfig}; + use crate::config::{LogNamespace, OutputId, TransformConfig, schema}; use crate::event::{LogEvent, Value}; use crate::test_util::components::assert_transform_compliance; use crate::transforms::test::create_topology; @@ -640,9 +640,10 @@ max_events = 0 match reduce_config { Ok(_conf) => unreachable!("max_events=0 should be rejected."), - Err(err) => assert!(err - .to_string() - .contains("invalid value: integer `0`, expected a nonzero usize")), + Err(err) => assert!( + err.to_string() + .contains("invalid value: integer `0`, expected a nonzero usize") + ), } } diff --git a/src/transforms/remap.rs b/src/transforms/remap.rs index 15af2ad2eacb2..dd739db58aaab 100644 --- a/src/transforms/remap.rs +++ b/src/transforms/remap.rs @@ -8,14 +8,14 @@ use std::{ }; use snafu::{ResultExt, Snafu}; +use vector_lib::TimeZone; use vector_lib::codecs::MetricTagValues; use vector_lib::compile_vrl; use vector_lib::config::LogNamespace; use vector_lib::configurable::configurable_component; use vector_lib::enrichment::TableRegistry; -use vector_lib::lookup::{metadata_path, owned_value_path, PathPrefix}; +use vector_lib::lookup::{PathPrefix, metadata_path, owned_value_path}; use vector_lib::schema::Definition; -use vector_lib::TimeZone; use vector_vrl_functions::set_semantic_meaning::MeaningList; use vrl::compiler::runtime::{Runtime, Terminate}; use vrl::compiler::state::ExternalEnv; @@ -27,15 +27,15 @@ use vrl::value::{Kind, Value}; use crate::config::OutputId; use crate::{ + Result, config::{ - log_schema, ComponentKey, DataType, Input, TransformConfig, TransformContext, - TransformOutput, + ComponentKey, DataType, Input, TransformConfig, TransformContext, TransformOutput, + log_schema, }, event::{Event, TargetEvents, VrlTarget}, internal_events::{RemapMappingAbort, RemapMappingError}, schema, transforms::{SyncTransform, Transform, TransformOutputsBuf}, - Result, }; const DROPPED: &str = "dropped"; @@ -185,7 +185,7 @@ impl RemapConfig { .lock() .expect("Data poisoned") .iter() - .find(|v| v.0 .0 == enrichment_tables && v.0 .1 == merged_schema_definition) + .find(|v| v.0.0 == enrichment_tables && v.0.1 == merged_schema_definition) { return res.clone().map_err(Into::into); } @@ -674,17 +674,17 @@ mod tests { use super::*; use crate::metrics::Controller; use crate::{ - config::{build_unit_tests, ConfigBuilder}, + config::{ConfigBuilder, build_unit_tests}, event::{ - metric::{MetricKind, MetricValue}, LogEvent, Metric, Value, + metric::{MetricKind, MetricValue}, }, schema, test_util::components::{ - assert_transform_compliance, init_test, COMPONENT_MULTIPLE_OUTPUTS_TESTS, + COMPONENT_MULTIPLE_OUTPUTS_TESTS, assert_transform_compliance, init_test, }, - transforms::test::create_topology, transforms::OutputBuffer, + transforms::test::create_topology, }; use chrono::DateTime; use tokio::sync::mpsc; diff --git a/src/transforms/route.rs b/src/transforms/route.rs index e9dbb6fb28727..1d0c6a3c51a8d 100644 --- a/src/transforms/route.rs +++ b/src/transforms/route.rs @@ -1,5 +1,5 @@ use indexmap::IndexMap; -use vector_lib::config::{clone_input_definitions, LogNamespace}; +use vector_lib::config::{LogNamespace, clone_input_definitions}; use vector_lib::configurable::configurable_component; use vector_lib::transform::SyncTransform; @@ -183,8 +183,8 @@ mod test { use super::*; use crate::{ - config::{build_unit_tests, ConfigBuilder}, - test_util::components::{init_test, COMPONENT_MULTIPLE_OUTPUTS_TESTS}, + config::{ConfigBuilder, build_unit_tests}, + test_util::components::{COMPONENT_MULTIPLE_OUTPUTS_TESTS, init_test}, }; #[test] diff --git a/src/transforms/sample/transform.rs b/src/transforms/sample/transform.rs index 18fee0c61a262..3570dc722ff5d 100644 --- a/src/transforms/sample/transform.rs +++ b/src/transforms/sample/transform.rs @@ -9,8 +9,8 @@ use crate::{ template::Template, transforms::{FunctionTransform, OutputBuffer}, }; -use vector_lib::lookup::lookup_v2::OptionalValuePath; use vector_lib::lookup::OwnedTargetPath; +use vector_lib::lookup::lookup_v2::OptionalValuePath; /// Exists only for backwards compatability purposes so that the value of sample_rate_key is /// consistent after the internal implementation of the Sample class was modified to work in terms diff --git a/src/transforms/tag_cardinality_limit/config.rs b/src/transforms/tag_cardinality_limit/config.rs index 3a348e8e287a0..5913379f69c52 100644 --- a/src/transforms/tag_cardinality_limit/config.rs +++ b/src/transforms/tag_cardinality_limit/config.rs @@ -4,8 +4,8 @@ use crate::config::{ DataType, GenerateConfig, Input, OutputId, TransformConfig, TransformContext, TransformOutput, }; use crate::schema; -use crate::transforms::tag_cardinality_limit::TagCardinalityLimit; use crate::transforms::Transform; +use crate::transforms::tag_cardinality_limit::TagCardinalityLimit; use vector_lib::config::LogNamespace; use vector_lib::configurable::configurable_component; diff --git a/src/transforms/tag_cardinality_limit/tests.rs b/src/transforms/tag_cardinality_limit/tests.rs index 8e573cc959bd7..951a742ed609c 100644 --- a/src/transforms/tag_cardinality_limit/tests.rs +++ b/src/transforms/tag_cardinality_limit/tests.rs @@ -8,13 +8,13 @@ use vector_lib::event::EventMetadata; use vector_lib::metric_tags; use super::*; -use crate::config::schema::Definition; use crate::config::LogNamespace; +use crate::config::schema::Definition; use crate::event::metric::TagValue; -use crate::event::{metric, Event, Metric, MetricTags}; +use crate::event::{Event, Metric, MetricTags, metric}; use crate::test_util::components::assert_transform_compliance; use crate::transforms::tag_cardinality_limit::config::{ - default_cache_size, BloomFilterConfig, Mode, + BloomFilterConfig, Mode, default_cache_size, }; use crate::transforms::test::create_topology; use tokio::sync::mpsc; @@ -529,11 +529,13 @@ async fn separate_value_limit_per_metric_name(config: TagCardinalityLimitConfig) assert_eq!(new_event_a1, Some(event_a1)); // The second event should have been modified to remove "tag1" let new_event_a2 = new_event_a2.unwrap(); - assert!(!new_event_a2 - .as_metric() - .tags() - .unwrap() - .contains_key("tag1")); + assert!( + !new_event_a2 + .as_metric() + .tags() + .unwrap() + .contains_key("tag1") + ); assert_eq!( "val1", new_event_a2 @@ -546,11 +548,13 @@ async fn separate_value_limit_per_metric_name(config: TagCardinalityLimitConfig) // The third event should have been modified to remove "tag2" let new_event_a3 = new_event_a3.unwrap(); - assert!(!new_event_a3 - .as_metric() - .tags() - .unwrap() - .contains_key("tag2")); + assert!( + !new_event_a3 + .as_metric() + .tags() + .unwrap() + .contains_key("tag2") + ); assert_eq!( "val1", new_event_a3 @@ -569,11 +573,13 @@ async fn separate_value_limit_per_metric_name(config: TagCardinalityLimitConfig) assert_eq!(new_event_c2, Some(event_c2)); // The third event should have been modified to remove "tag2" let new_event_c3 = new_event_c3.unwrap(); - assert!(!new_event_c3 - .as_metric() - .tags() - .unwrap() - .contains_key("tag2")); + assert!( + !new_event_c3 + .as_metric() + .tags() + .unwrap() + .contains_key("tag2") + ); assert_eq!( "val1", new_event_c3 diff --git a/src/transforms/throttle/config.rs b/src/transforms/throttle/config.rs index 75066ee9a22bb..e11629f976ad4 100644 --- a/src/transforms/throttle/config.rs +++ b/src/transforms/throttle/config.rs @@ -1,7 +1,7 @@ use governor::clock; use serde_with::serde_as; use std::time::Duration; -use vector_lib::config::{clone_input_definitions, LogNamespace}; +use vector_lib::config::{LogNamespace, clone_input_definitions}; use vector_lib::configurable::configurable_component; use super::transform::Throttle; diff --git a/src/transforms/throttle/transform.rs b/src/transforms/throttle/transform.rs index ad516098e8156..900695dfa4a99 100644 --- a/src/transforms/throttle/transform.rs +++ b/src/transforms/throttle/transform.rs @@ -1,6 +1,6 @@ use async_stream::stream; use futures::{Stream, StreamExt}; -use governor::{clock, Quota}; +use governor::{Quota, clock}; use snafu::Snafu; use std::hash::Hash; use std::{num::NonZeroU32, pin::Pin, time::Duration}; diff --git a/src/transforms/window/config.rs b/src/transforms/window/config.rs index 21a2a5d36cafc..f04b054ef7bfa 100644 --- a/src/transforms/window/config.rs +++ b/src/transforms/window/config.rs @@ -1,4 +1,4 @@ -use vector_lib::config::{clone_input_definitions, LogNamespace}; +use vector_lib::config::{LogNamespace, clone_input_definitions}; use vector_lib::configurable::configurable_component; use crate::{ diff --git a/src/types.rs b/src/types.rs index 4dff0fa98505c..e376c778d128c 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,4 +1,4 @@ #![allow(missing_docs)] pub use vector_lib::conversion::{ - parse_check_conversion_map, parse_conversion_map, Conversion, Error, + Conversion, Error, parse_check_conversion_map, parse_conversion_map, }; diff --git a/src/utilization.rs b/src/utilization.rs index cdb2cafcf2222..17ac19bce6f7d 100644 --- a/src/utilization.rs +++ b/src/utilization.rs @@ -1,10 +1,10 @@ use std::{ collections::HashMap, pin::Pin, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, time::{Duration, Instant}, }; -use tokio::sync::mpsc::{channel, Receiver, Sender}; +use tokio::sync::mpsc::{Receiver, Sender, channel}; use futures::{Stream, StreamExt}; use metrics::Gauge; diff --git a/src/vector_windows.rs b/src/vector_windows.rs index 21f26796b86d5..fead3981e2fc1 100644 --- a/src/vector_windows.rs +++ b/src/vector_windows.rs @@ -2,13 +2,13 @@ use std::{ffi::OsString, time::Duration}; use windows_service::{ - define_windows_service, + Result, define_windows_service, service::{ ServiceControl, ServiceControlAccept, ServiceExitCode, ServiceState, ServiceStatus, ServiceType, }, service_control_handler::ServiceControlHandlerResult, - service_dispatcher, Result, + service_dispatcher, }; use crate::{app::Application, signal::SignalTo}; @@ -24,12 +24,12 @@ pub mod service_control { use snafu::ResultExt; use windows_service::{ + Result, service::{ ServiceAccess, ServiceErrorControl, ServiceExitCode, ServiceInfo, ServiceStartType, ServiceState, ServiceStatus, }, service_manager::{ServiceManager, ServiceManagerAccess}, - Result, }; use crate::{ @@ -46,8 +46,8 @@ pub mod service_control { impl fmt::Display for ErrorDisplay<'_> { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - if let windows_service::Error::Winapi(ref win_error) = &self.error { - write!(f, "{}", win_error) + if let windows_service::Error::Winapi(win_error) = &self.error { + write!(f, "{win_error}") } else { write!(f, "{}", &self.error) } diff --git a/tests/e2e/datadog/metrics/mod.rs b/tests/e2e/datadog/metrics/mod.rs index a88a3c4c3155a..2d4cda31a1d8f 100644 --- a/tests/e2e/datadog/metrics/mod.rs +++ b/tests/e2e/datadog/metrics/mod.rs @@ -1,5 +1,5 @@ use async_compression::tokio::bufread::{ZstdDecoder, ZstdEncoder}; -use base64::{prelude::BASE64_STANDARD, Engine}; +use base64::{Engine, prelude::BASE64_STANDARD}; use bytes::Bytes; use flate2::read::ZlibDecoder; use std::io::Read; diff --git a/tests/e2e/datadog/metrics/series.rs b/tests/e2e/datadog/metrics/series.rs index 984b9fd63c6f1..e227bfbe47eda 100644 --- a/tests/e2e/datadog/metrics/series.rs +++ b/tests/e2e/datadog/metrics/series.rs @@ -6,8 +6,8 @@ mod ddmetric_proto { } use ddmetric_proto::{ - metric_payload::{MetricSeries, MetricType}, MetricPayload, + metric_payload::{MetricSeries, MetricType}, }; use tracing::info; use vector::common::datadog::DatadogSeriesMetric; diff --git a/tests/e2e/datadog/metrics/sketches.rs b/tests/e2e/datadog/metrics/sketches.rs index 792a1a4e70294..a64a5d12e0cb8 100644 --- a/tests/e2e/datadog/metrics/sketches.rs +++ b/tests/e2e/datadog/metrics/sketches.rs @@ -6,8 +6,8 @@ mod ddmetric_proto { } use ddmetric_proto::{ - sketch_payload::sketch::{Distribution, Dogsketch}, SketchPayload, + sketch_payload::sketch::{Distribution, Dogsketch}, }; use tracing::info; diff --git a/tests/e2e/datadog/mod.rs b/tests/e2e/datadog/mod.rs index a56111ec5cf40..3a1c07a17c87a 100644 --- a/tests/e2e/datadog/mod.rs +++ b/tests/e2e/datadog/mod.rs @@ -2,7 +2,7 @@ pub mod logs; pub mod metrics; use reqwest::{Client, Method}; -use serde::{de::DeserializeOwned, Deserialize}; +use serde::{Deserialize, de::DeserializeOwned}; use serde_json::Value; fn fake_intake_vector_address() -> String { diff --git a/tests/integration/lib.rs b/tests/integration/lib.rs index aafa1b02ae5af..49685c2fa613c 100644 --- a/tests/integration/lib.rs +++ b/tests/integration/lib.rs @@ -1,5 +1,5 @@ use std::{ - fs::{create_dir, OpenOptions}, + fs::{OpenOptions, create_dir}, io::Write, path::PathBuf, }; diff --git a/tests/integration/shutdown.rs b/tests/integration/shutdown.rs index af02d06e07814..b1d9d84941cd7 100644 --- a/tests/integration/shutdown.rs +++ b/tests/integration/shutdown.rs @@ -11,10 +11,10 @@ use std::{ use assert_cmd::prelude::*; use nix::{ - sys::signal::{kill, Signal}, + sys::signal::{Signal, kill}, unistd::Pid, }; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use similar_asserts::assert_eq; use vector::test_util::{next_addr, temp_file};