Beispiel #1
0
func (n *nerveUWSGICollector) queryService(serviceName string, port int) {
	serviceLog := n.log.WithField("service", serviceName)

	endpoint := fmt.Sprintf("http://localhost:%d/%s", port, n.queryPath)
	serviceLog.Debug("making GET request to ", endpoint)

	rawResponse, schemaVer, err := queryEndpoint(endpoint, n.timeout)
	if err != nil {
		serviceLog.Warn("Failed to query endpoint ", endpoint, ": ", err)
		return
	}
	metrics, err := dropwizard.Parse(rawResponse, schemaVer, n.serviceInWhitelist(serviceName))
	if err != nil {
		serviceLog.Warn("Failed to parse response into metrics: ", err)
		return
	}

	metric.AddToAll(&metrics, map[string]string{
		"service": serviceName,
		"port":    strconv.Itoa(port),
	})
	serviceLog.Debug("Sending ", len(metrics), " to channel")
	for _, m := range metrics {
		n.Channel() <- m
	}
}
Beispiel #2
0
func TestUWSGIResponseConversion(t *testing.T) {
	uwsgiRsp := []byte(getTestUWSGIResponse())

	actual, err := dropwizard.Parse(uwsgiRsp, "", false)

	assert.Nil(t, err)
	validateUWSGIResults(t, actual)
	for _, m := range actual {
		assert.Equal(t, 2, len(m.Dimensions))
	}
}