private void beforeEvent(String eventType) { Operation operation = new Operation() .type(TYPE) .put("event", eventType); frameBuilder.enter(operation); }
@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); }
builder.enter(op); return;
private void traceNextValve(Request request, Response response, TraceId traceId) throws IOException, ServletException { Operation operation = new Operation().type(OperationType.HTTP); frameBuilder.enter(operation); // TODO: What happens when this throws an exception? We will never add it to the // frame stack ... // Moreover, if we want to try / finally it, do we have enough valid information // in the response to compose the details? getNext().invoke(request, response); try { ApplicationName appName = getApplication(request); frameBuilder.setHintIfRoot(FrameBuilder.HINT_APPNAME, appName); frameBuilder.setHintIfRoot(FrameBuilder.HINT_TRACEID, traceId); fillInOperation(operation, request, response); frameBuilder.exit(); } catch(Throwable e) { // This can happen when frameBuilder.exit() throws an exception // (for instance with an imbalanced frame stack) if (enableLogging) { log.log(SEVERE, "Exception while logging trace to dispatcher", e); } } }
@Override public void invoke(Request request, Response response) throws IOException, ServletException { if (insightEnabled == false || insight.isContextIgnored(getApplicationName(request))) { // short circuit all Insight logic // create a faux operation to prevent child frames from appearing as unrooted traces Operation operation = new Operation(); frameBuilder.enter(operation); getNext().invoke(request, response); frameBuilder.dump(); return; } TraceId traceId = interceptConfig.generateNextTraceId(); if (canAddTraceIdResponseHeader()) { addTraceIdResponseHeader(response, traceId); } traceNextValve(request, response, traceId); }