Search in sources :

Example 1 with UtilizationData

use of com.newrelic.agent.utilization.UtilizationData in project newrelic-java-agent by newrelic.

the class RPMService method getStartOptions.

/**
 * Returns a map of startup options to be sent to RPM when the RPM service connects.
 */
protected Map<String, Object> getStartOptions() {
    AgentConfig agentConfig = ServiceFactory.getConfigService().getAgentConfig(appName);
    int pid = ServiceFactory.getEnvironmentService().getProcessPID();
    Map<String, Object> options = new HashMap<>();
    // options.add(System.getProperty("user.dir"));
    options.put("pid", pid);
    String language = agentConfig.getLanguage();
    options.put("language", language);
    String defaultHost = Hostname.getHostname(agentConfig, true);
    options.put("host", defaultHost);
    String displayHost = Hostname.getDisplayHostname(agentConfig, defaultHost);
    options.put("display_host", displayHost);
    Agent.LOG.log(Level.INFO, "Host name is {0}, display host {1} for application {2}", defaultHost, displayHost, appName);
    options.put("high_security", getAndLogHighSecurity(agentConfig));
    Environment environment = ServiceFactory.getEnvironmentService().getEnvironment();
    options.put("environment", environment);
    options.put("settings", getSettings(agentConfig.getProperty("send_environment_info", true)));
    UtilizationData utilizationData = ServiceFactory.getUtilizationService().updateUtilizationData();
    options.put("utilization", utilizationData.map());
    options.put(AgentConfigFactory.EVENT_HARVEST_CONFIG, ServiceFactory.getHarvestService().getEventDataHarvestLimits());
    String instanceName = environment.getAgentIdentity().getInstanceName();
    if (instanceName != null) {
        options.put("instance_name", instanceName);
    }
    // options.put("framework", "java"); // this belongs in the environment
    // options.put("launch_time",
    // JSON.serializeNumber(TimeConversion.convertMillisToSeconds(System.currentTimeMillis())));
    options.put("agent_version", Agent.getVersion());
    options.put("app_name", appNames);
    StringBuilder identifier = new StringBuilder(language);
    identifier.append(':').append(appName);
    Integer serverPort = environment.getAgentIdentity().getServerPort();
    if (serverPort != null) {
        identifier.append(':').append(serverPort);
    }
    options.put("identifier", identifier.toString());
    options.put("labels", agentConfig.getLabelsConfig());
    return options;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AgentConfig(com.newrelic.agent.config.AgentConfig) HashMap(java.util.HashMap) Environment(com.newrelic.agent.environment.Environment) UtilizationData(com.newrelic.agent.utilization.UtilizationData)

Aggregations

AgentConfig (com.newrelic.agent.config.AgentConfig)1 Environment (com.newrelic.agent.environment.Environment)1 UtilizationData (com.newrelic.agent.utilization.UtilizationData)1 HashMap (java.util.HashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1