Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d8891fd
add scaffolding for the differentiation of series API versions
neuronull Oct 2, 2023
91ca255
fix(datadog_metrics sink): fix the integration tests which weren't ac…
neuronull Oct 3, 2023
9afbd83
fix workflows
neuronull Oct 3, 2023
cc9cc2d
clippy
neuronull Oct 3, 2023
597305d
fix filter for traces
neuronull Oct 3, 2023
3f9cd72
add first pass
neuronull Oct 3, 2023
4e204c5
Merge branch 'neuronull/fix_datadog_metrics_sink_integration_tests' i…
neuronull Oct 3, 2023
3a96f18
add testing coverage
neuronull Oct 3, 2023
9923219
cargo.lock
neuronull Oct 3, 2023
4523fcd
reduce duplicated code
neuronull Oct 4, 2023
a87bf0c
cleanup
neuronull Oct 4, 2023
376da18
clippy
neuronull Oct 4, 2023
715cf22
Merge branch 'master' into neuronull/fix_datadog_metrics_sink_integra…
neuronull Oct 4, 2023
7117d98
Merge branch 'neuronull/fix_datadog_metrics_sink_integration_tests' i…
neuronull Oct 4, 2023
5912324
Merge branch 'master' into neuronull/sink_datadog_metrics_v2_series_e…
neuronull Oct 5, 2023
c95a326
feedback ds: remove check for sort by name
neuronull Oct 5, 2023
d73cfe0
feedback ds: extend unit tests for v2
neuronull Oct 5, 2023
c9c0fbc
feedback ds: extend the int test coverage
neuronull Oct 5, 2023
2ac5bbf
Revert "feedback ds: remove check for sort by name"
neuronull Oct 5, 2023
cb92dc5
add explicit sort check
neuronull Oct 5, 2023
96ef122
add env var for v1 support
neuronull Oct 5, 2023
2de3617
check events
neuronull Oct 5, 2023
b9181e0
add note in deprecations
neuronull Oct 6, 2023
4920c7c
Merge branch 'master' into neuronull/sink_datadog_metrics_v2_series_e…
neuronull Oct 10, 2023
d513eaf
Merge branch 'master' into neuronull/sink_datadog_metrics_v2_series_e…
neuronull Oct 10, 2023
244b9ed
remove dead code allow
neuronull Oct 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/DEPRECATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ When introducing a deprecation into Vector, the pull request introducing the dep
the new name will be appended with the text `(formerly OldName)`.
- Add a log message to Vector that is logged at the `WARN` level starting with the word `DEPRECATION` if Vector detects
the deprecated configuration or feature being used (when possible).
- Add the deprecation to [DEPRECATIONS.md](docs/DEPRECATIONS.md) to track migration (if applicable) and removal
- Add the deprecation to [DEPRECATIONS.md](DEPRECATIONS.md) to track migration (if applicable) and removal

When removing a deprecation in a subsequent release, the pull request should:

- Indicate that it is a breaking change by including `!` in the title after the type/scope
- Remove the deprecation from the documentation
- Add a note to the Breaking Changes section of the upgrade guide for the next release with a description and directions
for transitioning if applicable.
- Remove the deprecation from [DEPRECATIONS.md](docs/DEPRECATIONS.md)
- Remove the deprecation from [DEPRECATIONS.md](DEPRECATIONS.md)
1 change: 1 addition & 0 deletions docs/DEPRECATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ See [DEPRECATION.md](docs/DEPRECATION.md#process) for the process for updating t

## To be removed

* Support for `v1` series endpoint in the `datadog_metrics` sink should be removed.
* legacy_openssl_provider v0.34.0 OpenSSL legacy provider flag should be removed
* armv7_rpm v0.34.0 The armv7 RPM packages should be removed (replaced by armv7hl)
* yaml_migration v0.34.0 Prefer loading `/etc/vector/vector.yaml` first
7 changes: 7 additions & 0 deletions lib/vector-core/src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,13 @@ impl Event {
self
}

/// Sets the `source_type` in the event metadata to the provided value.
#[must_use]
pub fn with_source_type(mut self, source_type: &'static str) -> Self {
self.metadata_mut().set_source_type(source_type);
self
}

/// Sets the `upstream_id` in the event metadata to the provided value.
#[must_use]
pub fn with_upstream_id(mut self, upstream_id: Arc<OutputId>) -> Self {
Expand Down
58 changes: 51 additions & 7 deletions src/sinks/datadog/metrics/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::OnceLock;

use http::Uri;
use snafu::ResultExt;
use tower::ServiceBuilder;
Expand Down Expand Up @@ -42,27 +44,63 @@ impl SinkBatchSettings for DatadogMetricsDefaultBatchSettings {
const TIMEOUT_SECS: f64 = 2.0;
}

pub(super) const SERIES_V1_PATH: &str = "/api/v1/series";
pub(super) const SERIES_V2_PATH: &str = "/api/v2/series";
pub(super) const SKETCHES_PATH: &str = "/api/beta/sketches";

// TODO: the series V1 endpoint support is considered deprecated and should be removed in a future release.
// At that time when the V1 support is removed, the SeriesApiVersion stops being useful and can be removed.

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum SeriesApiVersion {
V1,
V2,
}

impl SeriesApiVersion {
pub const fn get_path(self) -> &'static str {
match self {
Self::V1 => SERIES_V1_PATH,
Self::V2 => SERIES_V2_PATH,
}
}
fn get_api_version_backwards_compatible() -> Self {
static API_VERSION: OnceLock<SeriesApiVersion> = OnceLock::new();
*API_VERSION.get_or_init(
|| match option_env!("VECTOR_TEMP_USE_DD_METRICS_SERIES_V1_API") {
Some(_) => Self::V1,
None => Self::V2,
},
)
}
}

/// Various metric type-specific API types.
///
/// Each of these corresponds to a specific request path when making a request to the agent API.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum DatadogMetricsEndpoint {
Series,
Series(SeriesApiVersion),
Sketches,
}

impl DatadogMetricsEndpoint {
/// Gets the content type associated with the specific encoder for a given metric endpoint.
pub const fn content_type(self) -> &'static str {
match self {
DatadogMetricsEndpoint::Series => "application/json",
DatadogMetricsEndpoint::Sketches => "application/x-protobuf",
Self::Series(SeriesApiVersion::V1) => "application/json",
Self::Sketches | Self::Series(SeriesApiVersion::V2) => "application/x-protobuf",
}
}

// Gets whether or not this is a series endpoint.
pub const fn is_series(self) -> bool {
matches!(self, Self::Series)
matches!(self, Self::Series { .. })
}

// Creates an instance of the `Series` variant with the default API version.
pub fn series() -> Self {
Self::Series(SeriesApiVersion::get_api_version_backwards_compatible())
}
}

Expand All @@ -84,7 +122,7 @@ impl DatadogMetricsEndpointConfiguration {
/// Gets the URI for the given Datadog metrics endpoint.
pub fn get_uri_for_endpoint(&self, endpoint: DatadogMetricsEndpoint) -> Uri {
match endpoint {
DatadogMetricsEndpoint::Series => self.series_endpoint.clone(),
DatadogMetricsEndpoint::Series { .. } => self.series_endpoint.clone(),
DatadogMetricsEndpoint::Sketches => self.sketches_endpoint.clone(),
}
}
Expand Down Expand Up @@ -169,8 +207,14 @@ impl DatadogMetricsConfig {
&self,
) -> crate::Result<DatadogMetricsEndpointConfiguration> {
let base_uri = self.get_base_agent_endpoint();
let series_endpoint = build_uri(&base_uri, "/api/v1/series")?;
let sketches_endpoint = build_uri(&base_uri, "/api/beta/sketches")?;

// TODO: the V1 endpoint support is considered deprecated and should be removed in a future release.
// At that time, the get_api_version_backwards_compatible() should be replaced with statically using the v2.
let series_endpoint = build_uri(
&base_uri,
SeriesApiVersion::get_api_version_backwards_compatible().get_path(),
)?;
let sketches_endpoint = build_uri(&base_uri, SKETCHES_PATH)?;

Ok(DatadogMetricsEndpointConfiguration::new(
series_endpoint,
Expand Down
Loading