Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 'collector.disable-go-runtime-metrics' flag #587

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package main
import (
"bufio"
"fmt"
"github.com/prometheus/client_golang/prometheus/collectors"
"net"
"net/http"
_ "net/http/pprof"
Expand Down Expand Up @@ -269,8 +270,10 @@ func main() {
relayAddr = kingpin.Flag("statsd.relay.address", "The UDP relay target address (host:port)").String()
relayPacketLen = kingpin.Flag("statsd.relay.packet-length", "Maximum relay output packet length to avoid fragmentation").Default("1400").Uint()
udpPacketQueueSize = kingpin.Flag("statsd.udp-packet-queue-size", "Size of internal queue for processing UDP packets.").Default("10000").Int()
disableGoMetrics = kingpin.Flag("collector.disable-go-runtime-metrics", "Disable collection of Go runtime metrics").Default("false").Bool()
)

registry := prometheus.NewRegistry()
promlogConfig := &promlog.Config{}
flag.AddFlags(kingpin.CommandLine, promlogConfig)
kingpin.Version(version.Print("statsd_exporter"))
Expand All @@ -282,7 +285,7 @@ func main() {
level.Error(logger).Log("msg", "failed to set log level", "error", err)
os.Exit(1)
}
prometheus.MustRegister(versioncollector.NewCollector("statsd_exporter"))
registry.MustRegister(versioncollector.NewCollector("statsd_exporter"))

parser := line.NewParser()
if *dogstatsdTagsEnabled {
Expand All @@ -297,6 +300,9 @@ func main() {
if *signalFXTagsEnabled {
parser.EnableSignalFXParsing()
}
if !*disableGoMetrics {
registry.MustRegister(collectors.NewGoCollector())
}

level.Info(logger).Log("msg", "Starting StatsD -> Prometheus Exporter", "version", version.Info())
level.Info(logger).Log("msg", "Build context", "context", version.BuildContext())
Expand Down Expand Up @@ -331,7 +337,7 @@ func main() {
}
}

exporter := exporter.NewExporter(prometheus.DefaultRegisterer, thisMapper, logger, eventsActions, eventsUnmapped, errorEventStats, eventStats, conflictingEventStats, metricsCount)
exporter := exporter.NewExporter(registry, thisMapper, logger, eventsActions, eventsUnmapped, errorEventStats, eventStats, conflictingEventStats, metricsCount)

if *checkConfig {
level.Info(logger).Log("msg", "Configuration check successful, exiting")
Expand Down Expand Up @@ -492,7 +498,7 @@ func main() {
}

mux := http.DefaultServeMux
mux.Handle(*metricsEndpoint, promhttp.Handler())
mux.Handle(*metricsEndpoint, promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))
if *metricsEndpoint != "/" && *metricsEndpoint != "" {
landingConfig := web.LandingConfig{
Name: "StatsD Exporter",
Expand Down