wp
This commit is contained in:
@@ -101,51 +101,54 @@ func sendRequests(conn *client.Connection) {
|
||||
err error
|
||||
)
|
||||
|
||||
_ = cumulativeMetricID
|
||||
_ = fracDigits
|
||||
|
||||
//conn.DeleteMetric(instantMetricID)
|
||||
//conn.DeleteMetric(cumulativeMetricID)
|
||||
|
||||
// ADD INSTANT METRIC
|
||||
|
||||
err = conn.AddMetric(proto.AddMetricReq{
|
||||
MetricID: cumulativeMetricID,
|
||||
MetricType: qb.Instant,
|
||||
FracDigits: fracDigits,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("conn.AddMetric: %s\n", err)
|
||||
} else {
|
||||
fmt.Printf("\nInstant metric %d added\n", cumulativeMetricID)
|
||||
}
|
||||
// err = conn.AddMetric(proto.AddMetricReq{
|
||||
// MetricID: cumulativeMetricID,
|
||||
// MetricType: qb.Instant,
|
||||
// FracDigits: fracDigits,
|
||||
// })
|
||||
// if err != nil {
|
||||
// log.Fatalf("conn.AddMetric: %s\n", err)
|
||||
// } else {
|
||||
// fmt.Printf("\nInstant metric %d added\n", cumulativeMetricID)
|
||||
// }
|
||||
|
||||
// GET INSTANT METRIC
|
||||
|
||||
// iMetric, err := conn.GetMetric(cumulativeMetricID)
|
||||
// if err != nil {
|
||||
// log.Fatalf("conn.GetMetric: %s\n", err)
|
||||
// } else {
|
||||
// fmt.Printf(`
|
||||
// iMetric, err := conn.GetMetric(cumulativeMetricID)
|
||||
// if err != nil {
|
||||
// log.Fatalf("conn.GetMetric: %s\n", err)
|
||||
// } else {
|
||||
// fmt.Printf(`
|
||||
// GetMetric:
|
||||
// metricID: %d
|
||||
// metricType: %s
|
||||
// fracDigits: %d
|
||||
// `,
|
||||
// iMetric.MetricID, metricTypeToName[iMetric.MetricType], fracDigits)
|
||||
//}
|
||||
// iMetric.MetricID, metricTypeToName[iMetric.MetricType], fracDigits)
|
||||
// }
|
||||
|
||||
// APPEND MEASURES
|
||||
|
||||
// instantMeasures := GenerateInstantMeasures(62, 220)
|
||||
// instantMeasures := GenerateInstantMeasures(62, 220)
|
||||
|
||||
// err = conn.AppendMeasures(proto.AppendMeasuresReq{
|
||||
// MetricID: instantMetricID,
|
||||
// Measures: instantMeasures,
|
||||
// })
|
||||
// if err != nil {
|
||||
// log.Fatalf("conn.AppendMeasures: %s\n", err)
|
||||
// } else {
|
||||
// fmt.Printf("\nAppended %d measures for the metric %d\n",
|
||||
// len(instantMeasures), instantMetricID)
|
||||
// }
|
||||
// err = conn.AppendMeasures(proto.AppendMeasuresReq{
|
||||
// MetricID: instantMetricID,
|
||||
// Measures: instantMeasures,
|
||||
// })
|
||||
// if err != nil {
|
||||
// log.Fatalf("conn.AppendMeasures: %s\n", err)
|
||||
// } else {
|
||||
// fmt.Printf("\nAppended %d measures for the metric %d\n",
|
||||
// len(instantMeasures), instantMetricID)
|
||||
// }
|
||||
|
||||
// // LIST INSTANT MEASURES
|
||||
|
||||
@@ -287,50 +290,62 @@ func sendRequests(conn *client.Connection) {
|
||||
// fmt.Printf("\nInstant metric %d deleted\n", instantMetricID)
|
||||
// }
|
||||
|
||||
// // ADD CUMULATIVE METRIC
|
||||
// ADD CUMULATIVE METRIC
|
||||
|
||||
// err = conn.AddMetric(proto.AddMetricReq{
|
||||
// MetricID: cumulativeMetricID,
|
||||
// MetricType: qb.Cumulative,
|
||||
// FracDigits: fracDigits,
|
||||
// })
|
||||
// if err != nil {
|
||||
// log.Fatalf("conn.AddMetric: %s\n", err)
|
||||
// } else {
|
||||
// fmt.Printf("\nCumulative metric %d added\n", cumulativeMetricID)
|
||||
err = conn.AddMetric(proto.AddMetricReq{
|
||||
MetricID: cumulativeMetricID,
|
||||
MetricType: qb.Cumulative,
|
||||
FracDigits: fracDigits,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("conn.AddMetric: %s\n", err)
|
||||
} else {
|
||||
fmt.Printf("\nCumulative metric %d added\n", cumulativeMetricID)
|
||||
}
|
||||
|
||||
// GET CUMULATIVE METRIC
|
||||
|
||||
cMetric, err := conn.GetMetric(cumulativeMetricID)
|
||||
if err != nil {
|
||||
log.Fatalf("conn.GetMetric: %s\n", err)
|
||||
} else {
|
||||
fmt.Printf(`
|
||||
GetMetric:
|
||||
metricID: %d
|
||||
metricType: %s
|
||||
fracDigits: %d
|
||||
`,
|
||||
cMetric.MetricID, metricTypeToName[cMetric.MetricType], cMetric.FracDigits)
|
||||
}
|
||||
|
||||
// APPEND MEASURES
|
||||
|
||||
cumulativeMeasures := GenerateCumulativeMeasures(62)
|
||||
|
||||
result, err := conn.AppendMeasures(proto.AppendMeasuresReq{
|
||||
MetricID: cumulativeMetricID,
|
||||
Measures: cumulativeMeasures[:1],
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("conn.AppendMeasures: %s\n", err)
|
||||
} else {
|
||||
fmt.Printf("\nAppended %d measures for the metric %d: count=%d, errorCode=%d\n",
|
||||
len(cumulativeMeasures), cumulativeMetricID, result.WrittenCount, result.ErrorCode)
|
||||
}
|
||||
|
||||
// currentValues, err := conn.ListCurrentValues([]uint32{
|
||||
// cumulativeMetricID,
|
||||
// })
|
||||
// if err != nil {
|
||||
// log.Fatalf("conn.ListCurrentValues: %s\n", err)
|
||||
// } else {
|
||||
// for _, v := range currentValues {
|
||||
// fmt.Println(v.MetricID, v.Timestamp, v.Value)
|
||||
// }
|
||||
// }
|
||||
|
||||
// // GET CUMULATIVE METRIC
|
||||
|
||||
// cMetric, err := conn.GetMetric(cumulativeMetricID)
|
||||
// if err != nil {
|
||||
// log.Fatalf("conn.GetMetric: %s\n", err)
|
||||
// } else {
|
||||
// fmt.Printf(`
|
||||
// GetMetric:
|
||||
// metricID: %d
|
||||
// metricType: %s
|
||||
// fracDigits: %d
|
||||
// `,
|
||||
// cMetric.MetricID, metricTypeToName[cMetric.MetricType], fracDigits)
|
||||
// }
|
||||
|
||||
// // APPEND MEASURES
|
||||
|
||||
// cumulativeMeasures := GenerateCumulativeMeasures(62)
|
||||
|
||||
// err = conn.AppendMeasures(proto.AppendMeasuresReq{
|
||||
// MetricID: cumulativeMetricID,
|
||||
// Measures: cumulativeMeasures,
|
||||
// })
|
||||
// if err != nil {
|
||||
// log.Fatalf("conn.AppendMeasures: %s\n", err)
|
||||
// } else {
|
||||
// fmt.Printf("\nAppended %d measures for the metric %d\n",
|
||||
// len(cumulativeMeasures), cumulativeMetricID)
|
||||
// }
|
||||
|
||||
// // LIST CUMULATIVE MEASURES
|
||||
// LIST CUMULATIVE MEASURES
|
||||
var cumulativeList []proto.CumulativeMeasure
|
||||
|
||||
// lastTimestamp = cumulativeMeasures[len(cumulativeMeasures)-1].Timestamp
|
||||
// until = time.Unix(int64(lastTimestamp), 0)
|
||||
@@ -352,17 +367,18 @@ func sendRequests(conn *client.Connection) {
|
||||
// }
|
||||
// }
|
||||
|
||||
// // LIST ALL CUMULATIVE MEASURES
|
||||
// LIST ALL CUMULATIVE MEASURES
|
||||
|
||||
// cumulativeList, err = conn.ListAllCumulativeMeasures(cumulativeMetricID)
|
||||
// if err != nil {
|
||||
// log.Fatalf("conn.ListAllCumulativeMeasures: %s\n", err)
|
||||
// } else {
|
||||
// fmt.Printf("\nListAllCumulativeMeasures (last 15 items):\n")
|
||||
// for _, item := range cumulativeList[:15] {
|
||||
// fmt.Printf(" %s => %.2f\n", formatTime(item.Timestamp), item.Value)
|
||||
// }
|
||||
// }
|
||||
cumulativeList, err = conn.ListAllCumulativeMeasures(cumulativeMetricID)
|
||||
if err != nil {
|
||||
log.Fatalf("conn.ListAllCumulativeMeasures: %s\n", err)
|
||||
} else {
|
||||
fmt.Printf("\nListAllCumulativeMeasures (last 15 items):\n")
|
||||
fmt.Printf("%#v\n", cumulativeList)
|
||||
for _, item := range cumulativeList {
|
||||
fmt.Printf(" %s => %.2f\n", formatTime(item.Timestamp), item.Value)
|
||||
}
|
||||
}
|
||||
|
||||
// // LIST CUMULATIVE PERIODS (group by hour)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user