@@ -52,8 +52,6 @@ import (
52
52
gcemd "cloud.google.com/go/compute/metadata"
53
53
"cloud.google.com/go/internal/version"
54
54
"cloud.google.com/go/profiler/internal"
55
- "github.com/golang/protobuf/proto"
56
- "github.com/golang/protobuf/ptypes"
57
55
"github.com/google/pprof/profile"
58
56
gax "github.com/googleapis/gax-go/v2"
59
57
"google.golang.org/api/option"
@@ -64,6 +62,7 @@ import (
64
62
"google.golang.org/grpc/codes"
65
63
grpcmd "google.golang.org/grpc/metadata"
66
64
"google.golang.org/grpc/status"
65
+ "google.golang.org/protobuf/proto"
67
66
)
68
67
69
68
var (
@@ -297,14 +296,13 @@ func abortedBackoffDuration(md grpcmd.MD) (time.Duration, error) {
297
296
var retryInfo edpb.RetryInfo
298
297
if err := proto .Unmarshal ([]byte (elem [0 ]), & retryInfo ); err != nil {
299
298
return 0 , err
300
- } else if time , err := ptypes .Duration (retryInfo .RetryDelay ); err != nil {
301
- return 0 , err
302
- } else {
303
- if time < 0 {
304
- return 0 , errors .New ("negative retry duration" )
305
- }
306
- return time , nil
307
299
}
300
+
301
+ time := retryInfo .RetryDelay .AsDuration ()
302
+ if time < 0 {
303
+ return 0 , errors .New ("negative retry duration" )
304
+ }
305
+ return time , nil
308
306
}
309
307
310
308
type retryer struct {
@@ -386,11 +384,7 @@ func (a *agent) profileAndUpload(ctx context.Context, p *pb.Profile) {
386
384
387
385
switch pt {
388
386
case pb .ProfileType_CPU :
389
- duration , err := ptypes .Duration (p .Duration )
390
- if err != nil {
391
- debugLog ("failed to get profile duration for CPU profile: %v" , err )
392
- return
393
- }
387
+ duration := p .Duration .AsDuration ()
394
388
if err := startCPUProfile (& prof ); err != nil {
395
389
debugLog ("failed to start CPU profile: %v" , err )
396
390
return
@@ -403,11 +397,7 @@ func (a *agent) profileAndUpload(ctx context.Context, p *pb.Profile) {
403
397
return
404
398
}
405
399
case pb .ProfileType_HEAP_ALLOC :
406
- duration , err := ptypes .Duration (p .Duration )
407
- if err != nil {
408
- debugLog ("failed to get profile duration for allocation profile: %v" , err )
409
- return
410
- }
400
+ duration := p .Duration .AsDuration ()
411
401
if err := deltaAllocProfile (ctx , duration , config .AllocForceGC , & prof ); err != nil {
412
402
debugLog ("failed to collect allocation profile: %v" , err )
413
403
return
@@ -418,11 +408,7 @@ func (a *agent) profileAndUpload(ctx context.Context, p *pb.Profile) {
418
408
return
419
409
}
420
410
case pb .ProfileType_CONTENTION :
421
- duration , err := ptypes .Duration (p .Duration )
422
- if err != nil {
423
- debugLog ("failed to get profile duration: %v" , err )
424
- return
425
- }
411
+ duration := p .Duration .AsDuration ()
426
412
if err := deltaMutexProfile (ctx , duration , & prof ); err != nil {
427
413
debugLog ("failed to collect mutex profile: %v" , err )
428
414
return
0 commit comments