mirror of
https://github.com/elyby/chrly.git
synced 2024-12-23 13:40:11 +05:30
Попытка внедрить statsd
This commit is contained in:
parent
34179ae1fe
commit
a0d940f8cd
2
data/statsd/.gitignore
vendored
Normal file
2
data/statsd/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
@ -11,3 +11,8 @@ services:
|
||||
RABBITMQ_DEFAULT_USER: "ely-skinsystem-app"
|
||||
RABBITMQ_DEFAULT_PASS: "ely-skinsystem-app-password"
|
||||
RABBITMQ_DEFAULT_VHOST: "/ely"
|
||||
|
||||
statsd:
|
||||
image: hopsoft/graphite-statsd
|
||||
volumes:
|
||||
- ./data/statsd:/opt/graphite/storage
|
||||
|
@ -11,6 +11,7 @@ services:
|
||||
links:
|
||||
- redis
|
||||
- rabbitmq
|
||||
- statsd
|
||||
|
||||
redis:
|
||||
extends:
|
||||
@ -21,3 +22,10 @@ services:
|
||||
extends:
|
||||
file: docker-compose.base.yml
|
||||
service: rabbitmq
|
||||
|
||||
statsd:
|
||||
extends:
|
||||
file: docker-compose.base.yml
|
||||
service: statsd
|
||||
ports:
|
||||
- "8123:80"
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func Textures(w http.ResponseWriter, r *http.Request) {
|
||||
services.Stats.Incr("textures-requests", 1)
|
||||
username := tools.ParseUsername(mux.Vars(r)["username"])
|
||||
log.Println("request textures for username " + username)
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"github.com/mediocregopher/radix.v2/pool"
|
||||
"github.com/streadway/amqp"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/quipo/statsd"
|
||||
)
|
||||
|
||||
var Router *mux.Router
|
||||
@ -13,3 +14,5 @@ var RedisPool *pool.Pool
|
||||
var RabbitMQChannel *amqp.Channel
|
||||
|
||||
var RootFolder string
|
||||
|
||||
var Stats *statsd.StatsdBuffer
|
||||
|
@ -11,6 +11,8 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/streadway/amqp"
|
||||
"github.com/mediocregopher/radix.v2/pool"
|
||||
"github.com/quipo/statsd"
|
||||
//"github.com/mediocregopher/radix.v2/redis"
|
||||
|
||||
"elyby/minecraft-skinsystem/lib/routes"
|
||||
"elyby/minecraft-skinsystem/lib/services"
|
||||
@ -56,6 +58,17 @@ func main() {
|
||||
}
|
||||
log.Println("Connected to rabbitmq channel")
|
||||
|
||||
// init
|
||||
statsClient := statsd.NewStatsdClient(statsString, "skinsystem.")
|
||||
statsErr := statsClient.CreateSocket()
|
||||
if statsErr != nil {
|
||||
log.Fatal(statsErr)
|
||||
}
|
||||
|
||||
interval := 2 * time.Second // aggregate stats and flush every 2 seconds
|
||||
stats := statsd.NewStatsdBuffer(interval, statsClient)
|
||||
defer stats.Close()
|
||||
|
||||
router := mux.NewRouter().StrictSlash(true)
|
||||
router.HandleFunc("/skins/{username}", routes.Skin).Methods("GET").Name("skins")
|
||||
router.HandleFunc("/cloaks/{username}", routes.Cape).Methods("GET").Name("cloaks")
|
||||
@ -75,6 +88,7 @@ func main() {
|
||||
services.Router = router
|
||||
services.RedisPool = redisPool
|
||||
services.RabbitMQChannel = rabbitChannel
|
||||
services.Stats = stats
|
||||
|
||||
_, file, _, _ := runtime.Caller(0)
|
||||
services.RootFolder = filepath.Dir(file)
|
||||
|
Loading…
Reference in New Issue
Block a user