diff --git a/server/tiledb/prometheus.go b/server/tiledb/prometheus.go new file mode 100644 index 0000000..0a4f164 --- /dev/null +++ b/server/tiledb/prometheus.go @@ -0,0 +1,23 @@ +package tiledb + +import ( + "github.com/prometheus/client_golang/prometheus" +) + +var ( + tiledbSaveDuration = prometheus.NewHistogram(prometheus.HistogramOpts{ + Name: "tiledb_save_durations", + Help: "Histogram for tiledb save timings", + Buckets: prometheus.LinearBuckets(0.005, 0.01, 10), + }) + tiledbLoadDuration = prometheus.NewHistogram(prometheus.HistogramOpts{ + Name: "tiledb_load_durations", + Help: "Histogram for tiledb load timings", + Buckets: prometheus.LinearBuckets(0.005, 0.01, 10), + }) +) + +func init() { + prometheus.MustRegister(tiledbSaveDuration) + prometheus.MustRegister(tiledbLoadDuration) +} diff --git a/server/tiledb/tiledb.go b/server/tiledb/tiledb.go index 8709594..71a5c0a 100644 --- a/server/tiledb/tiledb.go +++ b/server/tiledb/tiledb.go @@ -1,12 +1,13 @@ package tiledb import ( + "github.com/prometheus/client_golang/prometheus" + "github.com/sirupsen/logrus" "io/ioutil" "mapserver/coords" "os" "strconv" "sync" - "github.com/sirupsen/logrus" ) var mutex = &sync.RWMutex{} @@ -36,6 +37,9 @@ func (this *TileDB) GC() { } func (this *TileDB) GetTile(pos *coords.TileCoords) ([]byte, error) { + timer := prometheus.NewTimer(tiledbLoadDuration) + defer timer.ObserveDuration() + mutex.RLock() defer mutex.RUnlock() @@ -59,6 +63,9 @@ func (this *TileDB) GetTile(pos *coords.TileCoords) ([]byte, error) { } func (this *TileDB) SetTile(pos *coords.TileCoords, tile []byte) error { + timer := prometheus.NewTimer(tiledbSaveDuration) + defer timer.ObserveDuration() + mutex.Lock() defer mutex.Unlock() diff --git a/server/tilerendererjob/common.go b/server/tilerendererjob/common.go index 3b914c7..17f4eed 100644 --- a/server/tilerendererjob/common.go +++ b/server/tilerendererjob/common.go @@ -72,7 +72,7 @@ func renderMapblocks(ctx *app.App, mblist []*mapblockparser.MapBlock) int { //spin down worker pool close(jobs) - + for j := 0; j < ctx.Config.RenderingJobs; j++ { <-done } diff --git a/server/web/prometheus.go b/server/web/prometheus.go index 064c5f5..898f04c 100644 --- a/server/web/prometheus.go +++ b/server/web/prometheus.go @@ -26,11 +26,11 @@ var ( Help: "Websocket client count", }) mintestPlayers = prometheus.NewGauge(prometheus.GaugeOpts{ - Name: "minetest_player_count", + Name: "mapserver_minetest_player_count", Help: "game player count", }) mintestMaxLag = prometheus.NewGauge(prometheus.GaugeOpts{ - Name: "minetest_max_lag", + Name: "mapserver_minetest_max_lag", Help: "Max lag", }) )