Exemple #1
0
func initialize() {
	sender := metric_sender.NewMetricSender(AutowiredEmitter())
	batcher := metricbatcher.New(sender, defaultBatchInterval)
	metrics.Initialize(sender, batcher)
	logs.Initialize(log_sender.NewLogSender(AutowiredEmitter(), statsInterval, gosteno.NewLogger("dropsonde/logs")))
	go runtime_stats.NewRuntimeStats(autowiredEmitter, statsInterval).Run(nil)
	http.DefaultTransport = InstrumentedRoundTripper(http.DefaultTransport)
}
func TestDeaagent(t *testing.T) {
	RegisterFailHandler(Fail)

	BeforeSuite(func() {
		fakeLogSender = fake.NewFakeLogSender()
		logs.Initialize(fakeLogSender)
	})

	RunSpecs(t, "Deaagent Suite")
}
Exemple #3
0
func initializeMetrics(origin, destination string) (*metricbatcher.MetricBatcher, error) {
	err := setupDefaultEmitter(origin, destination)
	if err != nil {
		// Legacy holdover.  We would prefer to panic, rather than just throwing our metrics
		// away and pretending we're running fine, but for now, we just don't want to break
		// anything.
		dropsonde.DefaultEmitter = &dropsonde.NullEventEmitter{}
	}

	// Copied from dropsonde.initialize(), since we stopped using dropsonde.Initialize
	// but needed it to continue operating the same.
	sender := metric_sender.NewMetricSender(dropsonde.DefaultEmitter)
	batcher := metricbatcher.New(sender, defaultBatchInterval)
	metrics.Initialize(sender, batcher)
	logs.Initialize(log_sender.NewLogSender(dropsonde.DefaultEmitter, gosteno.NewLogger("dropsonde/logs")))
	envelopes.Initialize(envelope_sender.NewEnvelopeSender(dropsonde.DefaultEmitter))
	go runtime_stats.NewRuntimeStats(dropsonde.DefaultEmitter, statsInterval).Run(nil)
	http.DefaultTransport = dropsonde.InstrumentedRoundTripper(http.DefaultTransport)
	return batcher, err
}
var _ = Describe("AccessLog", func() {

	var (
		logger lager.Logger
	)
	Context("with a dropsonde source instance", func() {

		BeforeEach(func() {
			logger = lagertest.NewTestLogger("test")

		})
		It("logs to dropsonde", func() {

			fakeLogSender := fake.NewFakeLogSender()
			logs.Initialize(fakeLogSender)
			accessLogger := NewFileAndLoggregatorAccessLogger(logger, "42")
			go accessLogger.Run()

			accessLogger.Log(*CreateAccessLogRecord())

			Eventually(fakeLogSender.GetLogs).Should(HaveLen(1))
			Expect(fakeLogSender.GetLogs()[0].AppId).To(Equal("my_awesome_id"))
			Expect(fakeLogSender.GetLogs()[0].Message).To(MatchRegexp("^.*foo.bar.*\n"))
			Expect(fakeLogSender.GetLogs()[0].SourceType).To(Equal("RTR"))
			Expect(fakeLogSender.GetLogs()[0].SourceInstance).To(Equal("42"))
			Expect(fakeLogSender.GetLogs()[0].MessageType).To(Equal("OUT"))

			accessLogger.Stop()
		})