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

Remove unnecessary functions in PrometheusRemoteWriteExporter #3261

Merged

Conversation

sincejune
Copy link
Contributor

Description:
Modify code as suggested here: #3184 (comment)

Testing:
All unit tests passed.

dropped++
errs = append(errs, consumererror.Permanent(err))
errs = append(errs, consumererror.Permanent(fmt.Errorf("empty data points. %s is dropped", metric.Name())))
Copy link
Member

Choose a reason for hiding this comment

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

In a separate PR we should discuss about this, I don't think this should be an error.

Comment on lines 148 to 154
if dataPoints.Len() == 0 {
dropped++
errs = append(errs, consumererror.Permanent(fmt.Errorf("empty data points. %s is dropped", metric.Name())))
}
for x := 0; x < dataPoints.Len(); x++ {
addSingleIntDataPoint(dataPoints.At(x), resource, metric, prwe.namespace, tsMap, prwe.externalLabels)
}
Copy link
Member

Choose a reason for hiding this comment

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

I think we can reduce some of the duplicate code here by having a func that accepts IntDataPointSlice. So this and IntSum will call into the same func, as well as for double.

func addIntDataPoints(dataPoints pdata.IntDataPointSlice, ...) error {
	if dataPoints.Len() == 0 {
		dropped++							
		return consumererror.Permanent(fmt.Errorf("empty data points. %s is dropped", metric.Name()))
	}
	for x := 0; x &lt; dataPoints.Len(); x++ {	
		addSingleIntDataPoint(dataPoints.At(x), resource, metric, prwe.namespace, tsMap, prwe.externalLabels)
	}
	return nil
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually addSingleIntDataPoint requires the metric as a parameter. So I both passed datapoints and metric to the new function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in dcbc7ff

@sincejune sincejune requested a review from alolita as a code owner June 3, 2021 12:41
@bogdandrutu bogdandrutu merged commit db28270 into open-telemetry:main Jun 7, 2021
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.

5 participants