private List getTraceIdInjectorsReflectively()

in aws-xray-agent/src/main/java/com/amazonaws/xray/agent/runtime/config/XRaySDKConfiguration.java [389:405]


    private List<SegmentListener> getTraceIdInjectorsReflectively(ClassLoader classLoader) {
        final List<SegmentListener> listeners = new ArrayList<>();
        final String prefix = agentConfiguration.getTraceIdInjectionPrefix();
        log.debug("Prefix is: " + prefix);
        for (String className : TRACE_ID_INJECTION_CLASSES) {
            try {
                Class<?> listenerClass = Class.forName(className, true, classLoader);
                SegmentListener listener = (SegmentListener) listenerClass.getConstructor(String.class).newInstance(prefix);
                listeners.add(listener);
                log.debug("Enabled AWS X-Ray trace ID injection into logs using " + className);
            } catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException | ClassNotFoundException e) {
                log.debug("Could not find trace ID injection class " + className + " with class loader " + classLoader.getClass().getSimpleName());
            }
        }

        return listeners;
    }