File tree Expand file tree Collapse file tree
src/OpenTelemetry.Resources.Process
test/OpenTelemetry.Resources.Process.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 ([ #4080 ] ( https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/4080 ) )
77
88* Add new process resource attributes: ` process.args_count ` ,
9- ` process.command ` , ` process.creation.time ` ,
10- ` process.executable.path ` , ` process.title ` and
11- ` process.working_directory ` .
9+ ` process.creation.time ` , ` process.executable.path ` ,
10+ ` process.title ` and ` process.working_directory ` .
1211 ([ #4036 ] ( https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/4036 ) )
1312
1413## 1.15.0-beta.1
Original file line number Diff line number Diff line change @@ -48,20 +48,9 @@ public Resource Detect()
4848 // See https://github.com/open-telemetry/semantic-conventions/blob/v1.40.0/docs/resource/process.md#selecting-process-attributes.
4949 var commandArgs = GetCommandLineArgs ( ) ;
5050
51- if ( commandArgs . Length > 0 )
51+ if ( commandArgs is not null )
5252 {
53- #if NET
54- processPath ??= commandArgs [ 0 ] ;
55- #else
56- processPath = commandArgs [ 0 ] ;
57- #endif
58-
59- attributes . Add ( new ( ProcessSemanticConventions . AttributeProcessCommand , commandArgs [ 0 ] ) ) ;
60-
61- // Do not count the executable path as an argument
62- int count = commandArgs . Length - 1 ;
63-
64- attributes . Add ( new ( ProcessSemanticConventions . AttributeProcessArgsCount , count ) ) ;
53+ attributes . Add ( new ( ProcessSemanticConventions . AttributeProcessArgsCount , commandArgs . Length ) ) ;
6554 }
6655
6756 if ( ! string . IsNullOrEmpty ( processPath ) )
@@ -71,15 +60,15 @@ public Resource Detect()
7160
7261 return new Resource ( attributes ) ;
7362
74- static string [ ] GetCommandLineArgs ( )
63+ static string [ ] ? GetCommandLineArgs ( )
7564 {
7665 try
7766 {
7867 return Environment . GetCommandLineArgs ( ) ;
7968 }
8069 catch ( NotSupportedException )
8170 {
82- return [ ] ;
71+ return null ;
8372 }
8473 }
8574
Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ public void TestProcessAttributes()
1515 var resourceAttributes = resource . Attributes . ToDictionary ( x => x . Key , x => x . Value ) ;
1616
1717 Assert . IsType < long > ( resourceAttributes [ ProcessSemanticConventions . AttributeProcessArgsCount ] ) ;
18- Assert . IsType < string > ( resourceAttributes [ ProcessSemanticConventions . AttributeProcessCommand ] ) ;
1918 Assert . IsType < string > ( resourceAttributes [ ProcessSemanticConventions . AttributeProcessCreationTime ] ) ;
2019 Assert . IsType < string > ( resourceAttributes [ ProcessSemanticConventions . AttributeProcessExecutablePath ] ) ;
2120 Assert . IsType < string > ( resourceAttributes [ ProcessSemanticConventions . AttributeProcessOwner ] ) ;
You can’t perform that action at this time.
0 commit comments