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();
}
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;
}
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;
}
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;
}
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);
}
Aggregations