22
33import datadog .environment .EnvironmentVariables ;
44import datadog .trace .api .telemetry .ConfigInversionMetricCollectorProvider ;
5+ import java .util .ArrayList ;
56import java .util .Collections ;
67import java .util .HashMap ;
78import java .util .List ;
89import java .util .Locale ;
910import java .util .Map ;
11+ import java .util .Set ;
12+ import java .util .concurrent .ConcurrentHashMap ;
1013import org .slf4j .Logger ;
1114import org .slf4j .LoggerFactory ;
1215
@@ -49,6 +52,9 @@ public String toString() {
4952 // Default to production source
5053 private SupportedConfigurationSource configSource = new SupportedConfigurationSource ();
5154
55+ // Collects unsupported config keys encountered in STRICT_TEST mode
56+ private final Set <String > unsupportedConfigs = ConcurrentHashMap .newKeySet ();
57+
5258 public static ConfigHelper get () {
5359 return INSTANCE ;
5460 }
@@ -75,9 +81,18 @@ void resetCache() {
7581 void resetToDefaults () {
7682 configSource = new SupportedConfigurationSource ();
7783 this .configInversionStrict = StrictnessPolicy .WARNING ;
84+ unsupportedConfigs .clear ();
7885 resetCache ();
7986 }
8087
88+ /** Returns and clears the set of unsupported config keys encountered in STRICT_TEST mode. */
89+ public List <String > drainUnsupportedConfigs () {
90+ List <String > result = new ArrayList <>(unsupportedConfigs );
91+ unsupportedConfigs .clear ();
92+ Collections .sort (result );
93+ return result ;
94+ }
95+
8196 public static Map <String , String > env () {
8297 return get ().getEnvironmentVariables ();
8398 }
@@ -143,6 +158,7 @@ public String getEnvironmentVariable(String name) {
143158 }
144159
145160 if (configInversionStrict == StrictnessPolicy .STRICT_TEST ) {
161+ unsupportedConfigs .add (name );
146162 throw new IllegalArgumentException (
147163 "Unsupported configuration: "
148164 + name
0 commit comments