Azure Monitor OTel Exporter does not support array attributes on metrics #47262
Description
Try
using Azure.Monitor.OpenTelemetry.AspNetCore;
using System.Diagnostics;
using System.Diagnostics.Metrics;
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddOpenTelemetry()
.WithTracing(tp => tp.AddSource("test"))
.WithMetrics(mp => mp.AddMeter("test"))
.UseAzureMonitor(o => o.ConnectionString = "secret");
var app = builder.Build();
var test = new ActivitySource("test");
var testMeter = new Meter("test");
var testCounter = testMeter.CreateCounter<int>("this.is.a.test.counter");
app.MapGet("/", async () =>
{
using var act = test.StartActivity("test me");
act?.AddTag("array.attribute", new[] { 1, 2, 3 });
testCounter.Add(1, new KeyValuePair<string, object?>("array.attribute", new[] { 1, 2, 3 }));
});
app.Run();
Array attribute on spans works fine, but is converted to string with ToString()
on metrics here
The suggestion is to do it consistently (comma separated list).
context: open-telemetry/semantic-conventions#1525
use-case: as a user I might want to filter my metrics checking if array attribute contains a specific value among others.