log to influx once (#1438)
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							d8d8f0bfc8
						
					
				
				
					commit
					9350619afa
				
			@@ -72,7 +72,6 @@ impl Counter {
 | 
			
		||||
            self.lograte.store(lograte, Ordering::Relaxed);
 | 
			
		||||
        }
 | 
			
		||||
        if times % lograte == 0 && times > 0 {
 | 
			
		||||
            let lastlog = self.lastlog.load(Ordering::Relaxed);
 | 
			
		||||
            info!(
 | 
			
		||||
                "COUNTER:{{\"name\": \"{}\", \"counts\": {}, \"samples\": {},  \"now\": {}, \"events\": {}}}",
 | 
			
		||||
                self.name,
 | 
			
		||||
@@ -81,6 +80,12 @@ impl Counter {
 | 
			
		||||
                timing::timestamp(),
 | 
			
		||||
                events,
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            let lastlog = self.lastlog.load(Ordering::Relaxed);
 | 
			
		||||
            let prev = self
 | 
			
		||||
                .lastlog
 | 
			
		||||
                .compare_and_swap(lastlog, counts, Ordering::Relaxed);
 | 
			
		||||
            if prev == lastlog {
 | 
			
		||||
                metrics::submit(
 | 
			
		||||
                    influxdb::Point::new(&format!("counter-{}", self.name))
 | 
			
		||||
                        .add_field(
 | 
			
		||||
@@ -88,8 +93,7 @@ impl Counter {
 | 
			
		||||
                            influxdb::Value::Integer(counts as i64 - lastlog as i64),
 | 
			
		||||
                        ).to_owned(),
 | 
			
		||||
                );
 | 
			
		||||
            self.lastlog
 | 
			
		||||
                .compare_and_swap(lastlog, counts, Ordering::Relaxed);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user