public static void markCollectionError(Class<?> aspectClazz, String pluginName, Throwable throwable) { // Abort this trace InterceptConfiguration config=InterceptConfiguration.getInstance(); FrameBuilder builder=config.getFrameBuilder(); builder.setHint(FrameBuilder.HINT_ABORTED, Boolean.TRUE); if (aspectClazz != null) { String errorMsg=throwable.getClass().getSimpleName() + ": " + throwable.getMessage(); AspectManagementCollectionStrategy.enable(); Logger log = Logger.getLogger(CollectionErrors.class.getName()); log.log(Level.SEVERE, "Disabling aspect " + aspectClazz.getName() + " - " + errorMsg); AspectManagementCollectionStrategy.disableAspect(aspectClazz, pluginName, errorMsg); } }
public void markObscured(Object o) { ObscuredValueRegistry registry = builder.getHint(FrameBuilder.HINT_OBSCURED_REGISTRY, ObscuredValueRegistry.class); if (registry == null) { registry = new SimpleObscuredValueRegistry(); builder.setHint(FrameBuilder.HINT_OBSCURED_REGISTRY, registry); } registry.markObscured(o); } }
@Override protected void handleEnter(FrameBuilder builder, Operation op) { boolean aborted = isAborted(builder); if (aborted) { addFrameCount(builder); return; } long totalFrames = builder.getFrameCount(); int insightMaxFrames = getInsightMaxFrames(); //check if we reached overflow state and if so print a warning message and mark the trace as //aborted if (totalFrames >= insightMaxFrames) { Logger.getLogger(getClass().getName()).log(Level.WARNING, "Frame stack exceeded MAX_FRAMES_PER_TRACE limit or has been aborted " + "limit: " + insightMaxFrames + " frameCount: " + totalFrames + " aborted: " + aborted); builder.setHint(FrameBuilder.HINT_ABORTED, Boolean.TRUE); addFrameCount(builder); return; } builder.enter(op); }
private Frame exit() { Frame frame=builder.peekFrame(); /* * If about to exit the root frame and current app. name is not set, * make another try to determine it */ if (builder.isCurrentRootFrame(frame)) { ApplicationName name=builder.getHint(FrameBuilder.HINT_APPNAME, ApplicationName.class); if ((name == null) || ApplicationName.UNKOWN_APPLICATION.equals(name)) { ClassLoader cl=ClassUtil.getDefaultClassLoader(getClass()); name = ClassLoaderUtils.findApplicationName(cl); builder.setHint(FrameBuilder.HINT_APPNAME, name); } } return startegy.exit(builder); } }
/** * Update frames counter ({@link AbstractAbortTraceOverflowStrategy#addFrameCount(FrameBuilder)} * {@link AbstractAbortTraceOverflowStrategy#subFrameCount(FrameBuilder)}) * * @param builder frame builder * @param count update value * @return current counter value */ protected static final long updateFrameCount(FrameBuilder builder, long count) { MutableLong counter = builder.getHint(COUNTER_FIELD_HINT, MutableLong.class); if (counter == null) { counter = new MutableLong(0L); builder.setHint(COUNTER_FIELD_HINT, counter); } counter.increment(count); long countToreturn = counter.longValue(); //if the current counter value is negative reset it, but still return the negative value if (countToreturn < 0) { counter.set(0L); } return countToreturn; }
builder.setHint(INTERNAL_COUNTER, counter);