Exemple #1
0
func NewFunServant(cf *config.ConfigServant) (this *FunServantImpl) {
	this = &FunServantImpl{
		conf:            cf,
		digitNormalizer: regexp.MustCompile(`\d+`),
		proxyMode:       config.Engine.IsProxyOnly(),
	}

	// http REST to export internal state
	server.RegisterHttpApi("/svt/{cmd}",
		func(w http.ResponseWriter, req *http.Request,
			params map[string]interface{}) (interface{}, error) {
			return this.handleHttpQuery(w, req, params)
		}).Methods("GET")

	this.sessions = cache.NewLruCache(cf.SessionMaxItems)
	this.mysqlMergeMutexMap = mutexmap.New(cf.Mysql.JsonMergeMaxOutstandingItems)

	this.ctxReasonPercentage = metrics.NewPercentCounter()
	metrics.Register("call.reason", this.ctxReasonPercentage)
	this.dbCacheHits = metrics.NewPercentCounter()
	metrics.Register("db.cache.hits", this.dbCacheHits)

	this.createServants()

	return
}
Exemple #2
0
func newEngineStats() (this *engineStats) {
	this = &engineStats{
		memStats: new(runtime.MemStats),
		CallLatencies: metrics.NewHistogram(
			metrics.NewExpDecaySample(1028, 0.015)),
		CallPerSecond: metrics.NewMeter(),
		CallPerSession: metrics.NewHistogram(
			metrics.NewExpDecaySample(1028, 0.015)),
	}

	metrics.Register("latency.call", this.CallLatencies)
	metrics.Register("qps.call", this.CallPerSecond)
	metrics.Register("call.per.session", this.CallPerSession)
	return
}
Exemple #3
0
func (this *servantStats) registerMetrics() {
	this.calls = metrics.NewPercentCounter()
	metrics.Register("servant.calls", this.calls)
}