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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/target
/.idea
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a jetbrains config file!


6 changes: 6 additions & 0 deletions crates/datadog-trace-agent/src/env_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,10 @@ mod tests {
#[test]
#[serial]
fn test_is_azure_flex_without_resource_group_true() {
env::remove_var(DD_AZURE_RESOURCE_GROUP);
env::set_var(WEBSITE_SKU, "FlexConsumption");
assert!(is_azure_flex_without_resource_group());
env::remove_var(WEBSITE_SKU);
}

#[test]
Expand All @@ -652,12 +654,16 @@ mod tests {
env::set_var(DD_AZURE_RESOURCE_GROUP, "test-resource-group");
env::set_var(WEBSITE_SKU, "FlexConsumption");
assert!(!is_azure_flex_without_resource_group());
env::remove_var(DD_AZURE_RESOURCE_GROUP);
env::remove_var(WEBSITE_SKU);
}

#[test]
#[serial]
fn test_is_azure_flex_without_resource_group_false_not_flex() {
env::remove_var(DD_AZURE_RESOURCE_GROUP);
env::set_var(WEBSITE_SKU, "ElasticPremium");
assert!(!is_azure_flex_without_resource_group());
env::remove_var(WEBSITE_SKU);
}
}
19 changes: 8 additions & 11 deletions crates/datadog-trace-agent/src/mini_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl MiniAgent {
pub async fn start_mini_agent(&self) -> Result<(), Box<dyn std::error::Error>> {
let now = Instant::now();

// verify we are in a google cloud funtion environment. if not, shut down the mini agent.
// verify we are in a serverless function environment. if not, shut down the mini agent.
let mini_agent_metadata = Arc::new(
self.env_verifier
.verify_environment(
Expand All @@ -64,7 +64,6 @@ impl MiniAgent {
// flush to backend.
let trace_flusher = self.trace_flusher.clone();
tokio::spawn(async move {
let trace_flusher = trace_flusher.clone();
trace_flusher.start_trace_flusher(trace_rx).await;
});

Expand All @@ -78,7 +77,6 @@ impl MiniAgent {
let stats_flusher = self.stats_flusher.clone();
let stats_config = self.config.clone();
tokio::spawn(async move {
let stats_flusher = stats_flusher.clone();
stats_flusher
.start_stats_flusher(stats_config, stats_rx)
.await;
Expand All @@ -90,23 +88,22 @@ impl MiniAgent {
let endpoint_config = self.config.clone();

let service = service_fn(move |req| {
// called for each http request
let trace_processor = trace_processor.clone();
let trace_tx = trace_tx.clone();

let stats_processor = stats_processor.clone();
let stats_tx = stats_tx.clone();

let endpoint_config = endpoint_config.clone();
let mini_agent_metadata = Arc::clone(&mini_agent_metadata);

MiniAgent::trace_endpoint_handler(
endpoint_config.clone(),
endpoint_config,
req.map(hyper_migration::Body::incoming),
trace_processor.clone(),
trace_tx.clone(),
stats_processor.clone(),
stats_tx.clone(),
Arc::clone(&mini_agent_metadata),
trace_processor,
trace_tx,
stats_processor,
stats_tx,
mini_agent_metadata,
)
});

Expand Down
7 changes: 5 additions & 2 deletions crates/datadog-trace-agent/src/trace_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ struct ChunkProcessor {

impl TraceChunkProcessor for ChunkProcessor {
fn process(&mut self, chunk: &mut pb::TraceChunk, root_span_index: usize) {
// Clone app_name once instead of once per span
let app_name = self.config.app_name.clone();

trace_utils::set_serverless_root_span_tags(
&mut chunk.spans[root_span_index],
self.config.app_name.clone(),
app_name.clone(),
&self.config.env_type,
);
for span in chunk.spans.iter_mut() {
Expand All @@ -54,7 +57,7 @@ impl TraceChunkProcessor for ChunkProcessor {
trace_utils::enrich_span_with_google_cloud_function_metadata(
span,
&self.mini_agent_metadata,
self.config.app_name.clone(),
app_name.clone(),
);
}
obfuscate_span(span, &self.config.obfuscation_config);
Expand Down
Loading