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

Commit

Permalink
avoid expensive clones in splitCreateTimeSeriesRequest (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwiesmueller authored Apr 6, 2022
1 parent dfce60d commit 074d8ef
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,8 @@ var createServiceTimeSeries = func(ctx context.Context, c *monitoring.MetricClie
func splitCreateTimeSeriesRequest(req *monitoringpb.CreateTimeSeriesRequest) (*monitoringpb.CreateTimeSeriesRequest, *monitoringpb.CreateTimeSeriesRequest) {
var serviceReq, nonServiceReq *monitoringpb.CreateTimeSeriesRequest
serviceTs, nonServiceTs := splitTimeSeries(req.TimeSeries)
// reset timeseries as we just split it to avoid cloning it in the calls below
req.TimeSeries = nil
if len(serviceTs) > 0 {
serviceReq = proto.Clone(req).(*monitoringpb.CreateTimeSeriesRequest)
serviceReq.TimeSeries = serviceTs
Expand Down

0 comments on commit 074d8ef

Please sign in to comment.