@Override public Frame getScoringFrame(Trace trace) { Frame root=trace.getRootFrame(); if (validateScoringFrame(root) == null) { return null; } else { return root; } }
@Override // if ANY remote invocation failed, then declare the trace an error public Collection<Frame> locateFrames(Trace trace) { return trace.getAllFramesOfType(HttpInvokerRequestExecutorExternalResourceAnalyzer.HTTP_INVOKER); } }
public DuplicateTraceException(Trace trace) { super("Unable to add a trace which has already been added (app=" + trace.getAppName() + ", traceId=" + trace.getId() + ")"); appName = trace.getAppName(); traceId = trace.getId(); }
throw new RuntimeException("Error serializing trace", e); PersistedTrace persistedTrace = new PersistedTrace(trace.getId(), new Time(trace.getDate()), traceBytes); traceDao.storeTrace(persistedTrace); throw new InsightRuntimeException("Unable to store trace[" + trace.getId() + "] from server [" + trace.getServer() + "]: It depends on " + "resource [" + resourceKey.getKey() + "] which can't be found"); summary = new PersistedTraceSummary(trace.getLabel(), persistedTrace.getTraceId(), trace.getRange(), errors.size(), errorText(errors), persistedTags, trace.getServer(), trace.getAppName(), endPoint.getEndPointName()); summary = new PersistedTraceSummary(trace.getLabel(), persistedTrace.getTraceId(), trace.getRange(), errors.size(), errorText(errors), persistedTags, trace.getServer(), trace.getAppName(), extResource.getEndPointKey().getEndPointName(), extResource.getExternalName(), extResource.getExternalType(), extResource.getHost(), extResource.getPort(), extResource.getVendor(), extResource.isIncoming(),extResource.getDestination(), extResource.getParent(), extResource.isParent());
public List<TraceTag> findTags(TraceTagRuleContext context) { boolean hasError = context.hasError(); long traceMillis = context.getTrace().getRange().getDurationMillis(); if (hasError || traceMillis >= frustratedMillis) { return FRUSTRATED_LIST; } else if (traceMillis < thresholdMillis) { return SATISFIED_LIST; } else { return TOLERATING_LIST; } }
public TraceAnalysis(Trace traceValue, ServerResource sourceServer, EndPointAnalysis endPoint, Collection<Resource> extResources, Collection<TraceError> traceErrors, Collection<TraceTag> tags) { ServerName srcName=sourceServer.getServer(); ServerName trcName=traceValue.getServer(); if (!ObjectUtil.typedEquals(srcName, trcName)) { throw new IllegalArgumentException("Trace server name (" + trcName + ") does not match the source server (" + srcName + ")"); } this.trace = traceValue; this.server = sourceServer; this.endPointAnalysis = endPoint; this.externalResources = extResources; // Create a new TimeRange from the existing one. If the endPoint has a // SelfTimeRange the additional fields will be culled out as an optimization // for memory. this.responseTime = traceValue.getRange(); this.responseTimePoint = dataPointFromRange(responseTime); this.resources = new HashMap<ResourceType, Resource>(); this.traceTags = (ListUtil.size(tags) > 0) ? new HashSet<TraceTag>(tags) : new HashSet<TraceTag>(); this.errors = (ListUtil.size(traceErrors) > 0) ? new ArrayList<TraceError>(traceErrors) : new ArrayList<TraceError>(); this.applicationMetadata = ApplicationMetadataCache.getInstance(); addResources(); }
final ApplicationName appName = trace.getAppName(); final ServerName srvName = trace.getServer(); boolean multipleFrames = false; Collection<? extends ExternalResourceDescriptor> externalRes=extresList;
private Map<ResourceType, Resource> addResources() { TraceSource traceSource = trace.getTraceSource(); ApplicationName appName=trace.getAppName(); String applicationLabel=applicationMetadata.getLabel(appName); ApplicationResource application = new ApplicationResource(appName.makeKey(), applicationLabel); ApplicationEndPointResource endpoint = new ApplicationEndPointResource(appName, endPointAnalysis.getEndPointName(), endPointAnalysis.getResourceLabel(), traceSource); resources.put(APPLICATION, application); resources.put(SERVER, server); resources.put(APPLICATION_SERVER, new ApplicationServerResource(application, server)); resources.put(APPLICATION_END_POINT, endpoint); resources.put(APPLICATION_SERVER_END_POINT, new ApplicationServerEndPointResource(application, server, endpoint, traceSource)); return resources; }
public TraceAnalysis analyze(TraceInterface traceAccess) { Trace trace=traceAccess.asTrace(); ApplicationName trcName=traceAccess.getAppName(), appName=applicationMetadata.getApplicationName(trcName); TraceSource traceSource = sourceAnalysisService != null ? sourceAnalysisService.locateTraceSource(traceAccess) : null; trace.setTraceSource(traceSource); if (!ObjectUtil.typedEquals(trcName, appName)) { if (logger.isDebugEnabled()) { logger.debug("analyze(" + trace + ") modified application " + trcName + " => " + appName); } trace.setAppName(appName); } EndPointAnalysis endPointAnalysis=locateEndPoint(traceAccess); Collection<Resource> extResources=collectExternalResources(traceAccess, endPointAnalysis); List<TraceError> errors=locateErrors(trace); ServerName serverName=(traceAccess instanceof ServerNameCarrier) ? ((ServerNameCarrier) traceAccess).getServer() : trace.getServer() ; ServerResource server=serverResolver.resolve(serverName); TraceAnalysis res=new TraceAnalysis(trace, server, endPointAnalysis, extResources, errors, null); Set<TraceTag> tags=locateTags(traceAccess, (EndPointAwareResource) res.getResource(ResourceType.APPLICATION_SERVER_END_POINT), ListUtil.size(errors) > 0); res.addTags(tags); return res; }
Trace prepareTraceForTransport (Trace trace) { ServerName traceServer=trace.getServer(); // override only if not set or default if ((traceServer == null) || InterceptConfiguration.PLACEHOLDER_SERVER.equals(traceServer)) { DispatchConfiguration dispatchConfig=DispatchConfiguration.getInstance(); ServerName agentName=dispatchConfig.getServerName(); trace.setServer(agentName); } return trace; }
public TraceId getId() { Trace t=getTrace(); return (t == null) ? null : t.getId(); }
public TraceReport(Trace trace, TraceInterface traceAccess) { this((trace == null) ? null /* cause exception */ : trace.getServer(), traceAccess); }
public ApplicationName getAppName() { Trace t=getTrace(); return (t == null) ? null : t.getAppName(); }
@Override public Collection<Frame> locateFrames(Trace trace) { Frame frame = trace.getFirstFrameOfType(getOperationType()); if (frame == null) { return Collections.emptyList(); } else { return Collections.singletonList(frame); } }
public TraceSource getTraceSource() { return trace.getTraceSource(); }
public Date getDate() { Trace t=getTrace(); return (t == null) ? null : t.getDate(); }
@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); }
public List<Command> processTrace(TraceInterface traceAccess) { Trace trace=traceAccess.asTrace(); if (filter.filters(traceAccess)) { if (log.isDebugEnabled()) { log.debug("Trace [" + trace.getId() + "] was filtered"); } return Collections.emptyList(); } TraceAnalysis analysis = analyzer.analyze(traceAccess); List<Command> commands = commandGenerator.generateCommands(analysis); List<Command> metricGeneratorsCommands = metricsGenerators.generateCommands(traceAccess, analysis); commands.addAll(metricGeneratorsCommands); // TODO: Aggregation of some commands (increment) could happen here return commands; }
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; } }
TraceSource traceSource = trace.getTraceSource();