forked from topfreegames/pitaya
-
Notifications
You must be signed in to change notification settings - Fork 1
/
reporters.go
35 lines (32 loc) · 1.25 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
35
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"
"go.uber.org/zap"
)
// CreatePrometheusReporter create a Prometheus reporter instance
func CreatePrometheusReporter(serverType string, config config.MetricsConfig, customSpecs models.CustomMetricsSpec) (*metrics.PrometheusReporter, error) {
logger.Sugar.Infof("prometheus is enabled, configuring reporter on port %d", config.Prometheus.Port)
prometheus, err := metrics.GetPrometheusReporter(serverType, config, customSpecs)
if err != nil {
logger.Zap.Error("failed to start prometheus metrics reporter, skipping ", zap.Error(err))
}
return prometheus, err
}
// CreateStatsdReporter create a Statsd reporter instance
func CreateStatsdReporter(serverType string, config config.MetricsConfig) (*metrics.StatsdReporter, error) {
logger.Sugar.Infof(
"statsd is enabled, configuring the metrics reporter with host: %s",
config.Statsd.Host,
)
metricsReporter, err := metrics.NewStatsdReporter(
config,
serverType,
)
if err != nil {
logger.Zap.Error("failed to start statds metrics reporter, skipping", zap.Error(err))
}
return metricsReporter, err
}