Sun*_*ati 5 .net c# prometheus asp.net-core open-telemetry
封装参考
<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" />
Run Code Online (Sandbox Code Playgroud)
程序.cs
builder.Services.AddOpenTelemetryMetrics(b =>
{
b.AddPrometheusExporter();
b.AddMeter(TelemetryConstants.MyAppSource);
b.SetResourceBuilder(resource);
b.AddHttpClientInstrumentation();
b.AddAspNetCoreInstrumentation();
});
Run Code Online (Sandbox Code Playgroud)
当我运行该应用程序时,出现以下错误
System.TypeLoadException: 'Could not load type 'System.ServiceProviderExtensions' from assembly 'OpenTelemetry, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7bd6737fe5b67e3c'.'
在app.UseOpenTelemetryPrometheusScrapingEndpoint();
OpenTelemetry.Exporter.Prometheus当我同时引用和包时,我看到了这个问题OpenTelemetry.Exporter.Prometheus.AspNetCore。删除OpenTelemetry.Exporter.Prometheus包引用解决了该问题。
| 归档时间: |
|
| 查看次数: |
1462 次 |
| 最近记录: |