@@ -29,6 +29,7 @@ public static ResourceBuilder AddDigmaAttributes(this ResourceBuilder builder,
2929 Action < DigmaConfigurationOptions > ? configure = null )
3030 {
3131 var workingDirectory = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
32+ var hostName = Dns . GetHostName ( ) ;
3233
3334 DigmaConfigurationOptions options = new DigmaConfigurationOptions ( ) ;
3435 if ( configure != null )
@@ -37,13 +38,13 @@ public static ResourceBuilder AddDigmaAttributes(this ResourceBuilder builder,
3738 }
3839
3940 //If namespace not provided try to get it from the calling method
40- if ( string . IsNullOrEmpty ( options . NamespaceRoot ) )
41+ if ( string . IsNullOrWhiteSpace ( options . NamespaceRoot ) )
4142 {
4243 StackTrace stackTrace = new StackTrace ( ) ;
4344 options . NamespaceRoot = stackTrace ? . GetFrame ( 1 ) ? . GetMethod ( ) ? . DeclaringType ? . Namespace ?? "" ;
4445 }
4546
46- if ( string . IsNullOrEmpty ( options . NamespaceRoot ) )
47+ if ( string . IsNullOrWhiteSpace ( options . NamespaceRoot ) )
4748 {
4849 options . NamespaceRoot = Assembly . GetCallingAssembly ( ) . GetTypes ( )
4950 . Where ( x => x . Namespace != null )
@@ -53,23 +54,22 @@ public static ResourceBuilder AddDigmaAttributes(this ResourceBuilder builder,
5354 . FirstOrDefault ( ) ;
5455 }
5556
56- if ( options . CommitId == null )
57+ if ( string . IsNullOrWhiteSpace ( options . CommitId ) )
5758 {
5859 options . CommitId = Environment . GetEnvironmentVariable ( options . CommitIdEnvVariable ) ?? "" ;
5960 }
6061
61- var hostName = Dns . GetHostName ( ) ;
62- if ( options . Environment == null )
62+ if ( string . IsNullOrWhiteSpace ( options . Environment ) )
63+ {
64+ options . Environment = Environment . GetEnvironmentVariable ( options . DigmaEnvironmentEnvVariable ) ?? "" ;
65+ }
66+ if ( string . IsNullOrWhiteSpace ( options . Environment ) )
67+ {
68+ options . Environment = Environment . GetEnvironmentVariable ( options . EnvironmentEnvVariable ) ?? "" ;
69+ }
70+ if ( string . IsNullOrWhiteSpace ( options . Environment ) )
6371 {
64- var env = Environment . GetEnvironmentVariable ( options . EnvironmentEnvVariable ) ;
65- if ( string . IsNullOrWhiteSpace ( env ) )
66- {
67- options . Environment = hostName + "[local]" ;
68- }
69- else
70- {
71- options . Environment = env ;
72- }
72+ options . Environment = hostName + "[local]" ;
7373 }
7474
7575 builder . AddAttributes ( new [ ]
0 commit comments