open-telemetry / opentelemetry-dotnet

The OpenTelemetry .NET Client
https://opentelemetry.io
Apache License 2.0
3.23k stars 765 forks source link

[bug] Prometheus Exporter does not expose Meter Tags and Version #5836

Open ProbablePrime opened 2 months ago

ProbablePrime commented 2 months ago

Package

OpenTelemetry.Exporter.Prometheus.HttpListener

Package Version

    <PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.9.0-beta.2" />
    <PackageReference Include="OpenTelemetry.Exporter.Prometheus.HttpListener" Version="1.9.0-beta.2" />
    <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
    <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
    <PackageReference Include="OpenTelemetry.Instrumentation.Process" Version="0.5.0-beta.6" />
    <PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.9.0" />
    <PackageReference Include="System.Diagnostics.DiagnosticSource" Version="9.0.0-rc.1.24431.7" />

Runtime Version

net8.0

Description

When creating a System.Diagnostics.Metrics.Meter with a version and tags, e.g.

var meterTags = new KeyValuePair<string, object>[]
        {
            new KeyValuePair<string, object>("meterKey1", "value1"),
            new KeyValuePair<string, object>("meterKey2", "value2"),
        };
var meter = meterFactory.Create("Test", "1.0.0", meterTags);

The version and tags provided do not show up in Prometheus exported metrics.

Steps to Reproduce

I have a branch of this Repository with one of the integration tests edited to show this issue, you can find the branch here: https://github.com/open-telemetry/opentelemetry-dotnet/compare/main...ProbablePrime:opentelemetry-dotnet:prime/tests/meter-tags

Expected Result

I expect, the Meter sourced tags to be included in the output. This is shown in the test case expected data changes.

E.g. counter_double_bytes_total{{otel_scope_name='{MeterName}',otel_scope_version='{MeterVersion}',**meterKey1='value1',meterKey2='value2'**,key1='value1',key2='value2'}}

Actual Result

It results in a failed test. image

Additional Context

I apologize for any terminology goofs, here. I'm brand new to the OpenTelemetry scene. Please ask questions if you are unsure.

This is based on:

Which may have additional information to help.

Thank you!