Merge pull request #97 from mainflux/mainflux-96

Fixes inconsisent label cardinality error
This commit is contained in:
Drasko DRASKOVIC 2017-09-24 13:41:49 +02:00 committed by GitHub
commit 9afaea24c2
1 changed files with 4 additions and 5 deletions

View File

@ -57,8 +57,6 @@ func main() {
logger = log.NewJSONLogger(log.NewSyncWriter(os.Stdout)) logger = log.NewJSONLogger(log.NewSyncWriter(os.Stdout))
logger = log.With(logger, "ts", log.DefaultTimestampUTC) logger = log.With(logger, "ts", log.DefaultTimestampUTC)
logger.Log("start", "manager")
session, err := cassandra.Connect(strings.Split(cfg.Cluster, sep), cfg.Keyspace) session, err := cassandra.Connect(strings.Split(cfg.Cluster, sep), cfg.Keyspace)
if err != nil { if err != nil {
logger.Log("error", err) logger.Log("error", err)
@ -80,25 +78,26 @@ func main() {
var svc manager.Service var svc manager.Service
svc = manager.NewService(users, clients, channels, hasher, idp) svc = manager.NewService(users, clients, channels, hasher, idp)
svc = api.NewLoggingService(logger, svc) svc = api.NewLoggingService(logger, svc)
fields := []string{"method"}
svc = api.NewMetricService( svc = api.NewMetricService(
kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{ kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: "manager", Namespace: "manager",
Subsystem: "api", Subsystem: "api",
Name: "request_count", Name: "request_count",
Help: "Number of requests received.", Help: "Number of requests received.",
}, []string{}), }, fields),
kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{ kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: "manager", Namespace: "manager",
Subsystem: "api", Subsystem: "api",
Name: "request_latency_microseconds", Name: "request_latency_microseconds",
Help: "Total duration of requests in microseconds.", Help: "Total duration of requests in microseconds.",
}, []string{}), }, fields),
svc, svc,
) )
errs := make(chan error, 2) errs := make(chan error, 2)
logger.Log("http_port", cfg.Port)
go func() { go func() {
p := fmt.Sprintf(":%d", cfg.Port) p := fmt.Sprintf(":%d", cfg.Port)
errs <- http.ListenAndServe(p, api.MakeHandler(svc)) errs <- http.ListenAndServe(p, api.MakeHandler(svc))