(ctx context.Context, c ppb.ProfilingClient, f string)
| 42 | } |
| 43 | |
| 44 | func retrieveSnapshot(ctx context.Context, c ppb.ProfilingClient, f string) error { |
| 45 | logger.Infof("getting stream stats") |
| 46 | resp, err := c.GetStreamStats(ctx, &ppb.GetStreamStatsRequest{}) |
| 47 | if err != nil { |
| 48 | logger.Errorf("error calling GetStreamStats: %v\n", err) |
| 49 | return err |
| 50 | } |
| 51 | s := &snapshot{StreamStats: resp.StreamStats} |
| 52 | |
| 53 | logger.Infof("creating snapshot file %s", f) |
| 54 | file, err := os.Create(f) |
| 55 | if err != nil { |
| 56 | logger.Errorf("cannot create %s: %v", f, err) |
| 57 | return err |
| 58 | } |
| 59 | defer file.Close() |
| 60 | |
| 61 | logger.Infof("encoding data and writing to snapshot file %s", f) |
| 62 | encoder := gob.NewEncoder(file) |
| 63 | err = encoder.Encode(s) |
| 64 | if err != nil { |
| 65 | logger.Infof("error encoding: %v", err) |
| 66 | return err |
| 67 | } |
| 68 | |
| 69 | logger.Infof("successfully wrote profiling snapshot to %s", f) |
| 70 | return nil |
| 71 | } |
| 72 | |
| 73 | func remoteCommand() error { |
| 74 | ctx := context.Background() |
no test coverage detected