Meter tags not attached #5088
-
For example: public static class MetricsSample
{
public static void Main()
{
var services = new ServiceCollection();
services.AddMetrics();
using var serviceProvider = services.BuildServiceProvider();
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter(nameof(MetricsSample))
.AddConsoleExporter()
.Build();
var meterFactory = serviceProvider.GetRequiredService<IMeterFactory>();
var meter = meterFactory.Create(nameof(MetricsSample));
var counter = meter.CreateCounter<int>("test-counter", null, "test counter", GetMetricTags());
var observableGauge = meter.CreateObservableGauge("test-o-gauge", () => DateTimeOffset.UtcNow.ToUnixTimeSeconds(), null, null, GetMetricTags());
while (!Console.KeyAvailable)
{
Thread.Sleep(1000);
counter.Add(Random.Shared.Next(100), new KeyValuePair<string, object?>("host", Environment.MachineName));
}
Console.ReadLine();
}
private static IEnumerable<KeyValuePair<string, object?>> GetMetricTags()
{
yield return new KeyValuePair<string, object?>("machine_name", Environment.MachineName);
yield return new KeyValuePair<string, object?>("pid", Environment.ProcessId);
}
} Metrics output: Should the The library version I used is |
Beta Was this translation helpful? Give feedback.
Answered by
cijothomas
Nov 28, 2023
Replies: 1 comment 1 reply
-
Duplicate of #4563 - Not yet done. Separately, processid,machinename should be modelled as Resources, not Meter tags. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
cijothomas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Duplicate of #4563 - Not yet done.
Separately, processid,machinename should be modelled as Resources, not Meter tags.