diff --git a/cmd/ns1_exporter/ns1_exporter.go b/cmd/ns1_exporter/ns1_exporter.go index 144b8df..caac80e 100644 --- a/cmd/ns1_exporter/ns1_exporter.go +++ b/cmd/ns1_exporter/ns1_exporter.go @@ -51,8 +51,8 @@ const ( var ( // pkg level logger - logger = promlog.New(promlogConfig) promlogConfig = &promlog.Config{} + logger = promlog.New(promlogConfig) // so. many. flags. flagWebTelemetryPath = kingpin.Flag( diff --git a/pkg/exporter/exporter.go b/pkg/exporter/exporter.go index 26728e9..76c79e4 100644 --- a/pkg/exporter/exporter.go +++ b/pkg/exporter/exporter.go @@ -37,7 +37,6 @@ type Worker struct { EnableRecordQPS bool client *ns1_internal.Client - // add collector? zoneCache map[string]*ns1_internal.Zone qpsCache []*ns1_internal.QPS } diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 35edf8e..70a14f8 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -15,9 +15,10 @@ package metrics import ( + "sync" + "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/collectors" - "sync" ) const ( diff --git a/pkg/servicediscovery/sd.go b/pkg/servicediscovery/sd.go index 9215f33..47d21b4 100644 --- a/pkg/servicediscovery/sd.go +++ b/pkg/servicediscovery/sd.go @@ -58,8 +58,10 @@ type HTTPSDTarget struct { Labels promModel.LabelSet `json:"labels"` } -// Worker is a struct containing configs needed to retrieve stats from NS1 API -// to expose as prometheus metrics. It implements the prometheus.Collector interface +// Worker contains an API client to interact with the NS1 api, as well as a +// cache of DNS records and the Prometheus targets created from those records. +// Worker gets registered on a different handler for the `/sd` path and run via +// the same HTTP server as the metrics exporter. type Worker struct { client *ns1_internal.Client @@ -250,7 +252,6 @@ func (w *Worker) ServeHTTP(writer http.ResponseWriter, req *http.Request) { return } - // write results to json writer.Header().Set("content-type", "application/json; charset=utf-8") writer.WriteHeader(http.StatusOK) if bytesWritten, err := writer.Write(buf); err != nil {