Search in sources :

Example 11 with AgentBuilder

use of net.bytebuddy.agent.builder.AgentBuilder in project Aeron by real-logic.

the class AgentBuilderListener method startLogging.

private static synchronized void startLogging(final AgentBuilder.RedefinitionStrategy redefinitionStrategy, final Instrumentation instrumentation, final EnumMap<ConfigOption, String> configOptions) {
    if (null != logTransformer) {
        throw new IllegalStateException("agent already instrumented");
    }
    EventConfiguration.init(configOptions.get(ENABLED_DRIVER_EVENT_CODES), configOptions.get(DISABLED_DRIVER_EVENT_CODES), configOptions.get(ENABLED_ARCHIVE_EVENT_CODES), configOptions.get(DISABLED_ARCHIVE_EVENT_CODES), configOptions.get(ENABLED_CLUSTER_EVENT_CODES), configOptions.get(DISABLED_CLUSTER_EVENT_CODES));
    if (DRIVER_EVENT_CODES.isEmpty() && ARCHIVE_EVENT_CODES.isEmpty() && CLUSTER_EVENT_CODES.isEmpty()) {
        return;
    }
    EventLogAgent.instrumentation = instrumentation;
    readerAgentRunner = new AgentRunner(new SleepingMillisIdleStrategy(SLEEP_PERIOD_MS), Throwable::printStackTrace, null, newReaderAgent(configOptions));
    AgentBuilder agentBuilder = new AgentBuilder.Default(new ByteBuddy().with(TypeValidation.DISABLED)).disableClassFormatChanges().with(new AgentBuilderListener()).with(redefinitionStrategy);
    agentBuilder = addDriverInstrumentation(agentBuilder);
    agentBuilder = addArchiveInstrumentation(agentBuilder);
    agentBuilder = addClusterInstrumentation(agentBuilder);
    logTransformer = agentBuilder.installOn(instrumentation);
    thread = new Thread(readerAgentRunner);
    thread.setName("event-log-reader");
    thread.setDaemon(true);
    thread.start();
}
Also used : SleepingMillisIdleStrategy(org.agrona.concurrent.SleepingMillisIdleStrategy) AgentBuilder(net.bytebuddy.agent.builder.AgentBuilder) AgentRunner(org.agrona.concurrent.AgentRunner) ByteBuddy(net.bytebuddy.ByteBuddy)

Example 12 with AgentBuilder

use of net.bytebuddy.agent.builder.AgentBuilder in project Aeron by real-logic.

the class AgentBuilderListener method addClusterConsensusModuleAgentInstrumentation.

private static AgentBuilder addClusterConsensusModuleAgentInstrumentation(final AgentBuilder agentBuilder) {
    AgentBuilder tempBuilder = agentBuilder;
    tempBuilder = addEventInstrumentation(tempBuilder, CLUSTER_EVENT_CODES, ClusterEventCode.NEW_LEADERSHIP_TERM, "ConsensusModuleAgent", ClusterInterceptor.NewLeadershipTerm.class, "onNewLeadershipTerm");
    tempBuilder = addEventInstrumentation(tempBuilder, CLUSTER_EVENT_CODES, ClusterEventCode.STATE_CHANGE, "ConsensusModuleAgent", ClusterInterceptor.ConsensusModuleStateChange.class, "stateChange");
    tempBuilder = addEventInstrumentation(tempBuilder, CLUSTER_EVENT_CODES, ClusterEventCode.ROLE_CHANGE, "ConsensusModuleAgent", ClusterInterceptor.ConsensusModuleRoleChange.class, "roleChange");
    tempBuilder = addEventInstrumentation(tempBuilder, CLUSTER_EVENT_CODES, ClusterEventCode.CANVASS_POSITION, "ConsensusModuleAgent", ClusterInterceptor.CanvassPosition.class, "onCanvassPosition");
    tempBuilder = addEventInstrumentation(tempBuilder, CLUSTER_EVENT_CODES, ClusterEventCode.REQUEST_VOTE, "ConsensusModuleAgent", ClusterInterceptor.RequestVote.class, "onRequestVote");
    return tempBuilder;
}
Also used : AgentBuilder(net.bytebuddy.agent.builder.AgentBuilder)

Example 13 with AgentBuilder

use of net.bytebuddy.agent.builder.AgentBuilder in project Aeron by real-logic.

the class AgentBuilderListener method addDriverUdpChannelTransportInstrumentation.

private static AgentBuilder addDriverUdpChannelTransportInstrumentation(final AgentBuilder agentBuilder) {
    AgentBuilder tempBuilder = agentBuilder;
    tempBuilder = addEventInstrumentation(tempBuilder, DRIVER_EVENT_CODES, DriverEventCode.FRAME_OUT, "UdpChannelTransport", ChannelEndpointInterceptor.UdpChannelTransport.SendHook.class, "sendHook");
    tempBuilder = addEventInstrumentation(tempBuilder, DRIVER_EVENT_CODES, DriverEventCode.FRAME_IN, "UdpChannelTransport", ChannelEndpointInterceptor.UdpChannelTransport.ReceiveHook.class, "receiveHook");
    return tempBuilder;
}
Also used : AgentBuilder(net.bytebuddy.agent.builder.AgentBuilder)

Example 14 with AgentBuilder

use of net.bytebuddy.agent.builder.AgentBuilder in project Aeron by real-logic.

the class AgentBuilderListener method addDriverSenderProxyInstrumentation.

private static AgentBuilder addDriverSenderProxyInstrumentation(final AgentBuilder agentBuilder) {
    AgentBuilder tempBuilder = agentBuilder;
    tempBuilder = addEventInstrumentation(tempBuilder, DRIVER_EVENT_CODES, DriverEventCode.SEND_CHANNEL_CREATION, "SenderProxy", ChannelEndpointInterceptor.SenderProxy.RegisterSendChannelEndpoint.class, "registerSendChannelEndpoint");
    tempBuilder = addEventInstrumentation(tempBuilder, DRIVER_EVENT_CODES, DriverEventCode.SEND_CHANNEL_CLOSE, "SenderProxy", ChannelEndpointInterceptor.SenderProxy.CloseSendChannelEndpoint.class, "closeSendChannelEndpoint");
    return tempBuilder;
}
Also used : AgentBuilder(net.bytebuddy.agent.builder.AgentBuilder)

Example 15 with AgentBuilder

use of net.bytebuddy.agent.builder.AgentBuilder in project instrumentation-java by census-instrumentation.

the class ExecutorInstrumentationTest method instrument_disabled.

@Test
public void instrument_disabled() {
    Settings settings = new Settings(ConfigFactory.parseString(FEATURE + ".enabled = false"));
    AgentBuilder agentBuilder2 = instrumentation.instrument(agentBuilder, settings);
    assertThat(agentBuilder2).isSameInstanceAs(agentBuilder);
}
Also used : AgentBuilder(net.bytebuddy.agent.builder.AgentBuilder) Settings(io.opencensus.contrib.agent.Settings) Test(org.junit.Test)

Aggregations

AgentBuilder (net.bytebuddy.agent.builder.AgentBuilder)17 Settings (io.opencensus.contrib.agent.Settings)6 Test (org.junit.Test)6 Instrumenter (io.opencensus.contrib.agent.instrumentation.Instrumenter)1 JarFile (java.util.jar.JarFile)1 ByteBuddy (net.bytebuddy.ByteBuddy)1 AgentRunner (org.agrona.concurrent.AgentRunner)1 SleepingMillisIdleStrategy (org.agrona.concurrent.SleepingMillisIdleStrategy)1