open-telemetry / opentelemetry-dotnet

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

Metrics page may appear blank after a few seconds. #5713

Closed mhdimsy closed 4 months ago

mhdimsy commented 4 months ago

What is the question?

Hello everyone. The metrics page may appear blank after a few seconds. Then Prometheus shows the job is up, but metrics are not scraped.

My config is

services.AddOpenTelemetry()
.ConfigureResource(resource => resource.AddService("backend"))
.WithMetrics(builder => builder
.AddMeter(FormStepHandlerMeter.name)
                    .AddMeter("Microsoft.AspNetCore.Hosting")
                    .AddMeter("Microsoft.AspNetCore.Http.Connections")
                    .AddMeter("Microsoft.AspNetCore.Routing")
                    .AddMeter("Microsoft.AspNetCore.Diagnostics")
                    .AddMeter("Microsoft.AspNetCore.RateLimiting")
                    .AddAspNetCoreInstrumentation()
                    .AddRuntimeInstrumentation()
                    .AddPrometheusExporter()
                )

I use dotnet 6 and this packages: OpenTelemetry.Exporter.Console 1.9.0 OpenTelemetry.Exporter.Prometheus.AspNetCore 1.9.0-beta.1 OpenTelemetry.Extensions.Hosting 1.9.0 OpenTelemetry.Instrumentation.AspNetCore 1.9.0 OpenTelemetry.Instrumentation.EntityFrameworkCore 1.0.0-beta.12 OpenTelemetry.Instrumentation.Http 1.9.0 OpenTelemetry.Instrumentation.Runtime 1.9.0 OpenTelemetry.Instrumentation.SqlClient 1.9.0-beta.1

Even though nothing is being collected, it takes 259.968 to complete(last scraping).

cijothomas commented 4 months ago

Is the scraping endpoint setup as well? (The code snippet above does not indicate so...) https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/examples/AspNetCore/Program.cs#L168

mhdimsy commented 4 months ago

Yes In startup.cs file this line exist. Just the first few seconds it works fine, but then it stops sending. please see the image image

mhdimsy commented 4 months ago

FYI: I activate console exporter While the console is printing the metrics correctly, the issue I mentioned still exists.

Kielek commented 4 months ago

@mhdimsy, please give a chance to OpenTelemetry.Exporter.Prometheus.AspNetCore 1.9.0-beta.2. It was released yesterday.

mhdimsy commented 4 months ago

@Kielek , Thanks it works. But AddAspNetCoreInstrumentation not has http_server_active_requests metrics, this is correct?

Kielek commented 4 months ago

@mhdimsy, please check https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.AspNetCore-1.9.0/src/OpenTelemetry.Instrumentation.AspNetCore/README.md#metrics

I am closing this as the issue was solved. Please create separate one if you fins some problems with metrics.