-
Notifications
You must be signed in to change notification settings - Fork 214
chore: Added comments to the duplicate event.name code in EventLogger #1768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Added comments to the duplicate event.name code in EventLogger #1768
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1768 +/- ##
============================================
+ Coverage 68.38% 68.43% +0.04%
Complexity 2970 2970
============================================
Files 448 448
Lines 8712 8714 +2
============================================
+ Hits 5958 5963 +5
+ Misses 2754 2751 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 4 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Nevay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was done on purpose to ensure that we don't drop the event.name attribute.
Previously, While the code set the |
I have a memory of this, too. There is a unit test for it, and if that is passing then I think this change is OK now. |
|
The linked test verifies that the The first #[BackupGlobals(true)]
public function test_event_name_is_not_dropped_first(): void
{
$_SERVER['OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT'] = 1;
$eventLoggerProvider = new EventLoggerProvider((new LoggerProviderBuilder())
->addLogRecordProcessor(new SimpleLogRecordProcessor($exporter = new InMemoryExporter()))
->build());
$eventLogger = $eventLoggerProvider->getEventLogger('test');
Logging::disable();
try {
$eventLogger->emit('my.event', attributes: ['other.attribute' => 'not.my.event']);
} finally {
Logging::reset();
}
$eventLoggerProvider->forceFlush();
/** @var list<ReadableLogRecord> $logs */
$logs = $exporter->getStorage()->getArrayCopy();
$this->assertCount(1, $logs);
$this->assertArrayHasKey('event.name', $logs[0]->getAttributes()->toArray());
} |
|
Closing this PR as the function call is intended to set the first entry of the attributes so that it won't get dropped due to |
|
Does this warrant adding a comment to the existing code to explain the scenario that is being covered by this? |
|
@jerrytfleung thanks for the update. Could you also include the test Nevay provided above in this PR? |
Fixed duplicated code found in the emit function.
UPDATES: It is not duplicate code. It turns out it is intended to get the first placeholder for
event.namein attributes so it won't be dropped due to theOTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMITlimitation scenario.