
This commit includes updates that affects the build, testing, and deployment of Tile38. - The root level build.sh has been broken up into multiple scripts and placed in the "scripts" directory. - The vendor directory has been updated to follow the Go modules rules, thus `make` should work on isolated environments. Also some vendored packages may have been updated to a later version, if needed. - The Makefile has been updated to allow for making single binaries such as `make tile38-server`. There is some scaffolding during the build process, so from now on all binaries should be made using make. For example, to run a development version of the tile38-cli binary, do this: make tile38-cli && ./tile38-cli not this: go run cmd/tile38-cli/main.go - Travis.CI docker push script has been updated to address a change to Docker's JSON repo meta output, which in turn fixes a bug where new Tile38 versions were not being properly pushed to Docker
52 lines
2.1 KiB
Go
52 lines
2.1 KiB
Go
package sarama
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/rcrowley/go-metrics"
|
|
)
|
|
|
|
// Use exponentially decaying reservoir for sampling histograms with the same defaults as the Java library:
|
|
// 1028 elements, which offers a 99.9% confidence level with a 5% margin of error assuming a normal distribution,
|
|
// and an alpha factor of 0.015, which heavily biases the reservoir to the past 5 minutes of measurements.
|
|
// See https://github.com/dropwizard/metrics/blob/v3.1.0/metrics-core/src/main/java/com/codahale/metrics/ExponentiallyDecayingReservoir.java#L38
|
|
const (
|
|
metricsReservoirSize = 1028
|
|
metricsAlphaFactor = 0.015
|
|
)
|
|
|
|
func getOrRegisterHistogram(name string, r metrics.Registry) metrics.Histogram {
|
|
return r.GetOrRegister(name, func() metrics.Histogram {
|
|
return metrics.NewHistogram(metrics.NewExpDecaySample(metricsReservoirSize, metricsAlphaFactor))
|
|
}).(metrics.Histogram)
|
|
}
|
|
|
|
func getMetricNameForBroker(name string, broker *Broker) string {
|
|
// Use broker id like the Java client as it does not contain '.' or ':' characters that
|
|
// can be interpreted as special character by monitoring tool (e.g. Graphite)
|
|
return fmt.Sprintf(name+"-for-broker-%d", broker.ID())
|
|
}
|
|
|
|
func getOrRegisterBrokerMeter(name string, broker *Broker, r metrics.Registry) metrics.Meter {
|
|
return metrics.GetOrRegisterMeter(getMetricNameForBroker(name, broker), r)
|
|
}
|
|
|
|
func getOrRegisterBrokerHistogram(name string, broker *Broker, r metrics.Registry) metrics.Histogram {
|
|
return getOrRegisterHistogram(getMetricNameForBroker(name, broker), r)
|
|
}
|
|
|
|
func getMetricNameForTopic(name string, topic string) string {
|
|
// Convert dot to _ since reporters like Graphite typically use dot to represent hierarchy
|
|
// cf. KAFKA-1902 and KAFKA-2337
|
|
return fmt.Sprintf(name+"-for-topic-%s", strings.Replace(topic, ".", "_", -1))
|
|
}
|
|
|
|
func getOrRegisterTopicMeter(name string, topic string, r metrics.Registry) metrics.Meter {
|
|
return metrics.GetOrRegisterMeter(getMetricNameForTopic(name, topic), r)
|
|
}
|
|
|
|
func getOrRegisterTopicHistogram(name string, topic string, r metrics.Registry) metrics.Histogram {
|
|
return getOrRegisterHistogram(getMetricNameForTopic(name, topic), r)
|
|
}
|