@@ -360,7 +360,7 @@ func (*SupportBundle) Synopsis() string {
360
360
// Usage implements the subcommand interface for support bundle report collection for support team.
361
361
func (* SupportBundle ) Usage () string {
362
362
return `Usage: supportbundle [-sid=<SAP System Identifier>] [-instance-numbers=<Instance numbers>]
363
- [-hostname=<Hostname>] [agent-logs-only=true|false] [-metrics ] [-metrics]
363
+ [-hostname=<Hostname>] [agent-logs-only=true|false] [-pacemaker-diagnosis=true|false ] [-metrics=true|false ]
364
364
[-timestamp=<YYYY-MM-DD HH:MM:SS>] [-before-duration=<duration in seconds>] [-after-duration=<duration in seconds>]
365
365
[-h] [-loglevel=<debug|info|warn|error>]
366
366
[-result-bucket=<name of the result bucket where bundle zip is uploaded>] [-log-path=<log-path>]
@@ -433,6 +433,7 @@ func (s *SupportBundle) supportBundleHandler(ctx context.Context, destFilePathPr
433
433
s .oteLogger .LogErrorToFileAndConsole (ctx , "Invalid params for collecting support bundle Report for Agent for SAP" , errors .New (errMessage ))
434
434
return fmt .Sprintf ("Invalid params for collecting support bundle Report for Agent for SAP: %s" , errMessage ), subcommands .ExitUsageError
435
435
}
436
+ s .oteLogger .LogUsageAction (usagemetrics .SupportBundle )
436
437
s .Sid = strings .ToUpper (s .Sid )
437
438
bundlename := fmt .Sprintf ("supportbundle-%s-%s" , s .Hostname , strings .Replace (time .Now ().Format (time .RFC3339 ), ":" , "-" , - 1 ))
438
439
destFilesPath := fmt .Sprintf ("%s%s" , destFilePathPrefix , bundlename )
@@ -535,10 +536,12 @@ func (s *SupportBundle) supportBundleHandler(ctx context.Context, destFilePathPr
535
536
}
536
537
537
538
if s .ResultBucket != "" {
539
+ s .oteLogger .LogUsageAction (usagemetrics .SupportBundleUploadStarted )
538
540
if err := s .uploadZip (ctx , zipfile , bundlename , storage .ConnectToBucket , getReadWriter , fs , st .NewClient ); err != nil {
539
541
errMessage := fmt .Sprintf ("Error while uploading zip file %s to bucket %s" , destFilePathPrefix + ".zip" , s .ResultBucket )
540
542
s .oteLogger .LogMessageToConsole (fmt .Sprintf (errMessage , " Error: " , err ))
541
543
failureMsgs = append (failureMsgs , errMessage )
544
+ s .oteLogger .LogUsageError (usagemetrics .SupportBundleUploadFailure )
542
545
} else {
543
546
msg := fmt .Sprintf ("Bundle uploaded to bucket %s, path: %s" , s .ResultBucket , fmt .Sprintf ("gs://%s/%s/%s.zip" , s .ResultBucket , s .Name (), bundlename ))
544
547
successMsgs = append (successMsgs , msg )
@@ -549,6 +552,8 @@ func (s *SupportBundle) supportBundleHandler(ctx context.Context, destFilePathPr
549
552
failureMsgs = append (failureMsgs , errMessage )
550
553
}
551
554
}
555
+ } else {
556
+ s .oteLogger .LogUsageAction (usagemetrics .SupportBundleLocalCollection )
552
557
}
553
558
554
559
// Rotate out old support bundles so we don't fill the file system.
@@ -1437,7 +1442,7 @@ func (s *SupportBundle) getMetricsClients(ctx context.Context) error {
1437
1442
1438
1443
qc , err := s .createQueryClient (ctx )
1439
1444
if err != nil {
1440
- usagemetrics . Error (usagemetrics .QueryClientCreateFailure )
1445
+ s . oteLogger . LogUsageError (usagemetrics .QueryClientCreateFailure )
1441
1446
return err
1442
1447
}
1443
1448
cmr := & cloudmetricreader.CloudMetricReader {
@@ -1447,7 +1452,7 @@ func (s *SupportBundle) getMetricsClients(ctx context.Context) error {
1447
1452
1448
1453
mmc , err := s .createMetricClient (ctx )
1449
1454
if err != nil {
1450
- usagemetrics . Error (usagemetrics .MetricClientCreateFailure )
1455
+ s . oteLogger . LogUsageError (usagemetrics .MetricClientCreateFailure )
1451
1456
return err
1452
1457
}
1453
1458
@@ -1578,21 +1583,21 @@ func (s *SupportBundle) fetchLabelDescriptors(ctx context.Context, cp *ipb.Cloud
1578
1583
}
1579
1584
1580
1585
// newQueryClient abstracts the creation of a new Cloud Monitoring query client for testing purposes.
1581
- func newQueryClient (ctx context.Context ) (cloudmonitoring.TimeSeriesQuerier , error ) {
1586
+ func ( s * SupportBundle ) newQueryClient (ctx context.Context ) (cloudmonitoring.TimeSeriesQuerier , error ) {
1582
1587
mqc , err := monitoring .NewQueryClient (ctx )
1583
1588
if err != nil {
1584
- usagemetrics . Error (usagemetrics .QueryClientCreateFailure )
1589
+ s . oteLogger . LogUsageError (usagemetrics .QueryClientCreateFailure )
1585
1590
return nil , fmt .Errorf ("failed to create Cloud Monitoring query client: %v" , err )
1586
1591
}
1587
1592
1588
1593
return & cloudmetricreader.QueryClient {Client : mqc }, nil
1589
1594
}
1590
1595
1591
1596
// newMetricClient abstracts the creation of a new Cloud Monitoring metric client for testing purposes.
1592
- func newMetricClient (ctx context.Context ) (cloudmonitoring.TimeSeriesDescriptorQuerier , error ) {
1597
+ func ( s * SupportBundle ) newMetricClient (ctx context.Context ) (cloudmonitoring.TimeSeriesDescriptorQuerier , error ) {
1593
1598
mmc , err := monitoring .NewMetricClient (ctx )
1594
1599
if err != nil {
1595
- usagemetrics . Error (usagemetrics .MetricClientCreateFailure )
1600
+ s . oteLogger . LogUsageError (usagemetrics .MetricClientCreateFailure )
1596
1601
return nil , fmt .Errorf ("failed to create Cloud Monitoring metric client: %v" , err )
1597
1602
}
1598
1603
@@ -1627,8 +1632,8 @@ func (s *SupportBundle) validateParams() []string {
1627
1632
s .rest = & rest.Rest {}
1628
1633
s .rest .NewRest ()
1629
1634
1630
- s .createQueryClient = newQueryClient
1631
- s .createMetricClient = newMetricClient
1635
+ s .createQueryClient = s . newQueryClient
1636
+ s .createMetricClient = s . newMetricClient
1632
1637
1633
1638
return errs
1634
1639
}
0 commit comments