File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ const SERVICE_KEY: &str = "service";
4444const COMPUTE_STATS_KEY : & str = "_dd.compute_stats" ;
4545// ComputeStatsValue is the tag value indicating trace stats should be computed
4646const 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
4850const 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) ]
Original file line number Diff line number Diff 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
6166trait GetTags {
Original file line number Diff line number Diff 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" ) ,
You can’t perform that action at this time.
0 commit comments