Tags from instrument constructor ignored? #6314
-
The following code pass one tag at the creation of a counter and one tag when recording a value. It then prints the metric. using System.Diagnostics.Metrics;
using OpenTelemetry;
using OpenTelemetry.Metrics;
Meter meter = new("test");
List<Metric> metrics = [];
var meterProvider = Sdk.CreateMeterProviderBuilder().AddMeter(meter.Name).AddInMemoryExporter(metrics).Build();
Counter<long> counter = meter.CreateCounter<long>("my.counter", null, null,
[new KeyValuePair<string, object?>("AAAA", "0")]);
counter.Add(1, [new KeyValuePair<string, object?>("BBBB", "1")]);
meterProvider.ForceFlush();
foreach (var metric in metrics)
{
foreach (var point in metric.GetMetricPoints())
{
Console.Write($"{metric.Name}{{");
foreach (var tag in point.Tags)
{
Console.Write($"{tag.Key}={tag.Value}, ");
}
Console.WriteLine("}");
}
} The output is
Is it expected that the first tag is ignored? |
Beta Was this translation helpful? Give feedback.
Answered by
cijothomas
Jun 10, 2025
Replies: 1 comment
-
Yes, instrument tags are not supported. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
verdie-g
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, instrument tags are not supported.
#5478 (comment)