How to set default attributes for metrics ? #3333
-
Is there a way to add default attribute for all metrics ? I added attributes to ResourceBuilder: var defaultAttributes = new TagList
{
{ "var1", "value1" },
{ "var2", "value2" },
};
var resourceBuilder = ResourceBuilder
.CreateDefault()
.AddAttributes(defaultAttributes)
.AddService("WebApi1", serviceVersion: assemblyVersion, serviceInstanceId: Environment.MachineName); And then configured OpenTelemetryMetrics to use console exporter to a quick test:
And at Controller: var attributes = new TagList
{
{ "my_label", "value1" },
};
_metrics.TransactionAuthorized.Add(1, attributes); I'd expect to see
Is there anything I could do ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
Resource is a way to model this. (The console exporter for metrics is ignoring resource - its a bug. will send a fix). |
Beta Was this translation helpful? Give feedback.
Resource is a way to model this. (The console exporter for metrics is ignoring resource - its a bug. will send a fix).
But you must be using something other than Console for your actual service right? Like an OTLP exporter. it should already support Resources.