Skip to content

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

Merged
utpilla merged 9 commits into
open-telemetry:mainfrom
atrokhovsergey:feature
Feb 20, 2024
Merged

Option to not add _total suffix to counter metrics in Prometheus exporter#5305
utpilla merged 9 commits into
open-telemetry:mainfrom
atrokhovsergey:feature

Conversation

@atrokhovsergey

Copy link
Copy Markdown
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)

@linux-foundation-easycla

linux-foundation-easycla Bot commented Feb 1, 2024

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

@atrokhovsergey
atrokhovsergey requested a review from a team February 1, 2024 20:06
@codecov

codecov Bot commented Feb 1, 2024

Copy link
Copy Markdown

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

Comment thread src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusAspNetCoreOptions.cs Outdated
Co-authored-by: Mikel Blanchard <mblanchard@macrosssoftware.com>
@atrokhovsergey

Copy link
Copy Markdown
Contributor Author

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

@vishweshbankwar

Copy link
Copy Markdown
Member

@Bassardes Could you address this #5305 (comment)

@atrokhovsergey

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusMetric.cs Outdated
atrokhovsergey and others added 4 commits February 16, 2024 15:17
Co-authored-by: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com>

## Unreleased

* Added option to disable _total suffix addition to counter metrics in

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed


## Unreleased

* Added option to disable _total suffix addition to counter metrics in

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

@CodeBlanch CodeBlanch left a comment

Copy link
Copy Markdown
Member

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
AsherBond pushed a commit to OTEL-California/opentelemetry-specification that referenced this pull request Jun 29, 2026
## Changes

Update the compliance matrix for .NET as of 1.16.0 of the .NET SDK.

I got Copilot to do most of the work of researching what was missing
that had been implementing and finding the relevant PRs that implemented
then. I cross checked the PRs _looked_ correct, but some of it might be
incorrect, particularly things that seem to have been implemented for a
while and predate my contributions to OTel. I then had Claude review the
changes and cross-reference, which fixed some of the entries, but again
there might still be some mistakes.

~~Some of the entries might only be available as experimental features,
so maybe they shouldn't be updated?~~ Experimental entries removed, now
marked as ~~strikethrough~~ below.

Entries updated with relevant PR links where appropriate below.

/cc @open-telemetry/dotnet-maintainers 

### Traces

- Get a Tracer with schema_url:
open-telemetry/opentelemetry-dotnet#6736
- Get a Tracer with scope attributes:
open-telemetry/opentelemetry-dotnet#6137
- Associate Tracer with InstrumentationScope:
open-telemetry/opentelemetry-dotnet#239
- Fetch InstrumentationScope from ReadableSpan:
open-telemetry/opentelemetry-dotnet#679

### Metrics

- Associate Meter with InstrumentationScope:
open-telemetry/opentelemetry-dotnet#6714
- Gauge instrument is supported:
open-telemetry/opentelemetry-dotnet#5867
- Valid instrument created / warning for duplicate name:
open-telemetry/opentelemetry-dotnet#2916
- Duplicate instrument registration resolved by first-seen:
open-telemetry/opentelemetry-dotnet#2916
- Instrument names conform to specified syntax:
open-telemetry/opentelemetry-dotnet#3821
- Instrument supports advisory ExplicitBucketBoundaries:
open-telemetry/opentelemetry-dotnet#5854
- Instrument supports advisory Attributes: Not implemented
- name/version/schema_url create InstrumentationScope:
open-telemetry/opentelemetry-dotnet#6714
- ~~View allows configuring name, description, attributes, aggregation:
open-telemetry/opentelemetry-dotnet#2396
- ~~View allows configuring exemplar reservoir:
open-telemetry/opentelemetry-dotnet#5558
- Metrics Reader supports default aggregation config:
open-telemetry/opentelemetry-dotnet#6778
- Metrics Reader supports default temporality config:
open-telemetry/opentelemetry-dotnet#4667
- ~~ExemplarReservoir interface/extension point:
open-telemetry/opentelemetry-dotnet#5542
- ~~ExemplarReservoir has offer method:
open-telemetry/opentelemetry-dotnet#5542
- SimpleFixedSizeExemplarReservoir:
open-telemetry/opentelemetry-dotnet#4256
- AlignedHistogramBucketExemplarReservoir:
open-telemetry/opentelemetry-dotnet#4119

### Logs

- ~~LoggerProvider.GetLogger:
open-telemetry/opentelemetry-dotnet#4422
- LoggerProvider.GetLogger accepts attributes: Not implemented
- LoggerProvider.Shutdown:
open-telemetry/opentelemetry-dotnet#5648
- LoggerProvider.ForceFlush:
open-telemetry/opentelemetry-dotnet#5648
- Logger.Emit(LogRecord) with Exception parameter: Not implemented
- ~~LogRecord.Set EventName:
open-telemetry/opentelemetry-dotnet#6306
- Logger.Enabled: Not implemented
- Ergonomic API (ILogger bridge):
open-telemetry/opentelemetry-dotnet#3489
- SimpleLogRecordProcessor:
open-telemetry/opentelemetry-dotnet#1622
- BatchLogRecordProcessor:
open-telemetry/opentelemetry-dotnet#1622
- Can plug custom LogRecordProcessor:
open-telemetry/opentelemetry-dotnet#4916
- LogRecordProcessor.Enabled: Not implemented
- Can plug custom LogRecordExporter:
open-telemetry/opentelemetry-dotnet#1622

### Context Propagation

- Jaeger Propagator:
open-telemetry/opentelemetry-dotnet#3309
- TextMapPropagator:
open-telemetry/opentelemetry-dotnet#1427

### Environment Variables

- OTEL_SDK_DISABLED:
open-telemetry/opentelemetry-dotnet#6568
- OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT:
open-telemetry/opentelemetry-dotnet#4887
- OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT:
open-telemetry/opentelemetry-dotnet#4887
- OTEL_TRACES_SAMPLER:
open-telemetry/opentelemetry-dotnet#5448
- OTEL_TRACES_SAMPLER_ARG:
open-telemetry/opentelemetry-dotnet#5448
- OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION:
open-telemetry/opentelemetry-dotnet#6778

### Exporters — OTLP

- OTLP/HTTP gzip Content-Encoding support:
open-telemetry/opentelemetry-dotnet#7055
- ~~Honors retryable responses with backoff:
open-telemetry/opentelemetry-dotnet#5495
- ~~Honors non-retryable responses:
open-telemetry/opentelemetry-dotnet#5495
- ~~Honors throttling response:
open-telemetry/opentelemetry-dotnet#5495
- Metric Exporter configurable temporality preference:
open-telemetry/opentelemetry-dotnet#4667
- Metric Exporter configurable default aggregation:
open-telemetry/opentelemetry-dotnet#6778

### Exporters — Zipkin

- InstrumentationScope mapping:
open-telemetry/opentelemetry-dotnet#5473

### Exporters — Prometheus

- Metadata Deduplication:
open-telemetry/opentelemetry-dotnet#7237
- otel_scope_name and otel_scope_version labels:
open-telemetry/opentelemetry-dotnet#7237
- otel_scope_[attribute] labels:
open-telemetry/opentelemetry-dotnet#7237
- Prometheus Counters have _total suffix by default:
open-telemetry/opentelemetry-dotnet#5305
- Prometheus Counters _total suffixing can be disabled:
open-telemetry/opentelemetry-dotnet#5305
- Colliding sanitized attribute keys are merged:
open-telemetry/opentelemetry-dotnet#7239
- Exemplars for Histograms and Monotonic sums:
open-telemetry/opentelemetry-dotnet#7222
- target_info metric from Resource:
open-telemetry/opentelemetry-dotnet#5407

### OpenTracing Compatibility

- Create OpenTracing Shim:
open-telemetry/opentelemetry-dotnet#197
- Tracer shim:
open-telemetry/opentelemetry-dotnet#197
- Span shim:
open-telemetry/opentelemetry-dotnet#197
- SpanContext shim:
open-telemetry/opentelemetry-dotnet#197
- ScopeManager shim:
open-telemetry/opentelemetry-dotnet#197
- Error mapping for attributes/events:
open-telemetry/opentelemetry-dotnet#197
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.

6 participants