Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Add a metric batcher which preallocates batch sizes. #194

Merged
merged 6 commits into from
Sep 1, 2019

Conversation

bogdandrutu
Copy link
Contributor

No description provided.

if metric == nil || metric.MetricDescriptor == nil {
return nil, errNilMetricOrMetricDescriptor
mb.recordDroppedTimeseries(len(metric.GetTimeseries()), errNilMetricOrMetricDescriptor)
Copy link
Contributor

Choose a reason for hiding this comment

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

metric.GetTimeseries() may produce a nil pointer error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No:
func (m *Metric) GetTimeseries() []*TimeSeries {
if m != nil {
return m.Timeseries
}
return nil
}

// Send create time series requests to Stackdriver.
for _, req := range mb.allReqs {
if err := createTimeSeries(ctx, mc, req); err != nil {
mb.droppedTimeSeries += len(req.TimeSeries)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use mb.recordDroppedTimeseries 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.

Fixed the code now, I think this makes more sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

recordDroppedTimeseries will double count receivedTimeSeries, isn't it?

@songy23 songy23 requested a review from rghetia August 30, 2019 21:59
func (mb *metricsBatcher) addTimeSeries(ts *monitoringpb.TimeSeries) {
mb.receivedTimeSeries++
mb.allTss = append(mb.allTss, ts)
if len(mb.allReqs) == maxTimeSeriesPerUpload {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be len(mb.allTss)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

// Send create time series requests to Stackdriver.
for _, req := range mb.allReqs {
if err := createTimeSeries(ctx, mc, req); err != nil {
mb.droppedTimeSeries += len(req.TimeSeries)
Copy link
Contributor

Choose a reason for hiding this comment

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

recordDroppedTimeseries will double count receivedTimeSeries, isn't it?

@bogdandrutu
Copy link
Contributor Author

PTAL. Added a method that returns number of dropped timeseries. So we can use the helper for metrics recording in open-telemetry/opentelemetry-collector#315

@rghetia
Copy link
Contributor

rghetia commented Sep 1, 2019

LGTM

@bogdandrutu bogdandrutu merged commit 3b40441 into census-ecosystem:master Sep 1, 2019
@bogdandrutu bogdandrutu deleted the batcher branch September 1, 2019 16:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants