Search in sources :

Example 1 with TracerFactoryException

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

the class YmlExtensionPointCutConverter method getTracerFactory.

/**
 * Instantiates a tracer factory class of the given name.
 *
 * @param tracerFactoryName
 * @param config
 * @throws TracerFactoryException
 */
public static TracerFactory getTracerFactory(String tracerFactoryName, ClassLoader classLoader, TracerFactoryConfiguration config) throws TracerFactoryException {
    try {
        Class clazz = classLoader.loadClass(tracerFactoryName);
        String msg = MessageFormat.format("Instantiating custom tracer factory {0}", tracerFactoryName);
        Agent.LOG.finest(msg);
        if (TracerFactory.class.isAssignableFrom(clazz)) {
            return instantiateTracerFactory(clazz, config);
        } else if (MethodTracerFactory.class.isAssignableFrom(clazz)) {
            return instantiateMethodTracerFactory(clazz);
        } else {
            throw new TracerFactoryException("Unknown tracer factory type:" + tracerFactoryName);
        }
    } catch (Exception ex) {
        throw new TracerFactoryException("Unable to load tracer factory " + tracerFactoryName, ex);
    }
}
Also used : MethodTracerFactory(com.newrelic.api.agent.MethodTracerFactory) TracerFactoryException(com.newrelic.agent.TracerFactoryException) TracerFactoryException(com.newrelic.agent.TracerFactoryException)

Example 2 with TracerFactoryException

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

the class YmlExtensionPointCutConverter method getTracerFactoryName.

private static String getTracerFactoryName(Map attrs, String prefix, boolean dispatcher, Object metricNameFormat, ClassLoader loader) {
    String tracerFactoryNameString = null;
    Object tracerFactoryName = attrs.get(TRACER_FACTOR_KEY);
    if (tracerFactoryName != null) {
        try {
            TracerFactory factory = getTracerFactory(tracerFactoryName.toString(), loader, new TracerFactoryConfiguration(prefix, dispatcher, metricNameFormat, attrs));
            tracerFactoryNameString = tracerFactoryName.toString();
            ServiceFactory.getTracerService().registerTracerFactory(tracerFactoryNameString, factory);
        } catch (TracerFactoryException ex) {
            throw new RuntimeException("Unable to create tracer factory " + tracerFactoryName, ex);
        }
    }
    return tracerFactoryNameString;
}
Also used : TracerFactoryException(com.newrelic.agent.TracerFactoryException) MethodTracerFactory(com.newrelic.api.agent.MethodTracerFactory) TracerFactory(com.newrelic.agent.tracers.TracerFactory)

Aggregations

TracerFactoryException (com.newrelic.agent.TracerFactoryException)2 MethodTracerFactory (com.newrelic.api.agent.MethodTracerFactory)2 TracerFactory (com.newrelic.agent.tracers.TracerFactory)1