From 461afbdef457ddb5420caed915c0fcb8d2d497e2 Mon Sep 17 00:00:00 2001 From: Stephen Wakely Date: Wed, 6 Sep 2023 10:30:32 +0100 Subject: [PATCH] remove deprecated functions Signed-off-by: Stephen Wakely --- src/sinks/vector/config.rs | 8 ++++---- src/sources/datadog_agent/metrics.rs | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sinks/vector/config.rs b/src/sinks/vector/config.rs index c83f088c9e35b..b0e2b6c5a8e6f 100644 --- a/src/sinks/vector/config.rs +++ b/src/sinks/vector/config.rs @@ -161,12 +161,12 @@ async fn healthcheck( let request = service.client.health_check(proto::HealthCheckRequest {}); match request.await { - Ok(response) => match proto::ServingStatus::from_i32(response.into_inner().status) { - Some(proto::ServingStatus::Serving) => Ok(()), - Some(status) => Err(Box::new(VectorSinkError::Health { + Ok(response) => match proto::ServingStatus::try_from(response.into_inner().status) { + Ok(proto::ServingStatus::Serving) => Ok(()), + Ok(status) => Err(Box::new(VectorSinkError::Health { status: Some(status.as_str_name()), })), - None => Err(Box::new(VectorSinkError::Health { status: None })), + Err(_) => Err(Box::new(VectorSinkError::Health { status: None })), }, Err(source) => Err(Box::new(VectorSinkError::Request { source })), } diff --git a/src/sources/datadog_agent/metrics.rs b/src/sources/datadog_agent/metrics.rs index d4e8260b1b937..73064da1f671f 100644 --- a/src/sources/datadog_agent/metrics.rs +++ b/src/sources/datadog_agent/metrics.rs @@ -256,8 +256,8 @@ pub(crate) fn decode_ddseries_v2( .then(|| tags.replace("source_type_name".into(), serie.source_type_name)); // As per https://github.com/DataDog/datadog-agent/blob/a62ac9fb13e1e5060b89e731b8355b2b20a07c5b/pkg/serializer/internal/metrics/iterable_series.go#L224 // serie.unit is omitted - match metric_payload::MetricType::from_i32(serie.r#type) { - Some(metric_payload::MetricType::Count) => serie + match metric_payload::MetricType::try_from(serie.r#type) { + Ok(metric_payload::MetricType::Count) => serie .points .iter() .map(|dd_point| { @@ -277,7 +277,7 @@ pub(crate) fn decode_ddseries_v2( .with_namespace(namespace) }) .collect::>(), - Some(metric_payload::MetricType::Gauge) => serie + Ok(metric_payload::MetricType::Gauge) => serie .points .iter() .map(|dd_point| { @@ -297,7 +297,7 @@ pub(crate) fn decode_ddseries_v2( .with_namespace(namespace) }) .collect::>(), - Some(metric_payload::MetricType::Rate) => serie + Ok(metric_payload::MetricType::Rate) => serie .points .iter() .map(|dd_point| { @@ -323,7 +323,7 @@ pub(crate) fn decode_ddseries_v2( .with_namespace(namespace) }) .collect::>(), - Some(metric_payload::MetricType::Unspecified) | None => { + Ok(metric_payload::MetricType::Unspecified) | Err(_) => { warn!("Unspecified metric type ({}).", serie.r#type); Vec::new() }