本文整理汇总了Golang中github.com/cockroachdb/cockroach/ts.MakeDataKey函数的典型用法代码示例。如果您正苦于以下问题:Golang MakeDataKey函数的具体用法?Golang MakeDataKey怎么用?Golang MakeDataKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MakeDataKey函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestMetricsRecording
// TestMetricsRecording verifies that Node statistics are periodically recorded
// as time series data.
func TestMetricsRecording(t *testing.T) {
defer leaktest.AfterTest(t)
tsrv := &TestServer{}
tsrv.Ctx = NewTestContext()
tsrv.Ctx.MetricsFrequency = 5 * time.Millisecond
if err := tsrv.Start(); err != nil {
t.Fatal(err)
}
defer tsrv.Stop()
checkTimeSeriesKey := func(now int64, keyName string) error {
key := ts.MakeDataKey(keyName, "", ts.Resolution10s, now)
data := &proto.InternalTimeSeriesData{}
return tsrv.db.GetProto(key, data)
}
// Verify that metrics for the current timestamp are recorded. This should
// be true very quickly.
util.SucceedsWithin(t, time.Second, func() error {
now := tsrv.Clock().PhysicalNow()
if err := checkTimeSeriesKey(now, "cr.store.livebytes.1"); err != nil {
return err
}
if err := checkTimeSeriesKey(now, "cr.node.sys.allocbytes.1"); err != nil {
return err
}
return nil
})
}
示例2: TestMetricsRecording
// TestMetricsRecording verifies that Node statistics are periodically recorded
// as time series data.
func TestMetricsRecording(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _, kvDB := serverutils.StartServer(t, base.TestServerArgs{
MetricsSampleInterval: 5 * time.Millisecond})
defer s.Stopper().Stop()
checkTimeSeriesKey := func(now int64, keyName string) error {
key := ts.MakeDataKey(keyName, "", ts.Resolution10s, now)
data := roachpb.InternalTimeSeriesData{}
return kvDB.GetProto(key, &data)
}
// Verify that metrics for the current timestamp are recorded. This should
// be true very quickly.
util.SucceedsSoon(t, func() error {
now := s.Clock().PhysicalNow()
if err := checkTimeSeriesKey(now, "cr.store.livebytes.1"); err != nil {
return err
}
if err := checkTimeSeriesKey(now, "cr.node.sys.go.allocbytes.1"); err != nil {
return err
}
return nil
})
}