From 11dce1d49388af8138f947d8ef61f76926ee054b Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 26 May 2026 15:23:25 +1200 Subject: [PATCH 1/2] Fix hard coded spanName in DBCommandExtensions example --- conceptual/Npgsql/diagnostics/tracing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conceptual/Npgsql/diagnostics/tracing.md b/conceptual/Npgsql/diagnostics/tracing.md index f295c2c5..8d1fc22c 100644 --- a/conceptual/Npgsql/diagnostics/tracing.md +++ b/conceptual/Npgsql/diagnostics/tracing.md @@ -69,7 +69,7 @@ internal static class DbCommandExtensions public static async Task ExecuteReaderWithSpanNameAsync(this NpgsqlCommand command, string spanName) { var previousValue = CommandName.Value; - CommandName.Value = "FetchAllUsers"; + CommandName.Value = spanName; try { From 3b223e315396defa5a4b5e494e9313d9a4d07676 Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 26 May 2026 15:34:20 +1200 Subject: [PATCH 2/2] Tidied up AsyncLocal example sentence structures. --- conceptual/Npgsql/diagnostics/tracing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conceptual/Npgsql/diagnostics/tracing.md b/conceptual/Npgsql/diagnostics/tracing.md index 8d1fc22c..be31366f 100644 --- a/conceptual/Npgsql/diagnostics/tracing.md +++ b/conceptual/Npgsql/diagnostics/tracing.md @@ -57,7 +57,7 @@ This allows you to: ## Using `AsyncLocal` to pass arbitrary information to your callbacks -The callbacks available via only accept the or as their parameters; this makes it difficult to e.g. assign arbitrary names to your commands, so that show up as the span names in your tracing monitor. You can use .NET [`AsyncLocal`](https://learn.microsoft.com/dotnet/api/system.threading.asynclocal-1) to flow arbitrary information from the command call site (where you execute the command) to your tracing callbacks to achieve this. +The callbacks available via only accept the or as their parameters. This limitation makes it difficult to inject contextual data; such as assigning arbitrary names to your commands so they appear as the span names in your tracing monitor. You can solve this by using .NET [`AsyncLocal`](https://learn.microsoft.com/dotnet/api/system.threading.asynclocal-1) to flow arbitrary information from the command call site (where you execute the command) to your tracing callbacks. For example, the following adds an `ExecuteReaderWithSpanNameAsync` extension method to :