Skip to content

Commit b68b53d

Browse files
committed
Add _dd.tags.function to top level trace tags hashmap.
1 parent 3f1f391 commit b68b53d

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

bottlecap/src/tags/lambda/tags.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ const SERVICE_KEY: &str = "service";
4444
const COMPUTE_STATS_KEY: &str = "_dd.compute_stats";
4545
// ComputeStatsValue is the tag value indicating trace stats should be computed
4646
const COMPUTE_STATS_VALUE: &str = "1";
47+
// FunctionTagsKey is the tag key for a function's tags to be set on the top level tracepayload
48+
const FUNCTION_TAGS_KEY: &str = "_dd.tags.function";
4749
// TODO(astuyve) decide what to do with the version
4850
const EXTENSION_VERSION_KEY: &str = "dd_extension_version";
4951
// TODO(duncanista) figure out a better way to not hardcode this
@@ -249,6 +251,17 @@ impl Lambda {
249251
pub fn get_tags_map(&self) -> &hash_map::HashMap<String, String> {
250252
&self.tags_map
251253
}
254+
255+
#[must_use]
256+
pub fn get_function_tags_map(&self) -> hash_map::HashMap<String, String> {
257+
let tags = self
258+
.tags_map
259+
.iter()
260+
.map(|(k, v)| format!("{k}:{v}"))
261+
.collect::<Vec<String>>()
262+
.join(",");
263+
hash_map::HashMap::from_iter([(FUNCTION_TAGS_KEY.to_string(), tags)])
264+
}
252265
}
253266

254267
#[cfg(test)]

bottlecap/src/tags/provider.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ impl Provider {
5656
pub fn get_tags_map(&self) -> &hash_map::HashMap<String, String> {
5757
self.tag_provider.get_tags_map()
5858
}
59+
60+
#[must_use]
61+
pub fn get_function_tags_map(&self) -> hash_map::HashMap<String, String> {
62+
self.tag_provider.get_function_tags_map()
63+
}
5964
}
6065

6166
trait GetTags {

bottlecap/src/traces/trace_processor.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ impl TraceProcessor for ServerlessTraceProcessor {
137137
},
138138
true,
139139
);
140+
payload
141+
.tags
142+
.extend(tags_provider.get_function_tags_map().clone());
140143
let intake_url = trace_intake_url(&config.site);
141144
let endpoint = Endpoint {
142145
url: hyper::Uri::from_str(&intake_url).expect("can't parse trace intake URL, exiting"),

0 commit comments

Comments
 (0)