예제 #1
0
func newExternalSinkManager(externalSinks []sink_api.ExternalSink) (ExternalSinkManager, error) {
	// Get supported metrics.
	supportedMetrics := sink_api.SupportedStatMetrics()
	for i := range supportedMetrics {
		supportedMetrics[i].Labels = sink_api.SupportedLabels()
	}

	// Create the metrics.
	descriptors := make([]sink_api.MetricDescriptor, 0, len(supportedMetrics))
	for _, supported := range supportedMetrics {
		descriptors = append(descriptors, supported.MetricDescriptor)
	}

	for _, externalSink := range externalSinks {
		err := externalSink.Register(descriptors)
		if err != nil {
			return nil, err
		}
	}
	decoder := sink_api.NewDecoder()
	return &externalSinkManager{
		externalSinks: externalSinks,
		decoder:       decoder,
	}, nil
}
예제 #2
0
func queryInfluxDB(t *testing.T, client *influxdb.Client) {
	var series []*influxdb.Series
	var err error
	success := false
	for i := 0; i < maxInfluxdbRetries; i++ {
		if series, err = client.Query("list series", influxdb.Second); err == nil {
			glog.V(1).Infof("query:' list series' - output %+v from influxdb", series[0].Points)
			if len(series[0].Points) >= (len(sink_api.SupportedStatMetrics()) - 1) {
				success = true
				break
			}
		}
		glog.V(2).Infof("influxdb test case failed. Retrying")
		time.Sleep(30 * time.Second)
	}
	require.NoError(t, err, "failed to list series in Influxdb")
	require.True(t, success, "list series test case failed.")
}
예제 #3
0
func (self *externalSinkManager) DebugInfo() string {
	desc := "External Sinks\n"

	// Add metrics being exported.
	desc += "\tExported metrics:"
	for _, supported := range sink_api.SupportedStatMetrics() {
		desc += fmt.Sprintf("\t\t%s: %s", supported.Name, supported.Description)
	}

	// Add labels being used.
	desc += "\tExported labels:"
	for _, label := range sink_api.SupportedLabels() {
		desc += fmt.Sprintf("\t\t%s: %s", label.Key, label.Description)
	}
	desc += "\n\tExternal Sinks:"
	for _, externalSink := range self.externalSinks {
		desc += fmt.Sprintf("\n\t\t%s", externalSink.DebugInfo())
	}

	return desc
}