MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / saveMetrics

Function saveMetrics

dgraph/cmd/debuginfo/debugging.go:20–48  ·  view source on GitHub ↗
(addr, pathPrefix string, seconds uint32, metricTypes []string)

Source from the content-addressed store, hash-verified

18)
19
20func saveMetrics(addr, pathPrefix string, seconds uint32, metricTypes []string) {
21 u, err := url.Parse(addr)
22 if err != nil || (u.Host == "" && u.Scheme != "" && u.Scheme != "file") {
23 u, err = url.Parse("http://" + addr)
24 }
25 if err != nil || u.Host == "" {
26 glog.Errorf("error while parsing address %s: %s", addr, err)
27 return
28 }
29
30 duration := time.Duration(seconds) * time.Second
31
32 for _, metricType := range metricTypes {
33 source := u.String() + metricMap[metricType]
34 switch metricType {
35 case "cpu":
36 source += fmt.Sprintf("%s%d", "?seconds=", seconds)
37 case "trace":
38 source += fmt.Sprintf("%s%d", "?seconds=", seconds)
39 }
40 savePath := fmt.Sprintf("%s%s.gz", pathPrefix, metricType)
41 if err := saveDebug(source, savePath, duration); err != nil {
42 glog.Errorf("error while saving metric from %s: %s", source, err)
43 continue
44 }
45
46 glog.Infof("saving %s metric in %s", metricType, savePath)
47 }
48}
49
50// saveDebug writes the debug info specified in the argument fetching it from the host
51// provided in the configuration

Callers 1

collectDebugFunction · 0.85

Calls 5

saveDebugFunction · 0.85
InfofMethod · 0.80
ParseMethod · 0.65
ErrorfMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected