mirror of
				https://github.com/ClusterCockpit/cc-metric-collector.git
				synced 2025-10-31 09:05:05 +01:00 
			
		
		
		
	Change ccMetric->Influx functions
This commit is contained in:
		| @@ -24,8 +24,8 @@ type ccMetric struct { | |||||||
|  |  | ||||||
| // ccMetric access functions | // ccMetric access functions | ||||||
| type CCMetric interface { | type CCMetric interface { | ||||||
| 	ToPoint(metaAsTags bool) *write.Point  // Generate influxDB point for data type ccMetric | 	ToPoint(metaAsTags map[string]bool) *write.Point  // Generate influxDB point for data type ccMetric | ||||||
| 	ToLineProtocol(metaAsTags bool) string // Generate influxDB line protocol for data type ccMetric | 	ToLineProtocol(metaAsTags map[string]bool) string // Generate influxDB line protocol for data type ccMetric | ||||||
|  |  | ||||||
| 	Name() string        // Get metric name | 	Name() string        // Get metric name | ||||||
| 	SetName(name string) // Set metric name | 	SetName(name string) // Set metric name | ||||||
| @@ -61,25 +61,18 @@ func (m *ccMetric) String() string { | |||||||
| } | } | ||||||
|  |  | ||||||
| // ToLineProtocol generates influxDB line protocol for data type ccMetric | // ToLineProtocol generates influxDB line protocol for data type ccMetric | ||||||
| func (m *ccMetric) ToPoint(metaAsTags bool) (p *write.Point) { | func (m *ccMetric) ToPoint(metaAsTags map[string]bool) (p *write.Point) { | ||||||
|  |  | ||||||
| 	if !metaAsTags { |  | ||||||
| 	p = influxdb2.NewPoint(m.name, m.tags, m.fields, m.tm) | 	p = influxdb2.NewPoint(m.name, m.tags, m.fields, m.tm) | ||||||
| 	} else { | 	for key, ok1 := range metaAsTags { | ||||||
| 		tags := make(map[string]string, len(m.tags)+len(m.meta)) | 		if val, ok2 := m.GetMeta(key); ok1 && ok2 { | ||||||
| 		for key, value := range m.tags { | 			p.AddTag(key, val) | ||||||
| 			tags[key] = value |  | ||||||
| 		} | 		} | ||||||
| 		for key, value := range m.meta { |  | ||||||
| 			tags[key] = value |  | ||||||
| 	} | 	} | ||||||
| 		p = influxdb2.NewPoint(m.name, tags, m.fields, m.tm) | 	return p | ||||||
| 	} |  | ||||||
| 	return |  | ||||||
| } | } | ||||||
|  |  | ||||||
| // ToLineProtocol generates influxDB line protocol for data type ccMetric | // ToLineProtocol generates influxDB line protocol for data type ccMetric | ||||||
| func (m *ccMetric) ToLineProtocol(metaAsTags bool) string { | func (m *ccMetric) ToLineProtocol(metaAsTags map[string]bool) string { | ||||||
|  |  | ||||||
| 	return write.PointToLineProtocol( | 	return write.PointToLineProtocol( | ||||||
| 		m.ToPoint(metaAsTags), | 		m.ToPoint(metaAsTags), | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user