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

Export OpenMetrics format for prometheus exporters #5107

Conversation

robertcoltheart
Copy link
Contributor

@robertcoltheart robertcoltheart commented Dec 1, 2023

Fixes #
First part to addressing #3972

Changes

Export OpenMetrics format for Prometheus. See here.

  • Add Accept parser and set correct Content-Type
  • Write metric timestamps in OpenMetric format

Merge requirement checklist

  • CONTRIBUTING guidelines followed (nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@robertcoltheart robertcoltheart marked this pull request as ready for review December 1, 2023 01:11
@robertcoltheart robertcoltheart requested a review from a team as a code owner December 1, 2023 01:11
Copy link
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

codecov bot commented Dec 5, 2023

Codecov Report

Merging #5107 (015ad3b) into main (a963ec8) will increase coverage by 0.06%.
Report is 1 commits behind head on main.
The diff coverage is 96.66%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5107      +/-   ##
==========================================
+ Coverage   83.06%   83.13%   +0.06%     
==========================================
  Files         296      297       +1     
  Lines       12320    12369      +49     
==========================================
+ Hits        10234    10283      +49     
  Misses       2086     2086              
Flag Coverage Δ
unittests 83.13% <96.66%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...tpListener/Internal/PrometheusCollectionManager.cs 79.04% <100.00%> (+1.26%) ⬆️
...etheus.HttpListener/Internal/PrometheusExporter.cs 100.00% <100.00%> (ø)
...s.HttpListener/Internal/PrometheusHeadersParser.cs 100.00% <100.00%> (ø)
...s.HttpListener/Internal/PrometheusSerializerExt.cs 100.00% <100.00%> (ø)
....Prometheus.HttpListener/PrometheusHttpListener.cs 81.70% <100.00%> (+1.70%) ⬆️
...metheus.AspNetCore/PrometheusExporterMiddleware.cs 70.00% <92.30%> (+7.93%) ⬆️
...heus.HttpListener/Internal/PrometheusSerializer.cs 80.80% <90.00%> (+0.79%) ⬆️

... and 6 files with indirect coverage changes

robertcoltheart and others added 2 commits December 6, 2023 13:41
…orterMiddleware.cs

Co-authored-by: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com>
robertcoltheart and others added 2 commits December 6, 2023 13:42
…orterMiddleware.cs

Co-authored-by: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com>
…ttpListener.cs

Co-authored-by: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com>
.AddMeter(meter.Name)
.AddPrometheusHttpListener(options => options.UriPrefixes = new string[] { address })
.Build();
try
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It's simpler to not have the try/catch block here. This is a test so it's okay for it to fail with the original exception. Anyone troubleshooting the test failure would realize what the issue was anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I'm guessing its because there might be a potential conflict with an already open port? I can remove in the next PR in any case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I'm guessing its because there might be a potential conflict with an already open port?

The tests within a project are not run in parallel so it shouldn't be the case unless the listener instances are not getting disposed correctly.

@utpilla utpilla merged commit 7419d85 into open-telemetry:main Dec 7, 2023
78 checks passed
@robertcoltheart
Copy link
Contributor Author

Thanks very much! Will crack on with the next PR.

@robertcoltheart robertcoltheart deleted the feature/export-prometheus-openmetrics branch December 7, 2023 00:20
@utpilla
Copy link
Contributor

utpilla commented Dec 7, 2023

Thanks very much! Will crack on with the next PR.

@robertcoltheart Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants