Skip to content

Commit

Permalink
feat: fix tpm display; add app description
Browse files Browse the repository at this point in the history
  • Loading branch information
Qinyouzeng committed Oct 25, 2024
1 parent a057a90 commit b448df3
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ public class EnviromentAppDto
public AppTypes AppType { get; set; }

public string ProjectId { get; set; }

public string AppDescription { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public async Task<PaginatedListBase<SimpleTraceListDto>> GetSimpleTraceListAsync
sql1 = $@"select countMerge(Total) as Total from {Constants.DurationCountTable} where {where}";
}

sql1 = CombineOrs(sql1, ors);
sql1 = CombineOrs(sql1, ors);
var countSql = $"select sum(Total) from({sql1})";
result.Total = Convert.ToInt64(await Scalar(countSql, parameters));
}
Expand Down Expand Up @@ -418,6 +418,14 @@ private static SimpleTraceListDto ToSampleTraceListDto(IDataReader reader)
) {orderBy} @limit ";
PaginatedListBase<T> result = new() { Total = Convert.ToInt64(await Scalar(countSql, parameters)) };
await SetData(sql, parameters, result, query, reader => ToServiceList<T>(reader));
var totalMinits = Math.Floor((query.End - query.Start).TotalMinutes);
if (result.Result != null && result.Result.Count > 0)
{
result.Result.ForEach(x =>
{
x.Throughput = Math.Round(x.Throughput / totalMinits, 3);
});
}
return result;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Services/Masa.Tsc.Service.Admin/Services/ApmService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ private async Task<Dictionary<string, List<EnviromentAppDto>>> GetTeamAppsAsync(
{
AppId = item.Identity,
ProjectId = projects.Find(p => p.Id == item.ProjectId)?.Identity!,
AppType = item.Type
AppType = item.Type,
AppDescription = item.Description
}).ToList());
_memoryCache.Set(cacheKey, result, TimeSpan.FromMinutes(5));
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,25 @@ protected override void OnInitialized()
SetQueryList();
}

public EnviromentAppDto? GetService(string service)
{
if (string.IsNullOrEmpty(service))
return default;
if (enviromentServices.Count == 0)
return default;
foreach (var item in enviromentServices)
{
if (string.IsNullOrEmpty(Search.Environment) || item.Key == Search.Environment)
{
var findApp = item.Value.Find(app => app.AppId == service);
if (findApp != null)
return findApp;
}
}

return default!;
}

private void SetQueryList()
{
if (textFileds.Count > 0 || StorageConst.Current == null)
Expand Down
16 changes: 14 additions & 2 deletions src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Endpoint.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@page "/trace/{TraceId}"
<PageTitle>@I18n.Apm("PageTitles.Endpoint")</PageTitle>

<ApmSearchComponent ShowComparison
<ApmSearchComponent ShowComparison @ref=_apmSearchComponent
IsEndpoint
Value="Search"
ValueChanged="LoadASync" />
Expand Down Expand Up @@ -36,7 +36,19 @@
}
else if (context.Header.Value == nameof(ListChartData.Service))
{
@context.Item.Service
var text = _apmSearchComponent.GetService(context.Item.Name)?.AppDescription;
if (string.IsNullOrEmpty(text))
text = "";
<MTooltip Top Left Context="tooltipContent">
<ActivatorContent>
<div @attributes="@tooltipContent.Attrs" class="text-truncate">
@context.Item.Service
</div>
</ActivatorContent>
<ChildContent>
<span>@text</span>
</ChildContent>
</MTooltip>
}
else if (context.Header.Value == nameof(ListChartData.Latency))
{
Expand Down
3 changes: 3 additions & 0 deletions src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Endpoint.razor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using Masa.Tsc.Web.Admin.Rcl.Components.Apm;

namespace Masa.Tsc.Web.Admin.Rcl.Pages.Apm;

public partial class Endpoint
Expand All @@ -25,6 +27,7 @@ public partial class Endpoint
private bool isTableLoading = false;
private string? sortFiled;
private bool? sortBy;
private ApmSearchComponent _apmSearchComponent;

protected override async Task OnInitializedAsync()
{
Expand Down
18 changes: 16 additions & 2 deletions src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Service.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@page "/apm/services"
<PageTitle>@I18n.Apm("PageTitles.Service")</PageTitle>

<ApmSearchComponent ShowComparison
<ApmSearchComponent ShowComparison @ref=_apmSearchComponent
IsService
Value="Search"
ValueChanged="LoadASync" />
Expand All @@ -20,7 +20,21 @@
<ItemColContent>
@if (context.Header.Value == nameof(ListChartData.Name))
{
<a href="/apm/services/@(context.Item.Name+GetUrlParam(service: context.Item.Name, env: GetSearchEnv(Search.Environment, context.Item.Envs?.Split(',')), comparisonType: Search.ComparisonType, start: Search.Start, end: Search.End))">@context.Item.Name</a>
var text = _apmSearchComponent.GetService(context.Item.Name)?.AppDescription;
if (string.IsNullOrEmpty(text))
text = "";
<MTooltip Top Left Context="tooltipContent">
<ActivatorContent>
<div @attributes="@tooltipContent.Attrs" class="text-truncate">
<a href="/apm/services/@(context.Item.Name+GetUrlParam(service: context.Item.Name, env: GetSearchEnv(Search.Environment, context.Item.Envs?.Split(',')), comparisonType: Search.ComparisonType, start: Search.Start, end: Search.End))">
@context.Item.Name
</a>
</div>
</ActivatorContent>
<ChildContent>
<span>@text</span>
</ChildContent>
</MTooltip>
}
else if (context.Header.Value == nameof(ListChartData.Envs))
{
Expand Down
3 changes: 3 additions & 0 deletions src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Service.razor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

using Masa.Tsc.Web.Admin.Rcl.Components.Apm;

namespace Masa.Tsc.Web.Admin.Rcl.Pages.Apm;

public partial class Service
Expand All @@ -16,6 +18,7 @@ public partial class Service
new() { Text = I18n.Apm("Service.List.Failed"), Value = nameof(ListChartData.Failed)}
};

private ApmSearchComponent _apmSearchComponent;
private int defaultSize = 20;
private int total = 0;
private int page = 1;
Expand Down

0 comments on commit b448df3

Please sign in to comment.