func (m metricConf) printVarDefToGen(name string, gen *generator) {
	gen.Printf("		\"%s\": {\n", name)
	if m.Help != "" {
		gen.Printf("			Help: \"%s\",\n", m.Help)
	}
	if len(m.Labels) != 0 {
		ls := make([]string, len(m.Labels))
		for i, l := range m.Labels {
			ls[i] = fmt.Sprintf("\"%s\"", l)
		}
		gen.Printf("			Labels: []string{%s},\n", strings.Join(ls, ","))
	}
	if len(m.Buckets) != 0 {
		bs := make([]string, len(m.Buckets))
		for i, b := range m.Buckets {
			bs[i] = strconv.FormatFloat(b, 'f', -1, 64)
		}
		gen.Printf("			Buckets: []float64{%s},\n", strings.Join(bs, ","))
	}
	gen.Printf("		},\n")
}
printVarDefToGen prints a {metricType}Opt definition to the generator. These definitions
are used by clients to initialize metric backing stores.
package main
import (
	"bytes"
	"flag"
	"fmt"
	"go/format"
	"io/ioutil"
	"log"
	"os"
	"path/filepath"
	"regexp"
	"sort"
	"strconv"
	"strings"
	"gopkg.in/yaml.v2"
)
func convertToPascalCase(id string) string {
	result := strings.ToUpper(string(id[0]))
	makeNextUpper := false
	for i := range id[1:] {
		substr := id[i+1 : i+2]
		if substr == "_" {
			makeNextUpper = true
		} else {
			if makeNextUpper {
				substr = strings.ToUpper(substr)
				makeNextUpper = false
			}
			result += substr
		}
	}
	return result
}
func convertHelpToCommentFmt(help string) string {
	help = strings.TrimSpace(help)
	return strings.ToLower(help[0:1]) + help[1:len(help)-1]
}
var idRe = regexp.MustCompile(`[a-z][a-z_]*[a-z]`)
var helpRe = regexp.MustCompile(`[A-Z][a-zA-Z0-9 ]*\.`)
type confRoot map[string]metricConf
type metricConf struct {
	Type    string
	Help    string
	Buckets []float64  
	Labels  []string
}
func (m metricConf) validate(name string) {
	if !idRe.MatchString(name) {
		log.Fatalf("invalid metric name %s, must match id regex: %s", name, idRe.String())
	}
	switch m.Type {
	case "counter":
	case "gauge":
	case "histogram":
	default:
		log.Fatalf("unknown metric type %s on %s, must be one of {counter,gauge,histogram}", m.Type, name)
	}
	if !helpRe.MatchString(m.Help) {
		log.Fatalf("invalid help text for metric %s, %s", name, m.Help)
	}
	for _, l := range m.Labels {
		if !idRe.MatchString(l) {
			log.Fatalf("label %s on metric %s is incorrectly formatted", name, l)
		}
	}
	if m.Buckets != nil && m.Type != "histogram" {
		log.Fatalf("metric %s has type %s and buckets %v, but buckets are only allowed for histogram type",
			name, m.Type, m.Buckets)
	}
}