This is on .NET 6.
So I've added an enrich callback with the purpose of adding each parameter as a tag:
appBuilder.Services.AddOpenTelemetryTracing((builder) =>
builder
.AddAspNetCoreInstrumentation()
.SetSampler(new AlwaysOnSampler())
.AddSqlClientInstrumentation(options =>
{
options.SetDbStatementForText = true;
options.SetDbStatementForStoredProcedure = true;
options.RecordException = true;
options.EnableConnectionLevelAttributes = true;
options.Enrich = (activity, eventName, rawObject) =>
{
if (eventName.Equals("OnCustom"))
{
activity.SetTag("ParametersAdded", "true");
if (rawObject is SqlCommand cmd)
{
foreach (SqlParameter parameter in cmd.Parameters)
{
activity.SetTag(parameter.ParameterName, parameter.Value.ToString());
}
}
}
};
})
.AddZipkinExporter(options =>
{
options.Endpoint = new Uri(appBuilder.Configuration["TraceExporterUrl"]);
}));
I'm getting the export in Zipkin, but it's not added the tags, and it doesn't seem to be hitting that Enrich callback at all - the ParametersAdded tag isn't being hit either. Can't figure out why this isn't working - Have I fundamentally misunderstood something?