Skip to content

Commit

Permalink
ref: tidying up
Browse files Browse the repository at this point in the history
  • Loading branch information
tjhop committed Dec 21, 2023
1 parent cf7b4a0 commit b6ee1da
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/ns1_exporter/ns1_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion pkg/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
package metrics

import (
"sync"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
"sync"
)

const (
Expand Down
7 changes: 4 additions & 3 deletions pkg/servicediscovery/sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b6ee1da

Please sign in to comment.