33
44using OpenTelemetry . AutoInstrumentation . Configurations . FileBasedConfiguration ;
55using OpenTelemetry . AutoInstrumentation . Configurations . FileBasedConfiguration . Parser ;
6+ using OpenTelemetry . AutoInstrumentation . Logging ;
67
78namespace OpenTelemetry . AutoInstrumentation . Configurations ;
89
@@ -13,6 +14,7 @@ internal abstract class Settings
1314{
1415 private static readonly bool IsYamlConfigEnabled = Environment . GetEnvironmentVariable ( ConfigurationKeys . FileBasedConfiguration . Enabled ) == "true" ;
1516 private static readonly Lazy < YamlConfiguration > YamlConfiguration = new ( ReadYamlConfiguration ) ;
17+ private static readonly IOtelLogger Logger = OtelLogging . GetLogger ( ) ;
1618
1719 public static T FromDefaultSources < T > ( bool failFast )
1820 where T : Settings , new ( )
@@ -58,7 +60,28 @@ public void LoadFile(YamlConfiguration configuration)
5860
5961 private static YamlConfiguration ReadYamlConfiguration ( )
6062 {
61- var configFile = Environment . GetEnvironmentVariable ( ConfigurationKeys . FileBasedConfiguration . FileName ) ?? "config.yaml" ;
63+ var experimentalConfigFile = Environment . GetEnvironmentVariable ( ConfigurationKeys . FileBasedConfiguration . ExperimentalFileName ) ;
64+
65+ var configFile = Environment . GetEnvironmentVariable ( ConfigurationKeys . FileBasedConfiguration . FileName ) ;
66+
67+ if ( ! string . IsNullOrEmpty ( configFile ) )
68+ {
69+ if ( ! string . IsNullOrEmpty ( experimentalConfigFile ) )
70+ {
71+ Logger . Warning ( "Both OTEL_EXPERIMENTAL_CONFIG_FILE (deprecated) and OTEL_CONFIG_FILE are set. " +
72+ "Using OTEL_CONFIG_FILE and ignoring the deprecated variable." ) ;
73+ }
74+ }
75+ else if ( ! string . IsNullOrEmpty ( experimentalConfigFile ) )
76+ {
77+ Logger . Warning ( "OTEL_EXPERIMENTAL_CONFIG_FILE is deprecated. Please use OTEL_CONFIG_FILE instead." ) ;
78+ configFile = experimentalConfigFile ;
79+ }
80+ else
81+ {
82+ configFile = "config.yaml" ;
83+ }
84+
6285 // TODO validate file existence
6386
6487 var config = Parser . ParseYaml < YamlConfiguration > ( configFile ) ;
0 commit comments