func New(
	maxRetainedLogMessages uint32,
	skipCertVerify bool,
	blackListManager *blacklist.URLBlacklistManager,
	logger *gosteno.Logger,
	messageDrainBufferSize uint,
	dropsondeOrigin string,
	sinkTimeout,
	sinkIOTimeout,
	metricTTL,
	dialTimeout time.Duration,
) *SinkManager {
	return &SinkManager{
		doneChannel:            make(chan struct{}),
		errorChannel:           make(chan *events.Envelope, 100),
		urlBlacklistManager:    blackListManager,
		sinks:                  groupedsinks.NewGroupedSinks(logger),
		skipCertVerify:         skipCertVerify,
		recentLogCount:         maxRetainedLogMessages,
		metrics:                metrics.NewSinkManagerMetrics(),
		logger:                 logger,
		messageDrainBufferSize: messageDrainBufferSize,
		dropsondeOrigin:        dropsondeOrigin,
		sinkTimeout:            sinkTimeout,
		sinkIOTimeout:          sinkIOTimeout,
		metricTTL:              metricTTL,
		dialTimeout:            dialTimeout,

		grpcStreams:   newGRPCRegistry(),
		grpcFirehoses: newGRPCRegistry(),
	}
}
Exemple #2
0
func New(maxRetainedLogMessages uint32, skipCertVerify bool, blackListManager *blacklist.URLBlacklistManager, logger *gosteno.Logger, dropsondeOrigin string, sinkTimeout, metricTTL time.Duration) *SinkManager {
	sinkDropUpdateChannel := make(chan int64)

	return &SinkManager{
		doneChannel:           make(chan struct{}),
		errorChannel:          make(chan *events.Envelope, 100),
		urlBlacklistManager:   blackListManager,
		sinks:                 groupedsinks.NewGroupedSinks(logger),
		skipCertVerify:        skipCertVerify,
		recentLogCount:        maxRetainedLogMessages,
		metrics:               metrics.NewSinkManagerMetrics(sinkDropUpdateChannel),
		sinkDropUpdateChannel: sinkDropUpdateChannel,
		logger:                logger,
		dropsondeOrigin:       dropsondeOrigin,
		sinkTimeout:           sinkTimeout,
		metricTTL:             metricTTL,
	}
}
	"github.com/gogo/protobuf/proto"

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

var _ = Describe("SinkManagerMetrics", func() {

	var sinkManagerMetrics *metrics.SinkManagerMetrics
	var sink sinks.Sink
	var dropUpdateChan chan int64

	BeforeEach(func() {
		fakeEventEmitter.Reset()
		dropUpdateChan = make(chan int64)
		sinkManagerMetrics = metrics.NewSinkManagerMetrics(dropUpdateChan)
	})

	It("emits metrics for dump sinks", func() {
		Expect(fakeEventEmitter.GetMessages()).To(BeEmpty())

		sink = &dump.DumpSink{}
		sinkManagerMetrics.Inc(sink)

		Expect(fakeEventEmitter.GetMessages()[0].Event.(*events.ValueMetric)).To(Equal(&events.ValueMetric{
			Name:  proto.String("messageRouter.numberOfDumpSinks"),
			Value: proto.Float64(1),
			Unit:  proto.String("sinks"),
		}))

		sinkManagerMetrics.Dec(sink)
	"github.com/cloudfoundry/sonde-go/events"
	"github.com/gogo/protobuf/proto"

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

var _ = Describe("SinkManagerMetrics", func() {

	var sinkManagerMetrics *metrics.SinkManagerMetrics
	var sink sinks.Sink

	BeforeEach(func() {
		fakeEventEmitter.Reset()
		sinkManagerMetrics = metrics.NewSinkManagerMetrics()
	})

	It("emits metrics for dump sinks", func() {
		Expect(fakeEventEmitter.GetMessages()).To(BeEmpty())

		sink = &dump.DumpSink{}
		sinkManagerMetrics.Inc(sink)

		Expect(fakeEventEmitter.GetMessages()[0].Event.(*events.ValueMetric)).To(Equal(&events.ValueMetric{
			Name:  proto.String("messageRouter.numberOfDumpSinks"),
			Value: proto.Float64(1),
			Unit:  proto.String("sinks"),
		}))

		sinkManagerMetrics.Dec(sink)