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

Option to not add _total suffix to counter metrics in Prometheus exporter #5305

Merged
merged 9 commits into from
Feb 20, 2024
Merged

Conversation

Bassardes
Copy link
Contributor

Fixes #
Design discussion issue #

Changes

According to this doc

If the metric name for monotonic Sum metric points does not end in a suffix of _total a suffix of _total MUST be added by default, otherwise the name MUST remain unchanged. Exporters SHOULD provide a configuration option to disable the addition of _total suffixes.

This PR adds option to disable addition of _total suffix for counter metrics in Prometheus exporter

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, 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)

Copy link

linux-foundation-easycla bot commented Feb 1, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@Bassardes Bassardes requested a review from a team as a code owner February 1, 2024 20:06
Copy link

codecov bot commented Feb 1, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (6250307) 83.38% compared to head (d793d2e) 83.10%.
Report is 87 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5305      +/-   ##
==========================================
- Coverage   83.38%   83.10%   -0.28%     
==========================================
  Files         297      276      -21     
  Lines       12531    12011     -520     
==========================================
- Hits        10449     9982     -467     
+ Misses       2082     2029      -53     
Flag Coverage Δ
unittests ?
unittests-Solution-Experimental 83.08% <86.66%> (?)
unittests-Solution-Stable 83.08% <86.66%> (?)

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

Files Coverage Δ
...tpListener/Internal/PrometheusCollectionManager.cs 77.77% <100.00%> (ø)
...etheus.HttpListener/Internal/PrometheusExporter.cs 100.00% <100.00%> (ø)
...HttpListener/Internal/PrometheusExporterOptions.cs 100.00% <100.00%> (ø)
...ometheus.HttpListener/Internal/PrometheusMetric.cs 71.75% <100.00%> (ø)
...theusHttpListenerMeterProviderBuilderExtensions.cs 81.25% <100.00%> (-11.61%) ⬇️
...heus.HttpListener/PrometheusHttpListenerOptions.cs 100.00% <100.00%> (ø)
...ometheus.AspNetCore/PrometheusAspNetCoreOptions.cs 50.00% <0.00%> (-25.00%) ⬇️

... and 44 files with indirect coverage changes

Co-authored-by: Mikel Blanchard <mblanchard@macrosssoftware.com>
@Bassardes
Copy link
Contributor Author

I don't understand what happens with tests, locally it's all passes. I need help with it

@vishweshbankwar
Copy link
Member

@Bassardes Could you address this #5305 (comment)

@Bassardes
Copy link
Contributor Author

@vishweshbankwar Seems that I can't, because this merge c0eb638 wasn't done by me. I will try force push and merge master by myself

/// <summary>
/// Gets or sets a value indicating whether addition of _total suffix for counter metric names is disabled. Default value: <see langword="false"/>.
/// </summary>
public bool DisableTotalNameSuffixForCounters
Copy link
Member

Choose a reason for hiding this comment

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

public bool EnableCounterTotalSuffix = true - alternate suggestion.

The default should be true as per https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/prometheus_and_openmetrics.md#sums

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exporters SHOULD provide a configuration option to disable..

So I think DisableTotalNameSuffixForCounters will be better

Bassardes and others added 4 commits February 16, 2024 15:17
Co-authored-by: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com>
@@ -2,6 +2,10 @@

## Unreleased

* Added option to disable _total suffix addition to counter metrics in
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to mention "in Prometheus exporter". This CHANGELOG file is specific to Prometheus exporter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -2,6 +2,10 @@

## Unreleased

* Added option to disable _total suffix addition to counter metrics in
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member

@CodeBlanch CodeBlanch left a comment

Choose a reason for hiding this comment

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

LGTM

@utpilla utpilla merged commit bbce7ef into open-telemetry:main Feb 20, 2024
31 checks passed
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

6 participants