Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

48 allow explicit timer start #49

Merged
merged 3 commits into from
Feb 21, 2019

Conversation

dstepe
Copy link
Collaborator

@dstepe dstepe commented Feb 16, 2019

This is a draft PR so we can discuss this proposed change.

The change I need here is in support of changes in the Laravel package which uses these classes. Specifically, I want to use a Timer object but I must be able to set a start time rather than having the timer start when created. That isolated change is pretty easy and seems save.

At the same time, it makes sense to expose that capability through the existing Timer creational methods, which means updating the EventFactoryInterface, Transaction and Agent classes. The start time parameter is optional and safely defaults to null so should have no impact on existing use cases.

Any subclasses of the EventFactoryInterface will need to update the createTransaction method signature however.

I believe this change makes the Timer class usable in more circumstances without compromising current behavior.

@philkra
Copy link
Owner

philkra commented Feb 18, 2019

I'm having trouble understanding the sense, since it only captures the duration why should there be an external time to mess with the inner working of the Timer class?

@dstepe
Copy link
Collaborator Author

dstepe commented Feb 18, 2019

This supports the use case where the transaction is considered to have started before the Timer object is created. I believe this is the reason the Laravel module uses LARAVEL_START when calculating the duration:

https://github.com/philkra/elastic-apm-laravel/blob/master/src/Middleware/RecordTransaction.php#L64

Allowing the Timer to accept a start time would allow it to be used in such cases for getElapsed and getDuration.

@philkra
Copy link
Owner

philkra commented Feb 18, 2019

I moved the discussion to philkra/elastic-apm-laravel#33

src/Helper/Timer.php Show resolved Hide resolved
@dstepe dstepe marked this pull request as ready for review February 21, 2019 13:24
@dstepe
Copy link
Collaborator Author

dstepe commented Feb 21, 2019

It seems like we are in general agreement on the changes, so I've removed the draft status on this PR.

@philkra philkra merged commit ef83f84 into philkra:development Feb 21, 2019
@dstepe dstepe deleted the 48-allow-explicit-timer-start branch April 8, 2019 11:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants