open-telemetry / opentelemetry-dotnet

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

MeterProviderBuilder missing AddPrometheusExporter method #3335

Closed mbmcmullen27 closed 2 years ago

mbmcmullen27 commented 2 years ago

Bug Report

OpenTelemetry Package versions: OpenTelemetry.Api 1.3.0-beta.2 OpenTelemetry.Extensions.Hosting 1.0.0-rc9.3 OpenTelemetry.Instrumentation.AspNetCore 1.0.0-rc9 OpenTelemetry.Exporter.Console 1.3.0-beta.2 OpenTelemetry.Exporter.OpenTelemetryProtocol 1.3.0-beta.2 OpenTelemetry.Exporter.Prometheus 1.3.0-beta.2 OpenTelemetry.Instrumentation.Http 1.0.0-rc9

Runtime version : netcoreapp3.1

Symptom

I'm building a PoC of a simple webapi with OpenTelemetry Tracing using the dotnet new webapi template for dotnet 3.1 I was able to instrument the app with traces, without issue, and I can send them to Tempo and view them as expected.

However, when I attempt to add OpenTelemetry metrics and the Prometheus Exporter, following the instructions here I get unexpected errors. Specifically:

Startup.cs(36,25): error CS1061: 'MeterProviderBuilder' does not contain a definition for 'AddPrometheusExporter' and no accessible extension method 'AddPrometheusExporter'

According to the instructions and nuget this version of the Prometheus Exporter package should be compatible with dotnet core 3.1.

I would expect this to build so I could verify the behavior.

Reproduce

project repo: https://github.com/mbmcmullen27/dotnet-opentel-poc

alternatively if docker is available

both methods reproduce the same error

Additional Context

OpenTelemetry documentation website only has instructions for dotnet 6, is dotnet 3.1 still supported, did the method get moved, or am I missing something obvious here? Any advice on how to get this working is greatly appreciated.

Thanks

cijothomas commented 2 years ago

Have you done using OpenTelemetry.Metrics?

We have working examples in the repo https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/examples/AspNetCore You may check that.

mbmcmullen27 commented 2 years ago

Haha wow, yup it builds after adding that. I knew it had to be something silly. Thanks so much :+1: