Skip to content

Commit

Permalink
Feedback from Kyle
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com>
  • Loading branch information
StephenWakely committed Oct 11, 2023
1 parent 3cba7bc commit da9ef94
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
14 changes: 11 additions & 3 deletions src/sinks/gcp/stackdriver/metrics/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::{
use super::{
request_builder::{StackdriverMetricsEncoder, StackdriverMetricsRequestBuilder},
sink::StackdriverMetricsSink,
StackdriverMetricsDefaultBatchSettings,
};

/// Configuration for the `gcp_stackdriver_metrics` sink.
Expand Down Expand Up @@ -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())
Expand All @@ -136,6 +135,15 @@ impl SinkConfig for StackdriverConfig {
}
}

#[derive(Clone, Copy, Debug, Default)]
pub struct StackdriverMetricsDefaultBatchSettings;

impl SinkBatchSettings for StackdriverMetricsDefaultBatchSettings {
const MAX_EVENTS: Option<usize> = Some(1);
const MAX_BYTES: Option<usize> = None;
const TIMEOUT_SECS: f64 = 1.0;
}

#[derive(Debug, Clone)]
pub(super) struct StackdriverMetricsServiceRequestBuilder {
pub(super) uri: Uri,
Expand Down
19 changes: 4 additions & 15 deletions src/sinks/gcp/stackdriver/metrics/mod.rs
Original file line number Diff line number Diff line change
@@ -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<usize> = Some(1);
const MAX_BYTES: Option<usize> = None;
const TIMEOUT_SECS: f64 = 1.0;
}
4 changes: 3 additions & 1 deletion src/sinks/gcp/stackdriver/metrics/request_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ impl encoding::Encoder<Vec<Metric>> 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
Expand Down
2 changes: 1 addition & 1 deletion src/sinks/gcp/stackdriver/metrics/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ where
S::Response: DriverResponse + Send + 'static,
S::Error: std::fmt::Debug + Into<crate::Error> + Send,
{
/// Creates a new `StackdriverLogsSink`.
/// Creates a new `StackdriverMetricsSink`.
pub(super) const fn new(
service: S,
batch_settings: BatcherSettings,
Expand Down
4 changes: 2 additions & 2 deletions src/sinks/gcp/stackdriver/metrics/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit da9ef94

Please sign in to comment.