2
2
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2023-Present Datadog, Inc.
3
3
4
4
use ddcommon:: Endpoint ;
5
- use log:: { debug, error} ;
6
5
use std:: borrow:: Cow ;
7
6
use std:: env;
8
7
use std:: str:: FromStr ;
9
8
10
- use datadog_trace_obfuscation:: replacer :: { self , ReplaceRule } ;
9
+ use datadog_trace_obfuscation:: obfuscation_config ;
11
10
use datadog_trace_utils:: config_utils:: {
12
11
read_cloud_env, trace_intake_url, trace_intake_url_prefixed, trace_stats_url,
13
12
trace_stats_url_prefixed,
@@ -29,7 +28,7 @@ pub struct Config {
29
28
pub trace_intake : Endpoint ,
30
29
pub trace_stats_intake : Endpoint ,
31
30
pub dd_site : String ,
32
- pub tag_replace_rules : Option < Vec < ReplaceRule > > ,
31
+ pub obfuscation_config : obfuscation_config :: ObfuscationConfig ,
33
32
}
34
33
35
34
impl Config {
@@ -55,19 +54,11 @@ impl Config {
55
54
trace_stats_intake_url = trace_stats_url_prefixed ( & endpoint_prefix) ;
56
55
} ;
57
56
58
- let tag_replace_rules: Option < Vec < ReplaceRule > > = match env:: var ( "DD_APM_REPLACE_TAGS" ) {
59
- Ok ( replace_rules_str) => match replacer:: parse_rules_from_string ( & replace_rules_str) {
60
- Ok ( res) => {
61
- debug ! ( "Successfully parsed DD_APM_REPLACE_TAGS: {res:?}" ) ;
62
- Some ( res)
63
- }
64
- Err ( e) => {
65
- error ! ( "Failed to parse DD_APM_REPLACE_TAGS: {e}" ) ;
66
- None
67
- }
68
- } ,
69
- Err ( _) => None ,
70
- } ;
57
+ let obfuscation_config = obfuscation_config:: ObfuscationConfig :: new ( ) . map_err ( |err| {
58
+ anyhow:: anyhow!(
59
+ "Error creating obfuscation config, Mini Agent will not start. Error: {err}" ,
60
+ )
61
+ } ) ?;
71
62
72
63
Ok ( Config {
73
64
function_name : Some ( function_name) ,
@@ -86,7 +77,7 @@ impl Config {
86
77
url : hyper:: Uri :: from_str ( & trace_stats_intake_url) . unwrap ( ) ,
87
78
api_key : Some ( api_key) ,
88
79
} ,
89
- tag_replace_rules ,
80
+ obfuscation_config ,
90
81
} )
91
82
}
92
83
}
0 commit comments