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

Support monotonic operation for counter/sum #1783

Open
xuan-cao-swi opened this issue Dec 18, 2024 · 1 comment
Open

Support monotonic operation for counter/sum #1783

xuan-cao-swi opened this issue Dec 18, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@xuan-cao-swi
Copy link
Contributor

xuan-cao-swi commented Dec 18, 2024

The counter should be adjustable for monotonic operations so that, when enabled, it prevents any negative values.

Related discussion: #1778

Related docs:

@xuan-cao-swi xuan-cao-swi added the bug Something isn't working label Dec 18, 2024
@xuan-cao-swi xuan-cao-swi changed the title Support monotonic operation for counter Support monotonic operation for counter/sum Dec 18, 2024
@garoazinha
Copy link

garoazinha commented Jan 14, 2025

I also couldn't export metrics to prometheus and could fix it by changing the way the exporting is done. According to the specs non_monotonic type sum is based on the instrument. Doing this:

case instrument_type      
 when :counter
  Opentelemetry::Proto::Metrics::V1::Metric.new(
    name: metrics.name,
    description: metrics.description,
    unit: metrics.unit,
    sum: Opentelemetry::Proto::Metrics::V1::Sum.new(
      aggregation_temporality: as_otlp_aggregation_temporality(metrics.aggregation_temporality),
      data_points: metrics.data_points.map do |ndp|
        number_data_point(ndp)
      end,
      is_monotonic: true
     )
   )
end

on the metrics otlp exporter already solved the issue for me. The is_monotonic attribute should be tied to the Sum class though, as it is in other implementations. The parameter is usually set when initializing the sum aggregation object, in:
python impl
js impl
go impl

I am trying to do something similar but unsure if this is the way to to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants