MCPcopy
hub / github.com/dgraph-io/dgraph / saveDebug

Function saveDebug

dgraph/cmd/debuginfo/debugging.go:52–80  ·  view source on GitHub ↗

saveDebug writes the debug info specified in the argument fetching it from the host provided in the configuration

(sourceURL, filePath string, duration time.Duration)

Source from the content-addressed store, hash-verified

50// saveDebug writes the debug info specified in the argument fetching it from the host
51// provided in the configuration
52func saveDebug(sourceURL, filePath string, duration time.Duration) error {
53 var err error
54 var resp io.ReadCloser
55
56 glog.Infof("fetching information over HTTP from %s", sourceURL)
57 if duration > 0 {
58 glog.Info(fmt.Sprintf("please wait... (%v)", duration))
59 }
60
61 timeout := duration + duration/2 + 2*time.Second
62 resp, err = fetchURL(sourceURL, timeout)
63 if err != nil {
64 return err
65 }
66 defer func() {
67 if err := resp.Close(); err != nil {
68 glog.Warningf("error closing resp reader: %v", err)
69 }
70 }()
71 out, err := os.Create(filePath)
72 if err != nil {
73 return fmt.Errorf("error while creating debug file: %s", err)
74 }
75 defer func() {
76 out.Close()
77 }()
78 _, err = io.Copy(out, resp)
79 return err
80}
81
82// fetchURL fetches a profile from a URL using HTTP.
83func fetchURL(source string, timeout time.Duration) (io.ReadCloser, error) {

Callers 1

saveMetricsFunction · 0.85

Calls 7

fetchURLFunction · 0.85
InfofMethod · 0.80
InfoMethod · 0.80
WarningfMethod · 0.80
CloseMethod · 0.65
CreateMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected