Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to read active plugins? #1115

Open
KrohnicDev opened this issue Sep 11, 2024 · 5 comments
Open

Is there a way to read active plugins? #1115

KrohnicDev opened this issue Sep 11, 2024 · 5 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@KrohnicDev
Copy link

KrohnicDev commented Sep 11, 2024

Hi! I would like to read programmatically what plugins are active when wrapperPlugins property is not explicitly set, i.e. what are the default plugins. Is there an API for that?

@sergiyvamz
Copy link
Contributor

Hi @KrohnicDev

Thank you for reaching out! Unfortunately there's no API that can help you to read a list of active plugins. Plugins are loaded based on wrapperPlugins property. Is property isn't specified then default plugins are loaded.

protected static final String DEFAULT_PLUGINS = "auroraConnectionTracker,failover,efm2";

Would you be able to provide a brief description on the issue you're trying to solve by getting a list of active plugins? Thank you!

@KrohnicDev
Copy link
Author

I would like to print what plugins are active on startup AND allow use of default plugins. Currently there is no way to do both. If you want to print active plugins, you have to set them explicitly.

@sergiyvamz
Copy link
Contributor

Hi @KrohnicDev

There's a logging of a loaded and rearranged plugins. It's a list of effective plugins that takes into account wrapperPlugins configuration parameter, plugin factories from configuration profiles and various internal defaults. You might find it useful.

2024-09-06T16:42:27.5383755Z         [2024-09-06 16:42:27.464] [FINEST ] [Test worker] [software.amazon.jdbc.ConnectionPluginChainBuilder getPlugins] : Plugins order has been rearranged. The following order is in effect: AuroraConnectionTrackerPluginFactory, FailoverConnectionPluginFactory, HostMonitoringConnectionPluginFactory  

@sergiyvamz sergiyvamz added enhancement New feature or request question Further information is requested labels Oct 10, 2024
@KrohnicDev
Copy link
Author

KrohnicDev commented Oct 11, 2024

Thanks. I also have a use case where I would like to execute some logic based on whether efm/efm2 plugin is active. Based on this discussion, I assume that it's currently not possible. Could you please confirm?

@sergiyvamz
Copy link
Contributor

Hi @KrohnicDev

I think you can use the following workaround to check whether particular plugin is loaded. The idea is described here:

https://github.com/aws/aws-advanced-jdbc-wrapper/blob/main/docs/using-the-jdbc-driver/using-plugins/UsingTheDeveloperPlugin.md

The code example provided on that page shows how to use unwrap() method on a database connection to access ExceptionSimulator (that is implemented by Developer Plugin). You can use the same approach to get a reference to efm/efm2 plugin instance loaded for a connection. You can use the following classes as a parameter to unwrap() method.

software.amazon.jdbc.plugin.efm.HostMonitoringConnectionPlugin
software.amazon.jdbc.plugin.efm2.HostMonitoringConnectionPlugin

Please pat attention that unwrap() raises a SQLException if plugin is not presented/loaded for a particular connection.

I hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants