-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Switch Stackdriver sink to grpc-based Stackdriver API #1906
Conversation
@pongad |
/retest |
return &sd_api.TimeSeries{ | ||
Metric: &sd_api.Metric{ | ||
func createTimeSeries(resource string, resourceLabels map[string]string, metadata *metricMetadata, point *monitoringpb.Point) *monitoringpb.TimeSeries { | ||
//monitoringpb. |
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.
?
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.
Done.
/retest |
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.
A couple of nits, but I think it generally looks good.
"google.golang.org/api/googleapi" | ||
sd_api "google.golang.org/api/monitoring/v3" | ||
google_api5 "google.golang.org/genproto/googleapis/api/metric" | ||
google_api4 "google.golang.org/genproto/googleapis/api/monitoredres" |
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.
Maybe rename these imports?
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.
Done
timestamp time.Time, labels map[string]string, collectionStartTime time.Time, entityCreateTime time.Time) []*sd_api.TimeSeries { | ||
timeseries := make([]*sd_api.TimeSeries, 0) | ||
timestamp time.Time, labels map[string]string, collectionStartTime time.Time, entityCreateTime time.Time) []*monitoringpb.TimeSeries { | ||
timeseries := make([]*monitoringpb.TimeSeries, 0) |
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.
var timeseries []*monitoringpb.TimeSeries
? That way empty arrays don't allocate.
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.
Done
@@ -268,7 +270,7 @@ func (sink *StackdriverSink) requestSender(reqQueue chan *sd_api.CreateTimeSerie | |||
} |
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.
Isn't this loop just
for req := range reqQueue {sink.sendOneRequest(req)}
?
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.
Done
startTime := time.Now() | ||
empty, err := sink.stackdriverClient.Projects.TimeSeries.Create(fullProjectName(sink.project), req).Do() | ||
err := sink.stackdriverClient.CreateTimeSeries(context.Background(), req, gax.WithGRPCOptions()) |
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.
No need to write gax.WithGRPCOptions()
if you don't pass options.
This function is used for passing more options to gRPC layer.
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.
Done
return &sd_api.CreateTimeSeriesRequest{TimeSeries: make([]*sd_api.TimeSeries, 0)} | ||
func getReq(project string) *monitoringpb.CreateTimeSeriesRequest { | ||
return &monitoringpb.CreateTimeSeriesRequest{ | ||
TimeSeries: make([]*monitoringpb.TimeSeries, 0), |
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.
nil
?
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.
Done
return &monitoringpb.Point{ | ||
Interval: &monitoringpb.TimeInterval{ | ||
EndTime: &google_protobuf2.Timestamp{Seconds: endTime.Unix(), Nanos: int32(endTime.Nanosecond())}, | ||
StartTime: &google_protobuf2.Timestamp{Seconds: startTime.Unix(), Nanos: int32(startTime.Nanosecond())}, |
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.
Consider using this
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 think it actually returns different type.
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.
/lgtm
Cherry-pick changes from PR #1906 to 1.5 release branch
This PR together with #1907 lowers Heapster maximum resource usage by 60% CPU and 25% memory (tested over 2 hours on GCE, 100-node cluster with 3k running user pods).