arkaitzgarro / elastic-apm-laravel

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

ERROR: A transaction with the name POST /api/auth/login is already registered #39

Closed boris-ait closed 4 years ago

boris-ait commented 4 years ago

Hi I'm trying to use that apm agent for our php laravel project php: "^7.3" laravel/framework: 5.6.* apm server: 7.6.0

I'm getting below errors in the application log:

test.ERROR: A transaction with the name POST /api/auth/login is already registered. {"exception":"[object] (PhilKra\\Exception\\Transaction\\DuplicateTransactionNameException(code: 0): A transaction with the name POST /api/auth/login is already registered. at /var/app/vendor/philkra/elastic-apm-php-agent/src/Stores/TransactionsStore.php:30)
[stacktrace]
#0 /var/app/vendor/philkra/elastic-apm-php-agent/src/Agent.php(161): PhilKra\\Stores\\TransactionsStore->register(Object(PhilKra\\Events\\Transaction))
#1 /var/app/vendor/arkaitzgarro/elastic-apm-laravel/src/Middleware/RecordTransaction.php(103): PhilKra\\Agent->startTransaction('POST /api/auth/...', Array, 1585063877.3042)
#2 /var/app/vendor/arkaitzgarro/elastic-apm-laravel/src/Middleware/RecordTransaction.php(45): AG\\ElasticApmLaravel\\Middleware\\RecordTransaction->startTransaction('POST /api/auth/...')
#3 /var/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): AG\\ElasticApmLaravel\\Middleware\\RecordTransaction->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#4 /var/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#5 /var/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#6 /var/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#7 /var/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#8 /var/app/vendor/swooletw/laravel-swoole/src/Server/Sandbox.php(257): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#9 /var/app/vendor/swooletw/laravel-swoole/src/Server/Sandbox.php(217): SwooleTW\\Http\\Server\\Sandbox->handleRequest(Object(Illuminate\\Http\\Request))
#10 /var/app/vendor/swooletw/laravel-swoole/src/Server/Sandbox.php(179): SwooleTW\\Http\\Server\\Sandbox->prepareObResponse(Object(Illuminate\\Http\\Request))
#11 /var/app/vendor/swooletw/laravel-swoole/src/Server/Manager.php(225): SwooleTW\\Http\\Server\\Sandbox->run(Object(Illuminate\\Http\\Request))
#12 {main}

Can you please advise?

arkaitzgarro commented 4 years ago

That's strange, it means that the middleware is executed twice. Do you know if you have any specific configuration that could make a ServiceProvider to be registered twice?

boris-ait commented 4 years ago

+Ash. It's related to errors in web-app-api with apm agent. Can you please check below question?

On Wed, Mar 25, 2020, 14:44 Arkaitz Garro notifications@github.com wrote:

That's strange, it means that the middleware is executed twice. Do you know if you have any specific configuration that could make a ServiceProvider to be registered twice?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arkaitzgarro/elastic-apm-laravel/issues/39#issuecomment-603818167, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANEHYO2FJI36BAIE47V26FDRJH4DNANCNFSM4LTLIA2Q .

ashleigh-hopkins commented 4 years ago

@boris-ait Upon further review, I expect this is an issue with SwooleTW re-registering the service provider each time a new request is made. I'm trying some swoole options which can retain the registration throughout the lifecycle of the swoole worker, which I expect will resolve it.