@Test
  public void testOpenConnectionMetrics() throws Exception {
    CodahaleMetrics metrics = (CodahaleMetrics) MetricsFactory.getInstance();

    TCLIService.Client httpClient = getHttpClient();
    TOpenSessionReq openSessionReq = new TOpenSessionReq();
    TOpenSessionResp tOpenSessionResp = httpClient.OpenSession(openSessionReq);
    // wait a couple of sec to make sure the connection is closed
    TimeUnit.SECONDS.sleep(3);
    verifyConnectionMetrics(metrics.dumpJson(), 0, 1);
    TSessionHandle sessionHandle = tOpenSessionResp.getSessionHandle();

    TCloseSessionReq closeSessionReq = new TCloseSessionReq(sessionHandle);
    httpClient.CloseSession(closeSessionReq);
    TimeUnit.SECONDS.sleep(3);
    verifyConnectionMetrics(metrics.dumpJson(), 0, 2);

    tOpenSessionResp = httpClient.OpenSession(openSessionReq);
    TimeUnit.SECONDS.sleep(3);
    verifyConnectionMetrics(metrics.dumpJson(), 0, 3);
    sessionHandle = tOpenSessionResp.getSessionHandle();

    closeSessionReq = new TCloseSessionReq(sessionHandle);
    httpClient.CloseSession(closeSessionReq);
    TimeUnit.SECONDS.sleep(3);
    verifyConnectionMetrics(metrics.dumpJson(), 0, 4);

  }
Test the connection metrics using an HttpClient, when HS2 is start in http mode.
itests/hive-unit/src/test/java/org/apache/hive/jdbc/miniHS2/TestHs2ConnectionMetricsHttp.java