Skip to content

Don't add "unknown" to Blazor metricsΒ #63350

@JamesNK

Description

@JamesNK

Blazor metrics add "unknown" as a tag value when a value for the tag hasn't been passed in:

var tags = new TagList
{
{ "aspnetcore.components.type", componentType ?? "unknown" },
{ "code.function.name", methodName ?? "unknown" },
{ "aspnetcore.components.attribute.name", attributeName ?? "unknown" }
};

I don't think this is the right behavior.

All tags don't always need to be present on telemetrymeasurement. It's common for tags to be conditional and only added when needed or a value is known. For example, if a HTTP request doesn't specify a user-agent, no user agent tag is added to the activity.

A more standard behavior is to not include tags when no value is available for it.

For example,

private static void AddIsPersistent(ref TagList tags, bool? isPersistent)
{
if (isPersistent != null)
{
tags.Add("aspnetcore.authentication.is_persistent", isPersistent.Value);
}
}

Metadata

Metadata

Labels

area-blazorIncludes: Blazor, Razor Components

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions