-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from felipemarinho97/feat/add-monitoring
Feat/add monitoring
- Loading branch information
Showing
10 changed files
with
151 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM golang:1.19 as builder | ||
FROM golang:1.21 as builder | ||
|
||
WORKDIR /go/src/app | ||
COPY . . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
build: | ||
docker build -t torrent-indexer . | ||
|
||
run: | ||
go run main.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
module github.com/felipemarinho97/torrent-indexer | ||
|
||
go 1.18 | ||
go 1.21 | ||
|
||
require github.com/redis/go-redis/v9 v9.2.0 | ||
require github.com/redis/go-redis/v9 v9.5.1 | ||
|
||
require ( | ||
github.com/andybalholm/cascadia v1.3.1 // indirect | ||
github.com/andybalholm/cascadia v1.3.2 // indirect | ||
github.com/beorn7/perks v1.0.1 // indirect | ||
github.com/cespare/xxhash/v2 v2.2.0 // indirect | ||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect | ||
golang.org/x/net v0.7.0 // indirect | ||
github.com/prometheus/client_model v0.6.0 // indirect | ||
github.com/prometheus/common v0.50.0 // indirect | ||
github.com/prometheus/procfs v0.13.0 // indirect | ||
golang.org/x/net v0.22.0 // indirect | ||
golang.org/x/sys v0.18.0 // indirect | ||
google.golang.org/protobuf v1.33.0 // indirect | ||
) | ||
|
||
require github.com/PuerkitoBio/goquery v1.8.1 | ||
require ( | ||
github.com/PuerkitoBio/goquery v1.9.1 | ||
github.com/prometheus/client_golang v1.19.0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package monitoring | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
type Metrics struct { | ||
IndexerDuration *prometheus.HistogramVec | ||
IndexerErrors *prometheus.CounterVec | ||
IndexerRequests *prometheus.CounterVec | ||
CacheHits *prometheus.CounterVec | ||
CacheMisses *prometheus.CounterVec | ||
} | ||
|
||
func NewMetrics() *Metrics { | ||
return &Metrics{ | ||
IndexerDuration: prometheus.NewHistogramVec(prometheus.HistogramOpts{ | ||
Name: "indexer_duration_seconds", | ||
Help: "Duration of indexer requests", | ||
Buckets: []float64{0.1, 0.5, 1, 2, 5, 10, 20, 30}, | ||
}, []string{"indexer"}), | ||
IndexerErrors: prometheus.NewCounterVec(prometheus.CounterOpts{ | ||
Name: "indexer_errors_total", | ||
Help: "Number of indexer errors", | ||
}, []string{"indexer"}), | ||
IndexerRequests: prometheus.NewCounterVec(prometheus.CounterOpts{ | ||
Name: "indexer_requests_total", | ||
Help: "Number of indexer requests", | ||
}, []string{"indexer"}), | ||
CacheHits: prometheus.NewCounterVec(prometheus.CounterOpts{ | ||
Name: "cache_hits_total", | ||
Help: "Number of cache hits", | ||
}, []string{"cache"}), | ||
CacheMisses: prometheus.NewCounterVec(prometheus.CounterOpts{ | ||
Name: "cache_misses_total", | ||
Help: "Number of cache misses", | ||
}, []string{"cache"}), | ||
} | ||
} | ||
|
||
func (m *Metrics) Register() { | ||
prometheus.MustRegister(m.IndexerDuration) | ||
prometheus.MustRegister(m.IndexerErrors) | ||
prometheus.MustRegister(m.IndexerRequests) | ||
prometheus.MustRegister(m.CacheHits) | ||
prometheus.MustRegister(m.CacheMisses) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters