forked from topfreegames/pitaya
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reporters.go
34 lines (31 loc) · 1.21 KB
/
reporters.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
package pitaya
import (
"github.com/topfreegames/pitaya/v2/config"
"github.com/topfreegames/pitaya/v2/logger"
"github.com/topfreegames/pitaya/v2/metrics"
"github.com/topfreegames/pitaya/v2/metrics/models"
)
// CreatePrometheusReporter create a Prometheus reporter instance
func CreatePrometheusReporter(serverType string, config config.MetricsConfig, customSpecs models.CustomMetricsSpec) (*metrics.PrometheusReporter, error) {
logger.Log.Infof("prometheus is enabled, configuring reporter on port %d", config.Prometheus.Port)
prometheus, err := metrics.GetPrometheusReporter(serverType, config, customSpecs)
if err != nil {
logger.Log.Errorf("failed to start prometheus metrics reporter, skipping %v", err)
}
return prometheus, err
}
// CreateStatsdReporter create a Statsd reporter instance
func CreateStatsdReporter(serverType string, config config.MetricsConfig) (*metrics.StatsdReporter, error) {
logger.Log.Infof(
"statsd is enabled, configuring the metrics reporter with host: %s",
config.Statsd.Host,
)
metricsReporter, err := metrics.NewStatsdReporter(
config,
serverType,
)
if err != nil {
logger.Log.Errorf("failed to start statds metrics reporter, skipping %v", err)
}
return metricsReporter, err
}