Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prometheus exporter should return empty body with 200 code not 204 when no metrics #3582

Closed
kriswuollett opened this issue Aug 17, 2022 · 1 comment · Fixed by #3643
Closed
Labels
bug Something isn't working pkg:OpenTelemetry.Exporter.Prometheus.AspNetCore Issues related to OpenTelemetry.Exporter.Prometheus.AspNetCore NuGet package

Comments

@kriswuollett
Copy link

Bug Report

Not sure if exactly the same as mentioned in #2400 since that mentions a part of the system not being ready, but I think I encountered the 204 issue when simply no metrics had been populated yet. If this is the same issue, IMO keeping this one to track this specific issue outside of a catch-all would be nice.

For the case when there are no metrics, the Prometheus export should return an empty body with 200 status code, not "204 Empty Content", because the Prometheus scraper will think it is an error.

After I hit my health check endpoint it caused a counter to be modified which resulted in the metrics export returning content finally:

image

    <PackageReference Include="OpenTelemetry" Version="1.3.0" />
    <PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.3.0" />
    <PackageReference Include="OpenTelemetry.Exporter.Jaeger" Version="1.3.0" />
    <PackageReference Include="OpenTelemetry.Exporter.Prometheus" Version="1.3.0-rc.2" />
    <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9.4" />
    <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.4" />
    <PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9.4" />
Microsoft.AspNetCore.App 6.0.5
Microsoft.NETCore.App 6.0.5
@kriswuollett kriswuollett added the bug Something isn't working label Aug 17, 2022
@CodeBlanch
Copy link
Member

@Yun-Ting You want to tackle this? We looked for something documented about what the status code should be for success-no-data case but couldn't find anything so we went with 204. The code above shows the scraper behavior I think that is valid enough documentation to switch it to 200.

/cc @reyang

@reyang reyang added the pkg:OpenTelemetry.Exporter.Prometheus.AspNetCore Issues related to OpenTelemetry.Exporter.Prometheus.AspNetCore NuGet package label Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:OpenTelemetry.Exporter.Prometheus.AspNetCore Issues related to OpenTelemetry.Exporter.Prometheus.AspNetCore NuGet package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants