Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions data-pipeline/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
// Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/
// SPDX-License-Identifier: Apache-2.0
#![deny(missing_docs)]

//! TraceExporter provides a minimum viable product (MVP) to send traces to agents. The aim of the
//! project at this state is to provide a basic API in order to test its viability and integration
//! in different languages.

#[allow(missing_docs)]
pub mod span_concentrator;
#[allow(missing_docs)]
pub mod trace_exporter;
18 changes: 18 additions & 0 deletions data-pipeline/src/trace_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub enum TraceExporterInputFormat {
/// Proxy format is used when the traces are to be sent to the agent without processing them.
/// The whole payload is sent as is to the agent.
Proxy,
#[allow(missing_docs)]
#[default]
V04,
}
Expand All @@ -30,8 +31,10 @@ pub enum TraceExporterInputFormat {
#[derive(Copy, Clone, Debug, Default, PartialEq)]
#[repr(C)]
pub enum TraceExporterOutputFormat {
#[allow(missing_docs)]
#[default]
V04,
#[allow(missing_docs)]
V07,
}

Expand Down Expand Up @@ -105,6 +108,7 @@ impl<'a> From<&'a TracerTags> for HashMap<&'static str, String> {
}
}

#[allow(missing_docs)]
pub struct TraceExporter {
endpoint: Endpoint,
tags: TracerTags,
Expand All @@ -116,10 +120,12 @@ pub struct TraceExporter {
}

impl TraceExporter {
#[allow(missing_docs)]
pub fn builder() -> TraceExporterBuilder {
TraceExporterBuilder::default()
}

#[allow(missing_docs)]
pub fn send(&self, data: &[u8], trace_count: usize) -> Result<String, String> {
match self.input_format {
TraceExporterInputFormat::Proxy => self.send_proxy(data, trace_count),
Expand Down Expand Up @@ -257,6 +263,7 @@ impl TraceExporter {
}
}

#[allow(missing_docs)]
#[derive(Default)]
pub struct TraceExporterBuilder {
url: Option<String>,
Expand All @@ -270,46 +277,55 @@ pub struct TraceExporterBuilder {
}

impl TraceExporterBuilder {
#[allow(missing_docs)]
pub fn set_url(mut self, url: &str) -> Self {
self.url = Some(url.to_owned());
self
}

#[allow(missing_docs)]
pub fn set_tracer_version(mut self, tracer_version: &str) -> Self {
tracer_version.clone_into(&mut self.tracer_version);
self
}

#[allow(missing_docs)]
pub fn set_language(mut self, lang: &str) -> Self {
lang.clone_into(&mut self.language);
self
}

#[allow(missing_docs)]
pub fn set_language_version(mut self, lang_version: &str) -> Self {
lang_version.clone_into(&mut self.language_version);
self
}

#[allow(missing_docs)]
pub fn set_language_interpreter(mut self, lang_interpreter: &str) -> Self {
lang_interpreter.clone_into(&mut self.language_interpreter);
self
}

#[allow(missing_docs)]
pub fn set_input_format(mut self, input_format: TraceExporterInputFormat) -> Self {
self.input_format = input_format;
self
}

#[allow(missing_docs)]
pub fn set_output_format(mut self, output_format: TraceExporterOutputFormat) -> Self {
self.output_format = output_format;
self
}

#[allow(missing_docs)]
pub fn set_response_callback(mut self, response_callback: Box<dyn ResponseCallback>) -> Self {
self.response_callback = Some(response_callback);
self
}

#[allow(missing_docs)]
pub fn build(mut self) -> anyhow::Result<TraceExporter> {
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
Expand All @@ -331,7 +347,9 @@ impl TraceExporterBuilder {
}
}

#[allow(missing_docs)]
pub trait ResponseCallback {
#[allow(missing_docs)]
fn call(&self, response: &str);
}

Expand Down