diff --git a/src/Infrastructure/Masa.Tsc.Storage.Clickhouse.Apm/ApmClickhouseInit.cs b/src/Infrastructure/Masa.Tsc.Storage.Clickhouse.Apm/ApmClickhouseInit.cs index ebea0276..d0ddb395 100644 --- a/src/Infrastructure/Masa.Tsc.Storage.Clickhouse.Apm/ApmClickhouseInit.cs +++ b/src/Infrastructure/Masa.Tsc.Storage.Clickhouse.Apm/ApmClickhouseInit.cs @@ -24,13 +24,16 @@ private static void InitErrorTable(MasaStackClickhouseConnection connection) `ServiceName` String CODEC(ZSTD(1)), `Resource.service.namespace` String CODEC(ZSTD(1)), `Attributes.http.target` String CODEC(ZSTD(1)), - INDEX idx_log_id TraceId TYPE bloom_filter(0.001) GRANULARITY 1, - INDEX idx_log_spanid SpanId TYPE bloom_filter(0.001) GRANULARITY 1, - INDEX idx_log_environment `Resource.service.namespace` TYPE bloom_filter(0.001) GRANULARITY 1, - INDEX idx_log_servicename ServiceName TYPE bloom_filter(0.001) GRANULARITY 1, - INDEX idx_log_type `Attributes.exception.type` TYPE bloom_filter(0.001) GRANULARITY 1, - INDEX idx_log_endpoint `Attributes.http.target` TYPE bloom_filter(0.001) GRANULARITY 1, - INDEX idx_string_message `Attributes.exception.message` TYPE tokenbf_v1(30720, 2, 0) GRANULARITY 1 + `MsgGroupKey` String CODEC(ZSTD(1)), + + INDEX idx_error_id TraceId TYPE bloom_filter(0.001) GRANULARITY 1, + INDEX idx_error_spanid SpanId TYPE bloom_filter(0.001) GRANULARITY 1, + INDEX idx_error_environment `Resource.service.namespace` TYPE bloom_filter(0.001) GRANULARITY 1, + INDEX idx_error_servicename ServiceName TYPE bloom_filter(0.001) GRANULARITY 1, + INDEX idx_error_type `Attributes.exception.type` TYPE bloom_filter(0.001) GRANULARITY 1, + INDEX idx_error_endpoint `Attributes.http.target` TYPE bloom_filter(0.001) GRANULARITY 1, + INDEX idx_error_message `Attributes.exception.message` TYPE tokenbf_v1(30720, 2, 0) GRANULARITY 1, + INDEX idx_error_msggroupkey MsgGroupKey TYPE bloom_filter(0.001) GRANULARITY 1 ) ENGINE = MergeTree PARTITION BY toDate(Timestamp) @@ -38,6 +41,7 @@ ORDER BY (Timestamp, ServiceName, `Resource.service.namespace`, `Attributes.exception.type`, + `MsgGroupKey`, `Attributes.http.target`) TTL toDateTime(Timestamp) + toIntervalDay(30) SETTINGS index_granularity = 8192, @@ -46,8 +50,11 @@ TTL toDateTime(Timestamp) + toIntervalDay(30) $@"CREATE MATERIALIZED VIEW {Constants.ErrorTable.Replace(".",".v_")} TO {Constants.ErrorTable} AS SELECT -Timestamp,TraceId,SpanId, Body AS `Attributes.exception.message`,LogAttributes['exception.type'] AS `Attributes.exception.type`, - ServiceName,ResourceAttributes['service.namespace'] AS `Resource.service.namespace`, LogAttributes['RequestPath'] AS `Attributes.http.target` + Timestamp,TraceId,SpanId, if(position(Body, '\n') > 0,extract(Body, '[^\n\r]+'),Body) `Attributes.exception.message`,LogAttributes['exception.type'] AS `Attributes.exception.type`, + ServiceName,ResourceAttributes['service.namespace'] AS `Resource.service.namespace`, LogAttributes['RequestPath'] AS `Attributes.http.target`, +multiIf( + length(`Attributes.exception.message`)-150<=0,`Attributes.exception.message`, + extract(`Attributes.exception.message`, '[^,:\\.£º£¬\{{\[]+')) AS MsgGroupKey FROM {MasaStackClickhouseConnection.LogSourceTable} WHERE mapContains(LogAttributes, 'exception.type') "}; diff --git a/src/Infrastructure/Masa.Tsc.Storage.Clickhouse.Apm/Cliclhouse/ClickhouseApmService.cs b/src/Infrastructure/Masa.Tsc.Storage.Clickhouse.Apm/Cliclhouse/ClickhouseApmService.cs index 6556ccba..4b3c01cb 100644 --- a/src/Infrastructure/Masa.Tsc.Storage.Clickhouse.Apm/Cliclhouse/ClickhouseApmService.cs +++ b/src/Infrastructure/Masa.Tsc.Storage.Clickhouse.Apm/Cliclhouse/ClickhouseApmService.cs @@ -320,10 +320,10 @@ public Task> ErrorMessagePageAsync(ApmEndpoin query.IsServer = default; var (where, parameters) = AppendWhere(query); var groupby = $"group by Type,Message{(string.IsNullOrEmpty(query.Endpoint) ? "" : ",Endpoint")}"; - var countSql = $"select count(1) from (select Attributes.exception.type as Type,Attributes.exception.message as Message,max(Timestamp) time,count(1) from {Constants.ErrorTable} where {where} {groupby})"; + var countSql = $"select count(1) from (select `Attributes.exception.type` as Type,MsgGroupKey as Message,max(Timestamp) time,count(1) from {Constants.ErrorTable} where {where} {groupby})"; PaginatedListBase result = new() { Total = Convert.ToInt64(Scalar(countSql, parameters)) }; var orderBy = GetOrderBy(query, errorOrders); - var sql = $@"select * from( select Attributes.exception.type as Type,Attributes.exception.message as Message,max(Timestamp) time,count(1) total from {Constants.ErrorTable} where {where} {groupby} {orderBy} @limit)"; + var sql = $@"select * from( select `Attributes.exception.type` as Type,MsgGroupKey as Message,max(Timestamp) time,count(1) total from {Constants.ErrorTable} where {where} {groupby} {orderBy} @limit)"; SetData(sql, parameters, result, query, reader => new ErrorMessageDto() { Type = reader[0]?.ToString()!, diff --git a/src/Services/Masa.Tsc.Service.Admin/Extensions/AddTraceLogExtenstion.cs b/src/Services/Masa.Tsc.Service.Admin/Extensions/AddTraceLogExtenstion.cs index 58868d76..2e05e4c4 100644 --- a/src/Services/Masa.Tsc.Service.Admin/Extensions/AddTraceLogExtenstion.cs +++ b/src/Services/Masa.Tsc.Service.Admin/Extensions/AddTraceLogExtenstion.cs @@ -23,11 +23,6 @@ private static void AddClickHouse() if (ConfigConst.StorageConst.HasInit || !ConfigConst.IsClickhouse) return; if (string.IsNullOrEmpty(ConfigConst.ClikhouseConnection)) return; _services.AddMASAStackApmClickhouse(ConfigConst.ClikhouseConnection, ConfigConst.ClickhouseTableSuffix, ConfigConst.ClickHouseLogSourceTable, ConfigConst.ClickHouseTaceSourceTable); - //_services.AddMASAStackApmClickhouse( - // "Compress=True;CheckCompressedHash=False;Compressor=lz4;SocketTimeout=10000;Host=10.130.0.106;Port=4229;User=ss;Password=Ckapp@2023;Database=lonsid_fusion", - // "masav1", - // "otel_logs_masa", - // "otel_traces_masa"); ConfigConst.StorageConst.SetClickhouse(); } diff --git a/src/Services/Masa.Tsc.Service.Admin/Infrastructure/Const/ConfigConst.cs b/src/Services/Masa.Tsc.Service.Admin/Infrastructure/Const/ConfigConst.cs index b2d9aafd..de4003ae 100644 --- a/src/Services/Masa.Tsc.Service.Admin/Infrastructure/Const/ConfigConst.cs +++ b/src/Services/Masa.Tsc.Service.Admin/Infrastructure/Const/ConfigConst.cs @@ -1,8 +1,6 @@ // Copyright (c) MASA Stack All rights reserved. // Licensed under the MIT License. See LICENSE.txt in the project root for license information. -using Nest; - namespace Masa.Tsc.Service.Admin.Infrastructure.Const; internal class ConfigConst diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Data/Apm/SearchData.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Data/Apm/SearchData.cs index a77a530a..455efd33 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Data/Apm/SearchData.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Data/Apm/SearchData.cs @@ -20,6 +20,10 @@ public class SearchData public ApmComparisonTypes ComparisonType { get; set; } public long Timestamp { get; set; } + + public string ExceptionType { get; set; } + + public string ExceptionMsg { get; set; } } public enum ApmComparisonTypes diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/ErrorDetail.razor b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/ErrorDetail.razor index c19d9f89..54556231 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/ErrorDetail.razor +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/ErrorDetail.razor @@ -47,7 +47,7 @@
@I18n.Apm("Error.Detail.Message")
-
@currentLog?.Attributes["exception.message"]
+
@currentLog?.Body
diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/ErrorDetail.razor.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/ErrorDetail.razor.cs index 2da6643c..7b106d23 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/ErrorDetail.razor.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/ErrorDetail.razor.cs @@ -47,14 +47,13 @@ protected override void OnInitialized() if (!string.IsNullOrEmpty(exceptionType)) { - //append.AppendFormat(" and exception.type='{0}'", exceptionType); - append.AppendFormat(" and LogAttributesValues[indexOf(LogAttributesKeys,'exception.type')]='{0}'", exceptionType); + append.AppendFormat(" and `Attributes.exception.type`='{0}'", exceptionType); } - //if (!string.IsNullOrEmpty(exceptionMessage)) - //{ - // append.AppendFormat(" and LogAttributesValues[indexOf(LogAttributesKeys,'exception.message')]='{0}'", exceptionMessage); - //} - if (string.IsNullOrEmpty(Search.Text)) + if (!string.IsNullOrEmpty(exceptionMessage)) + { + append.AppendFormat(" and `Body` like '%{0}%'", exceptionMessage.Replace("x2E", ".").Replace("'", "''")); + } + if (string.IsNullOrEmpty(Search.Text) && append.Length > 0) append.Remove(0, 5); Search.Text = append.ToString(); } diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Errors.razor b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Errors.razor index d5ef62f0..73231a94 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Errors.razor +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Errors.razor @@ -32,7 +32,12 @@ else if (context.Header.Value == nameof(ErrorMessageDto.Message)) {
- @context.Item.Message + + @context.Item.Message +
} else if (context.Header.Value == nameof(ErrorMessageDto.LastTime)) diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceEndpoints.razor b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceEndpoints.razor index b44e4982..e9351749 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceEndpoints.razor +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceEndpoints.razor @@ -103,7 +103,7 @@ - + \ No newline at end of file diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceEndpoints.razor.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceEndpoints.razor.cs index 09f0e9d9..8dd84b3a 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceEndpoints.razor.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceEndpoints.razor.cs @@ -71,8 +71,7 @@ private async Task LoadASync(SearchData data = null) return; } StateHasChanged(); - await LoadPageDataAsync(); - isTableLoading = false; + await LoadPageDataAsync(); StateHasChanged(); await LoadChartDataAsync(); } @@ -107,6 +106,14 @@ private async Task LoadPageDataAsync() })); } total = (int)result.Total; + isTableLoading = false; + } + + private async Task OnPageChange((int page, int pageSize) pageData) + { + page = pageData.page; + defaultSize = pageData.pageSize; + await LoadPageDataAsync(); } private async Task LoadChartDataAsync() diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceErrors.razor b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceErrors.razor index b783d602..d7d7c70d 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceErrors.razor +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceErrors.razor @@ -39,7 +39,14 @@ else if (context.Header.Value == nameof(ErrorMessageDto.Message)) {
- @context.Item.Message +
} @if (context.Header.Value == nameof(ErrorMessageDto.LastTime)) diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceLogs.razor b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceLogs.razor index 0703809d..a5bbdeeb 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceLogs.razor +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceLogs.razor @@ -51,7 +51,7 @@ - + diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceLogs.razor.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceLogs.razor.cs index 65acff42..a70420d5 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceLogs.razor.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ServiceLogs.razor.cs @@ -70,8 +70,7 @@ private async Task LoadAsync(SearchData data = null) { return; } - await LoadPageDataAsync(); - isTableLoading = false; + await LoadPageDataAsync(); } private async Task LoadChartDataAsync() @@ -114,6 +113,14 @@ private async Task LoadPageDataAsync() data.AddRange(result.Result); } total = (int)result.Total; + isTableLoading = false; + } + + private async Task OnPageChange((int page, int pageSize) pageData) + { + page = pageData.page; + defaultSize = pageData.pageSize; + await LoadPageDataAsync(); } private EChartType ConvertLatencyChartData(List data, string lineColor = null, string areaLineColor = null, string? unit = null, string? lineName = null) diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ShortEndpoint.razor b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ShortEndpoint.razor index 1c86c942..b6ce42b5 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ShortEndpoint.razor +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ShortEndpoint.razor @@ -1,4 +1,4 @@ -@namespace Masa.Tsc.Web.Admin.Rcl.Pages.Apm.Services +@* @namespace Masa.Tsc.Web.Admin.Rcl.Pages.Apm.Services @inherits ApmComponentBase - \ No newline at end of file + *@ \ No newline at end of file diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ShortEndpoint.razor.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ShortEndpoint.razor.cs index ba64025b..34e4e12d 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ShortEndpoint.razor.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Services/ShortEndpoint.razor.cs @@ -1,193 +1,193 @@ -// Copyright (c) MASA Stack All rights reserved. -// Licensed under the MIT License. See LICENSE.txt in the project root for license information. - -namespace Masa.Tsc.Web.Admin.Rcl.Pages.Apm.Services; - -public partial class ShortEndpoint -{ - [CascadingParameter] - public SearchData SearchData { get; set; } - - [Parameter] - public MetricTypes MetricType { get; set; } - - private List> headers => new() - { - new() { Text = I18n.Apm("Endpoint.List.Name"), Value = nameof(ListChartData.Name)}, - new() { Text = I18n.Apm("Endpoint.List.Latency"), Value = nameof(ListChartData.Latency) }, - new() { Text = I18n.Apm("Endpoint.List.Throughput"), Value = nameof(ListChartData.Throughput)}, - new() { Text = I18n.Apm("Endpoint.List.Failed"), Value = nameof(ListChartData.Failed)} - }; - - private int defaultSize = 5; - private int total = 0; - private int page = 1; - private List data = new(); - private bool isTableLoading = false; - private string? sortFiled; - private bool? sortBy; - private string lastKey = string.Empty; - - private async Task OnTableOptionsChanged(DataOptions sort) - { - if (sort.SortBy.Any()) - sortFiled = sort.SortBy.First(); - else - sortFiled = default; - if (sort.SortDesc.Any()) - sortBy = sort.SortDesc.First(); - else - sortBy = default; - await LoadASync(); - } - - private void OpenAsync(ListChartData item) - { - } - - private ChartData GetLatencyChartData(ListChartData item) - { - return MetricType switch - { - MetricTypes.P95 => item.P95ChartData, - MetricTypes.P99 => item.P99ChartData, - _ => item.LatencyChartData, - }; - } - - protected override async Task OnParametersSetAsync() - { - var key = MD5Utils.Encrypt(JsonSerializer.Serialize(SearchData)); - if (lastKey != key) - { - lastKey = key; - await LoadASync(); - } - await base.OnParametersSetAsync(); - } - - private async Task LoadASync() - { - if (isTableLoading) - { - return; - } - StateHasChanged(); - await LoadPageDataAsync(); - isTableLoading = false; - StateHasChanged(); - await LoadChartDataAsync(); - } - - private async Task LoadPageDataAsync() - { - if (isTableLoading) return; - isTableLoading = true; - var query = new BaseApmRequestDto - { - Page = page, - PageSize = defaultSize, - Start = SearchData.Start, - End = SearchData.End, - OrderField = sortFiled, - Service = SearchData.Service, - Env = SearchData.Environment, - IsDesc = sortBy - }; - var result = await ApiCaller.ApmService.GetEndpointPageAsync(query); - data.Clear(); - if (result.Result != null && result.Result.Any()) - { - data.AddRange(result.Result.Select(item => new ListChartData - { - Name = $"{item.Method} {item.Name}", - Service = item.Service, - Endpoint = item.Name, - Failed = item.Failed, - Throughput = item.Throughput, - Latency = item.Latency - })); - } - total = (int)result.Total; - } - - private async Task LoadChartDataAsync() - { - if (data.Count == 0) - return; - var query = new ApmEndpointRequestDto - { - Page = page, - PageSize = defaultSize, - Start = SearchData.Start, - End = SearchData.End, - Service = SearchData.Service, - Env = SearchData.Environment - }; - var result = await ApiCaller.ApmService.GetChartsAsync(query); - if (result == null || !result.Any()) - { - return; - } - - foreach (var service in data) - { - var chartData = result.FirstOrDefault(s => s.Name == service.Name); - service.LatencyChartData = new(); - service.ThroughputChartData = new(); - service.FailedChartData = new(); - service.P95ChartData = new(); - service.P99ChartData = new(); - if (chartData == null) - { - service.LatencyChartData.EmptyChart = true; - service.ThroughputChartData.EmptyChart = true; - service.FailedChartData.EmptyChart = true; - service.P95ChartData.EmptyChart = true; - service.P99ChartData.EmptyChart = true; - - object emptyObj = new(); - service.LatencyChartData.Data = emptyObj; - service.ThroughputChartData.Data = emptyObj; - service.FailedChartData.Data = emptyObj; - service.P95ChartData.Data = emptyObj; - service.P99ChartData.Data = emptyObj; - } - else - { - service.LatencyChartData.Data = ConvertLatencyChartData(chartData, item => item.Latency).Json; - service.ThroughputChartData.Data = ConvertLatencyChartData(chartData, item => item.Throughput).Json; - service.FailedChartData.Data = ConvertLatencyChartData(chartData, item => item.Failed).Json; - service.P95ChartData.Data = ConvertLatencyChartData(chartData, item => item.P95).Json; - service.P99ChartData.Data = ConvertLatencyChartData(chartData, item => item.P99).Json; - } - service.LatencyChartData.ChartLoading = false; - service.ThroughputChartData.ChartLoading = false; - service.FailedChartData.ChartLoading = false; - service.P95ChartData.ChartLoading = false; - service.P99ChartData.ChartLoading = false; - } - StateHasChanged(); - } - - private static EChartType ConvertLatencyChartData(ChartLineDto data, Func fnProperty, string lineColor = null, string areaLineColor = null) - { - var chart = EChartConst.Line; - chart.SetValue("tooltip", new { }); - chart.SetValue("legend", new { }); - chart.SetValue("xAxis.show", false); - chart.SetValue("yAxis.show", false); - chart.SetValue("grid", new { top = "0%", left = "0%", right = "0%", bottom = "0%" }); - var index = 0; - if (data.Currents != null && data.Currents.Any()) - { - chart.SetValue($"series[{index++}]", new { type = "line", smooth = true, symbol = "none", data = data.Currents.Select(fnProperty) }); - } - if (data.Previous != null && data.Previous.Any()) - { - chart.SetValue($"series[{index}]", new { type = "line", smooth = true, areaStyle = new { }, lineStyle = new { width = 1 }, symbol = "none", data = data.Previous.Select(fnProperty) }); - } - - return chart; - } -} +//// Copyright (c) MASA Stack All rights reserved. +//// Licensed under the MIT License. See LICENSE.txt in the project root for license information. + +//namespace Masa.Tsc.Web.Admin.Rcl.Pages.Apm.Services; + +//public partial class ShortEndpoint +//{ +// [CascadingParameter] +// public SearchData SearchData { get; set; } + +// [Parameter] +// public MetricTypes MetricType { get; set; } + +// private List> headers => new() +// { +// new() { Text = I18n.Apm("Endpoint.List.Name"), Value = nameof(ListChartData.Name)}, +// new() { Text = I18n.Apm("Endpoint.List.Latency"), Value = nameof(ListChartData.Latency) }, +// new() { Text = I18n.Apm("Endpoint.List.Throughput"), Value = nameof(ListChartData.Throughput)}, +// new() { Text = I18n.Apm("Endpoint.List.Failed"), Value = nameof(ListChartData.Failed)} +// }; + +// private int defaultSize = 5; +// private int total = 0; +// private int page = 1; +// private List data = new(); +// private bool isTableLoading = false; +// private string? sortFiled; +// private bool? sortBy; +// private string lastKey = string.Empty; + +// private async Task OnTableOptionsChanged(DataOptions sort) +// { +// if (sort.SortBy.Any()) +// sortFiled = sort.SortBy.First(); +// else +// sortFiled = default; +// if (sort.SortDesc.Any()) +// sortBy = sort.SortDesc.First(); +// else +// sortBy = default; +// await LoadASync(); +// } + +// private void OpenAsync(ListChartData item) +// { +// } + +// private ChartData GetLatencyChartData(ListChartData item) +// { +// return MetricType switch +// { +// MetricTypes.P95 => item.P95ChartData, +// MetricTypes.P99 => item.P99ChartData, +// _ => item.LatencyChartData, +// }; +// } + +// protected override async Task OnParametersSetAsync() +// { +// var key = MD5Utils.Encrypt(JsonSerializer.Serialize(SearchData)); +// if (lastKey != key) +// { +// lastKey = key; +// await LoadASync(); +// } +// await base.OnParametersSetAsync(); +// } + +// private async Task LoadASync() +// { +// if (isTableLoading) +// { +// return; +// } +// StateHasChanged(); +// await LoadPageDataAsync(); +// isTableLoading = false; +// StateHasChanged(); +// await LoadChartDataAsync(); +// } + +// private async Task LoadPageDataAsync() +// { +// if (isTableLoading) return; +// isTableLoading = true; +// var query = new BaseApmRequestDto +// { +// Page = page, +// PageSize = defaultSize, +// Start = SearchData.Start, +// End = SearchData.End, +// OrderField = sortFiled, +// Service = SearchData.Service, +// Env = SearchData.Environment, +// IsDesc = sortBy +// }; +// var result = await ApiCaller.ApmService.GetEndpointPageAsync(query); +// data.Clear(); +// if (result.Result != null && result.Result.Any()) +// { +// data.AddRange(result.Result.Select(item => new ListChartData +// { +// Name = $"{item.Method} {item.Name}", +// Service = item.Service, +// Endpoint = item.Name, +// Failed = item.Failed, +// Throughput = item.Throughput, +// Latency = item.Latency +// })); +// } +// total = (int)result.Total; +// } + +// private async Task LoadChartDataAsync() +// { +// if (data.Count == 0) +// return; +// var query = new ApmEndpointRequestDto +// { +// Page = page, +// PageSize = defaultSize, +// Start = SearchData.Start, +// End = SearchData.End, +// Service = SearchData.Service, +// Env = SearchData.Environment +// }; +// var result = await ApiCaller.ApmService.GetChartsAsync(query); +// if (result == null || !result.Any()) +// { +// return; +// } + +// foreach (var service in data) +// { +// var chartData = result.FirstOrDefault(s => s.Name == service.Name); +// service.LatencyChartData = new(); +// service.ThroughputChartData = new(); +// service.FailedChartData = new(); +// service.P95ChartData = new(); +// service.P99ChartData = new(); +// if (chartData == null) +// { +// service.LatencyChartData.EmptyChart = true; +// service.ThroughputChartData.EmptyChart = true; +// service.FailedChartData.EmptyChart = true; +// service.P95ChartData.EmptyChart = true; +// service.P99ChartData.EmptyChart = true; + +// object emptyObj = new(); +// service.LatencyChartData.Data = emptyObj; +// service.ThroughputChartData.Data = emptyObj; +// service.FailedChartData.Data = emptyObj; +// service.P95ChartData.Data = emptyObj; +// service.P99ChartData.Data = emptyObj; +// } +// else +// { +// service.LatencyChartData.Data = ConvertLatencyChartData(chartData, item => item.Latency).Json; +// service.ThroughputChartData.Data = ConvertLatencyChartData(chartData, item => item.Throughput).Json; +// service.FailedChartData.Data = ConvertLatencyChartData(chartData, item => item.Failed).Json; +// service.P95ChartData.Data = ConvertLatencyChartData(chartData, item => item.P95).Json; +// service.P99ChartData.Data = ConvertLatencyChartData(chartData, item => item.P99).Json; +// } +// service.LatencyChartData.ChartLoading = false; +// service.ThroughputChartData.ChartLoading = false; +// service.FailedChartData.ChartLoading = false; +// service.P95ChartData.ChartLoading = false; +// service.P99ChartData.ChartLoading = false; +// } +// StateHasChanged(); +// } + +// private static EChartType ConvertLatencyChartData(ChartLineDto data, Func fnProperty, string lineColor = null, string areaLineColor = null) +// { +// var chart = EChartConst.Line; +// chart.SetValue("tooltip", new { }); +// chart.SetValue("legend", new { }); +// chart.SetValue("xAxis.show", false); +// chart.SetValue("yAxis.show", false); +// chart.SetValue("grid", new { top = "0%", left = "0%", right = "0%", bottom = "0%" }); +// var index = 0; +// if (data.Currents != null && data.Currents.Any()) +// { +// chart.SetValue($"series[{index++}]", new { type = "line", smooth = true, symbol = "none", data = data.Currents.Select(fnProperty) }); +// } +// if (data.Previous != null && data.Previous.Any()) +// { +// chart.SetValue($"series[{index}]", new { type = "line", smooth = true, areaStyle = new { }, lineStyle = new { width = 1 }, symbol = "none", data = data.Previous.Select(fnProperty) }); +// } + +// return chart; +// } +//} diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Shared/ApmComponentBase.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Shared/ApmComponentBase.cs index 05914147..134c41ee 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Shared/ApmComponentBase.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Shared/ApmComponentBase.cs @@ -105,6 +105,7 @@ public static string GetUrlParam(string? service = default, DateTime? end = default, ApmComparisonTypes? comparisonType = default, string? exType = default, + string? exMsg = default, string? traceId = default, string? spanId = default, string? search = default) @@ -124,6 +125,8 @@ public static string GetUrlParam(string? service = default, text.AppendFormat("&end={0}", HttpUtility.UrlEncode(end.Value.ToString("yyyy-MM-dd HH:mm:ss"))); if (!string.IsNullOrEmpty(exType)) text.AppendFormat("&ex_type={0}", HttpUtility.UrlEncode(exType)); + if (!string.IsNullOrEmpty(exMsg)) + text.AppendFormat("&ex_msg={0}", HttpUtility.UrlEncode(exMsg).Replace(".", "x2E")); if (!string.IsNullOrEmpty(traceId)) text.AppendFormat("&traceId={0}", HttpUtility.UrlEncode(traceId)); if (!string.IsNullOrEmpty(spanId))