sentry-laravel icon indicating copy to clipboard operation
sentry-laravel copied to clipboard

Elasticsearch support

Open nklmilojevic opened this issue 2 years ago • 6 comments

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!

nklmilojevic avatar Mar 28 '23 10:03 nklmilojevic

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.

antonpirker avatar Mar 28 '23 12:03 antonpirker

@nklmilojevic Are you using https://github.com/elastic/elasticsearch-php or something else?

cleptric avatar Mar 31 '23 23:03 cleptric

Hi @cleptric! We use https://github.com/cviebrock/laravel-elasticsearch which essentially wraps the official client into Laravel.

nklmilojevic avatar Mar 31 '23 23:03 nklmilojevic

This Package Will Be Abandoned

is kind of a red flag 🙁

cleptric avatar Mar 31 '23 23:03 cleptric

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.

nklmilojevic avatar Apr 03 '23 15:04 nklmilojevic

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 👍

stayallive avatar Apr 13 '23 08:04 stayallive