[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 
if we must use files, we should be using Stud::Temporary.file (or .path), ruby's tempfile is really bad and broken.