@@ -36,10 +36,11 @@ import (
3636)
3737
3838var (
39- server * http.Server
39+ // scraping endpoint implementation
40+ server * http.Server
41+ // objects to store incoming metrics
4042 metricsInternal * MetricsAggregate
4143 metricsHistogramInternal * MetricsReservoirSampling
42- // metrics []Metric
4344 // channel that is used to request end of metrics server, it sends notification when server ended.
4445 // It needs to be read!!!
4546 endChannel chan struct {}
5960 log = logger .New (logrus .StandardLogger (), "metrics" ).WithField ("level" , infologger .IL_Devel )
6061)
6162
62- func initChannels (messageBufferSize int ) {
63+ func initChannels () {
6364 endChannel = make (chan struct {})
6465 metricsRequestedChannel = make (chan struct {})
6566 // 100 was chosen arbitrarily as a number that seemed sensible to be high enough to provide nice buffer if
@@ -79,11 +80,12 @@ func closeChannels() {
7980}
8081
8182// this eventLoop is the main part that processes all metrics send to the package
82- // 3 events can happen:
83+ // 4 events can happen:
8384// 1. metricsChannel receives message from Send() method. We just add the new metric to metrics slice
84- // 2. metricsRequestChannel receives request to dump and request existing metrics. We send shallow copy of existing
85+ // 2. metricsHistosChannel receives message from Send() method. We just add the new metric to metrics slice
86+ // 3. metricsRequestChannel receives request to dump and request existing metrics. We send shallow copy of existing
8587// metrics to requestor (via metricsExportedToRequest channel) while resetting current metrics slice
86- // 3 . receive request to stop monitoring via endChannel. We send confirmation through endChannel to notify caller
88+ // 4 . receive request to stop monitoring via endChannel. We send confirmation through endChannel to notify caller
8789// that eventLoop stopped
8890func eventLoop () {
8991 for {
@@ -144,15 +146,14 @@ func handleFunc(endpointName string) {
144146
145147// \param port port where the scraping endpoint will be created
146148// \param endpointName name of the endpoint, which must start with a slash eg. "/internalmetrics"
147- // \param messageBufferSize size of buffer for messages where messages are kept between scraping request.
148149//
149150// If we attempt send more messages than the size of the buffer, these overflowing messages will be ignored and warning will be logged.
150- func Run (port uint16 , endpointName string , messageBufferSize int ) error {
151+ func Run (port uint16 , endpointName string ) error {
151152 if IsRunning () {
152153 return nil
153154 }
154155
155- initChannels (messageBufferSize )
156+ initChannels ()
156157
157158 go eventLoop ()
158159
0 commit comments