How do I troubleshoot this error in telegraf?

I have a custom python plugin that I am using to pull data into Telegraf. It print out line protocol output, as expected.

In my Ubuntu 18.04 environment, when this plugin is run I see a single line in my logs:

2020-12-28T21:55:00Z E! [inputs.exec] Error in plugin: exec: exit status 1 for command '/my_company/plugins-enabled/plugin-mysystem/': Traceback (most recent call last):...

That is it. I can’t figure out how to get the actual traceback.

If I run sudo -u telegraf /usr/bin/telegraf -config /etc/telegraf/telegraf.conf, the plugin works as expected. It polls and loads data exactly as it should.

I’m not sure how to move forward with troubleshooting this error when telegraf is executing the plugin on it’s own.

I have restarted the telegraf service. I have verified permissions (and I think that the execution above shows that it should work).

What do I do next?

It’s not clear to me where the limitation is, but it does appear to be on the python side rather than the telegraf side. So you might be able to implement a simple exception handler to be more verbose or stringify everything in the trace into a single line to try and get it into the telegraf log file - or you could dump the exception from python within the handler too maybe.
Python doc: traceback — Print or retrieve a stack traceback — Python 3.9.1 documentation