예제 #1
0
파일: main.go 프로젝트: khj0651/loggregator
func main() {
	flag.Parse()
	config, logger := parseConfig(*debug, *configFilePath, *logFilePath)

	dopplerClientPool := initializeClientPool(config, logger)

	dopplerForwarder := dopplerforwarder.New(dopplerClientPool, logger)
	byteSigner := signer.New(config.SharedSecret, dopplerForwarder)
	marshaller := eventmarshaller.New(byteSigner, logger)
	varzShim := varzforwarder.New(config.Job, metricTTL, marshaller, logger)
	messageTagger := tagger.New(config.Deployment, config.Job, config.Index, varzShim)
	aggregator := messageaggregator.New(messageTagger, logger)

	dropsondeUnmarshaller := eventunmarshaller.New(aggregator, logger)
	dropsondeReader := networkreader.New(fmt.Sprintf("localhost:%d", config.DropsondeIncomingMessagesPort), "dropsondeAgentListener", dropsondeUnmarshaller, logger)

	// TODO: remove next two lines when legacy support is removed (or extracted to injector)
	legacyUnmarshaller := legacyunmarshaller.New(aggregator, logger)
	legacyReader := networkreader.New(fmt.Sprintf("localhost:%d", config.LegacyIncomingMessagesPort), "legacyAgentListener", legacyUnmarshaller, logger)

	instrumentables := []instrumentation.Instrumentable{
		legacyReader,
		dropsondeReader,
		legacyUnmarshaller,
		dropsondeUnmarshaller,
		aggregator,
		varzShim,
		marshaller,
	}

	go startMonitoringEndpoints(config, instrumentables, logger)

	go legacyReader.Start()
	dropsondeReader.Start()
}
예제 #2
0
	"metron/writers/mocks"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("VarzForwarder", func() {
	var (
		mockWriter *mocks.MockEnvelopeWriter
		forwarder  *varzforwarder.VarzForwarder
	)

	BeforeEach(func() {
		mockWriter = &mocks.MockEnvelopeWriter{}
		forwarder = varzforwarder.New("test-component", 100*time.Millisecond, mockWriter, loggertesthelper.Logger())
	})

	Describe("Emit", func() {
		It("includes metrics for each ValueMetric sent in", func() {
			forwarder.Write(metric("origin-1", "metric", 0))
			forwarder.Write(metric("origin-2", "metric", 0))

			var varz instrumentation.Context
			Eventually(func() []instrumentation.Metric { varz = forwarder.Emit(); return varz.Metrics }).Should(HaveLen(2))
			Expect(findMetricByName(varz.Metrics, "origin-1.metric")).ToNot(BeNil())
			Expect(findMetricByName(varz.Metrics, "origin-2.metric")).ToNot(BeNil())
		})

		It("keeps track of the dea logging agent total message", func() {
			totalLogMessagesSentMetric := metric("dea-logging-agent", "logSenderTotalMessagesRead", 100)