Пример #1
0
func ServeMetrics(steno *gosteno.Logger, l logger.Logger, conf *config.Config) {
	store := connectToStore(l, conf)
	messageBus := connectToMessageBus(l, conf)

	acquireLock(l, conf, "metrics-server")

	collectorRegistrar := collectorregistrar.NewCollectorRegistrar(messageBus, steno)

	metricsServer := metricsserver.New(
		collectorRegistrar,
		steno,
		metricsaccountant.New(store),
		l,
		store,
		buildTimeProvider(l),
		conf,
	)

	err := metricsServer.Start()
	if err != nil {
		l.Error("Failed to serve metrics", err)
	}
	l.Info("Serving Metrics")
	select {}
}
Пример #2
0
func send(l logger.Logger, conf *config.Config, messageBus yagnats.NATSClient, store store.Store) error {
	l.Info("Sending...")

	sender := sender.New(store, metricsaccountant.New(store), conf, messageBus, buildTimeProvider(l), l)
	err := sender.Send()

	if err != nil {
		l.Error("Sender failed with error", err)
		return err
	} else {
		l.Info("Sender completed succesfully")
		return nil
	}
}
func StartListeningForActual(l logger.Logger, conf *config.Config) {
	messageBus := connectToMessageBus(l, conf)
	store, usageTracker := connectToStoreAndTrack(l, conf)

	acquireLock(l, conf, "listener")

	listener := actualstatelistener.New(conf,
		messageBus,
		store,
		usageTracker,
		metricsaccountant.New(store),
		buildClock(l),
		l,
	)

	listener.Start()
	l.Info("Listening for Actual State")
	select {}
}
func fetchDesiredState(l logger.Logger, conf *config.Config, store store.Store) error {
	l.Info("Fetching Desired State")
	fetcher := desiredstatefetcher.New(conf,
		store,
		metricsaccountant.New(store),
		httpclient.NewHttpClient(conf.SkipSSLVerification, conf.FetcherNetworkTimeout()),
		buildTimeProvider(l),
		l,
	)

	resultChan := make(chan desiredstatefetcher.DesiredStateFetcherResult, 1)
	fetcher.Fetch(resultChan)

	result := <-resultChan

	if result.Success {
		l.Info("Success", map[string]string{"Number of Desired Apps Fetched": strconv.Itoa(result.NumResults)})
		return nil
	} else {
		l.Error(result.Message, result.Error)
		return result.Error
	}
	return nil
}