philkra / elastic-apm-laravel Goto Github PK
View Code? Open in Web Editor NEWElastic APM Client for Laravel
Elastic APM Client for Laravel
I need to tag transactions with the Laravel environment and possibly other values. I'll make a PR.
Would it be better to add following information in README because Lumen doesn't support package discovery which Laravel does? Without this, it can't work in Lumen.
...
$app->register(\PhilKra\ElasticApmLaravel\Providers\ElasticApmServiceProvider::class);
...
Tested Lumen version: 5.5.
I've added the following to my configuration, but all of my .env
variables are being sent to the server. I've tried placing the env
parameter both inside and outside app
(the documentation doesn't specify). Am I doing something wrong here?
return [
// Sets whether the apm reporting should be active or not
'active' => true,
'app' => [
// The app name that will identify your app in Kibana / Elastic APM
'appName' => 'APP-' . env('APP_ENV'),
// The version of your app
'appVersion' => '0.1',
// Environment variables to send
'env' => ['APP_ENV'],
],
// ... Rest of config
]
Hi @philkra,
Awesome project, can't wait to implement this.
I noticed you tagged a new RC release in https://github.com/philkra/elastic-apm-php-agent.
When can we expect a release on the Laravel package?
Hi,
Can you add Laravel 5.8 support?
I can't use my APM server version 7.0.
I am getting this error:
[2019-05-08 18:17:18] local.ERROR: GuzzleHttp\Exception\ClientException: Client error: POST https://myserver.apm.us-east-1.aws.cloud.es.io/v1/transactions
resulted in a 404 Not Found
response: 404 page not found
According to this doc this endpoint was deprecated: https://www.elastic.co/guide/en/apm/server/7.0/transaction-endpoint.html
We need to change this endpoint request to event API: https://www.elastic.co/guide/en/apm/server/7.0/events-api.html
Just noticed this while trying to run my tests - even if I hardcode 'active' to false the agent still sends. It doesn't look like the setting is merged in to the agent.
return new Agent(
array_merge(
[
'framework' => 'Laravel',
'frameworkVersion' => app()->version(),
],
config('elastic-apm.app'),
config('elastic-apm.server')
)
);
I was able to overcome this by putting 'active' underneath the elastic-apm.app config block (as well as the top level)
Old
return [
// Sets whether the apm reporting should be active or not
'active' => false,
New
// Sets whether the apm reporting should be active or not
'active' => false,
app' => [
// Sets whether the apm reporting should be active or not
'active' => false,
I would think the fix could be to just merge in the setting.
The drop of the function Transaction::setSpans
in the used package elastic-apm-php-agent
causes a call to undefined method in the case not the latest version of this package is used, e.g. the previous version 5.8.2
From my point of view the version of elastic-apm-php-agent
in the composer.json should be stated like ^6.5.3 to get a compatible package.
Looking at the default behavior, is it not the case that the Agent will immediately try to send to http://127.0.0.1:8200 since that's the default serverUrl and active is true? Would it make sense to set the active indicator to true only when config('elastic-apm.active')
and there is a non-empty serverUrl
?
Something like:
$active = config('elastic-apm.active') && config('elastic-apm.server.serverUrl');
return new Agent(
array_merge(
[
'framework' => 'Laravel',
'frameworkVersion' => app()->version(),
],
['active' => $active],
$this->getAppConfig(),
config('elastic-apm.env'),
config('elastic-apm.server')
)
);
I can make a PR for this if you agree.
Hi there! I'm trying this package out and I noticed that when I have connection issues with the APM server the entire application will crash with something like the following:
GuzzleHttp \ Exception \ ConnectException cURL error 7: Failed to connect to 1.1.1.1 port 8200: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
I would think that I don't want the application to go down completely because it can't communicate with the APM. Wrapping in a try catch seems to help:
try {
ElasticApm::captureThrowable($exception);
ElasticApm::send();
} catch (\Throwable $ex) {
Log::error($ex);
}
Just wanted to pass this tip along
elastic-apm-laravel/composer.json
Line 19 in fce1d1d
I was having trouble installing without using an alias - this should probably be bumped to 6.4.*
We've run into two problems when running feature tests in Laravel with the module enabled. First, the agent attempts to send the transaction to APM regardless of the APM_ACTIVE value. I believe this is due to the agent performing a type check on config value ($this->config->get('active') === false
). When setting the env value via phpunit.xml, the string false
is set as an empty string in configuration. This could be addressed in the elastic-apm.php
config with something like this:
'active' => env('APM_ACTIVE', true) === true,
With this change, configuration would always have a properly typed value based on a clear positive assertion from the user. The default would not change, so I think this is safe.
I think it also makes sense to add documentation encouraging the creation of an .env.testing
file with APM_ACTIVE=false
explicitly set.
The second problem is the same as discussed in issue #16 and is related to the LARAVEL_START constant. The conclusion in the discussion is that there is some way of running PHPUnit tests through Laravel's bootstrap process, citing:
https://laravel.com/docs/5.7/testing#creating-and-running-tests
That documentation simply says "To run your tests, execute the phpunit command from your terminal" and does not provide a Laravel bootstrapped method of running tests. The artisan command can be used to create a test, but does not actually run them from what I'm reading.
I'd appreciate further clarification on running the feature and possibly revisiting this as an issue which needs to be addressed. We have many applications which use feature tests and our build process runs tests with PHPunit directly, so we can't make widespread use of the module until we have a solution.
backtraceDepth
and renderSource
is not configurable through environment variables. It would be nice to have available, since that's how we configure all the other config params.
Do you have any plans to update this to support Laravel 5.7?
Hey, I'm not very knowlesabe with Laravel or the APM-server. I was wondering if you can help me with this issue I'm having :).
When the PHP-Agent sends a porst request to the APM-Server's URL it results in a 404 error.
I'm not sure why this is as I have a Java-Agent hitting the same port and the data is showing up in Elasticsearch.
This is the error log that appears when testing.
[2018-11-15 09:30:49] local.ERROR: Client error: `POST https://1.1.1.1:8200/6.4.2/transactions` resulted in a `404 Not Found` response:
404 page not found
{"userId":1545,"email":"[email protected]","exception":"[object] (GuzzleHttp\\Exception\\ClientException(code: 404): Client error: `POST https://1.1.1.1:8200/6.4.2/transactions` resulted in a `404 Not Found` response:
404 page not found
at /home/vagrant/code/tmp/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113)
[stacktrace]
#0 /home/vagrant/code/tmp/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\\Exception\\RequestException::create(Object(GuzzleHttp\\Psr7\\Request), Object(GuzzleHttp\\Psr7\\Response))
#1 /home/vagrant/code/tmp/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\\Middleware::GuzzleHttp\\{closure}(Object(GuzzleHttp\\Psr7\\Response))
#2 /home/vagrant/code/tmp/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\\Promise\\Promise::callHandler(1, Object(GuzzleHttp\\Psr7\\Response), Array)
#3 /home/vagrant/code/tmp/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\\Promise\\Promise::GuzzleHttp\\Promise\\{closure}()
#4 /home/vagrant/code/tmp/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\\Promise\\TaskQueue->run(true)
#5 /home/vagrant/code/tmp/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\\Promise\\Promise->invokeWaitFn()
#6 /home/vagrant/code/tmp/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\\Promise\\Promise->waitIfPending()
#7 /home/vagrant/code/tmp/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\\Promise\\Promise->invokeWaitList()
#8 /home/vagrant/code/tmp/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\\Promise\\Promise->waitIfPending()
#9 /home/vagrant/code/tmp/vendor/guzzlehttp/guzzle/src/Client.php(106): GuzzleHttp\\Promise\\Promise->wait()
#10 /home/vagrant/code/tmp/vendor/philkra/elastic-apm-php-agent/src/Middleware/Connector.php(59): GuzzleHttp\\Client->send(Object(GuzzleHttp\\Psr7\\Request))
#11 /home/vagrant/code/tmp/vendor/philkra/elastic-apm-php-agent/src/Agent.php(230): PhilKra\\Middleware\\Connector->sendTransactions(Object(PhilKra\\Stores\\TransactionsStore))
#12 /home/vagrant/code/tmp/vendor/philkra/elastic-apm-laravel/src/Middleware/RecordTransaction.php(73): PhilKra\\Agent->send()
#13 /home/vagrant/code/tmp/app/Http/Middleware/RecordTransaction.php(20): PhilKra\\ElasticApmLaravel\\Middleware\\RecordTransaction->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#14 /home/vagrant/code/tmp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(218): App\\Http\\Middleware\\RecordTransaction->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#15 /home/vagrant/code/tmp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(189): Illuminate\\Foundation\\Http\\Kernel->terminateMiddleware(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#16 /home/vagrant/code/tmp/public/index.php(57): Illuminate\\Foundation\\Http\\Kernel->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#17 {main}
"}
I'm receiving this error from line 135 in ElasticApmServiceProvider when running tests. Is this a known issue? How would I selectively remove the middleware from Kernel.php when running tests?
Hi,
I got this error when I tried to use this in Lumen.
Does anyone know how to solve it? (Or it doesn't support lumen?)
Here is the error in logs.
[2019-07-31 09:18:35] local.ERROR: Illuminate\Contracts\Container\BindingResolutionException: Unresolvable dependency resolving [Parameter #0 [ <required> array $config ]] in class PhilKra\Agent in /Users/user/blog/vendor/illuminate/container/Container.php:977
Stack trace:
#0 /Users/user/blog/vendor/illuminate/container/Container.php(915): Illuminate\Container\Container->unresolvablePrimitive(Object(ReflectionParameter))
#1 /Users/user/blog/vendor/illuminate/container/Container.php(856): Illuminate\Container\Container->resolvePrimitive(Object(ReflectionParameter))
#2 /Users/user/blog/vendor/illuminate/container/Container.php(818): Illuminate\Container\Container->resolveDependencies(Array)
#3 /Users/user/blog/vendor/illuminate/container/Container.php(667): Illuminate\Container\Container->build('PhilKra\\Agent')
#4 /Users/user/blog/vendor/illuminate/container/Container.php(615): Illuminate\Container\Container->resolve('PhilKra\\Agent', Array)
#5 /Users/user/blog/vendor/laravel/lumen-framework/src/Application.php(267): Illuminate\Container\Container->make('PhilKra\\Agent', Array)
#6 /Users/user/blog/vendor/illuminate/container/Container.php(929): Laravel\Lumen\Application->make('PhilKra\\Agent')
#7 /Users/user/blog/vendor/illuminate/container/Container.php(857): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#8 /Users/user/blog/vendor/illuminate/container/Container.php(818): Illuminate\Container\Container->resolveDependencies(Array)
#9 /Users/user/blog/vendor/illuminate/container/Container.php(667): Illuminate\Container\Container->build('PhilKra\\Elastic...')
#10 /Users/user/blog/vendor/illuminate/container/Container.php(615): Illuminate\Container\Container->resolve('PhilKra\\Elastic...', Array)
#11 /Users/user/blog/vendor/laravel/lumen-framework/src/Application.php(267): Illuminate\Container\Container->make('PhilKra\\Elastic...', Array)
#12 /Users/user/blog/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(140): Laravel\Lumen\Application->make('PhilKra\\Elastic...')
#13 /Users/user/blog/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(117): Laravel\Lumen\Application->callTerminableMiddleware(Object(Illuminate\Http\Response))
#14 /Users/user/blog/public/index.php(28): Laravel\Lumen\Application->run()
#15 {main} {"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Unresolvable dependency resolving [Parameter #0 [ <required> array $config ]] in class PhilKra\\Agent at /Users/user/blog/vendor/illuminate/container/Container.php:977)
[stacktrace]
#0 /Users/user/blog/vendor/illuminate/container/Container.php(915): Illuminate\\Container\\Container->unresolvablePrimitive(Object(ReflectionParameter))
#1 /Users/user/blog/vendor/illuminate/container/Container.php(856): Illuminate\\Container\\Container->resolvePrimitive(Object(ReflectionParameter))
#2 /Users/user/blog/vendor/illuminate/container/Container.php(818): Illuminate\\Container\\Container->resolveDependencies(Array)
#3 /Users/user/blog/vendor/illuminate/container/Container.php(667): Illuminate\\Container\\Container->build('PhilKra\\\\Agent')
#4 /Users/user/blog/vendor/illuminate/container/Container.php(615): Illuminate\\Container\\Container->resolve('PhilKra\\\\Agent', Array)
#5 /Users/user/blog/vendor/laravel/lumen-framework/src/Application.php(267): Illuminate\\Container\\Container->make('PhilKra\\\\Agent', Array)
#6 /Users/user/blog/vendor/illuminate/container/Container.php(929): Laravel\\Lumen\\Application->make('PhilKra\\\\Agent')
#7 /Users/user/blog/vendor/illuminate/container/Container.php(857): Illuminate\\Container\\Container->resolveClass(Object(ReflectionParameter))
#8 /Users/user/blog/vendor/illuminate/container/Container.php(818): Illuminate\\Container\\Container->resolveDependencies(Array)
#9 /Users/user/blog/vendor/illuminate/container/Container.php(667): Illuminate\\Container\\Container->build('PhilKra\\\\Elastic...')
#10 /Users/user/blog/vendor/illuminate/container/Container.php(615): Illuminate\\Container\\Container->resolve('PhilKra\\\\Elastic...', Array)
#11 /Users/user/blog/vendor/laravel/lumen-framework/src/Application.php(267): Illuminate\\Container\\Container->make('PhilKra\\\\Elastic...', Array)
#12 /Users/user/blog/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(140): Laravel\\Lumen\\Application->make('PhilKra\\\\Elastic...')
#13 /Users/user/blog/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(117): Laravel\\Lumen\\Application->callTerminableMiddleware(Object(Illuminate\\Http\\Response))
#14 /Users/user/blog/public/index.php(28): Laravel\\Lumen\\Application->run()
#15 {main}
"}
I installed and configure two packages in laravel app.
"laravel/framework": "5.5.*",
"philkra/elastic-apm-laravel": "5.8.0",
"philkra/elastic-apm-php-agent": "6.5.3",
"ralouphie/getallheaders": "2.0.5",
PHP 7.1.32
I followed the documentation and configured. Set the environment in .env
# APM Configs
APM_ACTIVE=true
APM_APPNAME=myapp
APM_SERVERURL=http://elk.local
APM_SECRETTOKEN=none
I get these errors in laravel logs.
[2021-08-13 12:57:09] local.ERROR: TypeError: Return value of PhilKra\Events\EventBean::getEnv() must be an instance of PhilKra\Events\object, instance of stdClass returned in /Applications/MAMP/htdocs/projects/Villars_V32_CMS/vendor/philkra/elastic-apm-php-agent/src/Events/EventBean.php:183
Stack trace:
#0 /Applications/MAMP/htdocs/projects/Villars_V32_CMS/vendor/philkra/elastic-apm-php-agent/src/Events/EventBean.php(253): PhilKra\Events\EventBean->getEnv()
#1 /Applications/MAMP/htdocs/projects/Villars_V32_CMS/vendor/philkra/elastic-apm-php-agent/src/Events/Transaction.php(157): PhilKra\Events\EventBean->getContext()
#2 [internal function]: PhilKra\Events\Transaction->jsonSerialize()
#3 /Applications/MAMP/htdocs/projects/Villars_V32_CMS/vendor/philkra/elastic-apm-php-agent/src/Middleware/Connector.php(71): json_encode(Object(PhilKra\Serializers\Transactions))
#4 /Applications/MAMP/htdocs/projects/Villars_V32_CMS/vendor/philkra/elastic-apm-php-agent/src/Agent.php(239): PhilKra\Middleware\Connector->sendTransactions(Object(PhilKra\Stores\TransactionsStore))
#5 /Applications/MAMP/htdocs/projects/Villars_V32_CMS/vendor/philkra/elastic-apm-laravel/src/Middleware/RecordTransaction.php(85): PhilKra\Agent->send()
#6 /Applications/MAMP/htdocs/projects/Villars_V32_CMS/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(218): PhilKra\ElasticApmLaravel\Middleware\RecordTransaction->terminate(Object(Illuminate\Http\Request), Object(Illuminate\Http\JsonResponse))
#7 /Applications/MAMP/htdocs/projects/Villars_V32_CMS/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(189): Illuminate\Foundation\Http\Kernel->terminateMiddleware(Object(Illuminate\Http\Request), Object(Illuminate\Http\JsonResponse))
#8 /Applications/MAMP/htdocs/projects/Villars_V32_CMS/public/index.php(58): Illuminate\Foundation\Http\Kernel->terminate(Object(Illuminate\Http\Request), Object(Illuminate\Http\JsonResponse))
Hi,
I'm a newbie of laravel and elastic stack. I already setup by README, but i don't know how to setup my serverUrl. Can you give me more hint or keyword to search?
This is another issue we got with laravel 5.5. Entire application crashes when we use the default configuration, including the Apm middleware in global middleware in the Kernel.php.
When we added it as route middleware it was working, but still we need it defined globally. What can we do about this issue, any workaround?
I’ve been a casual contributor to this project and now have need of a stable release to work with Elastic APM v7+. Rather than continuing to place the burden on @philkra to own this, I propose that the package be moved to a GitHub organization where interested people can build a community to maintain it.
If this gets traction, I am happy to get the process started. If are interested, please comment on this issue and we’ll go from there. This will be my first GitHub organization and attempt to build a community maintained project. Please bear with me if I seem to go slow and take small steps. I think we can build some great on top of the work already done on this package.
It's probably a good idea to flush the query-log on agent send, inorder to keep the memory usage in check.
Hello,
I have a problem with the use of your module.
Previously, I had only one server with all the ELK stack installed on the same server.
But my environment has changed, and I now have to use AWS elasticsearch.
So I have a vps (EC2) with, logstash and apm server.
The configuration of the APM server is different because I have to send the data to the logstash and it sends the data to elasticsearch (AWS).
Unfortunately, I have some errors:
IN DISCOVER
`Error with Painless scripted field 'doc['context.service.name'].value'
You can address this error by editing the ‘doc['context.service.name'].value’ field in Management > Index Patterns, under the “Scripted fields” tab.
Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"script_exception","reason":"runtime error","script_stack":["org.elasticsearch.index.mapper.TextFieldMapper$TextFieldType.fielddataBuilder(TextFieldMapper.java:670)","org.elasticsearch.index.fielddata.IndexFieldDataService.getForField(IndexFieldDataService.java:115)","org.elasticsearch.index.query.QueryShardContext.lambda$lookup$0(QueryShardContext.java:280)","org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:88)","org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:85)","java.security.AccessController.doPrivileged(Native Method)","org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:85)","org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:39)","doc['context.service.name'].value"," ^---- HERE"],"script":"doc['context.service.name'].value","lang":"painless"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"fetch","grouped":true,"failed_shards":[{"shard":0,"index":"apm-server-6.4.2-2019.03.20","node":"QWoCwS11TFmuhfUKvNVq-Q","reason":{"type":"script_exception","reason":"runtime error","script_stack":["org.elasticsearch.index.mapper.TextFieldMapper$TextFieldType.fielddataBuilder(TextFieldMapper.java:670)","org.elasticsearch.index.fielddata.IndexFieldDataService.getForField(IndexFieldDataService.java:115)","org.elasticsearch.index.query.QueryShardContext.lambda$lookup$0(QueryShardContext.java:280)","org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:88)","org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:85)","java.security.AccessController.doPrivileged(Native Method)","org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:85)","org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:39)","doc['context.service.name'].value"," ^---- HERE"],"script":"doc['context.service.name'].value","lang":"painless","caused_by":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [context.service.name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}}}]},"status":500}
`
AND IN SOME DASHBOARD
Error: Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"script_exception","reason":"runtime error","script_stack":["org.elasticsearch.index.mapper.TextFieldMapper$TextFieldType.fielddataBuilder(TextFieldMapper.java:670)","org.elasticsearch.index.fielddata.IndexFieldDataService.getForField(IndexFieldDataService.java:115)","org.elasticsearch.index.query.QueryShardContext.lambda$lookup$0(QueryShardContext.java:280)","org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:88)","org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:85)","java.security.AccessController.doPrivileged(Native Method)","org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:85)","org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:39)","doc['context.service.name'].value"," ^---- HERE"],"script":"doc['context.service.name'].value","lang":"painless"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"fetch","grouped":true,"failed_shards":[{"shard":0,"index":"apm-server-6.4.2-2019.03.20","node":"pQKBqXhXTiS7yrEXwY4GsA","reason":{"type":"script_exception","reason":"runtime error","script_stack":["org.elasticsearch.index.mapper.TextFieldMapper$TextFieldType.fielddataBuilder(TextFieldMapper.java:670)","org.elasticsearch.index.fielddata.IndexFieldDataService.getForField(IndexFieldDataService.java:115)","org.elasticsearch.index.query.QueryShardContext.lambda$lookup$0(QueryShardContext.java:280)","org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:88)","org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:85)","java.security.AccessController.doPrivileged(Native Method)","org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:85)","org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:39)","doc['context.service.name'].value"," ^---- HERE"],"script":"doc['context.service.name'].value","lang":"painless","caused_by":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [context.service.name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}}}]},"status":500} at https://search-elk-project-dqsfqsdfjfdifhdfiu.eu-west-1.es.amazonaws.com/_plugin/kibana/bundles/commons.bundle.js:1:779873 at Function.Promise.try (https://search-elk-project-dqsfqsdfjfdifhdfiu.eu-west-1.es.amazonaws.com/_plugin/kibana/bundles/commons.bundle.js:1:488441) at https://search-elk-project-dqsfqsdfjfdifhdfiu.eu-west-1.es.amazonaws.com/_plugin/kibana/bundles/commons.bundle.js:1:487812 at Array.map (<anonymous>) at Function.Promise.map (https://search-elk-project-dqsfqsdfjfdifhdfiu.eu-west-1.es.amazonaws.com/_plugin/kibana/bundles/commons.bundle.js:1:487770) at callResponseHandlers (https://search-elk-project-dqsfqsdfjfdifhdfiu.eu-west-1.es.amazonaws.com/_plugin/kibana/bundles/commons.bundle.js:1:779232) at https://search-elk-project-dqsfqsdfjfdifhdfiu.eu-west-1.es.amazonaws.com/_plugin/kibana/bundles/commons.bundle.js:1:765209 at processQueue (https://search-elk-project-dqsfqsdfjfdifhdfiu.eu-west-1.es.amazonaws.com/_plugin/kibana/bundles/vendors.bundle.js:118:199684) at https://search-elk-project-dqsfqsdfjfdifhdfiu.eu-west-1.es.amazonaws.com/_plugin/kibana/bundles/vendors.bundle.js:118:200647 at Scope.$digest (https://search-elk-project-dqsfqsdfjfdifhdfiu.eu-west-1.es.amazonaws.com/_plugin/kibana/bundles/vendors.bundle.js:118:210409)
Thanks for reading !
Have a nice day !
This issue is found when I used pull request #82 in my project. The root cause is in listeningForQueries.
Sometimes $query->sql
is not string type but Illuminate\Database\Query\Expression
at least in Lumen 5.5*.
I tested it with string casting and no problem. What do you think about it?
I already set elastic-apm.active to false but it still send data because we register it in Kernel middleware :
class Kernel extends HttpKernel
protected $middleware = [
/* OTHER MIDDLEWARE */
\PhilKra\ElasticApmLaravel\Middleware\RecordTransaction::class,
];
So i remove it from Kernal and need to modify AppServiceProvider to add dynamically middleware :
public function boot(Kernel $kernel)
{
if (config('elastic-apm.active')) {
$kernel->pushMiddleware(\PhilKra\ElasticApmLaravel\Middleware\RecordTransaction::class);
}
}
hi
I have successfuly installed the package, Registered the middleware, successfuly set up Error/Exception Handling (I see them in elastic), but neither log is written even with APM_THRESHOLD = 1 nor Log while Level set to "debug".
So when running my integration tests, sometimes I have two API calls per test, and I run into the duplicate transaction name exception.
This is my test:
$this->patchJson('/some-endpoint/123', [
'foo' => 'bar
])
->assertStatus(200)
We get the following error:
PhilKra\Exception\Transaction\DuplicateTransactionNameException: A transaction with the name PATCH / is already registered.
// $path = ($request->server->get('PATH_INFO') == '') ? '/' : $request->server->get('PATH_INFO');
//proposed
$path = ($request->getPathInfo() == '') ? '/' : $request->getPathInfo();
return sprintf(
"%s %s",
$request->server->get('REQUEST_METHOD'),
$path
);
switching to $request->getPathInfo() seems to fix it in my case.
Is there a way to get the package to get the endpoint that the user went to for GET and POST requests, rather than the Laravel entry point?
Hi, Can I use this package on laravel 5.1?
The title pretty much sums it up. I would like to be able to set both the active status and the use of the route uri for transaction names from the env(). I'll make a PR for this shortly.
any idea of what might be needed?
I tested it in the Lumen 5.5.* project which didn't register AuthServiceProvider
and resulted in the following alert.
"InvalidArgumentException: [0] Auth guard driver [api] is not defined."
It was because $request->user()
tries to get authenticated user with default guard api
which is not defined. Would it be better that setUserContext
in RecordTransaction
is conditional based on configuration?
We are experiencing an issue when reporting to APM from our laravel app.
POST https://APP_ID.apm.eu-central-1.aws.cloud.es.io/v1/transactions` resulted in a `413 Request Entity Too Large`
I see there's an config option for limiting the backtraceDepth
, but can I be sure that limiting this is sufficient?
Hey!
Happy to take over maintenance of this package
While testing we came to an issue with latest version. This is what we got from the logs:
[2018-07-25 11:16:14] qa.ERROR: Client error: POST http://192.168.50.120:8200/v1/transactions
resulted in a 400 Bad Request
response:
data validation error: Problem validating JSON document against schema: I[#] S[#] doesn't validate with "transaction#"
(truncated...)
{"userId":891267,"email":"[email protected]","exception":"[object] (GuzzleHttp\Exception\ClientException(code: 400): Client error: POST http://192.168.50.120:8200/v1/transactions
resulted in a 400 Bad Request
response:
data validation error: Problem validating JSON document against schema: I[#] S[#] doesn't validate with "transaction#"
(truncated...)
at /var/sites/qa.erasmusplusols.eu/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113)
[stacktrace]
Any idea how to bypass this issue?
Just a quick FYI - we had to disable this from the cli entirely. We were running out of memory due to query/transaction logging from the agent and many of our batch jobs that run using artisan tasks processed thousands of queries.
You can probably close this but in case someone else came across it I wanted to make people ware.
//we do something like this:
'active' => PHP_SAPI !== 'cli' && env('ELASTIC_APM_ACTIVE', false),
I'd like to get a new release with the config changes I submitted. But before that, I found an inconsistency in the variable naming I want to fix. I'm also adding some configuration documentation. I'll have a PR shortly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.