public override async Task <bool> Handle(ConsoleCommandEvent <TracesConsoleCommand> request, CancellationToken cancellationToken) { if (request.Command.Recent) { var filterContext = LoggingFilterContext.Prepare(); // add some default criteria var entities = await this.repository.FindAllAsync( filterContext.GetSpecifications <LogTrace>().Insert(new Specification <LogTrace>(t => t.TrackType == "trace")), filterContext.GetFindOptions <LogTrace>(), cancellationToken).AnyContext(); var nodes = Node <LogTrace> .ToHierarchy(entities, l => l.SpanId, l => l.ParentSpanId, true); if (request.Command.Count > 0) { nodes = nodes.Take(request.Command.Count); } await nodes.RenderConsole( t => $"{t.Message} ({t.SpanId}/{t.ParentSpanId}) -> took {t.Duration.Humanize()}", t => $"{t.Timestamp.ToUniversalTime():u} [{t.Kind?.ToUpper().Truncate(6, string.Empty)}] ", orderBy : t => t.Ticks).AnyContext(); } return(true); }
private async Task <IEnumerable <LogEvent> > GetJsonAsync() { LoggingFilterContext.Prepare(this.filterContext); return(await this.repository.FindAllAsync( this.filterContext.GetSpecifications <LogEvent>(), this.filterContext.GetFindOptions <LogEvent>()).AnyContext()); }
private async Task <IEnumerable <LogTrace> > GetJsonAsync() { LoggingFilterContext.Prepare(this.filterContext); // add some default criteria return(await this.repository.FindAllAsync( this.filterContext.GetSpecifications <LogTrace>().Insert( new Specification <LogTrace>(t => t.TrackType == "trace")), this.filterContext.GetFindOptions <LogTrace>()).AnyContext()); }
private async Task <NaosHealthReport> GetJsonAsync() { LoggingFilterContext.Prepare(this.filterContext); var httpClient = this.httpClientFactory.CreateClient("health"); var response = await httpClient.GetAsync("https://localhost:5001/health").AnyContext(); var result = await response.ReadAsAsync <NaosHealthReport>().AnyContext(); if (result != null) { result.CorrelationId = response.GetCorrelationIdHeader(); } else { result = new NaosHealthReport { Status = "Unhealthy", Timestamp = DateTime.UtcNow, CorrelationId = response.GetCorrelationIdHeader() }; } return(result); }