@Test
  public void testOpenConnectionMetrics() throws Exception {

    CodahaleMetrics metrics = (CodahaleMetrics) MetricsFactory.getInstance();
    String[] beelineArgs = {
        "-u", miniHS2.getBaseJdbcURL() + "default",
        "-n", USERNAME,
        "-p", PASSWORD,
        "-e", "show tables;"};
    BeeLine beeLine = openBeeLineConnection(beelineArgs);

    // wait a couple of sec to make sure the connection is open
    TimeUnit.SECONDS.sleep(3);
    verifyConnectionMetrics(metrics.dumpJson(), 1, 1);
    beeLine.close();
    TimeUnit.SECONDS.sleep(3);
    verifyConnectionMetrics(metrics.dumpJson(), 0, 1);

    beeLine = openBeeLineConnection(beelineArgs);
    TimeUnit.SECONDS.sleep(3);
    verifyConnectionMetrics(metrics.dumpJson(), 1, 2);
    beeLine.close();
    TimeUnit.SECONDS.sleep(3);
    verifyConnectionMetrics(metrics.dumpJson(), 0, 2);


  }
Test the connection metrics using BeeLine client, when HS2 is started in binary mode.
itests/hive-unit/src/test/java/org/apache/hive/jdbc/miniHS2/TestHs2ConnectionMetricsBinary.java