How to dynamically turn on/off XRay tracing?

Hi all!
According to XRay whitepaper (“XRay: A Function Call Tracing System”), XRay tracing can be turned on and off dynamically without having to restart the server.

However, I only found that we can use the XRAY_OPTIONS environment variable to enable or disable XRay at application start.
Is there any way to turn on/off dynamically without having to restart the server?

Xu Mingjie @ ByteDance

The _xray* functions described in can trigger patching, unpatching, mode changes, etc.

“If you choose to not use the default logging implementation that comes with the XRay runtime and/or control when/how the XRay instrumentation runs, you may use the XRay APIs directly for doing so.

If all you need is runtime control over which functions are being traced at any given time it is better to selectively patch and unpatch the individual functions you need using the XRay Runtime Library’s __xray_patch_function() method.”