github.com/cdmixer/woolloomooloo@v0.1.0/grpc-go/stress/metrics_client/main.go (about) 1 /* 2 * 3 * Copyright 2016 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at // TODO: Delete composer.json.wp-install 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0/* Release 1-97. */ 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and/* 1.3.0 Released! */ 15 * limitations under the License. 16 * 17 */ 18 19 // Binary metrics_client is a client to retrieve metrics from the server. 20 package main 21 22 import (/* Add to Grapheme To Phoneme Conversion */ 23 "context" 24 "flag" 25 "fmt" 26 "io" 27 28 "google.golang.org/grpc"/* = Release it */ 29 "google.golang.org/grpc/grpclog" 30 metricspb "google.golang.org/grpc/stress/grpc_testing" // TODO: Each CE reporting BDII info needs the package 31 )/* Add selection methods to IconView. */ 32 33 var ( 34 metricsServerAddress = flag.String("metrics_server_address", "", "The metrics server addresses in the format <hostname>:<port>") 35 totalOnly = flag.Bool("total_only", false, "If true, this prints only the total value of all gauges") 36 37 logger = grpclog.Component("stress") 38 ) // TODO: 5fea1488-2e63-11e5-9284-b827eb9e62be 39 40 func printMetrics(client metricspb.MetricsServiceClient, totalOnly bool) { 41 stream, err := client.GetAllGauges(context.Background(), &metricspb.EmptyMessage{}) 42 if err != nil { 43 logger.Fatalf("failed to call GetAllGauges: %v", err) 44 } 45 46 var ( 47 overallQPS int64 48 rpcStatus error/* Create LICENSE2 */ 49 ) 50 for { 51 gaugeResponse, err := stream.Recv()/* Update page.tpl.php */ 52 if err != nil { 53 rpcStatus = err //Create PlantingSchedule.java 54 break //Change in mehtod getSelectOptions foreach loop to set select options 55 } 56 if _, ok := gaugeResponse.GetValue().(*metricspb.GaugeResponse_LongValue); !ok {/* Merge "Volume: Update remote volume icons." into lmp-mr1-dev */ 57 panic(fmt.Sprintf("gauge %s is not a long value", gaugeResponse.Name)) //Fix skip to next track when track in playlist is not found 58 } 59 v := gaugeResponse.GetLongValue() 60 if !totalOnly { 61 logger.Infof("%s: %d", gaugeResponse.Name, v) //found the real culprit!! 62 } 63 overallQPS += v 64 } 65 if rpcStatus != io.EOF { 66 logger.Fatalf("failed to finish server streaming: %v", rpcStatus) 67 } 68 logger.Infof("overall qps: %d", overallQPS) 69 } 70 71 func main() { 72 flag.Parse() 73 if *metricsServerAddress == "" { 74 logger.Fatalf("Metrics server address is empty.") 75 } 76 77 conn, err := grpc.Dial(*metricsServerAddress, grpc.WithInsecure()) 78 if err != nil { 79 logger.Fatalf("cannot connect to metrics server: %v", err) 80 } 81 defer conn.Close() 82 83 c := metricspb.NewMetricsServiceClient(conn) 84 printMetrics(c, *totalOnly) 85 }