SlimMessageBus icon indicating copy to clipboard operation
SlimMessageBus copied to clipboard

Tracing / OpenTelemetry

Open Juandavi1 opened this issue 3 years ago • 10 comments

Hi ! Do you know how to implement distributed tracing with slim ?

Juandavi1 avatar Feb 04 '23 00:02 Juandavi1

Hi @Juandavi1 could you please elaborate?

zarusz avatar Feb 06 '23 10:02 zarusz

Hi ! We are working with OpenTelemetry and we need to create the spans when consume and publish events. For example en Go we have otelsarama to do it ! There is an option to add an interceptor to add this functionality ?

Juandavi1 avatar Feb 06 '23 13:02 Juandavi1

Now it is more clear, thanks. I assume you are using Kafka transport, is that correct?

There is nothing available out of box, ideally tracing/metrics/instrumentation could be done as a producer/consumer interceptors which would add the necessary spans (or other instrumentation) to the consumers or producer. The interceptor implementation could use one of these:

Regarding otelsarama I do not know it, but it looks like it's meant for Go client application. Not sure if this could be used in .NET.

I am happy to review a contribution/PR for a tracing plugin to make this part of SMB, or provide help.

zarusz avatar Feb 06 '23 23:02 zarusz

Hi ! Awesome ! I was wondering whether there's a global interceptor 🤔 The currently interface requires a message type 🥲

Juandavi1 avatar Feb 10 '23 20:02 Juandavi1

Actually, you can make a generic message interceptor as explained here https://github.com/zarusz/SlimMessageBus/blob/master/docs/intro.md#generic-interceptors

You can see this working for the outbox plugin https://github.com/zarusz/SlimMessageBus/blob/master/src/SlimMessageBus.Host.Outbox/Configuration/ServiceCollectionExtensions.cs#L12

zarusz avatar Feb 11 '23 08:02 zarusz

I will try it! Thank you very much!

Juandavi1 avatar Feb 12 '23 02:02 Juandavi1

The feature should be generating instrumentation using: https://www.nuget.org/packages/System.Diagnostics.DiagnosticSource https://learn.microsoft.com/en-us/dotnet/core/diagnostics/diagnosticsource-diagnosticlistener

When the extension is built it needs to follow this: https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/docs/trace/extending-the-sdk/README.md#instrumentation-library

zarusz avatar Aug 17 '23 21:08 zarusz

Another useful link https://github.com/prometheus-net/prometheus-net/blob/master/Benchmark.NetCore/SdkComparisonBenchmarks.cs https://opentelemetry.io/docs/specs/semconv/messaging/messaging-spans/

zarusz avatar Jun 17 '24 13:06 zarusz