当前位置: 首页>>代码示例>>Golang>>正文


Golang Accumulator.SetDebug方法代码示例

本文整理汇总了Golang中github.com/ronaldslc/telegraf/testutil.Accumulator.SetDebug方法的典型用法代码示例。如果您正苦于以下问题:Golang Accumulator.SetDebug方法的具体用法?Golang Accumulator.SetDebug怎么用?Golang Accumulator.SetDebug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/ronaldslc/telegraf/testutil.Accumulator的用法示例。


在下文中一共展示了Accumulator.SetDebug方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
	}
}
开发者ID:ronaldslc,项目名称:telegraf,代码行数:27,代码来源:leofs_test.go

示例2: 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.Points))
}
开发者ID:ronaldslc,项目名称:telegraf,代码行数:13,代码来源:jolokia_test.go

示例3: 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)
}
开发者ID:ronaldslc,项目名称:telegraf,代码行数:93,代码来源:twemproxy_test.go


注:本文中的github.com/ronaldslc/telegraf/testutil.Accumulator.SetDebug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。