-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
40 lines (34 loc) · 780 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"log"
"net/http"
"os"
"github.com/prometheus/client_golang/prometheus"
)
var (
added = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "sudoku",
Subsystem: "api",
Name: "puzzles_added",
Help: "The number of puzzles added.",
})
duplicate = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "sudoku",
Subsystem: "api",
Name: "puzzles_duplicate",
Help: "The number of puzzles sent that already exist.",
})
)
func init() {
prometheus.MustRegister(added)
prometheus.MustRegister(duplicate)
}
func main() {
repo := newRedisRepo(os.Getenv("REDIS_ADDR"))
router := newRouter(repo)
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
log.Fatal(http.ListenAndServe(":"+port, router))
}