func readFromCollector(collector collector.Collector, metrics chan metric.Metric) { for metric := range collector.Channel() { if _, exists := metric.GetDimensionValue("collector"); !exists { metric.AddDimension("collector", collector.Name()) } metrics <- metric } }
func readFromCollector(collector collector.Collector, handlers []handler.Handler) { for metric := range collector.Channel() { var exists bool c := collector.CanonicalName() if _, exists = metric.GetDimensionValue("collector"); !exists { metric.AddDimension("collector", collector.Name()) } // We allow external collectors to provide us their collector's CanonicalName // by sending it as a metric dimension. For example in the case of Diamond the // individual python collectors can send their names this way. if val, ok := metric.GetDimensionValue("collectorCanonicalName"); ok { c = val metric.RemoveDimension("collectorCanonicalName") } for i := range handlers { if _, exists := handlers[i].CollectorChannels()[c]; exists { handlers[i].CollectorChannels()[c] <- metric } } } }