private boolean sameMethod(final Frame currentFrame, final Frame lastChildFrame) { final Operation lastOperation = lastChildFrame.getOperation(); final String lastMethod = getMethodAttribute(lastOperation); final Operation currentOperation = currentFrame.getOperation(); final String currentMethod = getMethodAttribute(currentOperation); return lastMethod.equals(currentMethod); }
@Override public void serialize(Frame value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); jgen.writeObjectField("id", value.getId()); jgen.writeObjectField("range",value.getRange()); jgen.writeObjectField("operation",value.getOperation()); jgen.writeObjectField("children",value.getChildren()); jgen.writeEndObject(); } }
public boolean shouldCollapse(final Frame currentFrame) { final Frame parentFrame = currentFrame.getParent(); final List<Frame> children = parentFrame.getChildren(); if (ListUtil.size(children) < 2) { return false; } final Frame lastChildFrame = children.get(children.size() - 2); return sameMethod(currentFrame, lastChildFrame); }
public EndPointAnalysis locateEndPoint(Trace trace) { Frame root = trace.getRootFrame(); if (root == null) { return null; } Operation rootOp = root.getOperation(); if (!rootOp.getType().equals(TYPE)) { return null; } EndPointName name = EndPointName.valueOf(rootOp.getSourceCodeLocation().getClassName() + "#" + rootOp.get("methodSignature")); String label = rootOp.getLabel(); String exampleRequest = ""; OperationList args = rootOp.get("arguments", OperationList.class); if (args.size() == 1) { exampleRequest = args.get(0, String.class); } int score = 0; return new EndPointAnalysis(root.getRange(), name, label, exampleRequest, score); } }
op.put("after", DESCRIPTION_AFTER); List<Frame> rootChildren = root.getChildren(); int size = ListUtil.size(rootChildren); start = lastChild.getRange().getEnd(); } else { start = root.getRange().getStart();
protected void updateParentReference (Frame frame) { Collection<? extends Frame> children=frame.getChildren(); if (ListUtil.size(children) > 0) { for (Frame child : children) { if (child instanceof SimpleFrame) { ((SimpleFrame) child).setParent(frame); } updateParentReference(child); } } } }
protected void updateParentReference (Frame frame) { Collection<? extends Frame> children=frame.getChildren(); if (ListUtil.size(children) > 0) { for (Frame child : children) { if (child instanceof SimpleFrame) { ((SimpleFrame) child).setParent(frame); } updateParentReference(child); } } } /*
@Override protected OperationType validateScoringFrame(Frame frame) { OperationType type=super.validateScoringFrame(frame); if (type == null) { return null; } Operation op=frame.getOperation(); Boolean fromValue=op.get("from", Boolean.class); if ((fromValue == null) || (!fromValue.booleanValue())) { return null; } return type; }
@Override public void serialize(Frame value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); jgen.writeObjectField("id", value.getId()); jgen.writeObjectField("range", value.getRange()); jgen.writeObjectField("operation", value.getOperation()); jgen.writeObjectField("children", value.getChildren()); jgen.writeEndObject(); } }
@Override protected boolean shouldCreateExteranlResource(Frame frame) { Operation op = frame.getOperation(); String hostname = getHostname(op); return !StringUtil.isEmpty(hostname) && !GemFireDefenitions.FIELD_UNKNOWN.equals(hostname); } }
@Override protected OperationType validateFrameOperation (Frame frame) { OperationType opType=super.validateFrameOperation(frame); if (opType == null) { return null; } // even if correct type, check if marked as endpoint Operation operation=frame.getOperation(); Boolean endPoint=operation.get(ENDPOINT_VALIDITY_PROP, Boolean.class); if ((endPoint == null) || (!endPoint.booleanValue())) { return null; } return opType; }
public List<TraceError> locateErrors(Trace trace) { Frame root = trace.getRootFrame(); if (root == null) { return EMPTY_LIST; } Operation rootOp = root.getOperation(); String exception = rootOp.get(EXCEPTION, String.class); if (exception != null) { int chars = Math.min(exception.length(), MAX_ERROR_LENGTH); return singletonList(new TraceError(exception.substring(0, chars))); } return EMPTY_LIST; } }
@Override public TraceError locateFrameError(Frame frame) { Operation op = frame.getOperation(); return new TraceError(op.getLabel()); } }
public List<TraceError> locateErrors(Trace trace) { Frame root = trace.getRootFrame(); if (root == null) { return Collections.emptyList(); } Operation rootOp = root.getOperation(); String exception = rootOp.get(OperationFields.EXCEPTION, String.class); if (!StringUtil.isEmpty(exception)) { int chars = Math.min(exception.length(), MAX_ERROR_LENGTH); return Collections.singletonList(new TraceError(exception.substring(0, chars))); } return Collections.emptyList(); } }
private void storeResourceKey (Trace trace, Frame frame, boolean isParent, ResourceKey extKey) { String keyName=isParent ? OperationFields.PARENT_KEY : OperationFields.OPERATION_KEY; Operation op=frame.getOperation(); String extResKey=extKey.getKey(), prevKey=op.get(keyName, String.class); /* * NOTE !!! we do not expect more than one parent or one child at this stage * @see METRICS-2945 and METRICS-2935 */ if (StringUtil.isEmpty(prevKey)) { if (logger.isTraceEnabled()) { logger.trace("externalResources(" + keyName + ")[" + trace + "]: " + extKey); } op.put(keyName, extResKey); } else if (!prevKey.equals(extResKey)) { // ignore if same value - @see METRICS-3007 logger.error("externalResources(" + keyName + ")[" + trace + "]" + " multiple values: " + extKey + " / " + prevKey); } } }
static Frame resolveEndPointFrame (Trace trace) { Frame execFrame=trace.getFirstFrameOfType(RunExecDefinitions.EXEC_OP), runFrame=trace.getFirstFrameOfType(RunExecDefinitions.RUN_OP); Operation opExec=(execFrame == null) ? null : execFrame.getOperation(), opRun=(runFrame == null) ? null : runFrame.getOperation(); if (opExec == null) { if (opRun == null) { return null; } else { return runFrame; } } else if (opRun == null) { return execFrame; } // at this stage we have 2 frames - prefer the one higher up the trace int execDepth = FrameUtil.getDepth(execFrame), runDepth = FrameUtil.getDepth(runFrame); if (execDepth < runDepth) { return execFrame; } else { return runFrame; } }
@Override protected EndPointAnalysis makeEndPoint(Frame lifecycleFrame, int depth) { Operation op = lifecycleFrame.getOperation(); String endPointExample = op.get("event", String.class); return new EndPointAnalysis(ENDPOINT_NAME, ENDPOINT_LABEL, endPointExample, getOperationScore(op, depth), op); } }
@Override public TraceError locateFrameError(Frame frame) { Operation op=frame.getOperation(); String remoteError=op.get(HttpInvokerRequestExecutorOperationCollector.REMOTE_EXCEPTION, String.class); if (StringUtil.isEmpty(remoteError)) { return null; } else { return new TraceError(remoteError); } }
@Override protected EndPointAnalysis makeEndPoint(Frame dispatchFrame, int depth) { Operation op=dispatchFrame.getOperation(); String label=op.getLabel(); EndPointName name=EndPointName.valueOf(label.replace('/', '_')); return new EndPointAnalysis(name, label, label, getOperationScore(op, depth), op); } }
@Override public List<MetricsBag> generateMetrics(Trace trace, ResourceKey endpointResourceKey, Collection<Frame> frames) { if (ListUtil.size(frames) <= 0) { return Collections.emptyList(); } int totalErrors=0; for (Frame frame : frames) { Operation op=frame.getOperation(); Number errorsCount=op.get(ValidationJoinPointFinalizer.ERRORS_COUNT, Number.class); int numErrors=(errorsCount == null) ? 0 : errorsCount.intValue(); if (numErrors <= 0) { continue; } else { totalErrors += numErrors; } } if (totalErrors <= 0) { return Collections.emptyList(); } MetricsBag mb=MetricsBag.create(endpointResourceKey, trace.getRange()); addCounterMetricToBag(trace, mb, METRIC_KEY, totalErrors); return Collections.singletonList(mb); }