Search in sources :

Example 1 with MonitorElementInstance

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

the class DBCPHookProxy 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)

Example 2 with MonitorElementInstance

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

the class MonitorServerUtil method matchClientUrl.

/**
 * 匹配client url对应的MonitorElementInstance
 *
 * @param me
 * @param jdbcURL
 * @param appid
 * @return
 */
public static MonitorElementInstance matchClientUrl(MonitorElement me, String jdbcURL, String appid) {
    jdbcURL = MonitorServerUtil.rewriteURLForLocalHost(jdbcURL);
    String clientId = MonitorServerUtil.getServerHostPort() + "#" + appid + "#" + jdbcURL;
    MonitorElementInstance inst = me.getInstance(clientId);
    return inst;
}
Also used : MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance)

Example 3 with MonitorElementInstance

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

the class MyAppMonitorCounterHandler method doCap.

@Override
public void doCap(MonitorElement elem, CaptureContext context) {
    if ("AppCustomMonitor_Counter".equals(elem.getMonitorElemId())) {
        // count each URL accessing to this servlet
        HttpServletRequest request = context.get(HttpServletRequest.class);
        MonitorElementInstance inst = elem.getInstance(request.getRequestURI());
        inst.increValue("count");
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance)

Example 4 with MonitorElementInstance

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

the class AbsDBPoolHookProxy method matchElemInstance.

/**
 * matchElemInstance
 *
 * @param clientElem
 * @param jdbcURL
 * @return
 */
public MonitorElementInstance matchElemInstance(MonitorElement clientElem, String jdbcURL) {
    jdbcURL = MonitorServerUtil.formatJDBCURL(jdbcURL);
    /**
     * 匹配客户端应用
     */
    MonitorElementInstance inst = MonitorServerUtil.matchClientUrl(clientElem, jdbcURL, appid);
    return inst;
}
Also used : MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance)

Example 5 with MonitorElementInstance

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

the class DruidHookProxy method collectDBPoolMetrics.

@Override
protected void collectDBPoolMetrics(MonitorElement clientElem) {
    Set<DruidDataSource> dsList = DruidDataSourceStatManager.getDruidDataSourceInstances();
    if (dsList == null || dsList.size() == 0) {
        return;
    }
    for (DruidDataSource ds : dsList) {
        String jdbcURL = ds.getRawJdbcUrl();
        /**
         * 匹配客户端应用
         */
        MonitorElementInstance inst = this.matchElemInstance(clientElem, jdbcURL);
        if (inst == null) {
            continue;
        }
        collectDataSourceStat(inst, ds);
    }
}
Also used : MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

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