Search in sources :

Example 1 with AgentConfig

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

the class Transaction method getLogEventData.

public Logs getLogEventData() {
    Logs logEventData = logEvents.get();
    if (logEventData == null) {
        AgentConfig defaultConfig = ServiceFactory.getConfigService().getDefaultAgentConfig();
        logEvents.compareAndSet(null, ServiceFactory.getServiceManager().getLogSenderService().getTransactionLogs(defaultConfig));
        logEventData = logEvents.get();
    }
    return logEventData;
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) Logs(com.newrelic.api.agent.Logs)

Example 2 with AgentConfig

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

the class Transaction method getInsightsData.

public Insights getInsightsData() {
    Insights insightsData = insights.get();
    if (insightsData == null) {
        AgentConfig defaultConfig = ServiceFactory.getConfigService().getDefaultAgentConfig();
        insights.compareAndSet(null, ServiceFactory.getServiceManager().getInsights().getTransactionInsights(defaultConfig));
        insightsData = insights.get();
    }
    return insightsData;
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) Insights(com.newrelic.api.agent.Insights)

Example 3 with AgentConfig

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

the class AgentLinkingMetadata method getLinkingMetadata.

/**
 * Get a map of all agent linking metadata.
 *
 * @param traceMetadata TraceMetadataImpl instance to get spanId and traceId
 * @param configService ConfigService to get hostName and entityName
 * @param rpmService    IRPMService to get entityGuid
 * @return Map of all agent linking metadata
 */
public static Map<String, String> getLinkingMetadata(TraceMetadata traceMetadata, ConfigService configService, IRPMService rpmService) {
    AgentConfig agentConfig = configService.getDefaultAgentConfig();
    Map<String, String> linkingMetadata = new ConcurrentHashMap<>();
    linkingMetadata.put(TRACE_ID, getTraceId(traceMetadata));
    linkingMetadata.put(SPAN_ID, getSpanId(traceMetadata));
    linkingMetadata.put(HOSTNAME, getHostname(agentConfig));
    linkingMetadata.put(ENTITY_NAME, getEntityName(agentConfig));
    linkingMetadata.put(ENTITY_TYPE, getEntityType());
    try {
        String entityGuid = getEntityGuid(rpmService);
        if (!entityGuid.isEmpty()) {
            linkingMetadata.put(ENTITY_GUID, entityGuid);
        }
    } catch (NullPointerException ignored) {
        logWarning();
    }
    return linkingMetadata;
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 4 with AgentConfig

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

the class ExtensionService method getExtensionDirectory.

/**
 * Retrieves the extension directory using the config property or the default directory.
 *
 * @return The config directory as a file or null if the directory does not exist or is not readable.
 */
private File getExtensionDirectory() {
    AgentConfig agentConfig = config.getDefaultAgentConfig();
    String configDirName = agentConfig.getProperty(AgentConfigImpl.EXT_CONFIG_DIR);
    if (configDirName == null) {
        configDirName = ConfigFileHelper.getNewRelicDirectory() + File.separator + ExtensionConversionUtility.DEFAULT_CONFIG_DIRECTORY;
    }
    File configDir = new File(configDirName);
    if (!configDir.exists()) {
        Agent.LOG.log(Level.FINE, "The extension directory " + configDir.getAbsolutePath() + " does not exist.");
        configDir = null;
    } else if (!configDir.isDirectory()) {
        Agent.LOG.log(Level.WARNING, "The extension directory " + configDir.getAbsolutePath() + " is not a directory.");
        configDir = null;
    } else if (!configDir.canRead()) {
        Agent.LOG.log(Level.WARNING, "The extension directory " + configDir.getAbsolutePath() + " is not readable.");
        configDir = null;
    }
    return configDir;
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) File(java.io.File)

Example 5 with AgentConfig

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

the class ClassTransformerServiceImpl method isRetransformationSupported.

private boolean isRetransformationSupported(InstrumentationProxy instrProxy) {
    AgentConfig config = ServiceFactory.getConfigService().getDefaultAgentConfig();
    Boolean enableClassRetransformation = config.getProperty(AgentConfigImpl.ENABLE_CLASS_RETRANSFORMATION);
    if (enableClassRetransformation != null) {
        return enableClassRetransformation;
    }
    try {
        return instrProxy.isRetransformClassesSupported();
    } catch (Exception e) {
        // AIX throws an UnsupportedOperationException
        String msg = MessageFormat.format("Unexpected error asking current JVM configuration if it supports retransformation of classes: {0}", e);
        getLogger().warning(msg);
        return false;
    }
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) IllegalClassFormatException(java.lang.instrument.IllegalClassFormatException) UnmodifiableClassException(java.lang.instrument.UnmodifiableClassException)

Aggregations

AgentConfig (com.newrelic.agent.config.AgentConfig)199 Test (org.junit.Test)110 HashMap (java.util.HashMap)73 ConfigService (com.newrelic.agent.config.ConfigService)39 MockServiceManager (com.newrelic.agent.MockServiceManager)32 ThreadService (com.newrelic.agent.ThreadService)17 TransactionService (com.newrelic.agent.TransactionService)16 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)16 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)14 Transaction (com.newrelic.agent.Transaction)13 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)13 ClassVisitor (org.objectweb.asm.ClassVisitor)13 ClassNode (org.objectweb.asm.tree.ClassNode)13 CheckClassAdapter (org.objectweb.asm.util.CheckClassAdapter)13 TokenNullCheckClassVisitor (com.newrelic.agent.instrumentation.weaver.preprocessors.AgentPreprocessors.TokenNullCheckClassVisitor)12 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)12 HarvestService (com.newrelic.agent.HarvestService)11 MockHarvestService (com.newrelic.agent.MockHarvestService)11 MockRPMService (com.newrelic.agent.MockRPMService)11 StatsService (com.newrelic.agent.stats.StatsService)11