From 499b3ee00a875f08cb332d77124ddfb2e7e51f9c Mon Sep 17 00:00:00 2001 From: Will Wang Date: Thu, 31 Aug 2023 10:06:10 -0400 Subject: [PATCH 1/6] Correct feature flag for http_client module --- src/sources/util/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sources/util/mod.rs b/src/sources/util/mod.rs index e7b5706c22d2f..9ffa7b5536f69 100644 --- a/src/sources/util/mod.rs +++ b/src/sources/util/mod.rs @@ -14,7 +14,11 @@ pub mod grpc; feature = "sources-utils-http-query" ))] pub mod http; -#[cfg(any(feature = "sources-http_client", feature = "sources-prometheus"))] +#[cfg(any( + feature = "sources-http_client", + feature = "sources-prometheus-scrape", + feature = "sources-prometheus-remote-write" +))] pub mod http_client; #[cfg(any(feature = "sources-aws_sqs", feature = "sources-gcp_pubsub"))] mod message_decoding; From 96b7bf8330d0191efc7b3ed53e7bc54b810f3576 Mon Sep 17 00:00:00 2001 From: Will Wang Date: Thu, 31 Aug 2023 10:09:51 -0400 Subject: [PATCH 2/6] Fix compilation for prometheus-scrape --- src/internal_events/mod.rs | 6 +++++- src/internal_events/prometheus.rs | 8 ++++---- src/sources/prometheus/parser.rs | 5 ++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/internal_events/mod.rs b/src/internal_events/mod.rs index 2fec43ea4f7cd..49b04aa724e8f 100644 --- a/src/internal_events/mod.rs +++ b/src/internal_events/mod.rs @@ -230,7 +230,11 @@ pub(crate) use self::nginx_metrics::*; pub(crate) use self::parser::*; #[cfg(feature = "sources-postgresql_metrics")] pub(crate) use self::postgresql_metrics::*; -#[cfg(any(feature = "sources-prometheus", feature = "sinks-prometheus"))] +#[cfg(any( + feature = "sources-prometheus-scrape", + feature = "sources-prometheus-remote-write", + feature = "sinks-prometheus" +))] pub(crate) use self::prometheus::*; #[cfg(feature = "sinks-pulsar")] pub(crate) use self::pulsar::*; diff --git a/src/internal_events/prometheus.rs b/src/internal_events/prometheus.rs index 6b94fa3051c7e..1f0c96684ba19 100644 --- a/src/internal_events/prometheus.rs +++ b/src/internal_events/prometheus.rs @@ -1,9 +1,9 @@ -#[cfg(feature = "sources-prometheus")] +#[cfg(feature = "sources-prometheus-scrape")] use std::borrow::Cow; use hyper::StatusCode; use metrics::counter; -#[cfg(feature = "sources-prometheus")] +#[cfg(feature = "sources-prometheus-scrape")] use prometheus_parser::ParserError; use vector_core::internal_event::InternalEvent; @@ -12,7 +12,7 @@ use vector_common::internal_event::{ error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL, }; -#[cfg(feature = "sources-prometheus")] +#[cfg(feature = "sources-prometheus-scrape")] #[derive(Debug)] pub struct PrometheusParseError<'a> { pub error: ParserError, @@ -20,7 +20,7 @@ pub struct PrometheusParseError<'a> { pub body: Cow<'a, str>, } -#[cfg(feature = "sources-prometheus")] +#[cfg(feature = "sources-prometheus-scrape")] impl<'a> InternalEvent for PrometheusParseError<'a> { fn emit(self) { error!( diff --git a/src/sources/prometheus/parser.rs b/src/sources/prometheus/parser.rs index 42e729e07adbc..7c28597a38164 100644 --- a/src/sources/prometheus/parser.rs +++ b/src/sources/prometheus/parser.rs @@ -1,7 +1,9 @@ use std::cmp::Ordering; use chrono::{DateTime, TimeZone, Utc}; -use prometheus_parser::{proto, GroupKind, MetricGroup, ParserError}; +#[cfg(feature = "sources-prometheus-remote-write")] +use prometheus_parser::proto; +use prometheus_parser::{GroupKind, MetricGroup, ParserError}; use crate::event::{ metric::{Bucket, Metric, MetricKind, MetricTags, MetricValue, Quantile}, @@ -21,6 +23,7 @@ pub(super) fn parse_text(packet: &str) -> Result, ParserError> { prometheus_parser::parse_text(packet).map(reparse_groups) } +#[cfg(feature = "sources-prometheus-remote-write")] pub(super) fn parse_request(request: proto::WriteRequest) -> Result, ParserError> { prometheus_parser::parse_request(request).map(reparse_groups) } From 05e7544994e94140c393ef0139a4a7f981b2247c Mon Sep 17 00:00:00 2001 From: Will Wang Date: Thu, 31 Aug 2023 10:25:02 -0400 Subject: [PATCH 3/6] Replace sources-prometheus --- src/sources/mod.rs | 1 - src/sources/util/mod.rs | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sources/mod.rs b/src/sources/mod.rs index bbc124c5291ca..332dccd7f5e82 100644 --- a/src/sources/mod.rs +++ b/src/sources/mod.rs @@ -67,7 +67,6 @@ pub mod opentelemetry; #[cfg(feature = "sources-postgresql_metrics")] pub mod postgresql_metrics; #[cfg(any( - feature = "sources-prometheus", feature = "sources-prometheus-scrape", feature = "sources-prometheus-remote-write" ))] diff --git a/src/sources/util/mod.rs b/src/sources/util/mod.rs index 9ffa7b5536f69..344fcd98d00ea 100644 --- a/src/sources/util/mod.rs +++ b/src/sources/util/mod.rs @@ -55,7 +55,8 @@ pub use self::body_decoding::Encoding; #[cfg(feature = "sources-utils-http-query")] pub use self::http::add_query_parameters; #[cfg(any( - feature = "sources-prometheus", + feature = "sources-prometheus-scrape", + feature = "sources-prometheus-remote-write", feature = "sources-utils-http-encoding" ))] pub use self::http::decode; From 11f07c3b956bf8f1578915711a87eff7e6ec53b2 Mon Sep 17 00:00:00 2001 From: Will Wang Date: Thu, 31 Aug 2023 10:29:09 -0400 Subject: [PATCH 4/6] Fix compilation sources-prometheus-remote-write --- Cargo.toml | 2 +- src/sources/prometheus/parser.rs | 1 + src/sources/util/mod.rs | 6 +----- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d0ba7db9657dc..2a1afe5831547 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -559,7 +559,7 @@ sources-opentelemetry = ["dep:hex", "dep:opentelemetry-proto", "dep:prost-types" sources-postgresql_metrics = ["dep:postgres-openssl", "dep:tokio-postgres"] sources-prometheus = ["sources-prometheus-scrape", "sources-prometheus-remote-write"] sources-prometheus-scrape = ["dep:prometheus-parser", "sinks-prometheus", "sources-utils-http-client"] -sources-prometheus-remote-write = ["dep:prometheus-parser", "sinks-prometheus", "sources-utils-http-client"] +sources-prometheus-remote-write = ["dep:prometheus-parser", "sinks-prometheus", "sources-utils-http"] sources-redis= ["dep:redis"] sources-socket = ["sources-utils-net", "tokio-util/net"] sources-splunk_hec = ["dep:roaring"] diff --git a/src/sources/prometheus/parser.rs b/src/sources/prometheus/parser.rs index 7c28597a38164..e630c181befe2 100644 --- a/src/sources/prometheus/parser.rs +++ b/src/sources/prometheus/parser.rs @@ -19,6 +19,7 @@ fn utc_timestamp(timestamp: Option, default: DateTime) -> DateTime Result, ParserError> { prometheus_parser::parse_text(packet).map(reparse_groups) } diff --git a/src/sources/util/mod.rs b/src/sources/util/mod.rs index 344fcd98d00ea..db8660fb05f94 100644 --- a/src/sources/util/mod.rs +++ b/src/sources/util/mod.rs @@ -14,11 +14,7 @@ pub mod grpc; feature = "sources-utils-http-query" ))] pub mod http; -#[cfg(any( - feature = "sources-http_client", - feature = "sources-prometheus-scrape", - feature = "sources-prometheus-remote-write" -))] +#[cfg(any(feature = "sources-http_client", feature = "sources-prometheus-scrape",))] pub mod http_client; #[cfg(any(feature = "sources-aws_sqs", feature = "sources-gcp_pubsub"))] mod message_decoding; From 033145fcae7b9dacecd34c1bccfa1e849e5d4be4 Mon Sep 17 00:00:00 2001 From: Will Wang Date: Thu, 31 Aug 2023 10:50:22 -0400 Subject: [PATCH 5/6] Replace sources-prometheus --- src/internal_events/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/internal_events/mod.rs b/src/internal_events/mod.rs index 49b04aa724e8f..2692212dc9e2e 100644 --- a/src/internal_events/mod.rs +++ b/src/internal_events/mod.rs @@ -94,7 +94,11 @@ mod parser; #[cfg(feature = "sources-postgresql_metrics")] mod postgresql_metrics; mod process; -#[cfg(any(feature = "sources-prometheus", feature = "sinks-prometheus"))] +#[cfg(any( + feature = "sources-prometheus-scrape", + feature = "sources-prometheus-remote-write", + feature = "sinks-prometheus" +))] mod prometheus; #[cfg(feature = "sinks-pulsar")] mod pulsar; From 84ad14a13bf971e74f4f8f7d03efd61b5fd45fcd Mon Sep 17 00:00:00 2001 From: Will Wang Date: Thu, 31 Aug 2023 12:07:30 -0400 Subject: [PATCH 6/6] Fix test compilation --- src/sources/prometheus/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sources/prometheus/parser.rs b/src/sources/prometheus/parser.rs index e630c181befe2..647571de9e211 100644 --- a/src/sources/prometheus/parser.rs +++ b/src/sources/prometheus/parser.rs @@ -19,7 +19,7 @@ fn utc_timestamp(timestamp: Option, default: DateTime) -> DateTime Result, ParserError> { prometheus_parser::parse_text(packet).map(reparse_groups) }