nipwaayoni / elastic-apm-php-agent

PHP Agent for Elastic APM
Other
28 stars 15 forks source link

EventBean uses creation timestamp rather than start timestamp #36

Closed dstepe closed 4 years ago

dstepe commented 4 years ago

The EventBean class sets the timestamp value in it's constructor:

https://github.com/nipwaayoni/elastic-apm-php-agent/blob/master/src/Events/EventBean.php#L104

This is inconsistent with derived classes such as Span which use a Timer started after construction to calculate the duration:

https://github.com/nipwaayoni/elastic-apm-php-agent/blob/master/src/Events/Span.php#L68

While most uses may see the Span::start() method, and therefore the Timer::start(), called immediately after the Span is created, that is not required and any amount of time could pass between the events. This could create a situation in which the staring point of the span within the transaction is represented at the wrong starting timestamp.