Search in sources :

Example 6 with MonitorElementInstance

use of com.creditease.monitor.captureframework.spi.MonitorElementInstance in project uavstack by uavorg.

the class TomcatJdbcHookProxy method collectDBPoolMetrics.

@Override
protected void collectDBPoolMetrics(MonitorElement clientElem) {
    if (this.datasources.size() == 0) {
        return;
    }
    for (DataSource ds : this.datasources) {
        String jdbcURL = (String) ReflectionHelper.invoke(ds.getClass().getName(), ds, "getUrl", null, null, ds.getClass().getClassLoader());
        /**
         * 匹配客户端应用
         */
        MonitorElementInstance inst = this.matchElemInstance(clientElem, jdbcURL);
        if (inst == null) {
            continue;
        }
        collectDataSourceStat(inst, ds);
    }
}
Also used : MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance) DataSource(javax.sql.DataSource)

Example 7 with MonitorElementInstance

use of com.creditease.monitor.captureframework.spi.MonitorElementInstance in project uavstack by uavorg.

the class ConnectionPoolManagerDelegate method collectDataPools.

/**
 * collectDataPools
 *
 * @param clientElem
 * @param proxy
 */
public void collectDataPools(MonitorElement clientElem, AbsDBPoolHookProxy proxy) {
    ConnectionPool[] cpList = ConnectionPoolManager.getInstance().getConnectionPools();
    if (cpList == null || cpList.length == 0) {
        return;
    }
    for (ConnectionPool cp : cpList) {
        String jdbcURL = cp.getDefinition().getUrl();
        /**
         * 匹配客户端应用
         */
        MonitorElementInstance inst = proxy.matchElemInstance(clientElem, jdbcURL);
        if (inst == null) {
            continue;
        }
        collectDataSourceStat(inst, cp);
    }
}
Also used : MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance)

Example 8 with MonitorElementInstance

use of com.creditease.monitor.captureframework.spi.MonitorElementInstance in project uavstack by uavorg.

the class C3P0HookProxy method collectDBPoolMetrics.

@SuppressWarnings("rawtypes")
@Override
public void collectDBPoolMetrics(MonitorElement clientElem) {
    Set dsList = C3P0Registry.getPooledDataSources();
    if (dsList == null || dsList.size() == 0) {
        return;
    }
    /**
     * Step 2: 匹配对应的jdbc url
     */
    for (Object ds : dsList) {
        if (!ComboPooledDataSource.class.isAssignableFrom(ds.getClass())) {
            continue;
        }
        ComboPooledDataSource pds = (ComboPooledDataSource) ds;
        String jdbcURL = pds.getJdbcUrl();
        /**
         * 匹配客户端应用
         */
        MonitorElementInstance inst = this.matchElemInstance(clientElem, jdbcURL);
        if (inst == null) {
            continue;
        }
        collectDataSourceStat(inst, pds);
    }
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) Set(java.util.Set) MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance)

Example 9 with MonitorElementInstance

use of com.creditease.monitor.captureframework.spi.MonitorElementInstance in project uavstack by uavorg.

the class HikariHookProxy method collectDBPoolMetrics.

@Override
protected void collectDBPoolMetrics(MonitorElement clientElem) {
    if (this.datasources.size() == 0) {
        return;
    }
    for (DataSource cp : this.datasources) {
        String jdbcURL = (String) ReflectionHelper.invoke(cp.getClass().getName(), cp, "getJdbcUrl", null, null, cp.getClass().getClassLoader());
        /**
         * ƥ��ͻ���Ӧ��
         */
        MonitorElementInstance inst = this.matchElemInstance(clientElem, jdbcURL);
        if (inst == null) {
            continue;
        }
        collectDataSourceStat(inst, cp);
    }
}
Also used : MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance) DataSource(javax.sql.DataSource)

Example 10 with MonitorElementInstance

use of com.creditease.monitor.captureframework.spi.MonitorElementInstance in project uavstack by uavorg.

the class MybatisHookProxy method collectDBPoolMetrics.

@Override
protected void collectDBPoolMetrics(MonitorElement clientElem) {
    if (this.datasources.size() == 0) {
        return;
    }
    for (DataSource cp : this.datasources) {
        String jdbcURL = (String) ReflectionHelper.invoke(cp.getClass().getName(), cp, "getUrl", null, null, cp.getClass().getClassLoader());
        MonitorElementInstance inst = this.matchElemInstance(clientElem, jdbcURL);
        if (inst == null) {
            continue;
        }
        collectDataSourceStat(inst, cp);
    }
}
Also used : MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance) DataSource(javax.sql.DataSource)

Aggregations

MonitorElementInstance (com.creditease.monitor.captureframework.spi.MonitorElementInstance)16 DataSource (javax.sql.DataSource)4 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)1 StandardMonitorRepository (com.creditease.monitor.captureframework.repository.StandardMonitorRepository)1 MonitorElemCapHandler (com.creditease.monitor.captureframework.spi.MonitorElemCapHandler)1 MonitorElement (com.creditease.monitor.captureframework.spi.MonitorElement)1 MonitorRepository (com.creditease.monitor.captureframework.spi.MonitorRepository)1 ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)1 Set (java.util.Set)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1