Skip to content

Instantly share code, notes, and snippets.

@heipacker
Created April 9, 2016 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heipacker/4439f791e202288c97f70e9c7b271bb3 to your computer and use it in GitHub Desktop.
Save heipacker/4439f791e202288c97f70e9c7b271bb3 to your computer and use it in GitHub Desktop.
testAgent
package com.dlmu.agent.server;
import com.dlmu.agent.CosmosAgent;
import java.lang.instrument.Instrumentation;
/**
* Created by fupan on 16-4-2.
*/
public class TestAgent {
/**
* 第一个种, 程序启动是attach
* VM options: -javaagent:/home/fupan/IdeaProjects/agentTest/agent-tools/target/agent-tools-1.0-SNAPSHOT.jar
* 第二种, 程序启动后attach
* attachAgent();
*
* @param args
*/
public static void main(String[] args) {
//程序启动时attach得把这个注释掉
CosmosAgent.install();
System.out.println("run test agent");
Instrumentation instrumentation = CosmosAgent.getInstrumentation();
ClassTransformerSupport.addCode(instrumentation);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment