diff --git a/src/sinks/gcp/stackdriver/metrics/config.rs b/src/sinks/gcp/stackdriver/metrics/config.rs index 057cff32c76c5..99d03d114fd29 100644 --- a/src/sinks/gcp/stackdriver/metrics/config.rs +++ b/src/sinks/gcp/stackdriver/metrics/config.rs @@ -15,7 +15,6 @@ use crate::{ use super::{ request_builder::{StackdriverMetricsEncoder, StackdriverMetricsRequestBuilder}, sink::StackdriverMetricsSink, - StackdriverMetricsDefaultBatchSettings, }; /// Configuration for the `gcp_stackdriver_metrics` sink. @@ -113,10 +112,10 @@ impl SinkConfig for StackdriverConfig { auth.spawn_regenerate_token(); - let stackdriver_logs_service_request_builder = + let stackdriver_metrics_service_request_builder = StackdriverMetricsServiceRequestBuilder { uri, auth }; - let service = HttpService::new(client, stackdriver_logs_service_request_builder); + let service = HttpService::new(client, stackdriver_metrics_service_request_builder); let service = ServiceBuilder::new() .settings(request_limits, http_response_retry_logic()) @@ -136,6 +135,15 @@ impl SinkConfig for StackdriverConfig { } } +#[derive(Clone, Copy, Debug, Default)] +pub struct StackdriverMetricsDefaultBatchSettings; + +impl SinkBatchSettings for StackdriverMetricsDefaultBatchSettings { + const MAX_EVENTS: Option = Some(1); + const MAX_BYTES: Option = None; + const TIMEOUT_SECS: f64 = 1.0; +} + #[derive(Debug, Clone)] pub(super) struct StackdriverMetricsServiceRequestBuilder { pub(super) uri: Uri, diff --git a/src/sinks/gcp/stackdriver/metrics/mod.rs b/src/sinks/gcp/stackdriver/metrics/mod.rs index a73070b11e02f..8c070ff20781a 100644 --- a/src/sinks/gcp/stackdriver/metrics/mod.rs +++ b/src/sinks/gcp/stackdriver/metrics/mod.rs @@ -1,20 +1,9 @@ -// TODO: In order to correctly assert component specification compliance, we would have to do some more advanced mocking -// off the endpoint, which would include also providing a mock OAuth2 endpoint to allow for generating a token from the -// mocked credentials. Let this TODO serve as a placeholder for doing that in the future. - -use crate::sinks::prelude::*; - +//! GCP Cloud Monitoring (formerly Stackdriver Metrics) sink. +//! Sends metrics to [GPC Cloud Monitoring][cloud monitoring]. +//! +//! [cloud monitoring]: https://cloud.google.com/monitoring/docs/monitoring-overview mod config; mod request_builder; mod sink; #[cfg(test)] mod tests; - -#[derive(Clone, Copy, Debug, Default)] -pub struct StackdriverMetricsDefaultBatchSettings; - -impl SinkBatchSettings for StackdriverMetricsDefaultBatchSettings { - const MAX_EVENTS: Option = Some(1); - const MAX_BYTES: Option = None; - const TIMEOUT_SECS: f64 = 1.0; -} diff --git a/src/sinks/gcp/stackdriver/metrics/request_builder.rs b/src/sinks/gcp/stackdriver/metrics/request_builder.rs index a52693c4c4e1e..12e4526f055f5 100644 --- a/src/sinks/gcp/stackdriver/metrics/request_builder.rs +++ b/src/sinks/gcp/stackdriver/metrics/request_builder.rs @@ -97,7 +97,9 @@ impl encoding::Encoder> for StackdriverMetricsEncoder { (*value, interval, gcp::GcpMetricKind::Gauge) } - _ => unreachable!(), + _ => { + unreachable!("sink has filtered out all metrics that aren't counter or gauge by this point") + }, }; let metric_labels = series .tags diff --git a/src/sinks/gcp/stackdriver/metrics/sink.rs b/src/sinks/gcp/stackdriver/metrics/sink.rs index 82f0dc1cb641d..538a666bdd91d 100644 --- a/src/sinks/gcp/stackdriver/metrics/sink.rs +++ b/src/sinks/gcp/stackdriver/metrics/sink.rs @@ -37,7 +37,7 @@ where S::Response: DriverResponse + Send + 'static, S::Error: std::fmt::Debug + Into + Send, { - /// Creates a new `StackdriverLogsSink`. + /// Creates a new `StackdriverMetricsSink`. pub(super) const fn new( service: S, batch_settings: BatcherSettings, diff --git a/src/sinks/gcp/stackdriver/metrics/tests.rs b/src/sinks/gcp/stackdriver/metrics/tests.rs index 5b25168e0ecf9..a27194f1900e4 100644 --- a/src/sinks/gcp/stackdriver/metrics/tests.rs +++ b/src/sinks/gcp/stackdriver/metrics/tests.rs @@ -3,11 +3,11 @@ use futures::{future::ready, stream}; use serde::Deserialize; use vector_core::event::{Metric, MetricKind, MetricValue}; -use super::{config::StackdriverConfig, *}; +use super::config::StackdriverConfig; use crate::{ config::SinkContext, gcp::GcpAuthConfig, - sinks::util::test::build_test_server, + sinks::{prelude::*, util::test::build_test_server}, test_util::{ components::{run_and_assert_sink_compliance, SINK_TAGS}, http::{always_200_response, spawn_blackhole_http_server},