Skip to content

Commit

Permalink
Merge branch 'main' into ivoanjo/prof-9476-managed-string-storage-try…
Browse files Browse the repository at this point in the history
…3-clean
  • Loading branch information
ivoanjo authored Jan 14, 2025
2 parents 20b9469 + 5fd43ab commit 3d22213
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 4 deletions.
84 changes: 81 additions & 3 deletions LICENSE-3rdparty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24363,7 +24363,37 @@ third_party_libraries:
limitations under the License.

- license: BSD-3-Clause
text: NOT FOUND
text: |+
BSD 3-Clause License

Copyright (c) 2019, Standard Cognition
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- package_name: serde
package_version: 1.0.214
repository: https://github.com/serde-rs/serde
Expand Down Expand Up @@ -42298,7 +42328,31 @@ third_party_libraries:
license: BSD-2-Clause OR Apache-2.0 OR MIT
licenses:
- license: BSD-2-Clause
text: NOT FOUND
text: |
Copyright 2019 The Fuchsia Authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- license: Apache-2.0
text: |2+
Apache License
Expand Down Expand Up @@ -42537,7 +42591,31 @@ third_party_libraries:
license: BSD-2-Clause OR Apache-2.0 OR MIT
licenses:
- license: BSD-2-Clause
text: NOT FOUND
text: |
Copyright 2019 The Fuchsia Authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- license: Apache-2.0
text: |2+
Apache License
Expand Down
8 changes: 8 additions & 0 deletions crashtracker/src/crash_info/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ impl TelemetryCrashUploader {
http::header::CONTENT_TYPE,
ddcommon::header::APPLICATION_JSON,
)
.header(
ddtelemetry::worker::http_client::header::API_VERSION,
ddtelemetry::data::ApiVersion::V2.to_str(),
)
.header(
ddtelemetry::worker::http_client::header::REQUEST_TYPE,
"logs",
)
.body(serde_json::to_string(&payload)?.into())?;

tokio::time::timeout(
Expand Down
8 changes: 8 additions & 0 deletions crashtracker/src/rfc5_crash_info/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ impl TelemetryCrashUploader {
http::header::CONTENT_TYPE,
ddcommon::header::APPLICATION_JSON,
)
.header(
ddtelemetry::worker::http_client::header::API_VERSION,
ddtelemetry::data::ApiVersion::V2.to_str(),
)
.header(
ddtelemetry::worker::http_client::header::REQUEST_TYPE,
"logs",
)
.body(serde_json::to_string(&payload)?.into())?;

tokio::time::timeout(
Expand Down
7 changes: 6 additions & 1 deletion data-pipeline-ffi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use data_pipeline::trace_exporter::error::{
BuilderErrorKind, NetworkErrorKind, TraceExporterError,
AgentErrorKind, BuilderErrorKind, NetworkErrorKind, TraceExporterError,
};
use std::ffi::{c_char, CString};
use std::fmt::Display;
Expand All @@ -19,6 +19,7 @@ pub enum ExporterErrorCode {
HttpBodyFormat,
HttpBodyTooLong,
HttpClient,
HttpEmptyBody,
HttpParse,
HttpServer,
HttpUnknown,
Expand All @@ -43,6 +44,7 @@ impl Display for ExporterErrorCode {
Self::HttpBodyFormat => write!(f, "Error parsing HTTP body"),
Self::HttpBodyTooLong => write!(f, "HTTP body too long"),
Self::HttpClient => write!(f, "HTTP error orgininated by client"),
Self::HttpEmptyBody => write!(f, "HTTP empty body"),
Self::HttpParse => write!(f, "Error while parsing HTTP message"),
Self::HttpServer => write!(f, "HTTP error orgininated by server"),
Self::HttpWrongStatus => write!(f, "HTTP wrong status number"),
Expand Down Expand Up @@ -79,6 +81,9 @@ impl ExporterError {
impl From<TraceExporterError> for ExporterError {
fn from(value: TraceExporterError) -> Self {
let code = match &value {
TraceExporterError::Agent(e) => match e {
AgentErrorKind::EmptyResponse => ExporterErrorCode::HttpEmptyBody,
},
TraceExporterError::Builder(e) => match e {
BuilderErrorKind::InvalidUri => ExporterErrorCode::InvalidUrl,
},
Expand Down
15 changes: 15 additions & 0 deletions data-pipeline/src/trace_exporter/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ use serde_json::error::Error as SerdeError;
use std::error::Error;
use std::fmt::{Debug, Display};

#[derive(Debug, PartialEq)]
pub enum AgentErrorKind {
EmptyResponse,
}

impl Display for AgentErrorKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
AgentErrorKind::EmptyResponse => write!(f, "Agent empty response"),
}
}
}

#[derive(Debug, PartialEq)]
pub enum BuilderErrorKind {
InvalidUri,
Expand Down Expand Up @@ -93,6 +106,7 @@ impl RequestError {
/// TraceExporterError holds different types of errors that occur when handling traces.
#[derive(Debug)]
pub enum TraceExporterError {
Agent(AgentErrorKind),
Builder(BuilderErrorKind),
Deserialization(DecodeError),
Io(std::io::Error),
Expand Down Expand Up @@ -150,6 +164,7 @@ impl From<std::io::Error> for TraceExporterError {
impl Display for TraceExporterError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TraceExporterError::Agent(e) => std::fmt::Display::fmt(e, f),
TraceExporterError::Builder(e) => std::fmt::Display::fmt(e, f),
TraceExporterError::Deserialization(e) => std::fmt::Display::fmt(e, f),
TraceExporterError::Io(e) => std::fmt::Display::fmt(e, f),
Expand Down
47 changes: 47 additions & 0 deletions data-pipeline/src/trace_exporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ impl TraceExporter {
TraceExporterInputFormat::V04 => self.send_deser_ser(data),
}
.and_then(|res| {
if res.is_empty() {
return Err(TraceExporterError::Agent(
error::AgentErrorKind::EmptyResponse,
));
}

let rates = res.parse::<Rates>()?;

let rate = rates.get(&self.metadata.service, &self.metadata.env)?;
Expand Down Expand Up @@ -917,6 +923,7 @@ pub trait ResponseCallback {

#[cfg(test)]
mod tests {
use self::error::AgentErrorKind;
use self::error::BuilderErrorKind;
use super::*;
use datadog_trace_utils::span_v04::Span;
Expand Down Expand Up @@ -1619,4 +1626,44 @@ mod tests {

assert_eq!(code, 500);
}

#[test]
#[cfg_attr(miri, ignore)]
fn agent_empty_response_error() {
let server = MockServer::start();
let _agent = server.mock(|_, then| {
then.status(200)
.header("content-type", "application/json")
.body("");
});

let exporter = TraceExporterBuilder::default()
.set_url(&server.url("/"))
.set_service("foo")
.set_env("foo-env")
.set_tracer_version("v0.1")
.set_language("nodejs")
.set_language_version("1.0")
.set_language_interpreter("v8")
.build()
.unwrap();

let traces: Vec<Vec<Span>> = vec![vec![Span {
name: BytesString::from_slice(b"test").unwrap(),
..Default::default()
}]];
let bytes = tinybytes::Bytes::from(
rmp_serde::to_vec_named(&traces).expect("failed to serialize static trace"),
);
let err = exporter.send(bytes, 1);

assert!(err.is_err());
assert_eq!(
match err.unwrap_err() {
TraceExporterError::Agent(e) => Some(e),
_ => None,
},
Some(AgentErrorKind::EmptyResponse)
);
}
}

0 comments on commit 3d22213

Please sign in to comment.