Exemplo n.º 1
0
// NewExternalSinkManager returns an external sink manager that will manage pushing data to all
// the sinks in 'externalSinks', which is a map of sink name to ExternalSink object.
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_old.NewDecoder()
	return &externalSinkManager{
		externalSinks: externalSinks,
		decoder:       decoder,
	}, nil
}
Exemplo n.º 2
0
func supportedMetricsDescriptors() []sink_api.MetricDescriptor {
	// 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)
	}
	return descriptors
}
Exemplo n.º 3
0
func (self *externalSinkManager) DebugInfo() string {
	desc := "External Sinks\n"

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

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

	return desc
}
Exemplo n.º 4
0
func (self *externalSinkManager) DebugInfo() string {
	b := &bytes.Buffer{}
	fmt.Fprintln(b, "External Sinks")

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

	// Add labels being used.
	fmt.Fprintln(b, "\tExported labels:")
	for _, label := range sink_api.SupportedLabels() {
		fmt.Fprintf(b, "\t\t%s: %s\n", label.Key, label.Description)
	}
	fmt.Fprintln(b, "\tExternal Sinks:")
	self.sinkMutex.RLock()
	defer self.sinkMutex.RUnlock()
	for _, externalSink := range self.externalSinks {
		fmt.Fprintf(b, "\t\t%s\n", externalSink.DebugInfo())
	}

	return b.String()
}