3

I have an ASP.NET Core Web API project, let's call it projectA.

ProjectA connects to a MySQL database.

Project A simply does this:

  • get a request
  • then make a query to the connected MySQL database
  • then return response to request

I want to measure time spent for database operation and send result to Jaeger.

For http requests opentelemetry automatically measure time spent for request and send results to jaeger.

How can I do the same thing with opentelemetry for database operations?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
yusuf
  • 51
  • 5
  • I'm not familiar with Jaeger but it seems that it can automatically gather data from database operation in `span`? See [this comment](https://github.com/jaegertracing/jaeger/issues/1944#issuecomment-559116290) and I saw there's some others' screenshot, and can trace mysql operations. – Tiny Wang Sep 27 '21 at 02:47

1 Answers1

1

You need to enable SQL Client instrumentation when configuring your tracer provider.

using OpenTelemetry.Trace;

public class Program
{
    public static void Main(string[] args)
    {
        using var tracerProvider = Sdk.CreateTracerProviderBuilder()
            .AddSqlClientInstrumentation()
            .AddConsoleExporter()
            .Build();
    }
}

Here's the official documentation: https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/src/OpenTelemetry.Instrumentation.SqlClient#readme

blargBlerg
  • 11
  • 2