本文整理汇总了Golang中github.com/youtube/vitess/go/stats.NewMultiCountersFunc函数的典型用法代码示例。如果您正苦于以下问题:Golang NewMultiCountersFunc函数的具体用法?Golang NewMultiCountersFunc怎么用?Golang NewMultiCountersFunc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewMultiCountersFunc函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: NewSchemaInfo
func NewSchemaInfo(queryCacheSize int, reloadTime time.Duration, idleTimeout time.Duration) *SchemaInfo {
si := &SchemaInfo{
queryCacheSize: queryCacheSize,
queries: cache.NewLRUCache(int64(queryCacheSize)),
rules: NewQueryRules(),
connPool: dbconnpool.NewConnectionPool("", 2, idleTimeout),
reloadTime: reloadTime,
ticks: timer.NewTimer(reloadTime),
}
stats.Publish("QueryCacheLength", stats.IntFunc(si.queries.Length))
stats.Publish("QueryCacheSize", stats.IntFunc(si.queries.Size))
stats.Publish("QueryCacheCapacity", stats.IntFunc(si.queries.Capacity))
stats.Publish("QueryCacheOldest", stats.StringFunc(func() string {
return fmt.Sprintf("%v", si.queries.Oldest())
}))
stats.Publish("SchemaReloadTime", stats.DurationFunc(func() time.Duration {
return si.reloadTime
}))
_ = stats.NewMultiCountersFunc("TableStats", []string{"Table", "Stats"}, si.getTableStats)
stats.Publish("TableInvalidations", stats.CountersFunc(si.getTableInvalidations))
_ = stats.NewMultiCountersFunc("QueryCounts", []string{"Table", "Plan"}, si.getQueryCount)
_ = stats.NewMultiCountersFunc("QueryTimesNs", []string{"Table", "Plan"}, si.getQueryTime)
_ = stats.NewMultiCountersFunc("QueryRowCounts", []string{"Table", "Plan"}, si.getQueryRowCount)
_ = stats.NewMultiCountersFunc("QueryErrorCounts", []string{"Table", "Plan"}, si.getQueryErrorCount)
http.Handle("/debug/query_plans", si)
http.Handle("/debug/query_stats", si)
http.Handle("/debug/table_stats", si)
http.Handle("/debug/schema", si)
return si
}
开发者ID:ninqing,项目名称:vitess,代码行数:30,代码来源:schema_info.go
示例2: NewSchemaInfo
// NewSchemaInfo creates a new SchemaInfo.
func NewSchemaInfo(
statsPrefix string,
checker MySQLChecker,
queryCacheSize int,
reloadTime time.Duration,
idleTimeout time.Duration,
cachePool *CachePool,
endpoints map[string]string,
enablePublishStats bool,
queryServiceStats *QueryServiceStats) *SchemaInfo {
si := &SchemaInfo{
queries: cache.NewLRUCache(int64(queryCacheSize)),
connPool: NewConnPool("", 2, idleTimeout, enablePublishStats, queryServiceStats, checker),
cachePool: cachePool,
ticks: timer.NewTimer(reloadTime),
endpoints: endpoints,
reloadTime: reloadTime,
queryRuleSources: NewQueryRuleInfo(),
queryServiceStats: queryServiceStats,
}
if enablePublishStats {
stats.Publish(statsPrefix+"QueryCacheLength", stats.IntFunc(si.queries.Length))
stats.Publish(statsPrefix+"QueryCacheSize", stats.IntFunc(si.queries.Size))
stats.Publish(statsPrefix+"QueryCacheCapacity", stats.IntFunc(si.queries.Capacity))
stats.Publish(statsPrefix+"QueryCacheOldest", stats.StringFunc(func() string {
return fmt.Sprintf("%v", si.queries.Oldest())
}))
stats.Publish(statsPrefix+"SchemaReloadTime", stats.DurationFunc(si.ticks.Interval))
_ = stats.NewMultiCountersFunc(statsPrefix+"RowcacheStats", []string{"Table", "Stats"}, si.getRowcacheStats)
_ = stats.NewMultiCountersFunc(statsPrefix+"RowcacheInvalidations", []string{"Table"}, si.getRowcacheInvalidations)
_ = stats.NewMultiCountersFunc(statsPrefix+"QueryCounts", []string{"Table", "Plan"}, si.getQueryCount)
_ = stats.NewMultiCountersFunc(statsPrefix+"QueryTimesNs", []string{"Table", "Plan"}, si.getQueryTime)
_ = stats.NewMultiCountersFunc(statsPrefix+"QueryRowCounts", []string{"Table", "Plan"}, si.getQueryRowCount)
_ = stats.NewMultiCountersFunc(statsPrefix+"QueryErrorCounts", []string{"Table", "Plan"}, si.getQueryErrorCount)
_ = stats.NewMultiCountersFunc(statsPrefix+"TableRows", []string{"Table"}, si.getTableRows)
_ = stats.NewMultiCountersFunc(statsPrefix+"DataLength", []string{"Table"}, si.getDataLength)
_ = stats.NewMultiCountersFunc(statsPrefix+"IndexLength", []string{"Table"}, si.getIndexLength)
_ = stats.NewMultiCountersFunc(statsPrefix+"DataFree", []string{"Table"}, si.getDataFree)
}
for _, ep := range endpoints {
http.Handle(ep, si)
}
return si
}
开发者ID:hadoop835,项目名称:vitess,代码行数:45,代码来源:schema_info.go
示例3: TestMultiCountersFunc
func TestMultiCountersFunc(t *testing.T) {
f := func() map[string]int64 {
return map[string]int64{
"a.b": 1,
}
}
v := stats.NewMultiCountersFunc("", []string{"label1", "label2"}, f)
testMetric(t, v, nil,
`Desc{fqName: "test_name", help: "test_help", constLabels: {}, variableLabels: [label1 label2]}`,
`label:<name:"label1" value:"a" > label:<name:"label2" value:"b" > gauge:<value:1 > `,
)
}
开发者ID:CowLeo,项目名称:vitess,代码行数:12,代码来源:collector_test.go
示例4: main
func main() {
flag.Parse()
servenv.Init()
ts := topo.GetServer()
defer topo.CloseServers()
resilientSrvTopoServer = vtgate.NewResilientSrvTopoServer(ts, "ResilientSrvTopoServer")
labels := []string{"Cell", "Keyspace", "ShardName", "DbType"}
_ = stats.NewMultiCountersFunc("EndpointCount", labels, resilientSrvTopoServer.EndpointCount)
_ = stats.NewMultiCountersFunc("DegradedEndpointCount", labels, resilientSrvTopoServer.DegradedEndpointCount)
// For the initial phase vtgate is exposing
// topoReader api. This will be subsumed by
// vtgate once vtgate's client functions become active.
topoReader = NewTopoReader(resilientSrvTopoServer)
topo.RegisterTopoReader(topoReader)
vtgate.Init(resilientSrvTopoServer, *cell, *retryDelay, *retryCount, *timeout, *maxInFlight)
servenv.RunDefault()
}
开发者ID:chinna1986,项目名称:vitess,代码行数:22,代码来源:vtgate.go
示例5: NewHealthCheck
// NewHealthCheck creates a new HealthCheck object.
func NewHealthCheck(connTimeout time.Duration, retryDelay time.Duration, healthCheckTimeout time.Duration, statsSuffix string) HealthCheck {
hc := &HealthCheckImpl{
addrToConns: make(map[string]*healthCheckConn),
targetToEPs: make(map[string]map[string]map[topodatapb.TabletType][]*topodatapb.EndPoint),
connTimeout: connTimeout,
retryDelay: retryDelay,
healthCheckTimeout: healthCheckTimeout,
closeChan: make(chan struct{}),
}
if hcConnCounters == nil {
hcConnCounters = stats.NewMultiCountersFunc("HealthcheckConnections"+statsSuffix, []string{"keyspace", "shardname", "tablettype"}, hc.servingConnStats)
}
go func() {
// Start another go routine to check timeout.
// Currently vttablet sends healthcheck response every 20 seconds.
// We set the default timeout to 1 minute (20s * 3),
// and also perform the timeout check in sync with vttablet frequency.
// When we change the healthcheck frequency on vttablet,
// we should also adjust here.
t := time.NewTicker(healthCheckTimeout / 3)
defer t.Stop()
for {
select {
case <-hc.closeChan:
return
case _, ok := <-t.C:
if !ok {
// the ticker stoped
return
}
hc.checkHealthCheckTimeout()
}
}
}()
return hc
}
开发者ID:aaijazi,项目名称:vitess,代码行数:37,代码来源:healthcheck.go
示例6: RegisterStats
// RegisterStats registers the connection counts stats
func (hc *HealthCheckImpl) RegisterStats() {
stats.NewMultiCountersFunc("HealthcheckConnections", []string{"keyspace", "shardname", "tablettype"}, hc.servingConnStats)
}
开发者ID:jmptrader,项目名称:vitess,代码行数:4,代码来源:healthcheck.go
注:本文中的github.com/youtube/vitess/go/stats.NewMultiCountersFunc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论