add in support for generating auto_discovery.json and fix the error when sending metrics - this is undefined within the exec callback and so have to use self