-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Collect execution stats for all JdbcClients #906
Collect execution stats for all JdbcClients #906
Conversation
presto-postgresql/src/main/java/io/prestosql/plugin/postgresql/PostgreSqlClientModule.java
Outdated
Show resolved
Hide resolved
8680ab2
to
a531654
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good overall, but we shouldn't limit it to PostgreSQL. It should also be simpler to expose this for all connectors in the base library.
@Inject | ||
@Provides | ||
@Singleton | ||
public PostgreSqlClient getOracleClient( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misnamed
I think we can do this by adding a binding annotation and provider @Provides
@Singleton
@ForMetadataFactory
public static JdbcClient createJdbcClientWithStats(JdbcClient client)
{
return new StatisticsAwareJdbcClient(client);
} Then do @Inject
public JdbcMetadataFactory(@ForMetadataFactory JdbcClient jdbcClient, JdbcMetadataConfig config)
{
...
} |
a531654
to
2336293
Compare
@electrum Thanks to your comment, I enabled this for all connectors. Here is an example output for postgresql connector (captured with |
btw, worth to notice:
|
The "Do not call ..." commit message title is too long |
Add I'm not sure why we have multiple copies of that. It can probably live in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good. I like the cleanup and injection of ConnectionFactory
. These stats will be very useful for tracking performance issues.
presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/JdbcConnectorFactory.java
Outdated
Show resolved
Hide resolved
presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/guice/InternalBaseJdbc.java
Outdated
Show resolved
Hide resolved
presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/guice/InternalBaseJdbc.java
Outdated
Show resolved
Hide resolved
presto-mysql/src/main/java/io/prestosql/plugin/mysql/MySqlClientModule.java
Outdated
Show resolved
Hide resolved
...e-jdbc/src/main/java/io/prestosql/plugin/jdbc/caching/TransactionScopeCachingJdbcClient.java
Outdated
Show resolved
Hide resolved
...e-jdbc/src/main/java/io/prestosql/plugin/jdbc/caching/TransactionScopeCachingJdbcClient.java
Outdated
Show resolved
Hide resolved
presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/JdbcMetadataFactory.java
Outdated
Show resolved
Hide resolved
presto-phoenix/src/main/java/io/prestosql/plugin/phoenix/PhoenixClientModule.java
Outdated
Show resolved
Hide resolved
9535bf7
to
e191376
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@electrum Comments addressed
presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/JdbcConnectorFactory.java
Outdated
Show resolved
Hide resolved
presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/guice/InternalBaseJdbc.java
Outdated
Show resolved
Hide resolved
presto-mysql/src/main/java/io/prestosql/plugin/mysql/MySqlClient.java
Outdated
Show resolved
Hide resolved
@electrum ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! A few minor comments
</dependency> | ||
|
||
<!-- used by tests but also needed transitively --> | ||
<dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs <scope>runtime</scope>
otherwise the dependency checker will fail as it's not referenced
@@ -100,6 +105,12 @@ | |||
<artifactId>jackson-databind</artifactId> | |||
</dependency> | |||
|
|||
<!-- used by tests but also needed transitively --> | |||
<dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably needs runtime scope
@@ -37,5 +52,19 @@ public void configure(Binder binder) | |||
binder.bind(JdbcPageSinkProvider.class).in(Scopes.SINGLETON); | |||
binder.bind(JdbcConnector.class).in(Scopes.SINGLETON); | |||
configBinder(binder).bindConfig(JdbcMetadataConfig.class); | |||
|
|||
// JMX | |||
install(new MBeanServerModule()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these to JdbcConnectorFactory
. We normally install modules at the top level.
@Override | ||
public List<JdbcColumnHandle> getColumns(ConnectorSession session, JdbcTableHandle tableHandle) | ||
{ | ||
return getColumnsCache.computeIfAbsent(tableHandle, jdbcTableHandle -> super.getColumns(session, jdbcTableHandle)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe shorten lambda variable to handle
. Or make it ignored
and use tableHandle
in the lambda.
public class StatisticsAwareConnectionFactory | ||
implements ConnectionFactory | ||
{ | ||
private final ConnectionFactoryStats stats = new ConnectionFactoryStats(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could simplify this by inlining the stats fields, since there are only two of them. Up to you.
@@ -83,4 +89,27 @@ public PhoenixConfig setCaseInsensitiveNameMatchingCacheTtl(Duration caseInsensi | |||
this.caseInsensitiveNameMatchingCacheTtl = caseInsensitiveNameMatchingCacheTtl; | |||
return this; | |||
} | |||
|
|||
public Properties getConnectionProperties() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this a private method in PhoenixClientModule
. Config classes should be simple beans.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It cannot be private as it is also used by PhoenixClient
e191376
to
3007059
Compare
- remove redundant parameter - remove redundant throws
3007059
to
9b27daa
Compare
Collect execution stats for PostgresSqlJdbcClient