public async Task <IEnumerable <TraceViewModel> > Get( [FromQuery] string service, [FromQuery] string tags, [FromQuery] long?startTimestamp, [FromQuery] long?finishTimestamp, [FromQuery] int?minDuration, [FromQuery] int?maxDuration, [FromQuery] int?limit) { var query = new TraceQuery { Tags = tags, ServiceName = service, StartTimestamp = TimestampHelpers.Convert(startTimestamp), FinishTimestamp = TimestampHelpers.Convert(finishTimestamp), MinDuration = minDuration, MaxDuration = maxDuration, Limit = limit.GetValueOrDefault(10) }; var data = await _spanQuery.GetTraces(query); var traceViewModels = _mapper.Map <List <TraceViewModel> >(data); foreach (var trace in traceViewModels) { var item = data.FirstOrDefault(x => x.TraceId == trace.TraceId); trace.Services = GetTraceServices(item); } return(traceViewModels); }
public async Task <IEnumerable <TraceHistogramViewModel> > GetTraceHistogram( [FromQuery] string service, [FromQuery] string tags, [FromQuery] long?startTimestamp, [FromQuery] long?finishTimestamp, [FromQuery] int?minDuration, [FromQuery] int?maxDuration, [FromQuery] int?limit) { var query = new TraceQuery { Tags = tags, ServiceName = service, StartTimestamp = TimestampHelpers.Convert(startTimestamp), FinishTimestamp = TimestampHelpers.Convert(finishTimestamp), MinDuration = minDuration, MaxDuration = maxDuration, Limit = limit.GetValueOrDefault(10) }; var data = await _spanQuery.GetTraceHistogram(query); return(_mapper.Map <List <TraceHistogramViewModel> >(data)); }
public async Task <DependencyViewModel> Get([FromQuery] long?startTimestamp, [FromQuery] long?finishTimestamp) { var spans = await _spanQuery.GetSpanDependencies( new DependencyQuery { StartTimestamp = TimestampHelpers.Convert(startTimestamp), FinishTimestamp = TimestampHelpers.Convert(finishTimestamp), }); 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); }