Skip to content

Commit

Permalink
Mutex to avoid issues with concurrent scrapes
Browse files Browse the repository at this point in the history
This is a hot fix
  • Loading branch information
rnaveiras committed Mar 7, 2019
1 parent c168625 commit 292be20
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Version 0.2.5 / 2019-03-07

[full changelog](https://github.com/rnaveiras/postgres_exporter/compare/v0.2.4...v0.2.5)

* Mutex to avoid issues with concurrent scrapes ([#23](https://github.com/rnaveiras/postgres_exporter/pull/23))

## Version 0.2.4 / 2018-09-20

[full changelog](https://github.com/rnaveiras/postgres_exporter/compare/v0.2.3...v0.2.4)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.4
0.2.5
5 changes: 5 additions & 0 deletions postgres_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"os"
"strings"
"sync"

// _ "net/http/pprof"

Expand All @@ -27,6 +28,7 @@ const (

var logger log.Logger
var conn *pgx.Conn
var handlerLock sync.Mutex

var (
listenAddress = kingpin.Flag("web.listen-address", "Address on which to expose metrics and web interface.").Default("0.0.0.0:9187").String()
Expand All @@ -40,6 +42,9 @@ func init() {
}

func handler(w http.ResponseWriter, r *http.Request) {
handlerLock.Lock()
defer handlerLock.Unlock()

filters := r.URL.Query()["collect[]"]
level.Debug(logger).Log("component", "web", "query", strings.Join(filters, ","))

Expand Down

0 comments on commit 292be20

Please sign in to comment.