wp
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"time"
|
||||
|
||||
"gopkg.in/ini.v1"
|
||||
"gordenko.dev/dima/qb"
|
||||
"gordenko.dev/dima/qb/client"
|
||||
"gordenko.dev/dima/qb/proto"
|
||||
)
|
||||
@@ -292,46 +291,46 @@ func sendRequests(conn *client.Connection) {
|
||||
|
||||
// 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
|
||||
// // 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)
|
||||
}
|
||||
// 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
|
||||
// // APPEND MEASURES
|
||||
|
||||
cumulativeMeasures := GenerateCumulativeMeasures(62)
|
||||
// cumulativeMeasures := GenerateCumulativeMeasures(62)
|
||||
|
||||
result, err := conn.AppendMeasures(proto.AppendMeasuresReq{
|
||||
MetricID: cumulativeMetricID,
|
||||
Measures: cumulativeMeasures[:1000],
|
||||
})
|
||||
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)
|
||||
}
|
||||
// result, err := conn.AppendMeasures(proto.AppendMeasuresReq{
|
||||
// MetricID: cumulativeMetricID,
|
||||
// Measures: cumulativeMeasures[:1000],
|
||||
// })
|
||||
// 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,
|
||||
@@ -374,8 +373,8 @@ func sendRequests(conn *client.Connection) {
|
||||
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("%#v\n", cumulativeList)
|
||||
for _, item := range cumulativeList[:15] {
|
||||
fmt.Printf(" %s => %.2f\n", formatTime(item.Timestamp), item.Value)
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user