arkaitzgarro / elastic-apm-laravel

Laravel APM agent for Elastic v2 intake API
MIT License
79 stars 17 forks source link

RecordTransaction middleware does not get called while running from console #139

Closed abdelrahmanna closed 1 year ago

abdelrahmanna commented 3 years ago

middleware does not get called when the app is running from console (unite tests/commands), so when the APM_ACTIVE=false no transaction will be created which will make ApmAgent::getCurrentTransaction() always throw an exception.

arkaitzgarro commented 3 years ago

@abdelrahmanna what would be the expected behaviour? Return null if the agent is not enabled?

abdelrahmanna commented 3 years ago

I think so, since no collectors are present when the agent is disabled the function in the Agent class should not be called so ApmAgent::getCurrentTransaction() should return null and ApmAgent::addTraceParentHeader(RequestInterface $request) sould $request. @arkaitzgarro