本文整理匯總了Golang中github.com/influxdata/telegraf/testutil.Accumulator.SetDebug方法的典型用法代碼示例。如果您正苦於以下問題:Golang Accumulator.SetDebug方法的具體用法?Golang Accumulator.SetDebug怎麽用?Golang Accumulator.SetDebug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/influxdata/telegraf/testutil.Accumulator
的用法示例。
在下文中一共展示了Accumulator.SetDebug方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: testMain
func testMain(t *testing.T, code string, endpoint string, serverType ServerType) {
// Build the fake snmpwalk for test
src := makeFakeSNMPSrc(code)
defer os.Remove(src)
buildFakeSNMPCmd(src)
defer os.Remove("./snmpwalk")
envPathOrigin := os.Getenv("PATH")
// Refer to the fake snmpwalk
os.Setenv("PATH", ".")
defer os.Setenv("PATH", envPathOrigin)
l := &LeoFS{
Servers: []string{endpoint},
}
var acc testutil.Accumulator
acc.SetDebug(true)
err := l.Gather(&acc)
require.NoError(t, err)
floatMetrics := KeyMapping[serverType]
for _, metric := range floatMetrics {
assert.True(t, acc.HasFloatField("leofs", metric), metric)
}
}
示例2: TestGrokParseLogFilesOneBad
// Test that test_a.log line gets parsed even though we don't have the correct
// pattern available for test_b.log
func TestGrokParseLogFilesOneBad(t *testing.T) {
thisdir := getCurrentDir()
p := &grok.Parser{
Patterns: []string{"%{TEST_LOG_A}", "%{TEST_LOG_BAD}"},
CustomPatternFiles: []string{thisdir + "grok/testdata/test-patterns"},
}
assert.NoError(t, p.Compile())
logparser := &LogParserPlugin{
FromBeginning: true,
Files: []string{thisdir + "grok/testdata/test_a.log"},
GrokParser: p,
}
acc := testutil.Accumulator{}
acc.SetDebug(true)
assert.NoError(t, logparser.Start(&acc))
time.Sleep(time.Millisecond * 500)
logparser.Stop()
acc.AssertContainsTaggedFields(t, "logparser_grok",
map[string]interface{}{
"clientip": "192.168.1.1",
"myfloat": float64(1.25),
"response_time": int64(5432),
"myint": int64(101),
},
map[string]string{"response_code": "200"})
}
示例3: TestHttpJsonJavaMultiValue
// Test that the proper values are ignored or collected for class=Java
func TestHttpJsonJavaMultiValue(t *testing.T) {
cassandra := genJolokiaClientStub(validJavaMultiValueJSON, 200,
MultipleServers, []string{HeapMetric})
var acc testutil.Accumulator
acc.SetDebug(true)
err := cassandra.Gather(&acc)
assert.Nil(t, err)
assert.Equal(t, 2, len(acc.Metrics))
fields := map[string]interface{}{
"HeapMemoryUsage_init": 67108864.0,
"HeapMemoryUsage_committed": 456130560.0,
"HeapMemoryUsage_max": 477626368.0,
"HeapMemoryUsage_used": 203288528.0,
}
tags1 := map[string]string{
"cassandra_host": "10.10.10.10",
"mname": "HeapMemoryUsage",
}
tags2 := map[string]string{
"cassandra_host": "10.10.10.11",
"mname": "HeapMemoryUsage",
}
acc.AssertContainsTaggedFields(t, "javaMemory", fields, tags1)
acc.AssertContainsTaggedFields(t, "javaMemory", fields, tags2)
}
示例4: TestHttpJsonOn404
// Test that the proper values are ignored or collected
func TestHttpJsonOn404(t *testing.T) {
jolokia := genJolokiaClientStub(validMultiValueJSON, 404, Servers,
[]Metric{UsedHeapMetric})
var acc testutil.Accumulator
acc.SetDebug(true)
err := jolokia.Gather(&acc)
assert.Nil(t, err)
assert.Equal(t, 0, len(acc.Metrics))
}
示例5: TestHttpJsonCassandraNestedMultiValue
// Test that the proper values are ignored or collected for class=Cassandra with
// nested values
func TestHttpJsonCassandraNestedMultiValue(t *testing.T) {
cassandra := genJolokiaClientStub(validCassandraNestedMultiValueJSON, 200, Servers, []string{NestedReadLatencyMetric})
var acc testutil.Accumulator
acc.SetDebug(true)
err := cassandra.Gather(&acc)
assert.Nil(t, err)
assert.Equal(t, 2, len(acc.Metrics))
fields1 := map[string]interface{}{
"ReadLatency_999thPercentile": 1.0,
"ReadLatency_Count": 100.0,
"ReadLatency_DurationUnit": "microseconds",
"ReadLatency_OneMinuteRate": 1.0,
"ReadLatency_RateUnit": "events/second",
}
fields2 := map[string]interface{}{
"ReadLatency_999thPercentile": 2.0,
"ReadLatency_Count": 200.0,
"ReadLatency_DurationUnit": "microseconds",
"ReadLatency_OneMinuteRate": 2.0,
"ReadLatency_RateUnit": "events/second",
}
tags1 := map[string]string{
"cassandra_host": "10.10.10.10",
"mname": "ReadLatency",
"keyspace": "test_keyspace1",
"scope": "test_table1",
}
tags2 := map[string]string{
"cassandra_host": "10.10.10.10",
"mname": "ReadLatency",
"keyspace": "test_keyspace2",
"scope": "test_table2",
}
acc.AssertContainsTaggedFields(t, "cassandraTable", fields1, tags1)
acc.AssertContainsTaggedFields(t, "cassandraTable", fields2, tags2)
}
示例6: TestHttpJsonJavaMultiType
func TestHttpJsonJavaMultiType(t *testing.T) {
cassandra := genJolokiaClientStub(validJavaMultiTypeJSON, 200, AuthServers, []string{GarbageCollectorMetric1, GarbageCollectorMetric2})
var acc testutil.Accumulator
acc.SetDebug(true)
err := cassandra.Gather(&acc)
assert.Nil(t, err)
assert.Equal(t, 2, len(acc.Metrics))
fields := map[string]interface{}{
"CollectionCount": 1.0,
}
tags := map[string]string{
"cassandra_host": "10.10.10.10",
"mname": "ConcurrentMarkSweep",
}
acc.AssertContainsTaggedFields(t, "javaGarbageCollector", fields, tags)
}
示例7: TestGather
func TestGather(t *testing.T) {
mockServer, err := mockTwemproxyServer()
if err != nil {
panic(err)
}
defer mockServer.Close()
twemproxy := &Twemproxy{
Addr: sampleAddr,
Pools: []string{"demo"},
}
var acc testutil.Accumulator
acc.SetDebug(true)
err = twemproxy.Gather(&acc)
require.NoError(t, err)
var sourceData map[string]interface{}
if err := json.Unmarshal([]byte(sampleStats), &sourceData); err != nil {
panic(err)
}
fields := map[string]interface{}{
"total_connections": float64(276448),
"curr_connections": float64(1322),
"timestamp": float64(1.447312436e+09),
}
tags := map[string]string{
"twemproxy": sampleAddr,
"source": sourceData["source"].(string),
}
acc.AssertContainsTaggedFields(t, "twemproxy", fields, tags)
poolName := "demo"
poolFields := map[string]interface{}{
"client_connections": float64(1305),
"client_eof": float64(126813),
"client_err": float64(147942),
"forward_error": float64(11684),
"fragments": float64(0),
"server_ejects": float64(0),
}
tags["pool"] = poolName
acc.AssertContainsTaggedFields(t, "twemproxy_pool", poolFields, tags)
poolServerTags1 := map[string]string{
"pool": "demo",
"server": "10.16.29.2:6379",
"source": "server1.website.com",
"twemproxy": "127.0.0.1:22222",
}
poolServerFields1 := map[string]interface{}{
"in_queue": float64(0),
"in_queue_bytes": float64(0),
"out_queue": float64(0),
"out_queue_bytes": float64(0),
"request_bytes": float64(2.412114759e+09),
"requests": float64(3.7870211e+07),
"response_bytes": float64(5.228980582e+09),
"responses": float64(3.7869551e+07),
"server_connections": float64(1),
"server_ejected_at": float64(0),
"server_eof": float64(0),
"server_err": float64(0),
"server_timedout": float64(25),
}
acc.AssertContainsTaggedFields(t, "twemproxy_pool_server",
poolServerFields1, poolServerTags1)
poolServerTags2 := map[string]string{
"pool": "demo",
"server": "10.16.29.1:6379",
"source": "server1.website.com",
"twemproxy": "127.0.0.1:22222",
}
poolServerFields2 := map[string]interface{}{
"in_queue": float64(0),
"in_queue_bytes": float64(0),
"out_queue": float64(0),
"out_queue_bytes": float64(0),
"request_bytes": float64(2.7758404e+09),
"requests": float64(4.3604566e+07),
"response_bytes": float64(7.663182096e+09),
"responses": float64(4.36039e+07),
"server_connections": float64(1),
"server_ejected_at": float64(0),
"server_eof": float64(0),
"server_err": float64(0),
"server_timedout": float64(24),
}
acc.AssertContainsTaggedFields(t, "twemproxy_pool_server",
poolServerFields2, poolServerTags2)
}