meilisearch / meilisearch-dotnet

.NET wrapper for the Meilisearch API
https://meilisearch.com
MIT License
260 stars 55 forks source link

Telemetry and logging #551

Open Alirexaa opened 3 months ago

Alirexaa commented 3 months ago

Description Could this Client support OpenTelemetry (including tracing, metrics, and logs)?

The following link helps with how to implement it. https://opentelemetry.io/docs/languages/net/instrumentation/

curquiza commented 3 months ago

Hello @Alirexaa To get data from Meilisearch? We already provide this feature -> https://github.com/orgs/meilisearch/discussions/625

Alirexaa commented 3 months ago

Hello @Alirexaa To get data from Meilisearch? We already provide this feature -> https://github.com/orgs/meilisearch/discussions/625

Is this feature still experimental? I think its should be support in client.

Also we need tracing too.

curquiza commented 2 months ago

I think its should be support in client.

What the point of having telemetry on the client side? Or do you mean being able to activated the experimental feature on the client side?

Also we need tracing too.

Are the meilisearch logs not enough? https://www.meilisearch.com/docs/learn/configuration/instance_options#log-level

Alirexaa commented 2 months ago

I'll explain to you in more detail.

Metrics:

You point out that meilisearch exposes some metrics but I don't see any API in the client to get these metrics, so I mean active this feature on the client side. Also, add some ability for the client to get these metrics in some regular period (for example get metrics every 5 seconds to show metrics on charts) this ability should be for easy integration of the meilisearch-dotnet client to user applications.

Tracing:

Just like other dotnet applications that use ActivitySource to trace requests, for example, attach tags, record request time, and more. Some of the dotnet clients use this pattern for tracing. for example elasticsearch-dotnet client support tracing:

Define activity resource: https://github.com/elastic/elastic-transport-net/blob/eb5416e8df75e4c50215bf5258e13189afd9017d/src/Elastic.Transport/Diagnostics/OpenTelemetry/OpenTelemetry.cs#L13-L72

Set activity: https://github.com/elastic/elastic-transport-net/blob/eb5416e8df75e4c50215bf5258e13189afd9017d/src/Elastic.Transport/DistributedTransport.cs#L116-L297

The client should support tracing for every request sent to meilisearch.

Logging

logging should support in client side. These logs are not related to meilisearch, it's related to the client side. and it is better to provide the ILoggerFactory param in the client constructor to have a single logger entire app.