Skip to content

Commit

Permalink
Fixup rebase issues.
Browse files Browse the repository at this point in the history
Signed-off-by: SuperQ <superq@gmail.com>
  • Loading branch information
SuperQ committed Jun 2, 2023
1 parent 3af19a7 commit 25f5eaf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
5 changes: 2 additions & 3 deletions cmd/memcached_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (

func main() {
var (
<<<<<<< HEAD
address = kingpin.Flag("memcached.address", "Memcached server address.").Default("localhost:11211").String()
timeout = kingpin.Flag("memcached.timeout", "memcached connect timeout.").Default("1s").Duration()
pidFile = kingpin.Flag("memcached.pid-file", "Optional path to a file containing the memcached PID for additional metrics.").Default("").String()
Expand Down Expand Up @@ -97,7 +96,7 @@ func main() {
prometheus.MustRegister(version.NewCollector("memcached_exporter"))

if *address != "" {
prometheus.MustRegister(exporter.New(*address, *timeout, logger))
prometheus.MustRegister(exporter.New(*address, *timeout, logger, tlsConfig))
}

if *pidFile != "" {
Expand All @@ -109,7 +108,7 @@ func main() {
}

http.Handle(*metricsPath, promhttp.Handler())
scraper := scraper.New(*timeout, logger)
scraper := scraper.New(*timeout, logger, tlsConfig)
http.Handle(*scrapePath, scraper.Handler())

if *metricsPath != "/" && *metricsPath != "" {
Expand Down
15 changes: 9 additions & 6 deletions scraper/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package scraper

import (
"crypto/tls"
"net/http"
"time"

Expand All @@ -25,18 +26,20 @@ import (
)

type Scraper struct {
logger log.Logger
timeout time.Duration
logger log.Logger
timeout time.Duration
tlsConfig *tls.Config

scrapeCount prometheus.Counter
scrapeErrors prometheus.Counter
}

func New(timeout time.Duration, logger log.Logger) *Scraper {
func New(timeout time.Duration, logger log.Logger, tlsConfig *tls.Config) *Scraper {
level.Debug(logger).Log("msg", "Started scrapper")
return &Scraper{
logger: logger,
timeout: timeout,
logger: logger,
timeout: timeout,
tlsConfig: tlsConfig,
scrapeCount: prometheus.NewCounter(prometheus.CounterOpts{
Name: "memcached_exporter_scrapes_total",
Help: "Count of memcached exporter scapes.",
Expand All @@ -62,7 +65,7 @@ func (s *Scraper) Handler() http.HandlerFunc {
return
}

e := exporter.New(target, s.timeout, s.logger)
e := exporter.New(target, s.timeout, s.logger, s.tlsConfig)
registry := prometheus.NewRegistry()
registry.Register(e)

Expand Down
5 changes: 3 additions & 2 deletions scraper/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package scraper

import (
"crypto/tls"
"net/http"
"net/http/httptest"
"strings"
Expand All @@ -27,7 +28,7 @@ func TestHandler(t *testing.T) {
t.Run("Success", func(t *testing.T) {
t.Parallel()

s := New(1*time.Second, log.NewNopLogger())
s := New(1*time.Second, log.NewNopLogger(), &tls.Config{})

req, err := http.NewRequest("GET", "/?target=127.0.0.1:11211", nil)

Expand Down Expand Up @@ -55,7 +56,7 @@ func TestHandler(t *testing.T) {
t.Run("No target", func(t *testing.T) {
t.Parallel()

s := New(1*time.Second, log.NewNopLogger())
s := New(1*time.Second, log.NewNopLogger(), &tls.Config{})

req, err := http.NewRequest("GET", "/", nil)

Expand Down

0 comments on commit 25f5eaf

Please sign in to comment.