Skip to content

Commit 82f99ec

Browse files
committed
fix conflicts
1 parent 5b796b1 commit 82f99ec

File tree

7 files changed

+58
-50
lines changed

7 files changed

+58
-50
lines changed

bottlecap/Cargo.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bottlecap/src/http_client.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use core::time::Duration;
33
use std::sync::Arc;
44
use tracing::error;
55

6-
#[must_use] pub fn get_client(config: Arc<config::Config>) -> reqwest::Client {
6+
#[must_use]
7+
pub fn get_client(config: Arc<config::Config>) -> reqwest::Client {
78
build_client(config).unwrap_or_else(|e| {
89
error!(
910
"Unable to parse proxy configuration: {}, no proxy will be used",

bottlecap/src/logs/flusher.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::config;
22
use crate::http_client;
33
use crate::logs::aggregator::Aggregator;
4+
use std::time::Instant;
45
use std::{
56
error::Error,
67
io::Write,
@@ -85,13 +86,14 @@ impl Flusher {
8586
compression_enabled: bool,
8687
compression_level: i32,
8788
) {
88-
let url = format!("{fqdn}/api/v2/logs");
8989
if !data.is_empty() {
90+
let url = format!("{fqdn}/api/v2/logs");
91+
debug!("Sending logs to datadog");
92+
let start = Instant::now();
9093
let body = if compression_enabled {
9194
let result = (|| -> Result<Vec<u8>, Box<dyn Error>> {
9295
let mut encoder = Encoder::new(Vec::new(), compression_level)
9396
.map_err(|e| Box::new(e) as Box<dyn Error>)?;
94-
9597
encoder
9698
.write_all(&data)
9799
.map_err(|e| Box::new(e) as Box<dyn Error>)?;
@@ -140,8 +142,6 @@ impl Flusher {
140142
);
141143
}
142144
}
143-
} else {
144-
debug!("No logs to send");
145145
}
146146
}
147147
}

bottlecap/src/tags/lambda/tags.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::config;
2-
use std::collections::hash_map;
2+
use std::collections::HashMap;
33
use std::env::consts::ARCH;
44
use std::fs;
55
use std::sync::Arc;
@@ -66,7 +66,7 @@ const RESOURCE_KEY: &str = "resource";
6666

6767
#[derive(Debug, Clone)]
6868
pub struct Lambda {
69-
tags_map: hash_map::HashMap<String, String>,
69+
tags_map: HashMap<String, String>,
7070
}
7171

7272
fn arch_to_platform<'a>() -> &'a str {
@@ -77,10 +77,10 @@ fn arch_to_platform<'a>() -> &'a str {
7777
}
7878

7979
fn tags_from_env(
80-
mut tags_map: hash_map::HashMap<String, String>,
80+
mut tags_map: HashMap<String, String>,
8181
config: Arc<config::Config>,
82-
metadata: &hash_map::HashMap<String, String>,
83-
) -> hash_map::HashMap<String, String> {
82+
metadata: &HashMap<String, String>,
83+
) -> HashMap<String, String> {
8484
if metadata.contains_key(FUNCTION_ARN_KEY) {
8585
let parts = metadata[FUNCTION_ARN_KEY].split(':').collect::<Vec<&str>>();
8686
if parts.len() > 6 {
@@ -222,10 +222,10 @@ impl Lambda {
222222
#[must_use]
223223
pub fn new_from_config(
224224
config: Arc<config::Config>,
225-
metadata: &hash_map::HashMap<String, String>,
225+
metadata: &HashMap<String, String>,
226226
) -> Self {
227227
Lambda {
228-
tags_map: tags_from_env(hash_map::HashMap::new(), config, metadata),
228+
tags_map: tags_from_env(HashMap::new(), config, metadata),
229229
}
230230
}
231231

@@ -248,19 +248,19 @@ impl Lambda {
248248
}
249249

250250
#[must_use]
251-
pub fn get_tags_map(&self) -> &hash_map::HashMap<String, String> {
251+
pub fn get_tags_map(&self) -> &HashMap<String, String> {
252252
&self.tags_map
253253
}
254254

255255
#[must_use]
256-
pub fn get_function_tags_map(&self) -> hash_map::HashMap<String, String> {
256+
pub fn get_function_tags_map(&self) -> HashMap<String, String> {
257257
let tags = self
258258
.tags_map
259259
.iter()
260260
.map(|(k, v)| format!("{k}:{v}"))
261261
.collect::<Vec<String>>()
262262
.join(",");
263-
hash_map::HashMap::from_iter([(FUNCTION_TAGS_KEY.to_string(), tags)])
263+
HashMap::from_iter([(FUNCTION_TAGS_KEY.to_string(), tags)])
264264
}
265265
}
266266

@@ -270,13 +270,14 @@ mod tests {
270270
use super::*;
271271
use crate::config::Config;
272272
use serial_test::serial;
273+
use std::collections::HashMap;
273274
use std::fs::File;
274275
use std::io::Write;
275276
use std::path::Path;
276277

277278
#[test]
278279
fn test_new_from_config() {
279-
let metadata = hash_map::HashMap::new();
280+
let metadata = HashMap::new();
280281
let tags = Lambda::new_from_config(Arc::new(Config::default()), &metadata);
281282
assert_eq!(tags.tags_map.len(), 3);
282283
assert_eq!(
@@ -297,7 +298,7 @@ mod tests {
297298

298299
#[test]
299300
fn test_new_with_function_arn_metadata() {
300-
let mut metadata = hash_map::HashMap::new();
301+
let mut metadata = HashMap::new();
301302
metadata.insert(
302303
FUNCTION_ARN_KEY.to_string(),
303304
"arn:aws:lambda:us-west-2:123456789012:function:my-function".to_string(),
@@ -317,7 +318,7 @@ mod tests {
317318
#[test]
318319
#[serial] //run test serially since it sets and unsets env vars
319320
fn test_with_lambda_env_vars() {
320-
let mut metadata = hash_map::HashMap::new();
321+
let mut metadata = HashMap::new();
321322
metadata.insert(
322323
FUNCTION_ARN_KEY.to_string(),
323324
"arn:aws:lambda:us-west-2:123456789012:function:My-function".to_string(),
@@ -387,7 +388,7 @@ mod tests {
387388

388389
#[test]
389390
fn test_get_function_tags_map() {
390-
let mut metadata = hash_map::HashMap::new();
391+
let mut metadata = HashMap::new();
391392
metadata.insert(
392393
FUNCTION_ARN_KEY.to_string(),
393394
"arn:aws:lambda:us-west-2:123456789012:function:my-function".to_string(),
@@ -402,7 +403,7 @@ mod tests {
402403
let tags = Lambda::new_from_config(config, &metadata);
403404
let function_tags = tags.get_function_tags_map();
404405
assert_eq!(function_tags.len(), 1);
405-
let fn_tags_map: hash_map::HashMap<String, String> = function_tags
406+
let fn_tags_map: HashMap<String, String> = function_tags
406407
.get(FUNCTION_TAGS_KEY)
407408
.unwrap()
408409
.split(',')

bottlecap/src/traces/span_pointers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ mod tests {
8181
expected_links: Option<serde_json::Value>,
8282
}
8383

84+
#[allow(clippy::too_many_lines)]
8485
#[test]
8586
#[allow(clippy::too_many_lines)]
8687
fn test_attach_span_pointers_to_span() {

bottlecap/src/traces/stats_flusher.rs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use async_trait::async_trait;
55
use std::str::FromStr;
66
use std::sync::Arc;
77
use tokio::sync::Mutex;
8-
use tracing::{debug, error};
98

109
use crate::config;
1110
use crate::traces::stats_aggregator::StatsAggregator;
1211
use datadog_trace_protobuf::pb;
1312
use datadog_trace_utils::{config_utils::trace_stats_url, stats_utils};
1413
use ddcommon::Endpoint;
14+
use tracing::{debug, error};
1515

1616
#[async_trait]
1717
pub trait StatsFlusher {
@@ -49,7 +49,7 @@ impl StatsFlusher for ServerlessStatsFlusher {
4949
let endpoint = Endpoint {
5050
url: hyper::Uri::from_str(&stats_url).expect("can't make URI from stats url, exiting"),
5151
api_key: Some(api_key.clone().into()),
52-
timeout_ms: Endpoint::DEFAULT_TIMEOUT,
52+
timeout_ms: config.flush_timeout * 1_000,
5353
test_token: None,
5454
};
5555

@@ -60,16 +60,6 @@ impl StatsFlusher for ServerlessStatsFlusher {
6060
}
6161
}
6262

63-
async fn flush(&self) {
64-
let mut guard = self.aggregator.lock().await;
65-
66-
let mut stats = guard.get_batch();
67-
while !stats.is_empty() {
68-
self.send(stats).await;
69-
70-
stats = guard.get_batch();
71-
}
72-
}
7363
async fn send(&self, stats: Vec<pb::ClientStatsPayload>) {
7464
if stats.is_empty() {
7565
return;
@@ -90,16 +80,9 @@ impl StatsFlusher for ServerlessStatsFlusher {
9080

9181
let stats_url = trace_stats_url(&self.config.site);
9282

93-
let endpoint = Endpoint {
94-
url: hyper::Uri::from_str(&stats_url).expect("can't make URI from stats url, exiting"),
95-
api_key: Some(self.resolved_api_key.clone().into()),
96-
timeout_ms: self.config.flush_timeout * 1_000,
97-
test_token: None,
98-
};
99-
10083
let start = std::time::Instant::now();
10184

102-
match stats_utils::send_stats_payload(
85+
let resp = stats_utils::send_stats_payload(
10386
serialized_stats_payload,
10487
&self.endpoint,
10588
&self.config.api_key,
@@ -118,4 +101,14 @@ impl StatsFlusher for ServerlessStatsFlusher {
118101
}
119102
};
120103
}
104+
async fn flush(&self) {
105+
let mut guard = self.aggregator.lock().await;
106+
107+
let mut stats = guard.get_batch();
108+
while !stats.is_empty() {
109+
self.send(stats).await;
110+
111+
stats = guard.get_batch();
112+
}
113+
}
121114
}

bottlecap/src/traces/trace_processor.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ use ddcommon::Endpoint;
2525
use std::str::FromStr;
2626
use std::sync::Arc;
2727

28-
use crate::config;
29-
use crate::traces::{
30-
AWS_XRAY_DAEMON_ADDRESS_URL_PREFIX, DNS_LOCAL_HOST_ADDRESS_URL_PREFIX,
31-
DNS_NON_ROUTABLE_ADDRESS_URL_PREFIX, INVOCATION_SPAN_RESOURCE, LAMBDA_EXTENSION_URL_PREFIX,
32-
LAMBDA_RUNTIME_URL_PREFIX, LAMBDA_STATSD_URL_PREFIX,
33-
};
34-
use datadog_trace_obfuscation::obfuscate::obfuscate_span;
35-
use datadog_trace_protobuf::pb::Span;
36-
use datadog_trace_utils::trace_utils::{self, SendData};
37-
3828
#[derive(Clone)]
3929
#[allow(clippy::module_name_repetitions)]
4030
pub struct ServerlessTraceProcessor {

0 commit comments

Comments
 (0)