Ejemplo n.º 1
0
func createPublishers() (publishers []canary.Publisher) {
	list := os.Getenv("PUBLISHERS")
	if list == "" {
		list = "stdout"
	}
	publisherList := strings.Split(list, ",")

	for _, publisher := range publisherList {
		switch publisher {
		case "stdout":
			publishers = append(publishers, stdoutpublisher.New())
		case "librato":
			p, err := libratopublisher.NewFromEnv()
			if err != nil {
				log.Fatal(err)
			}
			publishers = append(publishers, p)
		default:
			log.Fatalf("Unknown publisher: %s", publisher)
		}
	}

	return
}
Ejemplo n.º 2
0
func main() {
	conf, url, err := getConfig()
	if err != nil {
		log.Fatal(err)
	}

	c := canary.New([]canary.Publisher{stdoutpublisher.New()})
	manifest := manifest.Manifest{}

	manifest.StartDelays = []float64{0.0}
	manifest.Targets = []sampler.Target{
		sampler.Target{
			URL:      url,
			Interval: conf.DefaultSampleInterval,
		},
	}

	c.Config = conf
	c.Manifest = manifest

	// Start canary and block in the signal handler
	c.Run()
	c.SignalHandler()
}