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
Fix stats collection for JDBC based connector #3479
Conversation
@@ -58,21 +58,19 @@ public void configure(Binder binder) | |||
@StatsCollecting | |||
public JdbcClient createJdbcClientWithStats(@ForBaseJdbc JdbcClient client) | |||
{ | |||
StatisticsAwareJdbcClient statisticsAwareJdbcClient = new StatisticsAwareJdbcClient(client); |
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.
What was wrong?
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 looks like StatisticsAwareJdbcClient#getStats
is not exposed in JMX so the actual stats are not exposed
Before
Column | Type | Extra | Comment
-------------+---------+-------+---------
node | varchar | |
object_name | varchar | |
After
Column | Type | Extra | Comment
---------------------------------------------------------+---------+-------+---------
abortreadconnection.failures.fifteenminute.count | double | |
abortreadconnection.failures.fifteenminute.rate | double | |
abortreadconnection.failures.fiveminute.count | double | |
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.
Can you please add a test for that?
Or even better it would be to add a trap for things like that. Do you exact reasaon why stats were not exposed? Like not allowing to use newExporter
when bean does not expose method with @Managed
?
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 didn't work because the StatisticsAwareJdbcClient
instance was not a bean (never exposed at guice DI level) and so it could not get exported.
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.
Stats do not get exposed automatically, we expose them using newExporter(..)...
. This code was called but StatisticsAwareJdbcClient
was wrapped so annotated methods with @Managed
were not accessible. It would be nice to have something to prevent such bugs.
please
as this remains fragile still, can we have a test for this? |
00437cb
to
f7f9097
Compare
@findepi Thanks for your feedback and for the commit message.
This might break DI there by JdbcClient might not be injected in |
f7f9097
to
615dc3c
Compare
you're right |
615dc3c
to
71d8546
Compare
@@ -26,7 +26,7 @@ | |||
|
|||
import static java.lang.String.format; | |||
|
|||
class TestingH2JdbcModule | |||
public class TestingH2JdbcModule |
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.
Why?
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.
Previously it was package protected so we cant access in our JmxTest or we have to move JmxTest to a different package
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.
Please move JmxTest
to different package. I don't think we need separate package for single test, do we? Otherwise please squash commits.
{ | ||
@Test | ||
public void testJmxStatsExposure() | ||
throws MalformedObjectNameException, IntrospectionException, InstanceNotFoundException, ReflectionException |
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.
just throws Exception
?
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.
Modified
ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories()); | ||
factory.create("test", ImmutableMap.of("connection-url", "jdbc"), new TestingConnectorContext()); | ||
MBeanServer mbeanServer = getPlatformMBeanServer(); | ||
for (String domainName : mbeanServer.getDomains()) { |
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.
Please remove this for
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.
Removed it
} | ||
for (ObjectName objectName : mbeanServer.queryNames(new ObjectName("io.prestosql.plugin.jdbc:*"), null)) { | ||
MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(objectName); | ||
assertFalse(Arrays.isNullOrEmpty(mbeanInfo.getAttributes()), format("Object %s doesn't expose JMX stats", objectName.getCanonicalName())); |
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.
static import
presto-base-jdbc/src/test/java/io/prestosql/plugin/jdbc/jmx/TestJmxStats.java
Outdated
Show resolved
Hide resolved
71d8546
to
4715184
Compare
@kokosing Thanks for your feedback. Have applied your comments |
@@ -26,7 +26,7 @@ | |||
|
|||
import static java.lang.String.format; | |||
|
|||
class TestingH2JdbcModule | |||
public class TestingH2JdbcModule |
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.
Please move JmxTest
to different package. I don't think we need separate package for single test, do we? Otherwise please squash commits.
ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories()); | ||
factory.create("test", ImmutableMap.of("connection-url", "jdbc"), new TestingConnectorContext()); | ||
MBeanServer mbeanServer = getPlatformMBeanServer(); | ||
for (ObjectName objectName : mbeanServer.queryNames(new ObjectName("io.prestosql.plugin.jdbc:*"), null)) { |
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.
Please make sure that mbeanServer.queryNames(new ObjectName("io.prestosql.plugin.jdbc:*")
does not return empty list. Also please verify that few that we care of are there (jdbc client and coonnection factory)
0042c39
to
29ad571
Compare
29ad571
to
62f5c1e
Compare
62f5c1e
to
507c64c
Compare
No description provided.