From d1f090b6e0adaf89e2a81c0f357b8da7908eb702 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Fri, 8 Nov 2024 15:04:48 -0500 Subject: [PATCH] only track timestamp when activity doesn't exist --- .../Implementation/SqlClientDiagnosticListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs index 8a91e103cf..c5d234550e 100644 --- a/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.SqlClient/Implementation/SqlClientDiagnosticListener.cs @@ -69,7 +69,6 @@ public override void OnEventWritten(string name, object? payload) case SqlDataBeforeExecuteCommand: case SqlMicrosoftBeforeExecuteCommand: { - this.beginTimestamp.Value = Stopwatch.GetTimestamp(); _ = this.commandFetcher.TryFetch(payload, out var command); if (command == null) { @@ -91,6 +90,7 @@ public override void OnEventWritten(string name, object? payload) if (activity == null) { // There is no listener or it decided not to sample the current request. + this.beginTimestamp.Value = Stopwatch.GetTimestamp(); return; }