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/internal_events/mod.rs b/src/internal_events/mod.rs index 2fec43ea4f7cd..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; @@ -230,7 +234,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/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/prometheus/parser.rs b/src/sources/prometheus/parser.rs index 42e729e07adbc..647571de9e211 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}, @@ -17,10 +19,12 @@ fn utc_timestamp(timestamp: Option, default: DateTime) -> DateTime 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) } diff --git a/src/sources/util/mod.rs b/src/sources/util/mod.rs index e7b5706c22d2f..db8660fb05f94 100644 --- a/src/sources/util/mod.rs +++ b/src/sources/util/mod.rs @@ -14,7 +14,7 @@ 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",))] pub mod http_client; #[cfg(any(feature = "sources-aws_sqs", feature = "sources-gcp_pubsub"))] mod message_decoding; @@ -51,7 +51,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;