Skip to content

Azure Monitor OTel Exporter does not support array attributes on metrics #47262

@lmolkova

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

Properties.Add(new KeyValuePair<string, string>(tag.Key, tag.Value.ToString().Truncate(SchemaConstants.MetricsData_Properties_MaxValueLength) ?? "null"));

Image

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.

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue points to a problem in the data-plane of the library.Monitor - ExporterMonitor OpenTelemetry Exporter

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions