public static synchronized Runnable performRuntimeAttachment() {
		if (runtimeAttached || !corePlugin.isStagemonitorActive() || !corePlugin.isAttachAgentAtRuntime()) {
			return NOOP_ON_SHUTDOWN_ACTION;
		}
		runtimeAttached = true;

		final List<ClassFileTransformer> classFileTransformers = new ArrayList<ClassFileTransformer>();
		final AutoEvictingCachingBinaryLocator binaryLocator = new AutoEvictingCachingBinaryLocator();
		if (assertNoDifferentStagemonitorVersionIsDeployedOnSameJvm() && initInstrumentation()) {
			final long start = System.currentTimeMillis();
			classFileTransformers.add(initByteBuddyClassFileTransformer(binaryLocator));
			if (corePlugin.isDebugInstrumentation()) {
				logger.info("Attached agents in {} ms", System.currentTimeMillis() - start);
			}
			TimedElementMatcherDecorator.logMetrics();
		}
		return new Runnable() {
			public void run() {
				for (ClassFileTransformer classFileTransformer : classFileTransformers) {
					instrumentation.removeTransformer(classFileTransformer);
				}
				// This ClassLoader is shutting down so don't try to retransform classes of it in the future
				hashCodesOfClassLoadersToIgnore.add(ClassUtils.getIdentityString(AgentAttacher.class.getClassLoader()));
				binaryLocator.close();
			}
		};
	}
public static synchronized Runnable performRuntimeAttachment ( ) { if ( runtimeAttached || ! corePlugin . isStagemonitorActive ( ) || ! corePlugin . isAttachAgentAtRuntime ( ) ) { return NOOP_ON_SHUTDOWN_ACTION ; } runtimeAttached = true ; final List < ClassFileTransformer > classFileTransformers = new ArrayList < ClassFileTransformer > ( ) ; final AutoEvictingCachingBinaryLocator binaryLocator = new AutoEvictingCachingBinaryLocator ( ) ; if ( assertNoDifferentStagemonitorVersionIsDeployedOnSameJvm ( ) && initInstrumentation ( ) ) { final long start = System . currentTimeMillis ( ) ; classFileTransformers . add ( initByteBuddyClassFileTransformer ( binaryLocator ) ) ; if ( corePlugin . isDebugInstrumentation ( ) ) { logger . info ( "Attached agents in {} ms" , System . currentTimeMillis ( ) - start ) ; } TimedElementMatcherDecorator . logMetrics ( ) ; } return new Runnable ( ) { public void run ( ) { for ( ClassFileTransformer classFileTransformer : classFileTransformers ) { instrumentation . removeTransformer ( classFileTransformer ) ; } hashCodesOfClassLoadersToIgnore . add ( ClassUtils . getIdentityString ( AgentAttacher . class . getClassLoader ( ) ) ) ; binaryLocator . close ( ) ; } } ; }
Attaches the profiler and other instrumenters at runtime so that it is not necessary to add the -javaagent
command line argument.

@return A runnable that should be called on shutdown to unregister this class file transformer