5

Package References

    <PackageReference Include="OpenTelemetry.Exporter.Jaeger" Version="1.4.0-beta.2" />
    <PackageReference Include="OpenTelemetry.Exporter.Prometheus" Version="1.2.0-rc5"/>
    <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9.8" />
    <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.8" />
    <PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9.8" />

Program.cs

builder.Services.AddOpenTelemetryMetrics(b =>
{
    b.AddPrometheusExporter();
    b.AddMeter(TelemetryConstants.MyAppSource);
    b.SetResourceBuilder(resource);
    b.AddHttpClientInstrumentation();
    b.AddAspNetCoreInstrumentation();
});

When I run the application it's giving the following error

System.TypeLoadException: 'Could not load type 'System.ServiceProviderExtensions' from assembly 'OpenTelemetry, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7bd6737fe5b67e3c'.'

at app.UseOpenTelemetryPrometheusScrapingEndpoint();

4 Answers4

5

The error has gone after adding opentelemetry.exporter.prometheus.aspnetcore package.

5

I saw this issue when I had both OpenTelemetry.Exporter.Prometheus and OpenTelemetry.Exporter.Prometheus.AspNetCore packages referenced. Removing the OpenTelemetry.Exporter.Prometheus package reference solved the issue.

Mark
  • 11,257
  • 11
  • 61
  • 97
0

Try to switch the version of OpenTelemetry.Exporter.Prometheus back to 1.4.0-alpha.2 At least it solved my problem.

0

use OpenTelemetry.Exporter.Prometheus --version 1.2.0-beta1