Extras data is ignored
@SergeyKleyman is already working on this.
Since Feb 10, 2021.
Assessment
This issue has not been assessed yet.
Description
Hi,
I'm curious. Reading through source code to figure out why data that I am inserting via processors (e.g. MonoLog WebProcessor) is not being displayed by your formatter, I see that you are completely ignoring the extras array member of the Monolog record structure, and instead relying on data being in the context member of the record. This appears to be somewhat counter-intuitive to the way that Monolog normally works.
Is this purposeful, or just an unhandled scenario at the present time?
use \Codeception\Test\Unit as UnitTest;
use Elastic\Monolog\Formatter\ElasticCommonSchemaFormatter;
use Monolog\Handler\TestHandler;
use Monolog\Logger;
use Monolog\Processor\WebProcessor;
class ECSFormatterTest extends UnitTest
{
/**
* Logger
*/
protected $sut;
/**
* @var TestHandler
*/
protected $handler;
public function testECSFormatIsSupported()
{
$this->sut->error('Test Message', ['func' => __FUNCTION__]);
$record = $this->handler->getRecords()[0]['formatted'];
var_dump($record);exit;
}
protected function setUp(): void
{
$this->handler = new TestHandler();
$formatter = new ElasticCommonSchemaFormatter();
$this->handler->setFormatter($formatter);
//mock a web server
$serverData = [
'REQUEST_URI' => '/test',
'REMOTE_ADDR' => '127.0.0.1',
'REQUEST_METHOD' => 'GET',
'SERVER_NAME' => 'zinc.test',
'HTTP_REFERER' => 'http://zinc.test',
];
$this->sut = new Logger('test', [$this->handler], [new WebProcessor($serverData)]);
}
}
At the very least I would expect the data that gets injected into extras to get into the output format labels node, as the func item does in the above test snippet. Ideally I would see 'REMOTE_ADDR' being injected to source.ip in the output.
- Dominant language
- PHP
- Stars
- 21
- Forks
- 42
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from elastic/ecs-logging-php
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
elastic/ecs-logging-php#100 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
elastic/ecs-logging-php#50 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 35/100
elastic/ecs-logging-php#37 · 2 comments · 4 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 30/100
elastic/ecs-logging-php#33 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
elastic/ecs-logging-php#26 ·
All issues in elastic/ecs-logging-php
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Spomky-Labs/pwa-bundle#476 ·
-
domain/discovery
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
neos/flow-development-collection#3639 · 1 comment ·
Maintainers usually reply within 1 day
-
The PHP version check in prepare.php still allows PHP 7.2 and 7.3Possibly taken @ekamran claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
WordPress/phpunit-test-runner#359 ·
Maintainers usually reply within 2 days