I would like to have the ability to enable exporters only when needed for troubleshooting. Disabling the agent wouldn't make sense, since the instrumentation should happen when starting the jvm, so my idea is to start my server with disabled exporters like this:
opentelemetry-javaagent.jar -Dotel.traces.exporter=none -Dotel.metrics.exporter=none
and then somehow with JMX we can enable the exporters.
Is there a way to achieve this?
I would suggest that instead of disabling the export, you make a custom sampler. You can have sampling turned off most of the time and enable it as you see fit. This also would avoid the overhead of collecting and processing spans.