DataDog / dd-trace-dotnet

.NET Client Library for Datadog APM
https://docs.datadoghq.com/tracing/
Apache License 2.0
443 stars 138 forks source link

[Question] Datadog CLR Profiler - enable/disable SQL tracing #1519

Closed yhan closed 3 years ago

yhan commented 3 years ago

Hi,

With the ".net runtime metrics" integration enabled, all sql queries are tracked, I suppose also ingested as indexed spans to datadog?

I can see that datadog substitute code during the JIT:

06/03/21 08:26:45.742 PM [1336|18380] [info] *** JITCompilationStarted() replaced calls from Npgsql.NpgsqlCommand.ExecuteReader() to System.Data.Common.DbCommand.ExecuteReader() 167772677 with calls to Datadog.Trace.ClrProfiler.Integrations.AdoNet.DbCommandIntegration.ExecuteReader() 167774046 From https://github.com/DataDog/dd-trace-dotnet/blob/4a12c6b3f35710a0bd6522c3e0ba9eb485e41e6b/src/Datadog.Trace.ClrProfiler.Managed/Integrations/AdoNet/DbCommandIntegration.cs#L230 I can see the code is executed as regular .net code. Is the tracing done in the same process as the instrumented process? what's the overhead of it? For synchronous db call, I can see the tracing is done in a blocking way: https://github.com/DataDog/dd-trace-dotnet/blob/4a12c6b3f35710a0bd6522c3e0ba9eb485e41e6b/src/Datadog.Trace.ClrProfiler.Managed/Integrations/AdoNet/DbCommandIntegration.cs#L97 For certain apps, we don't need trace sql, or we need to activate this option occasionally. Can we enable/disable the sql tracing? Many thanks, Yi Tech Lead@Finexkap
andrewlock commented 3 years ago

With the ".net runtime metrics" integration enabled, all sql queries are tracked

I don't believe that's the case? You can see which runtime metrics are tracked in the documentation, but this doesn't mention any SQL metrics?

I suppose also ingested as indexed spans to datadog?

With the ADO.NET automatic instrumentation, yes, you will see a span for each sql query

Is the tracing done in the same process as the instrumented process? what's the overhead of it?

We use the .NET Profiling APIs to instrument your application. This inserts our tracing code around the instrumented method calls. The exact overhead will vary depending on your application. Generally speaking there is a startup cost where we insert our instrumentation, but the subsequent runtime cost should be small. We have work ongoing (which should be available very soon) to reduce the runtime cost even further.

Can we enable/disable the sql tracing?

If you don't need automatic instrumentation of a specific integration, you can disable it as described in the documentation.

Hope that helps!

yhan commented 3 years ago

Thank you @andrewlock. This really helps!