本文整理匯總了Golang中github.com/cloudfoundry/dropsonde/metric_sender.NewMetricSender函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewMetricSender函數的具體用法?Golang NewMetricSender怎麽用?Golang NewMetricSender使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewMetricSender函數的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: initializeMetrics
func initializeMetrics(batchIntervalMilliseconds uint) *metricbatcher.MetricBatcher {
eventEmitter := dropsonde.AutowiredEmitter()
metricSender := metric_sender.NewMetricSender(eventEmitter)
metricBatcher := metricbatcher.New(metricSender, time.Duration(batchIntervalMilliseconds)*time.Millisecond)
metrics.Initialize(metricSender, metricBatcher)
return metricBatcher
}
示例2: initialize
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)
}
示例3: initializeMetrics
func initializeMetrics(messageTagger *tagger.Tagger, config *config.Config, logger *gosteno.Logger) {
metricsAggregator := messageaggregator.New(messageTagger, logger)
eventWriter := eventwriter.New("MetronAgent", metricsAggregator)
metricSender := metric_sender.NewMetricSender(eventWriter)
metricBatcher := metricbatcher.New(metricSender, time.Duration(config.MetricBatchIntervalSeconds)*time.Second)
metrics.Initialize(metricSender, metricBatcher)
}
示例4: initializeMetrics
func initializeMetrics(byteSigner *signer.Signer, config *config.Config, logger *gosteno.Logger) {
metricsMarshaller := eventmarshaller.New(byteSigner, logger)
metricsTagger := tagger.New(config.Deployment, config.Job, config.Index, metricsMarshaller)
metricsAggregator := messageaggregator.New(metricsTagger, logger)
eventWriter := eventwriter.New("MetronAgent", metricsAggregator)
metricSender := metric_sender.NewMetricSender(eventWriter)
metricBatcher := metricbatcher.New(metricSender, time.Duration(config.MetricBatchIntervalSeconds)*time.Second)
metrics.Initialize(metricSender, metricBatcher)
}
示例5: initializeMetrics
func initializeMetrics(config *config.Config, stopChan chan struct{}, logger *gosteno.Logger) (*metricbatcher.MetricBatcher, *eventwriter.EventWriter) {
eventWriter := eventwriter.New(origin)
metricSender := metric_sender.NewMetricSender(eventWriter)
metricBatcher := metricbatcher.New(metricSender, time.Duration(config.MetricBatchIntervalMilliseconds)*time.Millisecond)
metrics.Initialize(metricSender, metricBatcher)
stats := runtime_stats.NewRuntimeStats(eventWriter, time.Duration(config.RuntimeStatsIntervalMilliseconds)*time.Millisecond)
go stats.Run(stopChan)
return metricBatcher, eventWriter
}
示例6: initializeMetrics
func initializeMetrics(messageTagger *tagger.Tagger, config *config.Config, stopChan chan struct{}, logger *gosteno.Logger) {
metricsAggregator := messageaggregator.New(messageTagger, logger)
eventWriter := eventwriter.New("MetronAgent", metricsAggregator)
metricSender := metric_sender.NewMetricSender(eventWriter)
metricBatcher := metricbatcher.New(metricSender, time.Duration(config.MetricBatchIntervalMilliseconds)*time.Millisecond)
metrics.Initialize(metricSender, metricBatcher)
stats := runtime_stats.NewRuntimeStats(eventWriter, time.Duration(config.RuntimeStatsIntervalMilliseconds)*time.Millisecond)
go stats.Run(stopChan)
}
示例7:
"os"
"sync"
)
// these tests need to be invoked individually from an external script,
// since environment variables need to be set/unset before starting the tests
var _ = Describe("Autowire End-to-End", func() {
Context("with DROPSONDE_ORIGIN set", func() {
var oldEnv string
BeforeEach(func() {
oldEnv = os.Getenv("DROPSONDE_ORIGIN")
os.Setenv("DROPSONDE_ORIGIN", "test-origin")
emitter, _ := autowire.CreateDefaultEmitter()
autowire.Initialize(emitter)
metrics.Initialize(metric_sender.NewMetricSender(autowire.AutowiredEmitter()))
})
AfterEach(func() {
os.Setenv("DROPSONDE_ORIGIN", oldEnv)
})
It("emits HTTP client/server events and heartbeats", func() {
udpListener, err := net.ListenPacket("udp4", ":3457")
Expect(err).ToNot(HaveOccurred())
defer udpListener.Close()
udpDataChan := make(chan []byte, 16)
receivedEvents := make(map[string]bool)
lock := sync.RWMutex{}
origin := os.Getenv("DROPSONDE_ORIGIN")
示例8:
"time"
)
var (
fakeEventEmitter *fake.FakeEventEmitter
uptimeMonitor monitor.Monitor
)
const (
interval = 100 * time.Millisecond
)
var _ = Describe("UptimeMonitor", func() {
BeforeEach(func() {
fakeEventEmitter = fake.NewFakeEventEmitter("MonitorTest")
sender := metric_sender.NewMetricSender(fakeEventEmitter)
batcher := metricbatcher.New(sender, 100*time.Millisecond)
metrics.Initialize(sender, batcher)
uptimeMonitor = monitor.NewUptimeMonitor(interval)
go uptimeMonitor.Start()
})
AfterEach(func() {
fakeEventEmitter.Close()
})
Context("stops automatically", func() {
AfterEach(func() {
示例9: init
func init() {
Initialize(metric_sender.NewMetricSender(autowire.AutowiredEmitter()))
}
示例10:
)
// these tests need to be invoked individually from an external script,
// since environment variables need to be set/unset before starting the tests
var _ = Describe("Autowire End-to-End", func() {
Context("with standard initialization", func() {
origin := []string{"test-origin"}
BeforeEach(func() {
var err error
udpListener, err = net.ListenPacket("udp4", ":3457")
Expect(err).ToNot(HaveOccurred())
go listenForEvents(origin)
dropsonde.Initialize("localhost:3457", origin...)
sender := metric_sender.NewMetricSender(dropsonde.AutowiredEmitter())
batcher := metricbatcher.New(sender, 100*time.Millisecond)
metrics.Initialize(sender, batcher)
})
AfterEach(func() {
udpListener.Close()
})
It("emits HTTP client/server events", func() {
httpListener, err := net.Listen("tcp", "localhost:0")
Expect(err).ToNot(HaveOccurred())
defer httpListener.Close()
httpHandler := dropsonde.InstrumentedHandler(FakeHandler{})
go http.Serve(httpListener, httpHandler)
示例11:
"github.com/cloudfoundry/dropsonde/events"
"github.com/cloudfoundry/dropsonde/metric_sender"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("MetricSender", func() {
var (
emitter *fake.FakeEventEmitter
sender metric_sender.MetricSender
)
BeforeEach(func() {
emitter = fake.NewFakeEventEmitter("origin")
sender = metric_sender.NewMetricSender(emitter)
})
It("sends a metric to its emitter", func() {
err := sender.SendValue("metric-name", 42, "answers")
Expect(err).NotTo(HaveOccurred())
Expect(emitter.GetMessages()).To(HaveLen(1))
metric := emitter.GetMessages()[0].Event.(*events.ValueMetric)
Expect(metric.GetName()).To(Equal("metric-name"))
Expect(metric.GetValue()).To(BeNumerically("==", 42))
Expect(metric.GetUnit()).To(Equal("answers"))
})
It("returns an error if it can't send metric value", func() {
emitter.ReturnError = errors.New("some error")