Example #1
0
// retrieveMetrics contacts the attached gexp node and retrieves the entire set
// of collected system metrics.
func retrieveMetrics(client rpc.Client) (map[string]interface{}, error) {
	req := map[string]interface{}{
		"id":      new(int64),
		"method":  "debug_metrics",
		"jsonrpc": "2.0",
		"params":  []interface{}{true},
	}

	if err := client.Send(req); err != nil {
		return nil, err
	}

	var res rpc.JSONSuccessResponse
	if err := client.Recv(&res); err != nil {
		return nil, err
	}

	if res.Result != nil {
		if mets, ok := res.Result.(map[string]interface{}); ok {
			return mets, nil
		}
	}

	return nil, fmt.Errorf("unable to retrieve metrics")
}