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

feat: add support for MetricTypeSum #37156

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

perebaj
Copy link
Contributor

@perebaj perebaj commented Jan 12, 2025

Description

Prometheus translation rw2 add support for MetricTypeSum.

The current work was inspired by #36353

Link to tracking issue #33661

Timestamp: timestamp.FromTime(exemplar.Timestamp().AsTime()),
}
}
// TODO append labels to promExemplar.Labels
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to implement something similar to the current version, but the type of LabelsRefs([]uint32) is a little different of prompb.Label. Do you have any tip to iterate and append LabelsRefs on exemplar field?

Copy link
Contributor

Choose a reason for hiding this comment

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

The addSample function does something similar to what you need to do here:

func (c *prometheusConverterV2) addSample(sample *writev2.Sample, lbls []prompb.Label) *writev2.TimeSeries {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I'm thinking to solve it in a next PR. Trying to figure out how to make the tests pass now

Comment on lines 83 to 85
dataPoints := metric.Sum().DataPoints()
if dataPoints.Len() == 0 {
errs = multierr.Append(errs, fmt.Errorf("empty data points. %s is dropped", metric.Name()))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dashpole you did a comment here saying to remove the error line. Should I remove it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but please remove it from the gauge case above as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

6c78f84

Removed

Comment on lines 83 to 85
dataPoints := metric.Sum().DataPoints()
if dataPoints.Len() == 0 {
errs = multierr.Append(errs, fmt.Errorf("empty data points. %s is dropped", metric.Name()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but please remove it from the gauge case above as well

@@ -80,7 +80,12 @@ func (c *prometheusConverterV2) fromMetrics(md pmetric.Metrics, settings Setting
}
c.addGaugeNumberDataPoints(dataPoints, resource, settings, promName)
case pmetric.MetricTypeSum:
// TODO implement
dataPoints := metric.Sum().DataPoints()
Copy link
Contributor

Choose a reason for hiding this comment

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

If the sum is non-monotonic, we need to emit it as a gauge instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

13ee3b6
Addressed

Timestamp: timestamp.FromTime(exemplar.Timestamp().AsTime()),
}
}
// TODO append labels to promExemplar.Labels
Copy link
Contributor

Choose a reason for hiding this comment

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

The addSample function does something similar to what you need to do here:

func (c *prometheusConverterV2) addSample(sample *writev2.Sample, lbls []prompb.Label) *writev2.TimeSeries {

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

Successfully merging this pull request may close these issues.

2 participants