Search in sources :

Example 1 with BrowserMonitoringConfig

use of com.newrelic.agent.config.BrowserMonitoringConfig in project newrelic-java-agent by newrelic.

the class RPMService method getSettings.

private Map<String, Object> getSettings(boolean sendEnvironmentInfo) {
    Map<String, Object> settings = new HashMap<>();
    if (sendEnvironmentInfo) {
        Map<String, Object> localSettings = ServiceFactory.getConfigService().getSanitizedLocalSettings();
        Map<String, Object> systemProperties = SystemPropertyFactory.getSystemPropertyProvider().getNewRelicPropertiesWithoutPrefix();
        Map<String, Object> envVars = SystemPropertyFactory.getSystemPropertyProvider().getNewRelicEnvVarsWithoutPrefix();
        settings.putAll(localSettings);
        if (!systemProperties.isEmpty()) {
            settings.put("system", systemProperties);
            for (Map.Entry<String, Object> entry : systemProperties.entrySet()) {
                AgentConfigFactory.addSimpleMappedProperty(entry.getKey(), entry.getValue(), settings);
            }
        }
        if (!envVars.isEmpty()) {
            settings.put("environment", envVars);
        }
        settings.putAll(envVars);
        // add the RUM configuration values
        BrowserMonitoringConfig browserConfig = ServiceFactory.getConfigService().getAgentConfig(appName).getBrowserMonitoringConfig();
        settings.put(AgentConfigImpl.BROWSER_MONITORING + "." + BrowserMonitoringConfigImpl.LOADER_TYPE, browserConfig.getLoaderType());
        settings.put(AgentConfigImpl.BROWSER_MONITORING + "." + BrowserMonitoringConfigImpl.DEBUG, browserConfig.isDebug());
    }
    // Always send the services configuration as RPM thread profiler depends on it.
    String buildDate = AgentJarHelper.getBuildDate();
    if (buildDate != null) {
        settings.put("build_date", buildDate);
    }
    settings.put("services", ServiceFactory.getServicesConfiguration());
    return settings;
}
Also used : BrowserMonitoringConfig(com.newrelic.agent.config.BrowserMonitoringConfig) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with BrowserMonitoringConfig

use of com.newrelic.agent.config.BrowserMonitoringConfig in project newrelic-java-agent by newrelic.

the class BrowserTransactionStateTest method mockMultipleFootersTest.

private BrowserTransactionState mockMultipleFootersTest(boolean allowMultipleFooters) {
    PriorityTransactionName ptn = PriorityTransactionName.create("/en/betting/Football", null, TransactionNamePriority.CUSTOM_HIGH);
    AgentConfig agentConfig = Mockito.mock(AgentConfig.class);
    BrowserMonitoringConfig bmConfig = Mockito.mock(BrowserMonitoringConfig.class);
    Mockito.when(bmConfig.isAllowMultipleFooters()).thenReturn(allowMultipleFooters);
    Mockito.when(agentConfig.getBrowserMonitoringConfig()).thenReturn(bmConfig);
    Mockito.when(tx.isInProgress()).thenReturn(true);
    Mockito.when(tx.isIgnore()).thenReturn(false);
    Mockito.when(tx.getApplicationName()).thenReturn("Test");
    Mockito.when(tx.getPriorityTransactionName()).thenReturn(ptn);
    Mockito.when(tx.getAgentConfig()).thenReturn(agentConfig);
    Mockito.doNothing().when(tx).freezeTransactionName();
    long durationInNanos = TimeUnit.NANOSECONDS.convert(200L, TimeUnit.MILLISECONDS);
    Mockito.when(tx.getRunningDurationInNanos()).thenReturn(durationInNanos);
    final BrowserConfig bConfig = Mockito.mock(BrowserConfig.class);
    BrowserTransactionState bts = new BrowserTransactionStateImpl(tx) {

        @Override
        protected BrowserConfig getBeaconConfig() {
            return bConfig;
        }
    };
    Mockito.when(bConfig.getBrowserTimingHeader()).thenReturn("header");
    Mockito.when(bConfig.getBrowserTimingFooter(bts)).thenReturn("footer");
    Mockito.when(bConfig.getBrowserTimingFooter(eq(bts), anyString())).thenReturn("footerWithNonce");
    return bts;
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) BrowserMonitoringConfig(com.newrelic.agent.config.BrowserMonitoringConfig) PriorityTransactionName(com.newrelic.agent.transaction.PriorityTransactionName)

Aggregations

BrowserMonitoringConfig (com.newrelic.agent.config.BrowserMonitoringConfig)2 AgentConfig (com.newrelic.agent.config.AgentConfig)1 PriorityTransactionName (com.newrelic.agent.transaction.PriorityTransactionName)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1