[filter/metrics] Fix flushing in metrics filter

As discovered in #1805, metrics filter is not correctly flushing events

The current spec was calling flush manually not relying on the pipeline periodic_flusher threads, 
here is a proposal test case using the full agent to cover this case + fix to metrics filter based on the changed done to other flushing filters (multiline, spool) in #1545 
also, variables for scope inside tests should use rspec's let:

```
let(:tmp_file) { Stud::Temporary.path }

# and clean up
after do
  File.unlink(tmp_file)
end
```