本文整理汇总了Golang中github.com/cloudfoundry/dropsonde/metrics.Initialize函数的典型用法代码示例。如果您正苦于以下问题:Golang Initialize函数的具体用法?Golang Initialize怎么用?Golang Initialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Initialize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:
fakeMetricSender *fake_metric_sender.FakeMetricSender
logger lager.Logger
fakeDiegoClient *fake_bbs.FakeClient
fakeCcClient *fakes.FakeCcClient
fakeBackend *fake_backend.FakeBackend
responseRecorder *httptest.ResponseRecorder
handler handlers.StagingHandler
)
BeforeEach(func() {
logger = lagertest.NewTestLogger("test")
fakeMetricSender = fake_metric_sender.NewFakeMetricSender()
metrics.Initialize(fakeMetricSender, nil)
fakeCcClient = &fakes.FakeCcClient{}
fakeBackend = &fake_backend.FakeBackend{}
fakeBackend.BuildRecipeReturns(&models.TaskDefinition{}, "", "", nil)
fakeDiegoClient = &fake_bbs.FakeClient{}
responseRecorder = httptest.NewRecorder()
handler = handlers.NewStagingHandler(logger, map[string]backend.Backend{"fake-backend": fakeBackend}, fakeCcClient, fakeDiegoClient)
})
Describe("Stage", func() {
var (
stagingRequestJson []byte
示例8:
. "github.com/onsi/gomega"
)
var _ = Describe("MetricsReporter", func() {
var metricsReporter *metrics.MetricsReporter
var req *http.Request
var endpoint *route.Endpoint
var sender *fake.FakeMetricSender
BeforeEach(func() {
metricsReporter = metrics.NewMetricsReporter()
req, _ = http.NewRequest("GET", "https://example.com", nil)
endpoint = route.NewEndpoint("someId", "host", 2222, "privateId", "2", map[string]string{}, 30, "", models.ModificationTag{})
sender = fake.NewFakeMetricSender()
batcher := metricbatcher.New(sender, time.Millisecond)
dropsondeMetrics.Initialize(sender, batcher)
})
It("increments the bad_requests metric", func() {
metricsReporter.CaptureBadRequest(req)
Eventually(func() uint64 { return sender.GetCounter("rejected_requests") }).Should(BeEquivalentTo(1))
metricsReporter.CaptureBadRequest(req)
Eventually(func() uint64 { return sender.GetCounter("rejected_requests") }).Should(BeEquivalentTo(2))
})
It("increments the bad_gateway metric", func() {
metricsReporter.CaptureBadGateway(req)
Eventually(func() uint64 { return sender.GetCounter("bad_gateways") }).Should(BeEquivalentTo(1))
metricsReporter.CaptureBadGateway(req)
示例9: TestUnmarshaller
package dropsonde_unmarshaller_test
import (
"time"
"github.com/cloudfoundry/dropsonde/emitter/fake"
"github.com/cloudfoundry/dropsonde/metric_sender"
"github.com/cloudfoundry/dropsonde/metricbatcher"
"github.com/cloudfoundry/dropsonde/metrics"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestUnmarshaller(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Dropsonde Unmarshaller Suite")
}
var fakeEventEmitter = fake.NewFakeEventEmitter("doppler")
var metricBatcher *metricbatcher.MetricBatcher
var _ = BeforeSuite(func() {
sender := metric_sender.NewMetricSender(fakeEventEmitter)
metricBatcher = metricbatcher.New(sender, 100*time.Millisecond)
metrics.Initialize(sender, metricBatcher)
})
示例10: NewFakeMetricSender
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Deadlock", func() {
var (
metricBatcher *metricbatcher.MetricBatcher
done chan struct{}
)
BeforeEach(func() {
done = make(chan struct{})
metricSender := NewFakeMetricSender(&done)
metricBatcher = metricbatcher.New(metricSender, 50*time.Millisecond)
metrics.Initialize(metricSender, metricBatcher)
})
It("doesn't deadlock when Batch functions are called while batch sending", func() {
metricBatcher.BatchAddCounter("count1", 2)
Eventually(done).Should(BeClosed())
}, 1)
})
type FakeMetricSender struct {
done *chan struct{}
}
func NewFakeMetricSender(done *chan struct{}) *FakeMetricSender {
return &FakeMetricSender{
done: done,
示例11:
var _ = Describe("Batch Writer", func() {
var (
byteWriter *mockByteWriter
messageBytes []byte
prefixedMessage []byte
batcher *batch.Writer
timeout time.Duration
logger *gosteno.Logger
sender *fake.FakeMetricSender
constructorErr error
)
BeforeEach(func() {
sender = fake.NewFakeMetricSender()
metrics.Initialize(sender, metricbatcher.New(sender, time.Millisecond*10))
byteWriter = newMockByteWriter()
close(byteWriter.WriteOutput.err)
messageBytes = []byte("this is a log message")
timeout = time.Second / 2
bufferSize = 1024
logger = loggertesthelper.Logger()
// zero out the values that are assigned in the JustBeforeEach
prefixedMessage = nil
batcher = nil
constructorErr = nil
})
JustBeforeEach(func() {
prefixedMessage = prefixWithLength(messageBytes)
示例12: TestWebsocketServer
"github.com/cloudfoundry/dropsonde/metrics"
"github.com/cloudfoundry/sonde-go/events"
"github.com/gogo/protobuf/proto"
"github.com/gorilla/websocket"
)
func TestWebsocketServer(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "WebsocketServer Suite")
}
var fakeMetricSender *fake.FakeMetricSender
var _ = BeforeSuite(func() {
fakeMetricSender = fake.NewFakeMetricSender()
metrics.Initialize(fakeMetricSender, metricbatcher.New(fakeMetricSender, 10*time.Millisecond))
})
func AddSlowWSSink(receivedChan chan []byte, errChan chan error, timeout time.Duration, url string) {
ws, _, err := websocket.DefaultDialer.Dial(url, http.Header{})
if err != nil {
panic(err)
}
go func() {
time.Sleep(timeout)
_, reader, err := ws.NextReader()
if err != nil {
errChan <- err
return
}
示例13:
. "github.com/onsi/gomega"
)
const TTL = 0
var _ = Describe("Convergence of Tasks", func() {
var (
sender *fake.FakeMetricSender
kickTasksDurationInSeconds, expirePendingTaskDurationInSeconds uint64
kickTasksDuration, expirePendingTaskDuration, expireCompletedTaskDuration time.Duration
)
BeforeEach(func() {
sender = fake.NewFakeMetricSender()
metrics.Initialize(sender, nil)
kickTasksDurationInSeconds = 10
kickTasksDuration = time.Duration(kickTasksDurationInSeconds) * time.Second
expirePendingTaskDurationInSeconds = 30
expirePendingTaskDuration = time.Duration(expirePendingTaskDurationInSeconds) * time.Second
expireCompletedTaskDuration = time.Hour
})
Describe("ConvergeTasks", func() {
const (
taskGuid = "some-guid"
taskGuid2 = "some-other-guid"
domain = "some-domain"
cellId = "cell-id"
)
示例14:
var _ = Describe("UDPWrapper", func() {
var (
client *mockClient
envelope *events.Envelope
udpWrapper *dopplerforwarder.UDPWrapper
logger *gosteno.Logger
message []byte
sharedSecret []byte
mockBatcher *mockMetricBatcher
)
BeforeEach(func() {
sharedSecret = []byte("secret")
mockBatcher = newMockMetricBatcher()
metrics.Initialize(nil, mockBatcher)
client = newMockClient()
envelope = &events.Envelope{
Origin: proto.String("fake-origin-1"),
EventType: events.Envelope_LogMessage.Enum(),
LogMessage: factories.NewLogMessage(events.LogMessage_OUT, "message", "appid", "sourceType"),
}
logger = loggertesthelper.Logger()
udpWrapper = dopplerforwarder.NewUDPWrapper(sharedSecret, logger)
var err error
message, err = proto.Marshal(envelope)
Expect(err).NotTo(HaveOccurred())
})
示例15: init
func init() {
sender = metrics_fakes.NewFakeMetricSender()
metrics.Initialize(sender, nil)
}