dotnet / dotnet/efcore

Reporting TagWith / TagWithCallsite to OpenTelemetry?

Open
#33,149 9 comments 2 reactions 0 assignees View on GitHub
area-diagnostics customer-reported needs-design
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

Is it possible to not only add the tag as a comment to the query but actually enrich the OpenTelemetry span of the query?

```
var blog = await sqlServerDb.Blogs
.OrderBy(b => b.BlogId)
.TagWith("Getting published blog posts")
.FirstAsync();
```

https://github.com/christophwille/OTel-de-Wille/blob/087e2dbd2972b25297da008a079c27950cb324d3/aspnet-aspiredashboard/Program.cs#L171

Screenshot of the as-is situation in Aspire Dashboard (note that due to having EF / SQL wired up I do see the execution):

![image](https://github.com/dotnet/efcore/assets/344208/825af0f4-29e1-4f43-b07b-17f3dc48d6b2)

Maybe is there something for the wire-up?

```
.AddHttpClientInstrumentation()
// .AddSqlClientInstrumentation()
.AddEntityFrameworkCoreInstrumentation(options =>
{
//options.EnrichWithIDbCommand = (activity, command) =>
//{
// var stateDisplayName = $"{command.CommandType} main";
// activity.DisplayName = stateDisplayName;
// activity.SetTag("db.name", stateDisplayName);
//};
})
```

https://github.com/christophwille/OTel-de-Wille/blob/087e2dbd2972b25297da008a079c27950cb324d3/aspnet-aspiredashboard/WebApplicationBuilderExtensions.cs#L62

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.