|
|
@ -7,7 +7,6 @@ import (
|
|
|
|
"github.com/tal-tech/go-zero/core/logx"
|
|
|
|
"github.com/tal-tech/go-zero/core/logx"
|
|
|
|
"github.com/tal-tech/go-zero/core/prometheus"
|
|
|
|
"github.com/tal-tech/go-zero/core/prometheus"
|
|
|
|
"github.com/tal-tech/go-zero/core/stat"
|
|
|
|
"github.com/tal-tech/go-zero/core/stat"
|
|
|
|
"github.com/tal-tech/go-zero/core/trace/opentelemetry"
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
const (
|
|
|
@ -30,7 +29,8 @@ type ServiceConf struct {
|
|
|
|
Mode string `json:",default=pro,options=dev|test|rt|pre|pro"`
|
|
|
|
Mode string `json:",default=pro,options=dev|test|rt|pre|pro"`
|
|
|
|
MetricsUrl string `json:",optional"`
|
|
|
|
MetricsUrl string `json:",optional"`
|
|
|
|
Prometheus prometheus.Config `json:",optional"`
|
|
|
|
Prometheus prometheus.Config `json:",optional"`
|
|
|
|
Telemetry opentelemetry.Config `json:",optional"`
|
|
|
|
// TODO: enable it in v1.2.1
|
|
|
|
|
|
|
|
// Telemetry opentelemetry.Config `json:",optional"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MustSetUp sets up the service, exits on error.
|
|
|
|
// MustSetUp sets up the service, exits on error.
|
|
|
@ -45,16 +45,18 @@ func (sc ServiceConf) SetUp() error {
|
|
|
|
if len(sc.Log.ServiceName) == 0 {
|
|
|
|
if len(sc.Log.ServiceName) == 0 {
|
|
|
|
sc.Log.ServiceName = sc.Name
|
|
|
|
sc.Log.ServiceName = sc.Name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(sc.Telemetry.Name) == 0 {
|
|
|
|
|
|
|
|
sc.Telemetry.Name = sc.Name
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := logx.SetUp(sc.Log); err != nil {
|
|
|
|
if err := logx.SetUp(sc.Log); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sc.initMode()
|
|
|
|
sc.initMode()
|
|
|
|
prometheus.StartAgent(sc.Prometheus)
|
|
|
|
prometheus.StartAgent(sc.Prometheus)
|
|
|
|
opentelemetry.StartAgent(sc.Telemetry)
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: enable it in v1.2.1
|
|
|
|
|
|
|
|
// if len(sc.Telemetry.Name) == 0 {
|
|
|
|
|
|
|
|
// sc.Telemetry.Name = sc.Name
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// opentelemetry.StartAgent(sc.Telemetry)
|
|
|
|
|
|
|
|
|
|
|
|
if len(sc.MetricsUrl) > 0 {
|
|
|
|
if len(sc.MetricsUrl) > 0 {
|
|
|
|
stat.SetReportWriter(stat.NewRemoteWriter(sc.MetricsUrl))
|
|
|
|
stat.SetReportWriter(stat.NewRemoteWriter(sc.MetricsUrl))
|
|
|
|