MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / GatherMetricBytes

Method GatherMetricBytes

metric/rpc.go:108–132  ·  view source on GitHub ↗

GatherMetricBytes gathers the registered metric info and encode it to [][]byte.

()

Source from the content-addressed store, hash-verified

106
107// GatherMetricBytes gathers the registered metric info and encode it to [][]byte.
108func (cc *CollectClient) GatherMetricBytes() (mfb [][]byte, err error) {
109 mfs, err := cc.Registry.Gather()
110 if err != nil {
111 log.Errorf("gather metrics failed: %s", err)
112 return
113 }
114 mfb = make([][]byte, 0, len(mfs))
115 for _, mf := range mfs[:] {
116 //log.Debugf("mf: %s", mf.String())
117 buf := new(bytes.Buffer)
118 //enc := expfmt.NewEncoder(buf, expfmt.FmtProtoCompact)
119 //err = enc.Encode(mf)
120 _, err := expfmt.MetricFamilyToText(buf, mf)
121 if err != nil {
122 log.Warnf("encode MetricFamily failed: %s", err)
123 continue
124 }
125 mfb = append(mfb, buf.Bytes())
126 }
127 if len(mfb) == 0 {
128 err = errors.New("no valid metric gathered")
129 }
130
131 return
132}
133
134// UploadMetrics calls RPC UploadMetrics to upload its metric info.
135func (cc *CollectClient) UploadMetrics(BPNodeID proto.NodeID) (err error) {

Callers 2

UploadMetricsMethod · 0.95

Calls 4

ErrorfFunction · 0.92
WarnfFunction · 0.92
NewMethod · 0.65
BytesMethod · 0.45

Tested by 1