本文整理汇总了Golang中org/apache/htrace/client.Client.GetServerStats方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.GetServerStats方法的具体用法?Golang Client.GetServerStats怎么用?Golang Client.GetServerStats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org/apache/htrace/client.Client
的用法示例。
在下文中一共展示了Client.GetServerStats方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testIngestedSpansMetricsImpl
func testIngestedSpansMetricsImpl(t *testing.T, usePacked bool) {
htraceBld := &MiniHTracedBuilder{Name: "TestIngestedSpansMetrics",
DataDirs: make([]string, 2),
}
ht, err := htraceBld.Build()
if err != nil {
t.Fatalf("failed to create datastore: %s", err.Error())
}
defer ht.Close()
var hcl *htrace.Client
hcl, err = htrace.NewClient(ht.ClientConf(), &htrace.TestHooks{
HrpcDisabled: !usePacked,
})
if err != nil {
t.Fatalf("failed to create client: %s", err.Error())
}
NUM_TEST_SPANS := 12
allSpans := createRandomTestSpans(NUM_TEST_SPANS)
err = hcl.WriteSpans(allSpans)
if err != nil {
t.Fatalf("WriteSpans failed: %s\n", err.Error())
}
for {
var stats *common.ServerStats
stats, err = hcl.GetServerStats()
if err != nil {
t.Fatalf("GetServerStats failed: %s\n", err.Error())
}
if stats.IngestedSpans == uint64(NUM_TEST_SPANS) {
break
}
time.Sleep(1 * time.Millisecond)
}
}
示例2: printServerStatsJson
// Print information retrieved from an htraced server via /server/info as JSON
func printServerStatsJson(hcl *htrace.Client) int {
stats, err := hcl.GetServerStats()
if err != nil {
fmt.Println(err.Error())
return EXIT_FAILURE
}
buf, err := json.MarshalIndent(stats, "", " ")
if err != nil {
fmt.Printf("Error marshalling server stats: %s", err.Error())
return EXIT_FAILURE
}
fmt.Printf("%s\n", string(buf))
return EXIT_SUCCESS
}
示例3: printServerStats
// Print information retrieved from an htraced server via /server/info
func printServerStats(hcl *htrace.Client) int {
stats, err := hcl.GetServerStats()
if err != nil {
fmt.Println(err.Error())
return EXIT_FAILURE
}
w := new(tabwriter.Writer)
w.Init(os.Stdout, 0, 8, 0, '\t', 0)
fmt.Fprintf(w, "HTRACED SERVER STATS\n")
fmt.Fprintf(w, "Datastore Start\t%s\n",
common.UnixMsToTime(stats.LastStartMs).Format(time.RFC3339))
fmt.Fprintf(w, "Server Time\t%s\n",
common.UnixMsToTime(stats.CurMs).Format(time.RFC3339))
fmt.Fprintf(w, "Spans reaped\t%d\n", stats.ReapedSpans)
fmt.Fprintf(w, "Spans ingested\t%d\n", stats.IngestedSpans)
fmt.Fprintf(w, "Spans written\t%d\n", stats.WrittenSpans)
fmt.Fprintf(w, "Spans dropped by server\t%d\n", stats.ServerDroppedSpans)
dur := time.Millisecond * time.Duration(stats.AverageWriteSpansLatencyMs)
fmt.Fprintf(w, "Average WriteSpan Latency\t%s\n", dur.String())
dur = time.Millisecond * time.Duration(stats.MaxWriteSpansLatencyMs)
fmt.Fprintf(w, "Maximum WriteSpan Latency\t%s\n", dur.String())
fmt.Fprintf(w, "Number of leveldb directories\t%d\n", len(stats.Dirs))
w.Flush()
fmt.Println("")
for i := range stats.Dirs {
dir := stats.Dirs[i]
fmt.Printf("==== %s ===\n", dir.Path)
fmt.Printf("Approximate number of bytes: %d\n", dir.ApproximateBytes)
stats := strings.Replace(dir.LevelDbStats, "\\n", "\n", -1)
fmt.Printf("%s\n", stats)
}
w = new(tabwriter.Writer)
w.Init(os.Stdout, 0, 8, 0, '\t', 0)
fmt.Fprintf(w, "HOST SPAN METRICS\n")
mtxMap := stats.HostSpanMetrics
keys := make(sort.StringSlice, len(mtxMap))
i := 0
for k, _ := range mtxMap {
keys[i] = k
i++
}
sort.Sort(keys)
for k := range keys {
mtx := mtxMap[keys[k]]
fmt.Fprintf(w, "%s\twritten: %d\tserver dropped: %d\n",
keys[k], mtx.Written, mtx.ServerDropped)
}
w.Flush()
return EXIT_SUCCESS
}
示例4: printServerStats
// Print information retrieved from an htraced server via /server/info
func printServerStats(hcl *htrace.Client) int {
stats, err := hcl.GetServerStats()
if err != nil {
fmt.Println(err.Error())
return EXIT_FAILURE
}
fmt.Printf("HTraced server stats:\n")
fmt.Printf("%d leveldb shards.\n", len(stats.Shards))
for i := range stats.Shards {
shard := stats.Shards[i]
fmt.Printf("==== %s ===\n", shard.Path)
fmt.Printf("Approximate number of spans: %d\n", shard.ApproxNumSpans)
stats := strings.Replace(shard.LevelDbStats, "\\n", "\n", -1)
fmt.Printf("%s\n", stats)
}
return EXIT_SUCCESS
}