// Path: telemetry-agent/src/main/java/com/yammer/telemetry/agent/handlers/MetricsRegistryHandler.java
// public static void switchImplementation(CtClass cc, ClassPool pool, String from, String to) throws NotFoundException, CannotCompileException {
//     CtClass oldClass = pool.get(from);
//     CtClass newClass = pool.get(to);
// 
//     CodeConverter converter = new CodeConverter();
//     converter.replaceNew(oldClass, newClass);
// 
//     cc.instrument(converter);
// }


import javassist.*;
import java.io.IOException;
import static com.yammer.telemetry.agent.handlers.MetricsRegistryHandler.switchImplementation;
package com.yammer.telemetry.agent.handlers;




public class EnvironmentExecutorClassHandler extends SubTypeInstrumentationHandler {
    public EnvironmentExecutorClassHandler() {
        super("com.yammer.dropwizard.config.Environment");
    }

    @Override
    protected boolean transform(CtClass cc, ClassPool pool) throws NotFoundException, CannotCompileException, IOException {
        if ("com.yammer.dropwizard.config.Environment".equals(cc.getName())) {
// Path: telemetry-agent/src/main/java/com/yammer/telemetry/agent/handlers/MetricsRegistryHandler.java
// public static void switchImplementation(CtClass cc, ClassPool pool, String from, String to) throws NotFoundException, CannotCompileException {
//     CtClass oldClass = pool.get(from);
//     CtClass newClass = pool.get(to);
// 
//     CodeConverter converter = new CodeConverter();
//     converter.replaceNew(oldClass, newClass);
// 
//     cc.instrument(converter);
// }


// Path: telemetry-agent/src/main/java/com/yammer/telemetry/agent/handlers/EnvironmentExecutorClassHandler.java
import javassist.*;
import java.io.IOException;
import static com.yammer.telemetry.agent.handlers.MetricsRegistryHandler.switchImplementation;

package com.yammer.telemetry.agent.handlers;




public class EnvironmentExecutorClassHandler extends SubTypeInstrumentationHandler {
    public EnvironmentExecutorClassHandler() {
        super("com.yammer.dropwizard.config.Environment");
    }

    @Override
    protected boolean transform(CtClass cc, ClassPool pool) throws NotFoundException, CannotCompileException, IOException {
        if ("com.yammer.dropwizard.config.Environment".equals(cc.getName())) {
            switchImplementation(cc, pool, "java.util.concurrent.ThreadPoolExecutor", "com.yammer.telemetry.agent.handlers.InstrumentedThreadPoolExecutor");