Skip to content

Commit 6955362

Browse files
committed
Use ECS process fields for PHP arguments
1 parent 948e77e commit 6955362

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/FilebeatContextProcessor.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function __invoke(LogRecord $record): LogRecord
1717
{
1818
$record->extra = array_merge($record->extra, $this->extras);
1919

20-
$record->extra = array_merge($record->extra, ['php' => self::phpExtras()]);
20+
$record->extra = array_merge($record->extra, ['process' => self::processExtras()]);
2121

2222
$record->extra = array_merge($record->extra, self::traceExtras());
2323

@@ -68,12 +68,16 @@ public static function errorExtras(Throwable $throwable): array
6868
/**
6969
* @return array<array-key, mixed>
7070
*/
71-
public static function phpExtras(): array
71+
public static function processExtras(): array
7272
{
73+
$arguments = [PHP_BINARY, ...($_SERVER['argv'] ?? [])];
74+
7375
return [
74-
'sapi' => PHP_SAPI,
75-
'argc' => $_SERVER['argc'] ?? null,
76-
'argv_string' => $_SERVER['argv'] ?? null ? implode(' ', $_SERVER['argv']) : null,
76+
'pid' => getmypid(),
77+
'executable' => PHP_BINARY,
78+
'args' => $arguments,
79+
'args_count' => count($arguments),
80+
'command_line' => implode(' ', $arguments),
7781
];
7882
}
7983

0 commit comments

Comments
 (0)