Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metrics例子运行不起来 #10

Open
superufo opened this issue May 7, 2020 · 2 comments
Open

metrics例子运行不起来 #10

superufo opened this issue May 7, 2020 · 2 comments

Comments

@superufo
Copy link

superufo commented May 7, 2020

版本 go-chassis V1.76
https://github.com/go-chassis/go-chassis-examples/blob/master/metrics/server/schema/schema.go
原来是init () 运行会有错的。因为archaius 还没有初始化。
做如下修改,可以运行:

`
func (*User) URLPatterns() []restful.Route {
Init()
return []restful.Route{
{Method: http.MethodPost, Path: "/login", ResourceFuncName: "Login"},
{Method: http.MethodGet, Path: "/sign_out", ResourceFuncName: "SignOut"},
}
}

const (
login = "login_total"
signOut = "sign_out_total"
label = "username"
)

// init()改成 Init() 在URLPatterns()中先初始化
func Init() {
//metrics.InstallPlugin("metrics", metrics.NewPrometheusExporter)
//archaius.Init(archaius.WithENVSource())

//os.Exit(0)
val := archaius.GetString("cse.metrics.enableGoRuntimeMetrics", "")
openlogging.GetLogger().Errorf("-----------val :%s", val)

//openlogging.GetLogger().Errorf("-----------val 1111111111111")

metrics.Init()
metrics.CreateCounter(metrics.CounterOpts{
	Help:   "count user login",
	Name:   login,
	Labels: []string{label}})
metrics.CreateCounter(metrics.CounterOpts{
	Help:   "user sign out",
	Name:   signOut,
	Labels: []string{label}})

}
`

@superufo superufo changed the title schema运行不起来问题 metrics例子运行不起来 May 7, 2020
@tianxiaoliang
Copy link
Member

我会看下

@tianxiaoliang
Copy link
Member

已经修复,试下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants