Skip to content

Commit

Permalink
Fix process resource detector triggers warning if running with unknow…
Browse files Browse the repository at this point in the history
…n uid (#840)
  • Loading branch information
Nevay authored Oct 9, 2022
1 parent 8562d0d commit 7940773
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/SDK/Resource/Detectors/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ public function getResource(): ResourceInfo
$attributes[ResourceAttributes::PROCESS_COMMAND_ARGS] = $_SERVER['argv'];
}

if (extension_loaded('posix')) {
$attributes[ResourceAttributes::PROCESS_OWNER] = \posix_getpwuid(\posix_geteuid())['name'];
/** @phan-suppress-next-line PhanTypeComparisonFromArray */
if (extension_loaded('posix') && ($user = \posix_getpwuid(\posix_geteuid())) !== false) {
$attributes[ResourceAttributes::PROCESS_OWNER] = $user['name'];
}

return ResourceInfo::create(Attributes::create($attributes), ResourceAttributes::SCHEMA_URL);
Expand Down

0 comments on commit 7940773

Please sign in to comment.