public async Task <DependencyViewModel> Get([FromQuery] DateTime?startTimestamp, [FromQuery] DateTime?finishTimestamp) { var spans = await _spanQuery.GetSpanDependencies( new DependencyQuery { StartTimestamp = startTimestamp?.ToUniversalTime(), FinishTimestamp = finishTimestamp?.ToUniversalTime() }); var dependency = new DependencyViewModel(); dependency.Nodes = GetNodes(spans).ToList(); var dependencies = spans.Where(x => x.References.Any(r => r.Reference == "ChildOf")).GroupBy(x => { var @ref = x.References.First(); var parent = spans.FirstOrDefault(s => s.SpanId == @ref.ParentId); return(new { source = ServiceHelpers.GetService(parent), target = ServiceHelpers.GetService(x) }); }); foreach (var item in dependencies) { if (item.Key.source == item.Key.target) { continue; } dependency.Edges.Add(new EdgeViewModel { Source = item.Key.source, Target = item.Key.target, Value = item.Count() }); } return(dependency); }
private List <TraceService> GetTraceServices(Trace trace) { var traceServices = new List <TraceService>(); foreach (var span in trace.Spans) { traceServices.Add(new TraceService(ServiceHelpers.GetService(span))); } return(traceServices); }