Ejemplo n.º 1
0
  @Test
  public void mysqlParse1() {

    DatabaseInfo dbInfo =
        jdbcUrlParser.parse(
            "jdbc:mysql://ip_address:3306/database_name?useUnicode=yes&characterEncoding=UTF-8");
    Assert.assertEquals(dbInfo.getType(), MySqlConstants.MYSQL);
    Assert.assertEquals(dbInfo.getHost().get(0), ("ip_address:3306"));
    Assert.assertEquals(dbInfo.getDatabaseId(), "database_name");
    Assert.assertEquals(dbInfo.getUrl(), "jdbc:mysql://ip_address:3306/database_name");
  }
  @Override
  protected void doInAfterTrace(
      SpanEventRecorder recorder,
      Object target,
      Object[] args,
      Object result,
      Throwable throwable) {
    DatabaseInfo databaseInfo = databaseInfoAccessor.get(target, UnKnownDatabaseInfo.INSTANCE);

    recorder.recordServiceType(databaseInfo.getType());
    recorder.recordEndPoint(databaseInfo.getMultipleHost());
    recorder.recordDestinationId(databaseInfo.getDatabaseId());

    recorder.recordApi(methodDescriptor, args);
    recorder.recordException(throwable);
  }
Ejemplo n.º 3
0
  @Test
  public void mysqlParse2() {

    DatabaseInfo dbInfo = jdbcUrlParser.parse("jdbc:mysql://10.98.133.22:3306/test_lucy_db");
    Assert.assertEquals(dbInfo.getType(), MySqlConstants.MYSQL);
    Assert.assertEquals(dbInfo.getHost().get(0), "10.98.133.22:3306");

    Assert.assertEquals(dbInfo.getDatabaseId(), "test_lucy_db");
    Assert.assertEquals(dbInfo.getUrl(), "jdbc:mysql://10.98.133.22:3306/test_lucy_db");
    logger.info(dbInfo.toString());
    logger.info(dbInfo.getMultipleHost());
  }
Ejemplo n.º 4
0
 @Test
 public void mysqlParseCookierunMaster() {
   DatabaseInfo dbInfo =
       jdbcUrlParser.parse(
           "jdbc:mysql://10.115.8.209:5605/db_cookierun?useUnicode=true&characterEncoding=UTF-8&noAccessToProcedureBodies=true&autoDeserialize=true&elideSetAutoCommits=true&sessionVariables=time_zone='%2B09:00',tx_isolation='READ-COMMITTED'");
   Assert.assertEquals(dbInfo.getType(), MySqlConstants.MYSQL);
   Assert.assertEquals(dbInfo.getHost().get(0), "10.115.8.209:5605");
   Assert.assertEquals(dbInfo.getDatabaseId(), "db_cookierun");
   Assert.assertEquals(dbInfo.getUrl(), "jdbc:mysql://10.115.8.209:5605/db_cookierun");
   logger.info(dbInfo.toString());
 }
Ejemplo n.º 5
0
 @Test
 public void mysqlParse3() {
   DatabaseInfo dbInfo =
       jdbcUrlParser.parse(
           "jdbc:mysql://61.74.71.31/log?useUnicode=yes&characterEncoding=UTF-8");
   Assert.assertEquals(dbInfo.getType(), MySqlConstants.MYSQL);
   Assert.assertEquals(dbInfo.getHost().get(0), "61.74.71.31");
   Assert.assertEquals(dbInfo.getDatabaseId(), "log");
   Assert.assertEquals(dbInfo.getUrl(), "jdbc:mysql://61.74.71.31/log");
   logger.info(dbInfo.toString());
 }