Currently it doesn’t make a difference, each time Telegraf runs your program it buffers the entire stdout and parses it after the program exits.
However, I still recommend doing the former if possible. If we decide to optimize the exec plugin in the future it will continue to work in the best way possible and uses the least amount of memory in your program and is probably faster. Also, it is the easiest to write and debug.