Skip to content

Commit

Permalink
Prevent a crash of the wavefront backend
Browse files Browse the repository at this point in the history
This commit prevents a crash of the wavefront backend when the a
TCP connection cannot be established on flush.

Signed-off-by: Brian L. Troutwine <blt@postmates.com>
  • Loading branch information
Brian L. Troutwine committed Jul 13, 2016
1 parent b82e84e commit 977c93c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/backends/wavefront.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,15 @@ impl Wavefront {

impl Backend for Wavefront {
fn flush(&mut self) {
debug!("wavefront flush");
let stats = self.format_stats(None);
debug!("wavefront - {}", stats);
self.points.clear();
let mut stream = TcpStream::connect(self.addr).unwrap();
let _ = stream.write(stats.as_bytes());
let res = TcpStream::connect(self.addr);
if res.is_ok() {
let mut stream = res.unwrap();
debug!("wavefront flush");
let stats = self.format_stats(None);
debug!("wavefront - {}", stats);
self.points.clear();
let _ = stream.write(stats.as_bytes());
}
}

fn deliver(&mut self, point: Rc<Metric>) {
Expand Down

0 comments on commit 977c93c

Please sign in to comment.