opentelemetry-dotnet-contrib icon indicating copy to clipboard operation
opentelemetry-dotnet-contrib copied to clipboard

MassTransit instrumentation is not needed in MassTransit 8

Open faustodavid opened this issue 3 years ago • 3 comments

When using MassTransit 8.0.1 and OpenTelemetry.Instrumentation.Masstransit 1.0.0-beta3 I can't find the traces. To fix it I need to manually add the "MassTransit" source.

Example:

services.AddOpenTelemetrySdk(x =>
{
    x.AddMassTransitInstrumentation();
    x.AddSource("MassTransit");

    x.UseJaegerExporter(config => {
      // Configure Jaeger
    });
});

Update:

As mentioned by @sgryphon, the library is not needed for MT8, maybe is good to make it explicit for the users?

faustodavid avatar Apr 23 '22 14:04 faustodavid

I've also been looking at this, and:

TL;DR; / FIX:

  • In MT8, you don't need this library at all, just .AddSource("MassTransit") is all that is needed (I am working on a demo/PoC using MT 8).
  • In MT7, you only need ".AddMassTransitInstrumentation()", and it works (I use this in a project with MT 7.3).

I've tried it with different combinations of the instrumentation (beta1, beta2), and none of that code has changed.

I also turned on a debug listener to low level EventSource in the contrib extensions library and it didn't register anything (no filters or exceptions, or even raising events), so not sure any of the code is even running with MT8.

From what I can see, I think they changed the code in MT8 so that it directly uses ActivitySource, to be directly compatible with OpenTelemetry.

Previously (MT7) they used DiagnosticSource.

MT7

The description of the instrumentation is "Automatically instruments DiagnosticSource events emitted by MassTransit library.", and from looking at the code that is what it does. It listens to the DiagnosticSource "MassTransit" and then converts/translates events and emits them to open telemetry.

This is all working fine in my MT 7.3 project, and there have been no changes to this part of the contrib library.

MT8

I think it no longer uses the DiagnosticSource, so the contrib code is listening to nothing, and does nothing.

MT8 now uses an ActivitySource, hence .AddSource("MassTransit") adds an activity listener and starts including events (and triggers activity propagation, e.g. for logs). Just add this and it all appears to work fine so far.

The AddMassTransitInstrumentation() isn't doing anything, and can be removed, and it still works.


@faustodavid maybe, if you can confirm, rename the issue to "Instrumentation if for MT7, but no longer needed for MT8".

Maybe the solution is to rename the library as OpenTelemetry.Instrumentation.MassTransit7, and then either have an MT8 library that has a single line AddSource("MassTransit") or simply just mention it and direct people to the MT project.

sgryphon avatar May 09 '22 04:05 sgryphon

thanks @sgryphon , yes, you are right. I will change the issue name.

faustodavid avatar May 16 '22 12:05 faustodavid

Maybe the solution is to rename the library as OpenTelemetry.Instrumentation.MassTransit7, and then either have an MT8 library that has a single line AddSource("MassTransit") or simply just mention it and direct people to the MT project.

Maybe OpenTelemetry.Instrumentation.MassTransit should take an explicit package dependency on MT < 8.0, so folks who try to mix it with MT >= 8.0 will get an error during package resolution.

reyang avatar Jul 26 '22 15:07 reyang

Package was deprecated. Code remove from this repository. Native support described under https://github.com/open-telemetry/opentelemetry-dotnet-contrib/tree/4d7e692ecc50a01f6cef76ef9ea61ac738b000df/src/OpenTelemetry.Instrumentation.MassTransit#deprecated.

Closing.

Kielek avatar Jun 30 '23 08:06 Kielek