Search in sources :

Example 1 with ConnectionListener

use of com.newrelic.agent.ConnectionListener in project newrelic-java-agent by newrelic.

the class NormalizedTransactionTrace method setUrlRules.

private String setUrlRules(JSONArray rules) {
    MockRPMServiceManager rpmServiceManager = (MockRPMServiceManager) ServiceFactory.getRPMServiceManager();
    List<ConnectionListener> connectionListeners = rpmServiceManager.getConnectionListeners();
    ConnectionListener connectionListener = connectionListeners.get(0);
    MockRPMService rpmService = (MockRPMService) rpmServiceManager.getRPMService();
    String appName = rpmService.getApplicationName();
    Map<String, Object> data = new HashMap<>();
    data.put(NormalizationRuleConfig.METRIC_NAME_RULES_KEY, rules);
    connectionListener.connected(rpmService, AgentConfigImpl.createAgentConfig(data));
    return appName;
}
Also used : HashMap(java.util.HashMap) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) JSONObject(org.json.simple.JSONObject) ConnectionListener(com.newrelic.agent.ConnectionListener) MockRPMService(com.newrelic.agent.MockRPMService)

Example 2 with ConnectionListener

use of com.newrelic.agent.ConnectionListener in project newrelic-java-agent by newrelic.

the class MetricNormalizerTest method setUrlRules.

private String setUrlRules(JSONArray rules) {
    MockRPMServiceManager rpmServiceManager = (MockRPMServiceManager) ServiceFactory.getRPMServiceManager();
    List<ConnectionListener> connectionListeners = rpmServiceManager.getConnectionListeners();
    ConnectionListener connectionListener = connectionListeners.get(0);
    MockRPMService rpmService = (MockRPMService) rpmServiceManager.getRPMService();
    String appName = rpmService.getApplicationName();
    Map<String, Object> data = new HashMap<>();
    data.put(NormalizationRuleConfig.URL_RULES_KEY, rules);
    // add a bogus segment term rule to make sure that has no side-effect of breaking stuff
    data.put("transaction_segment_terms", Arrays.asList(ImmutableMap.of("prefix", "This/Wont/Match/Anything", "terms", Arrays.asList("of", "endearment"))));
    connectionListener.connected(rpmService, AgentConfigImpl.createAgentConfig(data));
    return appName;
}
Also used : HashMap(java.util.HashMap) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) JSONObject(org.json.simple.JSONObject) ConnectionListener(com.newrelic.agent.ConnectionListener) MockRPMService(com.newrelic.agent.MockRPMService)

Example 3 with ConnectionListener

use of com.newrelic.agent.ConnectionListener in project newrelic-java-agent by newrelic.

the class TransactionNamingTest method setUrlRules.

private String setUrlRules(JSONArray urlRules) {
    MockRPMServiceManager rpmServiceManager = (MockRPMServiceManager) ServiceFactory.getRPMServiceManager();
    List<ConnectionListener> connectionListeners = rpmServiceManager.getConnectionListeners();
    ConnectionListener connectionListener = connectionListeners.get(0);
    MockRPMService rpmService = (MockRPMService) rpmServiceManager.getRPMService();
    String appName = rpmService.getApplicationName();
    Map<String, Object> data = new HashMap<>();
    data.put(NormalizationRuleConfig.URL_RULES_KEY, urlRules);
    connectionListener.connected(rpmService, AgentConfigImpl.createAgentConfig(data));
    return appName;
}
Also used : HashMap(java.util.HashMap) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) JSONObject(org.json.simple.JSONObject) ConnectionListener(com.newrelic.agent.ConnectionListener) MockRPMService(com.newrelic.agent.MockRPMService)

Example 4 with ConnectionListener

use of com.newrelic.agent.ConnectionListener in project newrelic-java-agent by newrelic.

the class TransactionNamingTest method setTransactionRules.

private String setTransactionRules(JSONArray metricRules) {
    MockRPMServiceManager rpmServiceManager = (MockRPMServiceManager) ServiceFactory.getRPMServiceManager();
    List<ConnectionListener> connectionListeners = rpmServiceManager.getConnectionListeners();
    ConnectionListener connectionListener = connectionListeners.get(0);
    MockRPMService rpmService = (MockRPMService) rpmServiceManager.getRPMService();
    String appName = rpmService.getApplicationName();
    Map<String, Object> data = new HashMap<>();
    data.put(NormalizationRuleConfig.TRANSACTION_NAME_RULES_KEY, metricRules);
    connectionListener.connected(rpmService, AgentConfigImpl.createAgentConfig(data));
    return appName;
}
Also used : HashMap(java.util.HashMap) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) JSONObject(org.json.simple.JSONObject) ConnectionListener(com.newrelic.agent.ConnectionListener) MockRPMService(com.newrelic.agent.MockRPMService)

Aggregations

ConnectionListener (com.newrelic.agent.ConnectionListener)4 MockRPMService (com.newrelic.agent.MockRPMService)4 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)4 HashMap (java.util.HashMap)4 JSONObject (org.json.simple.JSONObject)4