sentry-laravel
sentry-laravel copied to clipboard
Elasticsearch support
Hi!
We are in the process of switching from Datadog to Sentry fully (paid) and one thing I noticed is that there is no Elasticsearch traces. Is that something that is planned to support?
Thanks!
Hey @nklmilojevic !
Cool thing you want to use Sentry more. Currently there is no ElasticSearch support in PHP, you are right. As far as I know there is no ES support planned for now, but if enough people upvote this issue and we see that there is demand, we will put in on our todo list.
But as always: PRs are very welcome! If you want to give it a go, I would look at how we do support for databases and copy this and change it.
@nklmilojevic Are you using https://github.com/elastic/elasticsearch-php or something else?
Hi @cleptric! We use https://github.com/cviebrock/laravel-elasticsearch which essentially wraps the official client into Laravel.
This Package Will Be Abandoned
is kind of a red flag 🙁
It is - we planned to fork it and to maintain it as MailerLite company (of course, opensourced), and that will probably happen in the next few days.
The nice thing is that you can already enable tracing of the Elastic client.
$elasticClient = Elastic\Elasticsearch\ClientBuilder::create()
->setHttpClient($someHttpClient)
->build();
The Elastic ClientBuilder class supports setting a http client, it expects a PSR ClientInterface and Guzzle is one of those. And we already have a tracing middleware for Guzzle so combining those pieces of information:
$stack = GuzzleHttp\HandlerStack::create();
$stack->push(Sentry\Tracing\GuzzleTracingMiddleware::trace());
$httpClient = new GuzzleHttp\Client([
'handler' => $stack,
]);
$elasticClient = Elastic\Elasticsearch\ClientBuilder::create()
->setHttpClient($someHttpClient)
->build();
This $elasticClient can be bound tot he container for example to re-use throughout your application and will trace all HTTP requests the Elastic client makes 👍