opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

Instrument tags not attached

Open YarinOmesi opened this issue 11 months ago • 6 comments

What are you trying to achieve?

System.Diagnostics.DiagnosticSource v8.0 introduced the ability to instantiate an insrument with tags. for example Counter with tags.

Using System.Diagnostics.DiagnosticSource v8.0, when creating and exporting a counter with tags, I expect tags declared in an instrument will be attached and be exported (in prometheus).

Example Code:

Meter meter = new Meter("MyMeter", "1.0");

TagList counterTags = new TagList() {
    {"counter_tag", true}
};

Counter<long> myCounter = meter.CreateCounter<long>("myCounter", null, null, counterTags);

MeterProvider meterProvider = Sdk.CreateMeterProviderBuilder()
    .AddMeter("MyMeter")
    .AddConsoleExporter()
    .AddPrometheusHttpListener(options => options.UriPrefixes = new []{"http://localhost:9000"})
    .Build();

myCounter.Add(1);

meterProvider.Dispose();

What did you expect to see?

I expect tags declared in an instrument will be attached and be exported (in prometheus).

Actual output, without the instrument tags

# TYPE myCounter_total counter
myCounter_total 1 1706978095318

# EOF

Additional context.

Discussed In https://github.com/open-telemetry/opentelemetry-dotnet/discussions/5313

Relevant docs: https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/docs/metrics#metrics-enrichment

YarinOmesi avatar Mar 16 '24 10:03 YarinOmesi

hi @YarinOmesi! can you describe the change you would like to see in terms of the specification (instead of in terms of .Net)?

cc @open-telemetry/dotnet-approvers

trask avatar Mar 26 '24 20:03 trask

hi @YarinOmesi! can you describe the change you would like to see in terms of the specification (instead of in terms of .Net)?

cc @open-telemetry/dotnet-approvers

It looks like some miscommunicated! I did ask to open a new issue to track this, but I meant to open one on the otel .net repo!

Transferring issue to otel .net repo.

cijothomas avatar Mar 27 '24 14:03 cijothomas

Tags can be added to a meter, instrument, and be provided when adding a value. The meter overload with tags: Meter ctor

Right now, only tags specified when providing a value are used.

The OP's app is setup to use Prometheus exporter. In my case I don't see meter and instrument tags being exported in OTLP.

JamesNK avatar Jul 24 '24 08:07 JamesNK

Meter Tags are supported : https://github.com/open-telemetry/opentelemetry-dotnet/pull/5089

Not sure if you are using PrometheusExporter? Maybe its missing in Prometheus exporter

cijothomas avatar Jul 24 '24 16:07 cijothomas

I see meter tags are added to the scope. Never mind about them.

Instrument tags are still an issue. It doesn't look like their is an attributes field on metrics in the OTLP spec. Is there a plan to add them to the spec, or should they be included with attributes on each number data point?

JamesNK avatar Jul 25 '24 01:07 JamesNK

Instrument tags are still an issue. It doesn't look like their is an attributes field on metrics in the OTLP spec. Is there a plan to add them to the spec

Instrument Tags is a .NET only invention, not backed by a spec. This issue is opened to find a way to add support for it. Most likely, this will be supported in OTel .NET itself. (no ETA).

cijothomas avatar Jul 25 '24 02:07 cijothomas

Is this a duplicate/related to: https://github.com/open-telemetry/opentelemetry-dotnet/issues/5836 ?

ProbablePrime avatar Sep 17 '24 08:09 ProbablePrime

Is this a duplicate/related to: https://github.com/open-telemetry/opentelemetry-dotnet/issues/5836 ?

I belive not, this issue is about instruments tags and not about meter tags

YarinOmesi avatar Sep 17 '24 12:09 YarinOmesi

Is this a duplicate/related to: #5836 ?

I belive not, this issue is about instruments tags and not about meter tags

Correct.

cijothomas avatar Sep 17 '24 17:09 cijothomas