• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang metrics.Initialize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cloudfoundry/dropsonde/metrics.Initialize函数的典型用法代码示例。如果您正苦于以下问题:Golang Initialize函数的具体用法?Golang Initialize怎么用?Golang Initialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Initialize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:7,代码来源:doppler.go


示例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)
}
开发者ID:trainchou,项目名称:gorouter,代码行数:8,代码来源:dropsonde.go


示例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)
}
开发者ID:syslxg,项目名称:loggregator,代码行数:8,代码来源:main.go


示例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)
}
开发者ID:pkdevbox,项目名称:loggregator,代码行数:10,代码来源:main.go


示例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
}
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:10,代码来源:main.go


示例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)
}
开发者ID:sunatthegilddotcom,项目名称:loggregator,代码行数:11,代码来源:main.go


示例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
开发者ID:emc-xchallenge,项目名称:stager,代码行数:31,代码来源:staging_handler_test.go


示例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)
开发者ID:cloudfoundry,项目名称:gorouter,代码行数:31,代码来源:metrics_reporter_test.go


示例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)
})
开发者ID:trainchou,项目名称:gorouter,代码行数:29,代码来源:dropsonde_unmarshaller_suite_test.go


示例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,
开发者ID:fraenkel,项目名称:dropsonde,代码行数:31,代码来源:deadlock_test.go


示例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)
开发者ID:yingkitw,项目名称:loggregator,代码行数:31,代码来源:writer_test.go


示例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
		}
开发者ID:lyuyun,项目名称:loggregator,代码行数:31,代码来源:websocket_server_suite_test.go


示例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"
		)
开发者ID:emc-xchallenge,项目名称:bbs,代码行数:31,代码来源:task_convergence_test.go


示例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())

	})
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:30,代码来源:udp_wrapper_test.go


示例15: init

func init() {
	sender = metrics_fakes.NewFakeMetricSender()
	metrics.Initialize(sender, nil)
}
开发者ID:nagyistge,项目名称:gorouter,代码行数:4,代码来源:route_fetcher_test.go


示例16:

	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/rep"
	"github.com/cloudfoundry/dropsonde/metric_sender/fake"
	"github.com/cloudfoundry/dropsonde/metrics"

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

var _ = Describe("Auction Metric Emitter Delegate", func() {
	var delegate auctiontypes.AuctionMetricEmitterDelegate
	var metricSender *fake.FakeMetricSender

	BeforeEach(func() {
		metricSender = fake.NewFakeMetricSender()
		metrics.Initialize(metricSender, nil)

		delegate = auctionmetricemitterdelegate.New()
	})

	Describe("AuctionCompleted", func() {
		It("should adjust the metric counters", func() {
			resource := rep.NewResource(10, 10, "linux")
			delegate.AuctionCompleted(auctiontypes.AuctionResults{
				SuccessfulLRPs: []auctiontypes.LRPAuction{
					{
						LRP: rep.NewLRP(models.NewActualLRPKey("successful-start", 0, "domain"), resource),
					},
				},
				SuccessfulTasks: []auctiontypes.TaskAuction{
					{
开发者ID:emc-xchallenge,项目名称:auctioneer,代码行数:31,代码来源:auctionmetricemitterdelegate_test.go


示例17:

	"github.com/cloudfoundry/loggregatorlib/loggertesthelper"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("LogSender", func() {
	var (
		emitter *fake.FakeEventEmitter
		sender  log_sender.LogSender
	)

	BeforeEach(func() {
		emitter = fake.NewFakeEventEmitter("origin")
		metricSender := metric_sender.NewMetricSender(emitter)
		batcher := metricbatcher.New(metricSender, time.Millisecond)
		metrics.Initialize(metricSender, batcher)
		sender = log_sender.NewLogSender(emitter, loggertesthelper.Logger())
	})

	AfterEach(func() {
		emitter.Close()
		for !emitter.IsClosed() {
			time.Sleep(10 * time.Millisecond)
		}
	})

	Describe("SendAppLog", func() {
		It("sends a log message event to its emitter", func() {
			err := sender.SendAppLog("app-id", "custom-log-message", "App", "0")
			Expect(err).NotTo(HaveOccurred())
开发者ID:fraenkel,项目名称:dropsonde,代码行数:30,代码来源:log_sender_test.go


示例18:

	var (
		inputChan   chan *events.Envelope
		outputChan  chan []byte
		runComplete chan struct{}
		marshaller  dropsonde_marshaller.DropsondeMarshaller
		fakeSender  *fake.FakeMetricSender
	)

	BeforeEach(func() {
		inputChan = make(chan *events.Envelope, 100)
		outputChan = make(chan []byte, 10)
		runComplete = make(chan struct{})
		marshaller = dropsonde_marshaller.NewDropsondeMarshaller(loggertesthelper.Logger())
		fakeSender = fake.NewFakeMetricSender()
		batcher := metricbatcher.New(fakeSender, 200*time.Millisecond)
		metrics.Initialize(fakeSender, batcher)

		go func() {
			marshaller.Run(inputChan, outputChan)
			close(runComplete)
		}()
	})

	AfterEach(func() {
		close(inputChan)
		Eventually(runComplete).Should(BeClosed())
	})

	It("marshals envelopes into bytes", func() {
		envelope := &events.Envelope{
			Origin:     proto.String("fake-origin-1"),
开发者ID:fraenkel,项目名称:dropsonde,代码行数:31,代码来源:dropsonde_marshaller_test.go


示例19:

import (
	"github.com/cloudfoundry/dropsonde/metric_sender/fake"
	"github.com/cloudfoundry/dropsonde/metricbatcher"
	"github.com/cloudfoundry/dropsonde/metrics"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"time"
)

var _ = Describe("Metrics", func() {
	var fakeMetricSender *fake.FakeMetricSender

	BeforeEach(func() {
		fakeMetricSender = fake.NewFakeMetricSender()
		metricBatcher := metricbatcher.New(fakeMetricSender, time.Millisecond)
		metrics.Initialize(fakeMetricSender, metricBatcher)
	})

	It("delegates SendValue", func() {
		metrics.SendValue("metric", 42.42, "answers")

		Expect(fakeMetricSender.GetValue("metric").Value).To(Equal(42.42))
		Expect(fakeMetricSender.GetValue("metric").Unit).To(Equal("answers"))
	})

	It("delegates IncrementCounter", func() {
		metrics.IncrementCounter("count")

		Expect(fakeMetricSender.GetCounter("count")).To(BeEquivalentTo(1))

		metrics.IncrementCounter("count")
开发者ID:benlaplanche,项目名称:emitter,代码行数:31,代码来源:metrics_test.go


示例20:

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() {
			uptimeMonitor.Stop()
		})
开发者ID:lyuyun,项目名称:loggregator,代码行数:30,代码来源:uptime_monitor_test.go



注:本文中的github.com/cloudfoundry/dropsonde/metrics.Initialize函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang metrics.SendValue函数代码示例发布时间:2022-05-23
下一篇:
Golang metrics.IncrementCounter函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap