Skip to content

Commit

Permalink
Merge eefee92 into bb97311
Browse files Browse the repository at this point in the history
  • Loading branch information
andrehp committed Jul 19, 2018
2 parents bb97311 + eefee92 commit fb3ff05
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func NewAgent(
metricsReporters: metricsReporters,
}

// bindng session
// binding session
s := session.New(a, true)
metrics.ReportNumberOfConnectedClients(metricsReporters, session.SessionCount)
a.Session = s
Expand Down
5 changes: 4 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ func Configure(
app.metricsReporters = make([]metrics.Reporter, 0)

defaultTags := app.config.GetStringMapString("pitaya.metrics.tags")
AddMetricsReporter(metrics.GetPrometheusReporter(serverType, app.config.GetString("pitaya.game"), app.config.GetInt("pitaya.metrics.prometheus.port"), defaultTags))
if app.config.GetBool("pitaya.metrics.prometheus.enabled") {
logger.Log.Infof("prometheus is enabled, configuring the metrics reporter on port %d", app.config.GetInt("pitaya.metrics.prometheus.port"))
AddMetricsReporter(metrics.GetPrometheusReporter(serverType, app.config.GetString("pitaya.game"), app.config.GetInt("pitaya.metrics.prometheus.port"), defaultTags))
}

if app.config.GetBool("pitaya.metrics.statsd.enabled") {
logger.Log.Infof("statsd is enabled, configuring the metrics reporter with host: %s", app.config.Get("pitaya.metrics.statsd.host"))
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func (c *Config) fillDefaultValues() {
"pitaya.metrics.statsd.rate": 1,
"pitaya.metrics.prometheus.port": 9090,
"pitaya.metrics.tags": map[string]string{},
"pitaya.metrics.prometheus.enabled": true,
}

for param := range defaultsMap {
Expand Down
14 changes: 14 additions & 0 deletions metrics/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package metrics

var (
// ResponseTime reports the response time of handlers and rpc
ResponseTime = "response_time_ns"
// ConnectedClients represents the number of current connected clients in frontend servers
ConnectedClients = "connected_clients"
// CountServers counts the number of servers of different types
CountServers = "count_servers"
// ChannelCapacity represents the capacity of a channel (available slots)
ChannelCapacity = "channel_capacity"
// DroppedMessages reports the number of dropped messages in rpc server (messages that will not be handled)
DroppedMessages = "dropped_messages"
)
12 changes: 1 addition & 11 deletions metrics/prometheus_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ import (
)

var (
// ResponseTime reports the response time of handlers and rpc
ResponseTime = "response_time_ns"
// ConnectedClients represents the number of current connected clients in frontend servers
ConnectedClients = "connected_clients"
// CountServers counts the number of servers of different types
CountServers = "count_servers"
// ChannelCapacity represents the capacity of a channel (available slots)
ChannelCapacity = "channel_capacity"
// DroppedMessages reports the number of dropped messages in rpc server (messages that will not be handled)
DroppedMessages = "dropped_messages"
prometheusReporter *PrometheusReporter
once sync.Once
)
Expand All @@ -58,7 +48,7 @@ func (p *PrometheusReporter) registerMetrics(constLabels map[string]string) {
constLabels["game"] = p.game
constLabels["serverType"] = p.serverType

// HanadlerResponseTimeMs summaary
// HandlerResponseTimeMs summary
p.summaryReportersMap[ResponseTime] = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Namespace: "pitaya",
Expand Down

0 comments on commit fb3ff05

Please sign in to comment.