Java Code Examples for net.bytebuddy.asm.Advice#OnMethodEnter
The following examples show how to use
net.bytebuddy.asm.Advice#OnMethodEnter .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElasticsearchClientAsyncInstrumentation.java From apm-agent-java with Apache License 2.0 | 6 votes |
@Advice.OnMethodEnter(suppress = Throwable.class) private static void onBeforeExecute(@Advice.Argument(0) Request request, @Advice.Argument(value = 1, readOnly = false) ResponseListener responseListener, @Advice.Local("span") Span span, @Advice.Local("wrapped") boolean wrapped, @Advice.Local("helper") ElasticsearchRestClientInstrumentationHelper<HttpEntity, Response, ResponseListener> helper) { helper = esClientInstrHelperManager.getForClassLoaderOfClass(Request.class); if (helper != null) { span = helper.createClientSpan(request.getMethod(), request.getEndpoint(), request.getEntity()); if (span != null) { responseListener = helper.<ResponseListener>wrapResponseListener(responseListener, span); wrapped = true; } } }
Example 2
Source File: CaptureSpanInstrumentation.java From apm-agent-java with Apache License 2.0 | 6 votes |
@Advice.OnMethodEnter(suppress = Throwable.class) public static void onMethodEnter( @SimpleMethodSignatureOffsetMappingFactory.SimpleMethodSignature String signature, @AnnotationValueOffsetMappingFactory.AnnotationValueExtractor(annotationClassName = "co.elastic.apm.api.CaptureSpan", method = "value") String spanName, @AnnotationValueOffsetMappingFactory.AnnotationValueExtractor(annotationClassName = "co.elastic.apm.api.CaptureSpan", method = "type") String type, @Nullable @AnnotationValueOffsetMappingFactory.AnnotationValueExtractor(annotationClassName = "co.elastic.apm.api.CaptureSpan", method = "subtype") String subtype, @Nullable @AnnotationValueOffsetMappingFactory.AnnotationValueExtractor(annotationClassName = "co.elastic.apm.api.CaptureSpan", method = "action") String action, @Advice.Local("span") Span span) { if (tracer != null) { final AbstractSpan<?> parent = tracer.getActive(); if (parent != null) { span = parent.createSpan(); span.setType(type, subtype, action); span.withName(spanName.isEmpty() ? signature : spanName) .activate(); } else { logger.debug("Not creating span for {} because there is no currently active span.", signature); } } }
Example 3
Source File: CheckSourceLevelAdvice.java From jabel with Apache License 2.0 | 5 votes |
@Advice.OnMethodEnter public static void checkSourceLevel( @Advice.Argument(value = 1, readOnly = false) Feature feature ) { if (feature.allowedInSource(Source.JDK8)) { //noinspection UnusedAssignment feature = Source.Feature.LAMBDA; } }
Example 4
Source File: CodeTemplates.java From lams with GNU General Public License v2.0 | 5 votes |
@Advice.OnMethodEnter static void $$_hibernate_clearDirtyAttributes( @Advice.FieldValue(value = EnhancerConstants.TRACKER_FIELD_NAME) DirtyTracker $$_hibernate_tracker) { if ( $$_hibernate_tracker != null ) { $$_hibernate_tracker.clear(); } }
Example 5
Source File: CodeTemplates.java From lams with GNU General Public License v2.0 | 5 votes |
@Advice.OnMethodEnter static void enter(@FieldValue Collection<?> field, @Advice.Argument(0) Collection<?> argument, @MappedBy String mappedBy) { if ( field != null && Hibernate.isPropertyInitialized( field, mappedBy ) ) { Object[] array = field.toArray(); for ( int i = 0; i < array.length; i++ ) { if ( argument == null || !argument.contains( array[i] ) ) { setterNull( array[i], null ); } } } }
Example 6
Source File: AbstractSpanInstrumentation.java From apm-agent-java with Apache License 2.0 | 5 votes |
@VisibleForAdvice @Advice.OnMethodEnter(suppress = Throwable.class) public static void setType(@Advice.Argument(0) Object span, @Advice.Argument(1) @Nullable String type, @Advice.Argument(2) @Nullable String subtype, @Advice.Argument(3) @Nullable String action) { if (span instanceof Span) { ((Span) span).setType(type, subtype, action); } }
Example 7
Source File: AlibabaResponseCallbackInstrumentation.java From apm-agent-java with Apache License 2.0 | 5 votes |
@Advice.OnMethodEnter(suppress = Throwable.class) private static void onEnter(@Advice.This ResponseCallback thiz, @Advice.Local("span") AbstractSpan<?> span) { span = AlibabaResponseFutureInstrumentation.callbackSpanMap.remove(thiz); if (span != null) { span.activate(); } }
Example 8
Source File: CodeTemplates.java From lams with GNU General Public License v2.0 | 5 votes |
@Advice.OnMethodEnter static void $$_hibernate_removeDirtyFields( @Advice.Argument(value = 0, readOnly = false) LazyAttributeLoadingInterceptor lazyInterceptor, @Advice.FieldValue(EnhancerConstants.TRACKER_COLLECTION_NAME) Object $$_hibernate_attributeInterceptor) { if ( $$_hibernate_attributeInterceptor instanceof LazyAttributeLoadingInterceptor ) { lazyInterceptor = (LazyAttributeLoadingInterceptor) $$_hibernate_attributeInterceptor; } }
Example 9
Source File: ServletVersionInstrumentation.java From apm-agent-java with Apache License 2.0 | 5 votes |
@Advice.OnMethodEnter(suppress = Throwable.class) @SuppressWarnings("Duplicates") // duplication is fine here as it allows to inline code private static void onEnter(@Advice.This Servlet servlet) { if (alreadyLogged) { return; } alreadyLogged = true; ServletConfig servletConfig = servlet.getServletConfig(); int majorVersion = -1; int minorVersion = -1; String serverInfo = null; if (servletConfig != null) { ServletContext servletContext = servletConfig.getServletContext(); if (null != servletContext) { majorVersion = servletContext.getMajorVersion(); minorVersion = servletContext.getMinorVersion(); serverInfo = servletContext.getServerInfo(); } } logger.info("Servlet container info = {}", serverInfo); if (majorVersion < 3) { logger.warn("Unsupported servlet version detected: {}.{}, no Servlet transaction will be created", majorVersion, minorVersion); } }
Example 10
Source File: ServerCallHandlerInstrumentation.java From apm-agent-java with Apache License 2.0 | 5 votes |
@Advice.OnMethodEnter(suppress = Throwable.class) private static void onEnter(@Advice.Origin Class<?> clazz, @Advice.Argument(0) ServerCall<?, ?> serverCall, @Advice.Argument(1) Metadata headers, @Advice.Local("transaction") Transaction transaction) { if (tracer == null || grpcHelperManager == null) { return; } GrpcHelper helper = grpcHelperManager.getForClassLoaderOfClass(ServerCall.class); if (helper != null) { transaction = helper.startTransaction(tracer, clazz.getClassLoader(), serverCall, headers); } }
Example 11
Source File: SpringMessagingAgentRule.java From java-specialagent with Apache License 2.0 | 4 votes |
@Advice.OnMethodEnter public static void enter(final @ClassName String className, final @Advice.Origin String origin, final @Advice.This Object thiz) { if (isAllowed(className, origin)) SpringMessagingAgentIntercept.enter(thiz); }
Example 12
Source File: DynamicAgentRule.java From java-specialagent with Apache License 2.0 | 4 votes |
@Advice.OnMethodEnter public static void enter(final @ClassName String className, final @Advice.Origin String origin) { if (isAllowed(className, origin)) DynamicAgentIntercept.enter(origin); }
Example 13
Source File: CxfRsClientAgentRule.java From java-specialagent with Apache License 2.0 | 4 votes |
@Advice.OnMethodEnter public static void enter(final @ClassName String className, final @Advice.Origin String origin, final @Advice.This Object thiz) { if (isAllowed(className, origin)) CxfAgentIntercept.addClientTracingFeature(thiz); }
Example 14
Source File: LegacySpanInstrumentation.java From apm-agent-java with Apache License 2.0 | 4 votes |
@VisibleForAdvice @Advice.OnMethodEnter public static void setName(@Advice.FieldValue(value = "span", typing = Assigner.Typing.DYNAMIC) AbstractSpan<?> span, @Advice.Argument(0) String name) { span.withName(name, PRIO_USER_SUPPLIED); }
Example 15
Source File: SpymemcachedAgentRule.java From java-specialagent with Apache License 2.0 | 4 votes |
@Advice.OnMethodEnter public static void enter(final @ClassName String className, final @Advice.Origin String origin, final @Advice.Argument(value = 0) Object key, @Advice.Argument(value = 2, typing = Typing.DYNAMIC, readOnly = false) Object callback) { if (isAllowed(className, origin)) callback = SpymemcachedAgentIntercept.tracingCallback("touch", key, callback); }
Example 16
Source File: EarlyReturnTest.java From java-specialagent with Apache License 2.0 | 4 votes |
@Advice.OnMethodEnter() public static void enter() throws IOException { System.out.println(">>>>>>>>"); throw new IOException(); }
Example 17
Source File: BufferAlignmentInterceptor.java From agrona with Apache License 2.0 | 4 votes |
@Advice.OnMethodEnter public static void verifyAlignment(final int index, final @Advice.This DirectBuffer buffer) { verifyAlignment(index, buffer, BitUtil.SIZE_OF_LONG); }
Example 18
Source File: ClusterInterceptor.java From aeron with Apache License 2.0 | 4 votes |
@Advice.OnMethodEnter static <E extends Enum<E>> void stateChange(final E oldState, final E newState, final int memberId) { LOGGER.logStateChange(ELECTION_STATE_CHANGE, oldState, newState, memberId); }
Example 19
Source File: PlayWSAgentRule.java From java-specialagent with Apache License 2.0 | 4 votes |
@Advice.OnMethodEnter public static void enter(final @ClassName String className, final @Advice.Origin String origin, final @Advice.Argument(value = 0) Object arg0, @Advice.Argument(value = 1, readOnly = false, typing = Typing.DYNAMIC) Object arg1) { if (isAllowed(className, origin)) arg1 = PlayWSAgentIntercept.executeStart(arg0, arg1); }
Example 20
Source File: ClusterInterceptor.java From aeron with Apache License 2.0 | 4 votes |
@Advice.OnMethodEnter static void roleChange(final Cluster.Role oldRole, final Cluster.Role newRole, final int memberId) { LOGGER.logStateChange(ROLE_CHANGE, oldRole, newRole, memberId); }