-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
base: main
Are you sure you want to change the base?
Conversation
Timestamp: timestamp.FromTime(exemplar.Timestamp().AsTime()), | ||
} | ||
} | ||
// TODO append labels to promExemplar.Labels |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite/metrics_to_prw_v2.go
Line 111 in 667e81e
func (c *prometheusConverterV2) addSample(sample *writev2.Sample, lbls []prompb.Label) *writev2.TimeSeries { |
There was a problem hiding this comment.
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
dataPoints := metric.Sum().DataPoints() | ||
if dataPoints.Len() == 0 { | ||
errs = multierr.Append(errs, fmt.Errorf("empty data points. %s is dropped", metric.Name())) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
dataPoints := metric.Sum().DataPoints() | ||
if dataPoints.Len() == 0 { | ||
errs = multierr.Append(errs, fmt.Errorf("empty data points. %s is dropped", metric.Name())) |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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:
opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite/metrics_to_prw_v2.go
Line 111 in 667e81e
func (c *prometheusConverterV2) addSample(sample *writev2.Sample, lbls []prompb.Label) *writev2.TimeSeries { |
Description
Prometheus translation rw2 add support for MetricTypeSum.
The current work was inspired by #36353
Link to tracking issue #33661