diff --git a/src/ApiGateways/Masa.Tsc.ApiGateways.Caller/Masa.Tsc.ApiGateways.Caller.csproj b/src/ApiGateways/Masa.Tsc.ApiGateways.Caller/Masa.Tsc.ApiGateways.Caller.csproj index 3fde42be..ab86bf5b 100644 --- a/src/ApiGateways/Masa.Tsc.ApiGateways.Caller/Masa.Tsc.ApiGateways.Caller.csproj +++ b/src/ApiGateways/Masa.Tsc.ApiGateways.Caller/Masa.Tsc.ApiGateways.Caller.csproj @@ -17,5 +17,6 @@ + diff --git a/src/Contracts/Masa.Tsc.Contracts.Admin/Infrastructure/Const/StorageConst.cs b/src/Contracts/Masa.Tsc.Contracts.Admin/Infrastructure/Const/StorageConst.cs index 362d49e4..9b5bf1f1 100644 --- a/src/Contracts/Masa.Tsc.Contracts.Admin/Infrastructure/Const/StorageConst.cs +++ b/src/Contracts/Masa.Tsc.Contracts.Admin/Infrastructure/Const/StorageConst.cs @@ -1,50 +1,50 @@ -// Copyright (c) MASA Stack All rights reserved. -// Licensed under the MIT License. See LICENSE.txt in the project root for license information. +//// 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.Contracts.Admin.Infrastructure.Const; +//namespace Masa.Tsc.Contracts.Admin.Infrastructure.Const; -public sealed class StorageConst -{ - private StorageConst() { } +//public sealed class StorageConst +//{ +// private StorageConst() { } - public static string Timestimap(bool isElasticsearch = false, bool isClickhouse = false) - { - if (isElasticsearch) - { - return "@timestamp"; - } - else if (isClickhouse) - { - return "Timestamp"; - } - return default!; - } +// public static string Timestimap(bool isElasticsearch = false, bool isClickhouse = false) +// { +// if (isElasticsearch) +// { +// return "@timestamp"; +// } +// else if (isClickhouse) +// { +// return "Timestamp"; +// } +// return default!; +// } - public const string LogLevelText = "SeverityText"; +// public const string LogLevelText = "SeverityText"; - public const string LogErrorText = "Error"; +// public const string LogErrorText = "Error"; - public const string LogWarningText = "Warning"; +// public const string LogWarningText = "Warning"; - public const string ServiceName = "Resource.service.name"; +// public const string ServiceName = "Resource.service.name"; - public const string ServiceInstance = "Resource.service.instance.id"; +// public const string ServiceInstance = "Resource.service.instance.id"; - public const string URL = "Attributes.http.target"; +// public const string URL = "Attributes.http.target"; - public const string HttpPort = "Attributes.http.status_code"; +// public const string HttpPort = "Attributes.http.status_code"; - public static string TraceId { get; private set; } = "TraceId"; +// public static string TraceId { get; private set; } = "TraceId"; - public static string SpanId { get; private set; } = "SpanId"; +// public static string SpanId { get; private set; } = "SpanId"; - public const string Environment = "Resource.service.namespace"; +// public const string Environment = "Resource.service.namespace"; - public const string ExceptionMessage = "Attributes.exception.message"; +// public const string ExceptionMessage = "Attributes.exception.message"; - public const string ExceptionType = "Attributes.exception.type"; +// public const string ExceptionType = "Attributes.exception.type"; - public const string TaskId = "Attributes.TaskId"; +// public const string TaskId = "Attributes.TaskId"; - public const string UserId = "Attributes.enduser.id"; -} \ No newline at end of file +// public const string UserId = "Attributes.enduser.id"; +//} \ No newline at end of file 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 1dd2e2fa..7ed86900 100644 --- a/src/Infrastructure/Masa.Tsc.Storage.Clickhouse.Apm/Cliclhouse/ClickhouseApmService.cs +++ b/src/Infrastructure/Masa.Tsc.Storage.Clickhouse.Apm/Cliclhouse/ClickhouseApmService.cs @@ -118,11 +118,11 @@ public async Task> GetEndpointsAsync(BaseApmRequestDto query) var period = GetPeriod(query); var tableName = Constants.GetAggregateTable(period); var (where, ors, parameters) = AppendWhere(query); - var sql = @$"select {StorageConstaaa.Current.Trace.URL} + var sql = @$"select {StorageConst.Current.Trace.URL} from {tableName} where {where} - group by ServiceName,{StorageConstaaa.Current.Trace.URL} - order by {StorageConstaaa.Current.Trace.URL}"; + group by ServiceName,{StorageConst.Current.Trace.URL} + order by {StorageConst.Current.Trace.URL}"; var result = new List(); using var reader = await Query(sql, parameters); while (await reader.NextResultAsync()) @@ -330,7 +330,7 @@ public async Task> TraceLatencyDetailAsync(A { conditions.Add(new FieldConditionDto { - Name = StorageConstaaa.Current.Environment, + Name = StorageConst.Current.Environment, Type = ConditionTypes.Equal, Value = query.Env }); @@ -340,7 +340,7 @@ public async Task> TraceLatencyDetailAsync(A { conditions.Add(new FieldConditionDto { - Name = StorageConstaaa.Current.Trace.Duration, + Name = StorageConst.Current.Trace.Duration, Type = ConditionTypes.GreatEqual, Value = (long)(query.LatMin.Value * MILLSECOND), }); @@ -351,7 +351,7 @@ public async Task> TraceLatencyDetailAsync(A || query.LatMin.HasValue && query.LatMax - query.LatMin.Value > 0)) conditions.Add(new FieldConditionDto { - Name = StorageConstaaa.Current.Trace.Duration, + Name = StorageConst.Current.Trace.Duration, Type = ConditionTypes.LessEqual, Value = (long)(query.LatMax.Value * MILLSECOND), }); @@ -388,11 +388,11 @@ public async Task> GetSimpleTraceListAsync private static SimpleTraceListDto ToSampleTraceListDto(IDataReader reader) { - var startTime = Convert.ToDateTime(reader[StorageConstaaa.Current.Timestimap]); + var startTime = Convert.ToDateTime(reader[StorageConst.Current.Timestimap]); long ns = Convert.ToInt64(reader["Duration"]); var result = new SimpleTraceListDto { - TraceId = reader[StorageConstaaa.Current.TraceId].ToString()!, + TraceId = reader[StorageConst.Current.TraceId].ToString()!, Timestamp = startTime, EndTimestamp = startTime.AddMilliseconds(ns / 1e6), }; @@ -656,17 +656,17 @@ private static (string where, List ors, List parame { List parameters = new(); var sql = new StringBuilder(); - sql.AppendLine($" {StorageConstaaa.Current.Timestimap} between @startTime and @endTime"); + sql.AppendLine($" {StorageConst.Current.Timestimap} between @startTime and @endTime"); parameters.Add(new ClickHouseParameter { ParameterName = "startTime", Value = MasaStackClickhouseConnection.ToTimeZone(query.Start), DbType = DbType.DateTime }); parameters.Add(new ClickHouseParameter { ParameterName = "endTime", Value = MasaStackClickhouseConnection.ToTimeZone(query.End), DbType = DbType.DateTime }); if (!string.IsNullOrEmpty(query.Env)) { - sql.AppendLine($" and {StorageConstaaa.Current.Environment}=@environment"); + sql.AppendLine($" and {StorageConst.Current.Environment}=@environment"); parameters.Add(new ClickHouseParameter { ParameterName = "environment", Value = query.Env }); } if (!string.IsNullOrEmpty(query.Service)) { - sql.AppendLine($" and {StorageConstaaa.Current.ServiceName}=@serviceName"); + sql.AppendLine($" and {StorageConst.Current.ServiceName}=@serviceName"); parameters.Add(new ClickHouseParameter { ParameterName = "serviceName", Value = query.Service }); } //if (query.IsServer.HasValue && (query.IsMetric == null || !query.IsMetric.Value)) @@ -703,11 +703,11 @@ private static List AppendRawQuery(TQuery query, List AppendRawQuery(TQuery query, List= 0 && num - 600 < 0 && isTrace) { - list.Add($" and {StorageConstaaa.Current.Trace.HttpStatusCode}='{query.Queries}'"); + list.Add($" and {StorageConst.Current.Trace.HttpStatusCode}='{query.Queries}'"); return list; } //exception if (str.EndsWith("exception", StringComparison.CurrentCultureIgnoreCase) && Regex.IsMatch(str, @"[\da-zA-Z]+")) { - list.Add($" and {StorageConstaaa.Current.ExceptionType} = '{str}'"); + list.Add($" and {StorageConst.Current.ExceptionType} = '{str}'"); return list; } if (isLog) { - list.Add(ClickhouseHelper.AppendLike(StorageConstaaa.Current.Log.Body, "p1", str)); + list.Add(ClickhouseHelper.AppendLike(StorageConst.Current.Log.Body, "p1", str)); } else if (isTrace) { - list.Add(ClickhouseHelper.AppendLike(StorageConstaaa.Current.Trace.URL, "p1", str)); - list.Add(ClickhouseHelper.AppendLike(StorageConstaaa.Current.Trace.HttpRequestBody, "p1", str)); + list.Add(ClickhouseHelper.AppendLike(StorageConst.Current.Trace.URL, "p1", str)); + list.Add(ClickhouseHelper.AppendLike(StorageConst.Current.Trace.HttpRequestBody, "p1", str)); } if (!isTrace) - list.Add(ClickhouseHelper.AppendLike(StorageConstaaa.Current.ExceptionMessage, "p1", str)); + list.Add(ClickhouseHelper.AppendLike(StorageConst.Current.ExceptionMessage, "p1", str)); parameters.Add(ClickhouseHelper.GetLikeParameter("p1", str)); return list; @@ -765,12 +765,12 @@ private static void AppendEndpoint(ApmEndpointRequestDto? traceQuery, StringBuil var name = "endpoint"; if (traceQuery.IsLog.HasValue && traceQuery.IsLog.Value) { - sql.AppendLine($" and {ClickhouseHelper.GetName(StorageConstaaa.Current.Log.Url, true)} like @{name}"); + sql.AppendLine($" and {ClickhouseHelper.GetName(StorageConst.Current.Log.Url, true)} like @{name}"); parameters.Add(new ClickHouseParameter { ParameterName = name, Value = $"{traceQuery.Endpoint}%" }); } else { - sql.AppendLine($" and {StorageConstaaa.Current.Trace.URL}=@{name}"); + sql.AppendLine($" and {StorageConst.Current.Trace.URL}=@{name}"); parameters.Add(new ClickHouseParameter { ParameterName = name, Value = traceQuery.Endpoint }); } } @@ -780,12 +780,12 @@ private static void AppendDuration(ApmTraceLatencyRequestDto? query, StringBuild if (query == null || !query.LatMin.HasValue && !query.LatMax.HasValue || query.IsMetric != null && query.IsMetric.Value) return; if (query.LatMin.HasValue && query.LatMin > 0) { - sql.AppendLine($" and {StorageConstaaa.Current.Trace.Duration} >=@minDuration"); + sql.AppendLine($" and {StorageConst.Current.Trace.Duration} >=@minDuration"); parameters.Add(new ClickHouseParameter { ParameterName = "minDuration", Value = (long)(query.LatMin * MILLSECOND) }); } if (query.LatMax.HasValue && query.LatMax > 0) { - sql.AppendLine($" and {StorageConstaaa.Current.Trace.Duration} <=@maxDuration"); + sql.AppendLine($" and {StorageConst.Current.Trace.Duration} <=@maxDuration"); parameters.Add(new ClickHouseParameter { ParameterName = "maxDuration", Value = (long)(query.LatMax * MILLSECOND) }); } } diff --git a/src/Infrastructure/Masa.Tsc.Storage.Clickhouse.Apm/Cliclhouse/ClickhouseApmServiceNew.cs b/src/Infrastructure/Masa.Tsc.Storage.Clickhouse.Apm/Cliclhouse/ClickhouseApmServiceNew.cs index 98e55cd0..df10c51f 100644 --- a/src/Infrastructure/Masa.Tsc.Storage.Clickhouse.Apm/Cliclhouse/ClickhouseApmServiceNew.cs +++ b/src/Infrastructure/Masa.Tsc.Storage.Clickhouse.Apm/Cliclhouse/ClickhouseApmServiceNew.cs @@ -24,16 +24,16 @@ public ClickhouseApmServiceNew(MasaStackClickhouseConnection dbConnection, ITrac _logger = logger; serviceOrders ??= new() { - { nameof(ServiceListDto.Name), StorageConstaaa.Current.ServiceName }, - { nameof(ServiceListDto.Envs), StorageConstaaa.Current.Environment }, + { nameof(ServiceListDto.Name), StorageConst.Current.ServiceName }, + { nameof(ServiceListDto.Envs), StorageConst.Current.Environment }, { nameof(ServiceListDto.Latency), "Latency" }, { nameof(ServiceListDto.Throughput), "Throughput" }, { nameof(ServiceListDto.Failed), "Failed" }, }; endpointOrders ??= new() { - { nameof(EndpointListDto.Name), StorageConstaaa.Current.Trace.URL }, - { nameof(EndpointListDto.Service), StorageConstaaa.Current.ServiceName }, - { nameof(EndpointListDto.Method), StorageConstaaa.Current.Trace.HttpMethod }, + { nameof(EndpointListDto.Name), StorageConst.Current.Trace.URL }, + { nameof(EndpointListDto.Service), StorageConst.Current.ServiceName }, + { nameof(EndpointListDto.Method), StorageConst.Current.Trace.HttpMethod }, { nameof(EndpointListDto.Latency), "Latency" }, { nameof(EndpointListDto.Throughput), "Throughput" }, { nameof(EndpointListDto.Failed), "Failed" }, @@ -282,7 +282,7 @@ public async Task> TraceLatencyDetailAsync(A { conditions.Add(new FieldConditionDto { - Name = StorageConstaaa.Current.Environment, + Name = StorageConst.Current.Environment, Type = ConditionTypes.Equal, Value = query.Env }); @@ -292,7 +292,7 @@ public async Task> TraceLatencyDetailAsync(A { conditions.Add(new FieldConditionDto { - Name = StorageConstaaa.Current.Trace.Duration, + Name = StorageConst.Current.Trace.Duration, Type = ConditionTypes.GreatEqual, Value = (long)(query.LatMin.Value * MILLSECOND), }); @@ -303,7 +303,7 @@ public async Task> TraceLatencyDetailAsync(A || query.LatMin.HasValue && query.LatMax - query.LatMin.Value > 0)) conditions.Add(new FieldConditionDto { - Name = StorageConstaaa.Current.Trace.Duration, + Name = StorageConst.Current.Trace.Duration, Type = ConditionTypes.LessEqual, Value = (long)(query.LatMax.Value * MILLSECOND), }); @@ -318,7 +318,7 @@ public async Task> GetSimpleTraceListAsync //query.IsServer = default; //query.IsTrace = true; var (where, ors, parameters) = AppendWhere(query); - var orderBy = GetOrderBy(query, new() { { StorageConstaaa.Current.Timestimap, StorageConstaaa.Current.Timestimap } }); + var orderBy = GetOrderBy(query, new() { { StorageConst.Current.Timestimap, StorageConst.Current.Timestimap } }); PaginatedListBase result = new() { }; if (query.HasPage) @@ -340,11 +340,11 @@ public async Task> GetSimpleTraceListAsync private static SimpleTraceListDto ToSampleTraceListDto(IDataReader reader) { - var startTime = Convert.ToDateTime(reader[StorageConstaaa.Current.Timestimap]); + var startTime = Convert.ToDateTime(reader[StorageConst.Current.Timestimap]); long ns = Convert.ToInt64(reader["Duration"]); var result = new SimpleTraceListDto { - TraceId = reader[StorageConstaaa.Current.TraceId].ToString()!, + TraceId = reader[StorageConst.Current.TraceId].ToString()!, Timestamp = startTime, EndTimestamp = startTime.AddMilliseconds(ns / 1e6), }; @@ -603,11 +603,11 @@ public async Task> GetEndpointsAsync(BaseApmRequestDto query) var period = GetPeriod(query); var tableName = Constants.GetAggregateTable(period); var (where, ors, parameters) = AppendWhere(query); - var sql = @$"select {StorageConstaaa.Current.Trace.URL} + var sql = @$"select {StorageConst.Current.Trace.URL} from {tableName} where {where} - group by ServiceName,{StorageConstaaa.Current.Trace.URL} - order by {StorageConstaaa.Current.Trace.URL}"; + group by ServiceName,{StorageConst.Current.Trace.URL} + order by {StorageConst.Current.Trace.URL}"; var result = new List(); using var reader = await Query(sql, parameters); while (await reader.NextResultAsync()) @@ -673,28 +673,28 @@ private static (string where, List ors, List parame if (!string.IsNullOrEmpty(query.ExType)) { query.IsInstrument = true; - sql.AppendLine($" and {StorageConstaaa.Current.ExceptionType}=@exType"); + sql.AppendLine($" and {StorageConst.Current.ExceptionType}=@exType"); parameters.Add(new ClickHouseParameter { ParameterName = "exType", Value = query.ExType }); } if (!string.IsNullOrEmpty(query.TraceId)) { query.IsInstrument = true; - sql.AppendLine($" and {StorageConstaaa.Current.TraceId}=@traceId"); + sql.AppendLine($" and {StorageConst.Current.TraceId}=@traceId"); parameters.Add(new ClickHouseParameter { ParameterName = "traceId", Value = query.TraceId }); } if (!string.IsNullOrEmpty(query.TextField) && !string.IsNullOrEmpty(query.TextValue)) { query.IsInstrument = true; - if (string.Equals(query.TextField, StorageConstaaa.Current.TraceId)) + if (string.Equals(query.TextField, StorageConst.Current.TraceId)) { - sql.AppendLine($" and {StorageConstaaa.Current.TraceId}=@traceId"); + sql.AppendLine($" and {StorageConst.Current.TraceId}=@traceId"); parameters.Add(new ClickHouseParameter { ParameterName = "traceId", Value = query.TextValue.Trim() }); } - else if (string.Equals(query.TextField, StorageConstaaa.Current.SpanId)) + else if (string.Equals(query.TextField, StorageConst.Current.SpanId)) { - sql.AppendLine($" and {StorageConstaaa.Current.SpanId}=@spanId"); + sql.AppendLine($" and {StorageConst.Current.SpanId}=@spanId"); parameters.Add(new ClickHouseParameter { ParameterName = "spanId", Value = query.TextValue.Trim() }); } else @@ -707,7 +707,7 @@ private static (string where, List ors, List parame if (!string.IsNullOrEmpty(query.ExMessage)) { query.IsInstrument = true; - sql.AppendLine($" and {StorageConstaaa.Current.ExceptionMessage} like @exMessage"); + sql.AppendLine($" and {StorageConst.Current.ExceptionMessage} like @exMessage"); parameters.Add(new ClickHouseParameter { ParameterName = "exMessage", Value = $"{query.ExMessage}%" }); } @@ -762,7 +762,7 @@ private static void AppendEndpoint(ApmEndpointRequestDto? traceQuery, StringBuil { if (!string.IsNullOrEmpty(traceQuery.Endpoint)) { - sql.AppendLine($" and {ClickhouseHelper.GetName(StorageConstaaa.Current.Log.Url, true)} like @{name}"); + sql.AppendLine($" and {ClickhouseHelper.GetName(StorageConst.Current.Log.Url, true)} like @{name}"); parameters.Add(new ClickHouseParameter { ParameterName = name, Value = $"{traceQuery.Endpoint}%" }); } } @@ -770,13 +770,13 @@ private static void AppendEndpoint(ApmEndpointRequestDto? traceQuery, StringBuil { if (!string.IsNullOrEmpty(traceQuery.Endpoint)) { - sql.AppendLine($" and {StorageConstaaa.Current.Trace.URL}=@{name}"); + sql.AppendLine($" and {StorageConst.Current.Trace.URL}=@{name}"); parameters.Add(new ClickHouseParameter { ParameterName = name, Value = traceQuery.Endpoint }); } if (!string.IsNullOrEmpty(traceQuery.Method)) { - sql.AppendLine($" and {StorageConstaaa.Current.Trace.HttpMethod}=@method"); + sql.AppendLine($" and {StorageConst.Current.Trace.HttpMethod}=@method"); parameters.Add(new ClickHouseParameter { ParameterName = "method", Value = traceQuery.Endpoint }); } @@ -785,7 +785,7 @@ private static void AppendEndpoint(ApmEndpointRequestDto? traceQuery, StringBuil if (traceQuery.IsTrace.HasValue && traceQuery.IsTrace!.Value && !string.IsNullOrEmpty(traceQuery.StatusCode)) { traceQuery.IsInstrument = true; - sql.AppendLine($" and {StorageConstaaa.Current.Trace.HttpStatusCode}=@status_code"); + sql.AppendLine($" and {StorageConst.Current.Trace.HttpStatusCode}=@status_code"); parameters.Add(new ClickHouseParameter { ParameterName = "status_code", Value = traceQuery.StatusCode }); } } @@ -797,12 +797,12 @@ private static void AppendDuration(ApmTraceLatencyRequestDto? query, StringBuild if (query == null || !query.LatMin.HasValue && !query.LatMax.HasValue || query.IsMetric != null && query.IsMetric.Value) return; if (query.LatMin.HasValue && query.LatMin > 0) { - sql.AppendLine($" and {StorageConstaaa.Current.Trace.Duration} >=@minDuration"); + sql.AppendLine($" and {StorageConst.Current.Trace.Duration} >=@minDuration"); parameters.Add(new ClickHouseParameter { ParameterName = "minDuration", Value = (long)(query.LatMin * MILLSECOND) }); } if (query.LatMax.HasValue && query.LatMax > 0) { - sql.AppendLine($" and {StorageConstaaa.Current.Trace.Duration} <=@maxDuration"); + sql.AppendLine($" and {StorageConst.Current.Trace.Duration} <=@maxDuration"); parameters.Add(new ClickHouseParameter { ParameterName = "maxDuration", Value = (long)(query.LatMax * MILLSECOND) }); } } @@ -1015,17 +1015,17 @@ private static (string, List) GetMetricWhere(TReq { List parameters = new(); var sql = new StringBuilder(); - sql.AppendLine($" {StorageConstaaa.Current.Timestimap} between @startTime and @endTime"); + sql.AppendLine($" {StorageConst.Current.Timestimap} between @startTime and @endTime"); parameters.Add(new ClickHouseParameter { ParameterName = "startTime", Value = MasaStackClickhouseConnection.ToTimeZone(query.Start), DbType = DbType.DateTime }); parameters.Add(new ClickHouseParameter { ParameterName = "endTime", Value = MasaStackClickhouseConnection.ToTimeZone(query.End), DbType = DbType.DateTime }); if (!string.IsNullOrEmpty(query.Env)) { - sql.AppendLine($" and {StorageConstaaa.Current.Environment}=@environment"); + sql.AppendLine($" and {StorageConst.Current.Environment}=@environment"); parameters.Add(new ClickHouseParameter { ParameterName = "environment", Value = query.Env }); } if (!string.IsNullOrEmpty(query.Service)) { - sql.AppendLine($" and {StorageConstaaa.Current.ServiceName}=@serviceName"); + sql.AppendLine($" and {StorageConst.Current.ServiceName}=@serviceName"); parameters.Add(new ClickHouseParameter { ParameterName = "serviceName", Value = query.Service }); } if (isContainsEndpoint) diff --git a/src/Infrastructure/Masa.Tsc.Storage.Clickhouse/ClickhouseHelper.cs b/src/Infrastructure/Masa.Tsc.Storage.Clickhouse/ClickhouseHelper.cs index b669a34f..3ffbbdbd 100644 --- a/src/Infrastructure/Masa.Tsc.Storage.Clickhouse/ClickhouseHelper.cs +++ b/src/Infrastructure/Masa.Tsc.Storage.Clickhouse/ClickhouseHelper.cs @@ -12,14 +12,14 @@ private ClickhouseHelper() { } public static string GetName(string name, bool isLog) { - if (name.Equals("@timestamp", StringComparison.CurrentCultureIgnoreCase) || name.Equals(StorageConstaaa.Current.Timestimap, StringComparison.CurrentCultureIgnoreCase)) - return StorageConstaaa.Current.Timestimap; + if (name.Equals("@timestamp", StringComparison.CurrentCultureIgnoreCase) || name.Equals(StorageConst.Current.Timestimap, StringComparison.CurrentCultureIgnoreCase)) + return StorageConst.Current.Timestimap; - if (!isLog && name.Equals(StorageConstaaa.Current.Trace.Duration, StringComparison.CurrentCultureIgnoreCase)) - return StorageConstaaa.Current.Trace.Duration; + if (!isLog && name.Equals(StorageConst.Current.Trace.Duration, StringComparison.CurrentCultureIgnoreCase)) + return StorageConst.Current.Trace.Duration; - if (!isLog && (name.Equals("kind", StringComparison.InvariantCultureIgnoreCase) || name.Equals(StorageConstaaa.Current.Trace.SpanKind, StringComparison.InvariantCultureIgnoreCase))) - return StorageConstaaa.Current.Trace.SpanKind; + if (!isLog && (name.Equals("kind", StringComparison.InvariantCultureIgnoreCase) || name.Equals(StorageConst.Current.Trace.SpanKind, StringComparison.InvariantCultureIgnoreCase))) + return StorageConst.Current.Trace.SpanKind; if (name.StartsWith(RESOURCE_KEY, StringComparison.CurrentCultureIgnoreCase)) return GetResourceName(name); diff --git a/src/Infrastructure/Masa.Tsc.Storage.Clickhouse/ClickhouseStorageConst.cs b/src/Infrastructure/Masa.Tsc.Storage.Clickhouse/ClickhouseStorageConst.cs index e30deda7..a8f8788e 100644 --- a/src/Infrastructure/Masa.Tsc.Storage.Clickhouse/ClickhouseStorageConst.cs +++ b/src/Infrastructure/Masa.Tsc.Storage.Clickhouse/ClickhouseStorageConst.cs @@ -1,9 +1,9 @@ // 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.Storage.Contracts; +namespace Masa.Tsc.Storage.Clickhouse; -public class ClickhouseStorageConst : StorageConstaaa +public class ClickhouseStorageConst : StorageConst { private readonly ClickhouseStorageLog log = new(); private readonly ClickhouseStorageTrace trace = new(); @@ -47,6 +47,8 @@ internal ClickhouseStorageLog() { } public override string LogWarningText => "Warning"; public override string Url => "Attributes.http.target"; + + public override string TaskId => "Attributes.TaskId"; } public class ClickhouseStorageTrace : StorageTrace diff --git a/src/Infrastructure/Masa.Tsc.Storage.Clickhouse/Extensions/IDbConnectionExtensitions.cs b/src/Infrastructure/Masa.Tsc.Storage.Clickhouse/Extensions/IDbConnectionExtensitions.cs index 0046c2e9..406848a2 100644 --- a/src/Infrastructure/Masa.Tsc.Storage.Clickhouse/Extensions/IDbConnectionExtensitions.cs +++ b/src/Infrastructure/Masa.Tsc.Storage.Clickhouse/Extensions/IDbConnectionExtensitions.cs @@ -81,7 +81,7 @@ public static List GetTraceByTraceId(this IDbConnection connec //query.Start = default; //query.End = default; var (where, parameters, _) = AppendWhere(query); - var timeField = StorageConstaaa.Current.Timestimap; + var timeField = StorageConst.Current.Timestimap; return Query(connection, $@"select * from ( select {timeField},TraceId,SpanId,ParentSpanId,TraceState,SpanKind,Duration,SpanName,Spans,Resources from {MasaStackClickhouseConnection.TraceHttpServerTable} where {where} @@ -96,7 +96,7 @@ order by {timeField} public static string AppendOrderBy(BaseRequestDto query, bool isLog) { - var field = StorageConstaaa.Current.Timestimap; + var field = StorageConst.Current.Timestimap; var isDesc = query.Sort?.IsDesc ?? true; if (isLog && query.Sort != null && !string.IsNullOrEmpty(query.Sort.Name)) { @@ -115,28 +115,28 @@ public static (string where, List @parameters, List ors) && query.End > DateTime.MinValue && query.End < DateTime.MaxValue && query.End > query.Start) { - sql.Append($" and {StorageConstaaa.Current.Timestimap} BETWEEN @Start and @End"); + sql.Append($" and {StorageConst.Current.Timestimap} BETWEEN @Start and @End"); @paramerters.Add(new ClickHouseParameter() { ParameterName = "Start", Value = MasaStackClickhouseConnection.ToTimeZone(query.Start), DbType = DbType.DateTime2 }); @paramerters.Add(new ClickHouseParameter() { ParameterName = "End", Value = MasaStackClickhouseConnection.ToTimeZone(query.End), DbType = DbType.DateTime2 }); } if (!string.IsNullOrEmpty(query.Service)) { - sql.Append($" and {ClickhouseHelper.GetName(StorageConstaaa.Current.ServiceName, !isTrace)} = @serviceName"); + sql.Append($" and {ClickhouseHelper.GetName(StorageConst.Current.ServiceName, !isTrace)} = @serviceName"); @paramerters.Add(new ClickHouseParameter() { ParameterName = "serviceName", Value = query.Service }); } if (!string.IsNullOrEmpty(query.Instance)) { - sql.Append($" and {ClickhouseHelper.GetName(StorageConstaaa.Current.ServiceInstance, !isTrace)} = @serviceInstanceId"); + sql.Append($" and {ClickhouseHelper.GetName(StorageConst.Current.ServiceInstance, !isTrace)} = @serviceInstanceId"); @paramerters.Add(new ClickHouseParameter() { ParameterName = "serviceInstanceId", Value = query.Instance }); } if (isTrace && !string.IsNullOrEmpty(query.Endpoint)) { - sql.Append($" and {ClickhouseHelper.GetName(StorageConstaaa.Current.Trace.URL, !isTrace)} = @httpTarget"); + sql.Append($" and {ClickhouseHelper.GetName(StorageConst.Current.Trace.URL, !isTrace)} = @httpTarget"); @paramerters.Add(new ClickHouseParameter() { ParameterName = "httpTarget", Value = query.Endpoint }); } if (!string.IsNullOrEmpty(query.TraceId)) { - sql.Append($" and {StorageConstaaa.Current.TraceId} = @TraceId"); + sql.Append($" and {StorageConst.Current.TraceId} = @TraceId"); @paramerters.Add(new ClickHouseParameter() { ParameterName = "TraceId", Value = query.TraceId }); } @@ -174,43 +174,43 @@ private static List AppendKeyword(string keyword, List @ { if (int.TryParse(keyword, out var num) && num - -1 > 0 && num - 600 < 0) { - sqls.Add($" and {ClickhouseHelper.GetName(StorageConstaaa.Current.Trace.HttpStatusCode, !isTrace)}=@HttpStatusCode"); + sqls.Add($" and {ClickhouseHelper.GetName(StorageConst.Current.Trace.HttpStatusCode, !isTrace)}=@HttpStatusCode"); paramerters.Add(new ClickHouseParameter() { ParameterName = "HttpStatusCode", Value = keyword }); return sqls; } if (Guid.TryParse(keyword, out var _) && keyword.Length - 32 == 0) { - sqls.Add($" and {StorageConstaaa.Current.TraceId}=@TraceUserId"); + sqls.Add($" and {StorageConst.Current.TraceId}=@TraceUserId"); paramerters.Add(new ClickHouseParameter() { ParameterName = "TraceUserId", Value = keyword }); return sqls; } else { - sqls.Add(ClickhouseHelper.AppendLike(ClickhouseHelper.GetName(StorageConstaaa.Current.Trace.HttpRequestBody, false), "Keyword", keyword)); - sqls.Add(ClickhouseHelper.AppendLike(ClickhouseHelper.GetName(StorageConstaaa.Current.Trace.URLFull, false), "Keyword", keyword)); + sqls.Add(ClickhouseHelper.AppendLike(ClickhouseHelper.GetName(StorageConst.Current.Trace.HttpRequestBody, false), "Keyword", keyword)); + sqls.Add(ClickhouseHelper.AppendLike(ClickhouseHelper.GetName(StorageConst.Current.Trace.URLFull, false), "Keyword", keyword)); } } else { if (keyword.Equals("error", StringComparison.CurrentCultureIgnoreCase)) { - sqls.Add($" and {StorageConstaaa.Current.Log.LogLevelText}='Error'"); + sqls.Add($" and {StorageConst.Current.Log.LogLevelText}='Error'"); return sqls; } if (keyword.EndsWith("exception", StringComparison.CurrentCultureIgnoreCase) && Regex.IsMatch(keyword, @"[\da-zA-Z]+")) { - sqls.Add($" and {StorageConstaaa.Current.ExceptionType} = '{keyword}'"); + sqls.Add($" and {StorageConst.Current.ExceptionType} = '{keyword}'"); return sqls; } if (Guid.TryParse(keyword, out var _)) { - sqls.Add($" and {StorageConstaaa.Current.TraceId}=@TraceUserId"); + sqls.Add($" and {StorageConst.Current.TraceId}=@TraceUserId"); paramerters.Add(new ClickHouseParameter() { ParameterName = "TraceUserId", Value = keyword }); return sqls; } - sqls.Add(ClickhouseHelper.AppendLike(StorageConstaaa.Current.Log.Body, "Keyword", keyword)); - sqls.Add(ClickhouseHelper.AppendLike(ClickhouseHelper.GetName(StorageConstaaa.Current.ExceptionMessage, !isTrace), "Keyword", keyword)); + sqls.Add(ClickhouseHelper.AppendLike(StorageConst.Current.Log.Body, "Keyword", keyword)); + sqls.Add(ClickhouseHelper.AppendLike(ClickhouseHelper.GetName(StorageConst.Current.ExceptionMessage, !isTrace), "Keyword", keyword)); } paramerters.Add(ClickhouseHelper.GetLikeParameter("Keyword", keyword)); @@ -230,15 +230,15 @@ private static void AppendConditions(IEnumerable? conditions, { item.Value = MasaStackClickhouseConnection.ToTimeZone(time); } - else if (string.Equals(name, StorageConstaaa.Current.ServiceName, StringComparison.CurrentCultureIgnoreCase)) + else if (string.Equals(name, StorageConst.Current.ServiceName, StringComparison.CurrentCultureIgnoreCase)) { AppendField(item, @paramerters, sql, name, "serviceName"); } - else if (string.Equals(name, StorageConstaaa.Current.ServiceInstance, StringComparison.CurrentCultureIgnoreCase)) + else if (string.Equals(name, StorageConst.Current.ServiceInstance, StringComparison.CurrentCultureIgnoreCase)) { AppendField(item, @paramerters, sql, name, "serviceInstanceId"); } - else if (string.Equals(name, StorageConstaaa.Current.Environment, StringComparison.CurrentCultureIgnoreCase)) + else if (string.Equals(name, StorageConst.Current.Environment, StringComparison.CurrentCultureIgnoreCase)) { AppendField(item, @paramerters, sql, name, "serviceNameSpace"); } @@ -412,7 +412,7 @@ public static MappingResponseDto ConvertToMapping(IDataReader reader) public static TraceResponseDto ConvertTraceDto(IDataReader reader) { - var startTime = Convert.ToDateTime(reader[StorageConstaaa.Current.Timestimap]); + var startTime = Convert.ToDateTime(reader[StorageConst.Current.Timestimap]); long ns = Convert.ToInt64(reader["Duration"]); string resource = reader["Resources"].ToString()!, spans = reader["Spans"].ToString()!; var result = new TraceResponseDto @@ -444,7 +444,7 @@ public static LogResponseDto ConvertLogDto(IDataReader reader) SeverityText = reader["SeverityText"].ToString()!, TraceFlags = Convert.ToInt32(reader["TraceFlags"]), SpanId = reader["SpanId"].ToString()!, - Timestamp = Convert.ToDateTime(reader[StorageConstaaa.Current.Timestimap]), + Timestamp = Convert.ToDateTime(reader[StorageConst.Current.Timestimap]), }; if (!string.IsNullOrEmpty(resource)) result.Resource = JsonSerializer.Deserialize>(resource)!; @@ -571,7 +571,7 @@ public static int ConvertInterval(string s) public static string GetMaxDelayTraceId(this IDbConnection dbConnection, BaseRequestDto requestDto) { var (where, parameters, _) = AppendWhere(requestDto); - var text = $"select * from( {StorageConstaaa.Current.TraceId} from {MasaStackClickhouseConnection.TraceHttpServerTable} where {where} order by {StorageConstaaa.Current.Trace.Duration} desc) as t limit 1"; + var text = $"select * from( {StorageConst.Current.TraceId} from {MasaStackClickhouseConnection.TraceHttpServerTable} where {where} order by {StorageConst.Current.Trace.Duration} desc) as t limit 1"; return dbConnection.ExecuteScalar(text, parameters?.ToArray())?.ToString()!; } } diff --git a/src/Infrastructure/Masa.Tsc.Storage.Contracts/StorageConstaaa.cs b/src/Infrastructure/Masa.Tsc.Storage.Contracts/StorageConst.cs similarity index 89% rename from src/Infrastructure/Masa.Tsc.Storage.Contracts/StorageConstaaa.cs rename to src/Infrastructure/Masa.Tsc.Storage.Contracts/StorageConst.cs index 51505a88..51679f7e 100644 --- a/src/Infrastructure/Masa.Tsc.Storage.Contracts/StorageConstaaa.cs +++ b/src/Infrastructure/Masa.Tsc.Storage.Contracts/StorageConst.cs @@ -3,11 +3,11 @@ namespace Masa.Tsc.Storage.Contracts; -public class StorageConstaaa +public class StorageConst { - public static StorageConstaaa Current { get; protected set; } + public static StorageConst Current { get; protected set; } - protected StorageConstaaa() + protected StorageConst() { if (Current == null) { @@ -17,7 +17,7 @@ protected StorageConstaaa() } } - public static void Init(StorageConstaaa current) => Current ??= current; + public static void Init(StorageConst current) => Current ??= current; public virtual string Timestimap => "Timestamp"; @@ -58,6 +58,8 @@ internal static StorageLog GetInstance() public virtual string LogWarningText => "Warning"; public virtual string Url => "RequestPath"; + + public virtual string TaskId => "Attributes.TaskId"; } public class StorageTrace diff --git a/src/Infrastructure/Masa.Tsc.Storage.Elasticsearch/ElasticsearchStorageConst.cs b/src/Infrastructure/Masa.Tsc.Storage.Elasticsearch/ElasticsearchStorageConst.cs new file mode 100644 index 00000000..6ff18330 --- /dev/null +++ b/src/Infrastructure/Masa.Tsc.Storage.Elasticsearch/ElasticsearchStorageConst.cs @@ -0,0 +1,69 @@ +// 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.Storage.Elasticsearch; + +public class ElasticsearchStorageConst : StorageConst +{ + private readonly ElasticsearchStorageLog log = new(); + private readonly ElasticsearchStorageTrace trace = new(); + + public ElasticsearchStorageConst() : base() + { + Current = this; + } + + public override string Timestimap => "@timestamp"; + + public override string ServiceName => "Resource.service.name"; + + public override string ServiceInstance => "Resource.service.instance.id"; + + public override string Environment => "Resource.service.namespace"; + + public override string TraceId => "TraceId"; + + public override string SpanId => "SpanId"; + + public override string ExceptionMessage => "Attributes.exception.message"; + + public override string ExceptionType => "Attributes.exception.type"; + + public override StorageLog Log => log; + + public override StorageTrace Trace => trace; +} + +public class ElasticsearchStorageLog : StorageLog +{ + internal ElasticsearchStorageLog() { } + + public override string Body => "Body"; + + public override string LogLevelText => "SeverityText"; + + public override string LogErrorText => "Error"; + + public override string LogWarningText => "Warning"; + + public override string Url => "Attributes.http.target"; + + public override string TaskId => "Attributes.TaskId"; +} + +public class ElasticsearchStorageTrace : StorageTrace +{ + internal ElasticsearchStorageTrace() { } + + public override string URL => "Attributes.http.target"; + + public override string URLFull => "Attributes.http.url"; + + public override string HttpStatusCode => "Attributes.http.status_code"; + + public override string HttpMethod => "Attributes.http.method"; + + public override string HttpRequestBody => "Attributes.http.request_content_body"; + + public override string UserId => "Attributes.enduser.id"; +} \ No newline at end of file diff --git a/src/Infrastructure/Masa.Tsc.Storage.Elasticsearch/Extenistions/ServiceExtenistion.cs b/src/Infrastructure/Masa.Tsc.Storage.Elasticsearch/Extenistions/ServiceExtenistion.cs index e95ad673..e3aa246f 100644 --- a/src/Infrastructure/Masa.Tsc.Storage.Elasticsearch/Extenistions/ServiceExtenistion.cs +++ b/src/Infrastructure/Masa.Tsc.Storage.Elasticsearch/Extenistions/ServiceExtenistion.cs @@ -78,6 +78,7 @@ public static IServiceCollection AddElasticClientLogAndTrace(this IServiceCollec private static IServiceCollection AddElasticsearch(IServiceCollection services, string[] nodes, string name) { + _ = new ElasticsearchStorageConst(); return services.AddElasticsearch(name, options => { options.UseNodes(nodes).UseConnectionSettings(setting => setting.EnableApiVersioningHeader(false)); diff --git a/src/Services/Masa.Tsc.Service.Admin/Application/Logs/QueryHandler.cs b/src/Services/Masa.Tsc.Service.Admin/Application/Logs/QueryHandler.cs index 321a8f54..ae183154 100644 --- a/src/Services/Masa.Tsc.Service.Admin/Application/Logs/QueryHandler.cs +++ b/src/Services/Masa.Tsc.Service.Admin/Application/Logs/QueryHandler.cs @@ -35,7 +35,7 @@ public async Task GetLatestDataAsync(LatestLogQuery queryData) RawQuery = queryData.Query, Page = 1, PageSize = 1, - Sort = new FieldOrderDto { Name = StorageConst.Timestimap(ConfigConst.IsElasticsearch, ConfigConst.IsClickhouse), IsDesc = !queryData.IsDesc } + Sort = new FieldOrderDto { Name = StorageConst.Current.Timestimap, IsDesc = !queryData.IsDesc } }; if (query.End < query.Start) { @@ -91,7 +91,7 @@ public async Task GetPageListAsync(LogsQuery queryData) }); } - bool isRawQuery = queryData.Query.IsRawQuery(ConfigConst.StorageConst.IsElasticSearch, ConfigConst.StorageConst.IsClickhouse);// (queryData.Query?.IndexOfAny(new char[] { '{', '}' }) ?? -1) >= 0; + bool isRawQuery = queryData.Query.IsRawQuery(ConfigConst.StorageSetting.IsElasticSearch, ConfigConst.StorageSetting.IsClickhouse);// (queryData.Query?.IndexOfAny(new char[] { '{', '}' }) ?? -1) >= 0; var query = new BaseRequestDto { Service = queryData.Service!, @@ -101,7 +101,7 @@ public async Task GetPageListAsync(LogsQuery queryData) RawQuery = isRawQuery ? queryData.Query! : string.Empty, Page = queryData.Page, PageSize = queryData.Size, - Sort = new FieldOrderDto { Name = string.IsNullOrEmpty(queryData.SortField) ? StorageConst.Timestimap(ConfigConst.IsElasticsearch, ConfigConst.IsClickhouse) : queryData.SortField, IsDesc = queryData.IsDesc }, + Sort = new FieldOrderDto { Name = string.IsNullOrEmpty(queryData.SortField) ? StorageConst.Current.Timestimap : queryData.SortField, IsDesc = queryData.IsDesc }, Conditions = conditions, }; if (query.Page - 1 > 0) @@ -130,7 +130,7 @@ public async Task GetErrorTypesAsync(LogErrorTypesQuery query) Service = query.Service, Start = query.Start, End = query.End, - Name = StorageConst.ExceptionMessage, + Name = StorageConst.Current.ExceptionMessage, Type = AggregateTypes.GroupBy, MaxCount = 999, AllValue = true diff --git a/src/Services/Masa.Tsc.Service.Admin/Application/Teams/QueryHandler.cs b/src/Services/Masa.Tsc.Service.Admin/Application/Teams/QueryHandler.cs index 93702007..b0129a3d 100644 --- a/src/Services/Masa.Tsc.Service.Admin/Application/Teams/QueryHandler.cs +++ b/src/Services/Masa.Tsc.Service.Admin/Application/Teams/QueryHandler.cs @@ -266,7 +266,7 @@ private async Task> GetAllMonitServicesAsync(string env, DateTime? var query = new SimpleAggregateRequestDto { - Name = StorageConst.ServiceName, + Name = StorageConst.Current.ServiceName, Start = start.Value, End = end.Value, Type = AggregateTypes.GroupBy, @@ -304,24 +304,24 @@ private async Task> GetErrorOrWarnAsync(IEnumerable appids, { var obj = await _traceService.AggregateAsync(new SimpleAggregateRequestDto { - Name = StorageConst.ServiceName, + Name = StorageConst.Current.ServiceName, Start = start ?? DateTime.MinValue, End = end ?? DateTime.MinValue, Type = AggregateTypes.GroupBy, MaxCount = 999, Conditions = new FieldConditionDto[] { new FieldConditionDto{ - Name=StorageConst.Environment, + Name=StorageConst.Current.Environment, Type=ConditionTypes.Equal, Value =env }, new FieldConditionDto{ - Name=StorageConst.HttpPort, + Name=StorageConst.Current.Trace.HttpStatusCode, Type= ConditionTypes.In, Value=errorPorts.Select(num=>(object)num) }, new FieldConditionDto{ - Name=StorageConst.ServiceName, + Name=StorageConst.Current.ServiceName, Type= ConditionTypes.In, Value=appids } @@ -343,24 +343,24 @@ private async Task GetErrorOrWarnCountAsync(IEnumerable appids, in return default; var obj = await _traceService.AggregateAsync(new SimpleAggregateRequestDto { - Name = StorageConst.ServiceName, + Name = StorageConst.Current.ServiceName, Start = start ?? DateTime.MinValue, End = end ?? DateTime.MinValue, Type = AggregateTypes.Count, Conditions = new FieldConditionDto[] { new FieldConditionDto{ - Name=StorageConst.Environment, + Name=StorageConst.Current.Environment, Type=ConditionTypes.Equal, Value =env }, new FieldConditionDto{ - Name=StorageConst.HttpPort, + Name=StorageConst.Current.Trace.HttpStatusCode, Type = ConditionTypes.In, Value=errorPorts.Select(num=>(object)num) }, new FieldConditionDto { - Name=StorageConst.ServiceName, + Name=StorageConst.Current.ServiceName, Type= ConditionTypes.In, Value=appids } diff --git a/src/Services/Masa.Tsc.Service.Admin/Application/Traces/QueryHandler.cs b/src/Services/Masa.Tsc.Service.Admin/Application/Traces/QueryHandler.cs index 63e2d4d6..210145dd 100644 --- a/src/Services/Masa.Tsc.Service.Admin/Application/Traces/QueryHandler.cs +++ b/src/Services/Masa.Tsc.Service.Admin/Application/Traces/QueryHandler.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 Masa.Tsc.Storage.Contracts; - namespace Masa.Tsc.Service.Admin.Application.Traces; public class QueryHandler : EnvQueryHandler @@ -40,7 +38,7 @@ public async Task GetTraceIdByMetricAsync(TraceIdByMetricQuery query) Start = query.Start, End = query.End, Conditions = new List { new FieldConditionDto { - Name=StorageConst.URL, + Name=StorageConst.Current.Trace.URL, Type= ConditionTypes.Equal, Value=query.Url } } @@ -62,7 +60,7 @@ public async Task GetListAsync(TraceListQuery query) PageSize = query.Size, Start = query.Start, TraceId = query.TraceId, - Sort = new FieldOrderDto { Name = "@timestamp", IsDesc = query.IsDesc } + Sort = new FieldOrderDto { Name = StorageConst.Current.Timestimap, IsDesc = query.IsDesc } }; queryDto.SetHasPage(query.HasPage); @@ -71,13 +69,13 @@ public async Task GetListAsync(TraceListQuery query) { var endpointCondition = new FieldConditionDto { - Name = StorageConst.URL, + Name = StorageConst.Current.Trace.URL, Type = ConditionTypes.Equal, Value = query.Endpoint }; list.Add(endpointCondition); } - bool isRawQuery = query.Keyword.IsRawQuery(ConfigConst.StorageConst.IsElasticSearch, ConfigConst.StorageConst.IsClickhouse); + bool isRawQuery = query.Keyword.IsRawQuery(ConfigConst.StorageSetting.IsElasticSearch, ConfigConst.StorageSetting.IsClickhouse); if (!string.IsNullOrEmpty(query.Keyword)) { if (isRawQuery) @@ -95,7 +93,7 @@ public async Task GetListAsync(TraceListQuery query) { list.Add(new FieldConditionDto { - Name = StorageConst.SpanId, + Name = StorageConst.Current.SpanId, Type = ConditionTypes.Equal, Value = query.SpanId }); @@ -105,7 +103,7 @@ public async Task GetListAsync(TraceListQuery query) { list.Add(new FieldConditionDto { - Name = StorageConst.HttpPort, + Name = StorageConst.Current.Trace.HttpStatusCode, Type = ConditionTypes.In, Value = ConfigConst.TraceErrorStatus.Select(num => (object)num) }); @@ -117,7 +115,7 @@ public async Task GetListAsync(TraceListQuery query) { conditions.Add(new FieldConditionDto { - Name = "Resource.service.namespace", + Name = StorageConst.Current.Environment, Type = ConditionTypes.Equal, Value = query.Env }); @@ -132,7 +130,7 @@ public async Task GetListAsync(TraceListQuery query) { conditions.Add(new FieldConditionDto { - Name = "Duration", + Name = StorageConst.Current.Trace.Duration, Type = ConditionTypes.GreatEqual, Value = query.LatMin.Value, }); @@ -143,7 +141,7 @@ public async Task GetListAsync(TraceListQuery query) || query.LatMin.HasValue && query.LatMax - query.LatMin.Value > 0)) conditions.Add(new FieldConditionDto { - Name = "Duration", + Name = StorageConst.Current.Trace.Duration, Type = ConditionTypes.LessEqual, Value = query.LatMax.Value, }); @@ -163,22 +161,22 @@ public async Task GetAttrValuesAsync(TraceAttrValuesQuery query) list.Add(new FieldConditionDto { - Name = "Kind", + Name = StorageConst.Current.Trace.SpanKind, Type = ConditionTypes.Equal, Value = "SPAN_KIND_SERVER" }); if (string.IsNullOrEmpty(query.Data.Service)) { - query.Data.Name = StorageConst.ServiceName; + query.Data.Name = StorageConst.Current.ServiceName; } else if (query.Data.Instance == null) { - query.Data.Name = StorageConst.ServiceInstance; + query.Data.Name = StorageConst.Current.ServiceInstance; } else { - query.Data.Name = "Attributes.http.target"; + query.Data.Name = StorageConst.Current.Trace.URL; } query.Data.Conditions = list; query.Data.Keyword = default!; @@ -206,7 +204,7 @@ public async Task GetNextPrevAsync(TraceDetailNextQuery query) Service = query.Service, Sort = new FieldOrderDto { - Name = StorageConst.Timestimap(ConfigConst.StorageConst.IsElasticSearch, ConfigConst.StorageConst.IsClickhouse), + Name = StorageConst.Current.Timestimap, IsDesc = !query.IsNext }, Page = 1, @@ -215,12 +213,12 @@ public async Task GetNextPrevAsync(TraceDetailNextQuery query) var list = new List() { new FieldConditionDto{ - Name=StorageConst.URL, + Name=StorageConst.Current.Trace.URL, Type =ConditionTypes.Equal, Value=query.Url }, new FieldConditionDto{ - Name=StorageConst.TraceId, + Name= StorageConst.Current.TraceId, Type =ConditionTypes.NotEqual, Value=query.TraceId } @@ -230,7 +228,7 @@ public async Task GetNextPrevAsync(TraceDetailNextQuery query) { list.Add(new FieldConditionDto { - Name = StorageConst.Timestimap(ConfigConst.StorageConst.IsElasticSearch, ConfigConst.StorageConst.IsClickhouse), + Name = StorageConst.Current.Timestimap, Type = ConditionTypes.Great, Value = query.Time }); @@ -239,7 +237,7 @@ public async Task GetNextPrevAsync(TraceDetailNextQuery query) { list.Add(new FieldConditionDto { - Name = StorageConst.Timestimap(ConfigConst.StorageConst.IsElasticSearch, ConfigConst.StorageConst.IsClickhouse), + Name = StorageConst.Current.Timestimap, Type = ConditionTypes.Less, Value = query.Time }); diff --git a/src/Services/Masa.Tsc.Service.Admin/Extensions/AddTraceLogExtenstion.cs b/src/Services/Masa.Tsc.Service.Admin/Extensions/AddTraceLogExtenstion.cs index 730035dd..c40a8f2e 100644 --- a/src/Services/Masa.Tsc.Service.Admin/Extensions/AddTraceLogExtenstion.cs +++ b/src/Services/Masa.Tsc.Service.Admin/Extensions/AddTraceLogExtenstion.cs @@ -20,19 +20,19 @@ public static IServiceCollection AddTraceLog(this IServiceCollection services) private static void AddClickHouse() { - if (ConfigConst.StorageConst.HasInit || !ConfigConst.IsClickhouse) return; + if (ConfigConst.StorageSetting.HasInit || !ConfigConst.IsClickhouse) return; if (string.IsNullOrEmpty(ConfigConst.ClikhouseConnection)) return; _services.AddMASAStackApmClickhouse(ConfigConst.ClikhouseConnection, ConfigConst.ClickhouseTableSuffix, ConfigConst.ClickHouseLogSourceTable, ConfigConst.ClickHouseTaceSourceTable , appLogSourceTable: ConfigConst.ClickHouseAppLogSourceTable, AppTraceSourceTable: ConfigConst.ClickHouseAppTraceSourceTable); - ConfigConst.StorageConst.SetClickhouse(); + ConfigConst.StorageSetting.SetClickhouse(); } private static void AddElasticSearch() { - if (ConfigConst.StorageConst.HasInit || !ConfigConst.IsElasticsearch) return; + if (ConfigConst.StorageSetting.HasInit || !ConfigConst.IsElasticsearch) return; string[] elasticsearchUrls = _services.GetMasaStackConfig().ElasticModel.Nodes?.ToArray() ?? Array.Empty(); _services.AddElasticClientLogAndTrace(elasticsearchUrls, ConfigConst.LogIndex, ConfigConst.TraceIndex); - ConfigConst.StorageConst.SetElasticSearch(); + ConfigConst.StorageSetting.SetElasticSearch(); } private static void ValueChanged(AppSettingConfiguration config) diff --git a/src/Services/Masa.Tsc.Service.Admin/Extensions/SimpleAggregateRequestDtoExtensions.cs b/src/Services/Masa.Tsc.Service.Admin/Extensions/SimpleAggregateRequestDtoExtensions.cs index e54b11e6..b1b8d3ac 100644 --- a/src/Services/Masa.Tsc.Service.Admin/Extensions/SimpleAggregateRequestDtoExtensions.cs +++ b/src/Services/Masa.Tsc.Service.Admin/Extensions/SimpleAggregateRequestDtoExtensions.cs @@ -26,11 +26,11 @@ public static void SetEnv(this BaseRequestDto dto, string envName, bool isMustSe var list = dto.Conditions?.ToList() ?? new(); - if (!list.Any() || !list.Exists(item => item.Name == StorageConst.Environment)) + if (!list.Any() || !list.Exists(item => item.Name == StorageConst.Current.Environment)) { list.Add(new FieldConditionDto { - Name = StorageConst.Environment, + Name = StorageConst.Current.Environment, Type = ConditionTypes.Equal, Value = envName }); 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 665a8b1b..6f2daf66 100644 --- a/src/Services/Masa.Tsc.Service.Admin/Infrastructure/Const/ConfigConst.cs +++ b/src/Services/Masa.Tsc.Service.Admin/Infrastructure/Const/ConfigConst.cs @@ -38,7 +38,7 @@ public static void SetConfiguration(AppSettingConfiguration config) public static string ClickHouseTaceSourceTable => Configuration.Clickhouse?.TraceSource!; - internal sealed class StorageConst + internal sealed class StorageSetting { public static bool IsElasticSearch { get; private set; } @@ -64,6 +64,6 @@ public static void SetClickhouse() IsClickhouse = true; } - private StorageConst() { } + private StorageSetting() { } } } diff --git a/src/Services/Masa.Tsc.Service.Admin/Services/SettingService.cs b/src/Services/Masa.Tsc.Service.Admin/Services/SettingService.cs index 644b62ae..15d4a8f6 100644 --- a/src/Services/Masa.Tsc.Service.Admin/Services/SettingService.cs +++ b/src/Services/Masa.Tsc.Service.Admin/Services/SettingService.cs @@ -7,5 +7,5 @@ public class SettingService : ServiceBase { public SettingService() : base("/api/settings") { } - public SettingDto GetStorage() => new() { IsClickhouse = ConfigConst.StorageConst.IsClickhouse, IsElasticsearch = ConfigConst.StorageConst.IsClickhouse }; + public SettingDto GetStorage() => new() { IsClickhouse = ConfigConst.StorageSetting.IsClickhouse, IsElasticsearch = ConfigConst.StorageSetting.IsClickhouse }; } diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Components/Apm/ApmSearchComponent.razor.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Components/Apm/ApmSearchComponent.razor.cs index 3eef62ce..ae4897d9 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Components/Apm/ApmSearchComponent.razor.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Components/Apm/ApmSearchComponent.razor.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 Masa.Tsc.Storage.Contracts; - namespace Masa.Tsc.Web.Admin.Rcl.Components.Apm; public partial class ApmSearchComponent @@ -117,22 +115,22 @@ protected override void OnInitialized() { base.OnInitialized(); textFileds = new List { - StorageConstaaa.Current.TraceId, - StorageConstaaa.Current.SpanId + StorageConst.Current.TraceId, + StorageConst.Current.SpanId }; if (IsEndpoint) { textFileds.AddRange(new string[] { - StorageConstaaa.Current.Trace.URLFull, - StorageConstaaa.Current.Trace.UserId, - StorageConstaaa.Current.Trace.HttpRequestBody + StorageConst.Current.Trace.URLFull, + StorageConst.Current.Trace.UserId, + StorageConst.Current.Trace.HttpRequestBody }); } else if (!IsService) { - textFileds.Add(StorageConstaaa.Current.ExceptionMessage); + textFileds.Add(StorageConst.Current.ExceptionMessage); if (IsLog) - textFileds.Add(StorageConstaaa.Current.Log.Body); + textFileds.Add(StorageConst.Current.Log.Body); } Value.TextField = textFileds[0]; var uri = NavigationManager.ToAbsoluteUri(NavigationManager.Uri); @@ -146,12 +144,12 @@ protected override void OnInitialized() if (!string.IsNullOrEmpty(Search.SpanId)) { - Search.TextField = StorageConstaaa.Current.SpanId; + Search.TextField = StorageConst.Current.SpanId; Search.TextValue = Search.SpanId; } else if (!string.IsNullOrEmpty(Search.TraceId)) { - Search.TextField = StorageConstaaa.Current.TraceId; + Search.TextField = StorageConst.Current.TraceId; Search.TextValue = Search.TraceId; } } diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Components/Dashboards/Configurations/Panel/Log/LogPanel.razor.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Components/Dashboards/Configurations/Panel/Log/LogPanel.razor.cs index c06d9d75..3cc14e83 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Components/Dashboards/Configurations/Panel/Log/LogPanel.razor.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Components/Dashboards/Configurations/Panel/Log/LogPanel.razor.cs @@ -80,9 +80,9 @@ protected override async Task OnInitializedAsync() if (!string.IsNullOrWhiteSpace(TaskId)) { if (_storageSetting.IsClickhouse) - Search = $"{StorageConst.TaskId}='{TaskId}'"; + Search = $"{StorageConst.Current.Log.TaskId}='{TaskId}'"; else if (_storageSetting.IsElasticsearch) - Search = $"{{\"term\":{{\"{StorageConst.TaskId}.keyword\":\"{TaskId}\"}}}}"; + Search = $"{{\"term\":{{\"{StorageConst.Current.Log.TaskId}.keyword\":\"{TaskId}\"}}}}"; } } @@ -200,16 +200,16 @@ protected override void OnInitialized() if (string.Equals("error", Keyword, StringComparison.InvariantCultureIgnoreCase)) { if (_storageSetting.IsClickhouse) - Search = $"{StorageConst.ServiceName}='{Service}' and {StorageConst.LogLevelText}='{Keyword}'"; + Search = $"{StorageConst.Current.ServiceName}='{Service}' and {StorageConst.Current.Log.LogLevelText}='{Keyword}'"; else if (_storageSetting.IsElasticsearch) - Search = $"{{\"term\":{{\"{StorageConst.ServiceName}.keyword\":\"{Service.Replace("'", "''")}\"}}}},{{\"term\":{{\"{StorageConst.LogLevelText}.keyword\": \"{Keyword.Replace("'", "''")}\"}}}}"; + Search = $"{{\"term\":{{\"{StorageConst.Current.ServiceName}.keyword\":\"{Service.Replace("'", "''")}\"}}}},{{\"term\":{{\"{StorageConst.Current.Log.LogLevelText}.keyword\": \"{Keyword.Replace("'", "''")}\"}}}}"; } else { if (_storageSetting.IsClickhouse) - Search = $"{StorageConst.ServiceName}='{Service}' and {StorageConst.ExceptionMessage}='{Keyword.Replace("'", "''")}'"; + Search = $"{StorageConst.Current.ServiceName}='{Service}' and {StorageConst.Current.ExceptionMessage}='{Keyword.Replace("'", "''")}'"; else if (_storageSetting.IsElasticsearch) - Search = $"{{\"term\":{{\"{StorageConst.ServiceName}.keyword\":\"{Service}\"}}}},{{\"term\":{{\"{StorageConst.ExceptionMessage}.keyword\": \"{Keyword}\"}}}}"; + Search = $"{{\"term\":{{\"{StorageConst.Current.ServiceName}.keyword\":\"{Service}\"}}}},{{\"term\":{{\"{StorageConst.Current.ExceptionMessage}.keyword\": \"{Keyword}\"}}}}"; } } base.OnInitialized(); diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Masa.Tsc.Web.Admin.Rcl.csproj b/src/Web/Masa.Tsc.Web.Admin.Rcl/Masa.Tsc.Web.Admin.Rcl.csproj index 1188cc77..75321fe4 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Masa.Tsc.Web.Admin.Rcl.csproj +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Masa.Tsc.Web.Admin.Rcl.csproj @@ -21,7 +21,7 @@ - + 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 3b417216..1aa8e776 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 @@ -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 Masa.Tsc.Storage.Contracts; - namespace Masa.Tsc.Web.Admin.Rcl.Pages.Apm; public partial class ErrorDetail @@ -94,19 +92,19 @@ private async Task LoadLogAysnc() var list = new List(); if (!string.IsNullOrEmpty(Search.Environment)) { - list.Add(new FieldConditionDto { Name = StorageConstaaa.Current.Environment, Value = Search.Environment, Type = ConditionTypes.Equal }); + list.Add(new FieldConditionDto { Name = StorageConst.Current.Environment, Value = Search.Environment, Type = ConditionTypes.Equal }); } if (!string.IsNullOrEmpty(Search.ExceptionType)) { - list.Add(new FieldConditionDto { Name = StorageConstaaa.Current.ExceptionType, Value = Search.ExceptionType, Type = ConditionTypes.Equal }); + list.Add(new FieldConditionDto { Name = StorageConst.Current.ExceptionType, Value = Search.ExceptionType, Type = ConditionTypes.Equal }); } if (!string.IsNullOrEmpty(Search.ExceptionMsg)) { - list.Add(new FieldConditionDto { Name = StorageConstaaa.Current.Log.Body, Value = Search.ExceptionMsg, Type = ConditionTypes.Regex }); + list.Add(new FieldConditionDto { Name = StorageConst.Current.Log.Body, Value = Search.ExceptionMsg, Type = ConditionTypes.Regex }); } if (!string.IsNullOrEmpty(Search.TextField) && !string.IsNullOrEmpty(Search.TextValue)) { - if (Search.TextField == StorageConstaaa.Current.ExceptionMessage || Search.TextField == StorageConstaaa.Current.Log.Body) + if (Search.TextField == StorageConst.Current.ExceptionMessage || Search.TextField == StorageConst.Current.Log.Body) { list.Add(new FieldConditionDto { Name = Search.TextField, Value = Search.TextValue, Type = ConditionTypes.Regex }); } diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Logs.razor.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Logs.razor.cs index 0783388a..4e9cf008 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Logs.razor.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Logs.razor.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 Masa.Tsc.Storage.Contracts; - namespace Masa.Tsc.Web.Admin.Rcl.Pages.Apm; public partial class Logs @@ -90,15 +88,15 @@ private async Task LoadPageDataAsync() var list = new List(); if (!string.IsNullOrEmpty(Search.Environment)) { - list.Add(new FieldConditionDto { Name = StorageConstaaa.Current.Environment, Value = Search.Environment, Type = ConditionTypes.Equal }); + list.Add(new FieldConditionDto { Name = StorageConst.Current.Environment, Value = Search.Environment, Type = ConditionTypes.Equal }); } if (!string.IsNullOrEmpty(Search.ExceptionType)) { - list.Add(new FieldConditionDto { Name = StorageConstaaa.Current.ExceptionType, Value = Search.ExceptionType, Type = ConditionTypes.Equal }); + list.Add(new FieldConditionDto { Name = StorageConst.Current.ExceptionType, Value = Search.ExceptionType, Type = ConditionTypes.Equal }); } if (!string.IsNullOrEmpty(Search.TextField) && !string.IsNullOrEmpty(Search.TextValue)) { - if (Search.TextField == StorageConstaaa.Current.ExceptionMessage || Search.TextField == StorageConstaaa.Current.Log.Body) + if (Search.TextField == StorageConst.Current.ExceptionMessage || Search.TextField == StorageConst.Current.Log.Body) { list.Add(new FieldConditionDto { Name = Search.TextField, Value = Search.TextValue, Type = ConditionTypes.Regex }); } 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 4feca4ca..10c2812e 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 @@ -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 Masa.Tsc.Storage.Contracts; - namespace Masa.Tsc.Web.Admin.Rcl.Pages.Apm.Services; public partial class ServiceLogs @@ -139,12 +137,12 @@ private async Task LoadPageDataAsync() }; var list = new List(); if (!string.IsNullOrEmpty(SearchData.Environment)) - list.Add(new FieldConditionDto { Value = SearchData.Environment!, Name = StorageConstaaa.Current.Environment }); + list.Add(new FieldConditionDto { Value = SearchData.Environment!, Name = StorageConst.Current.Environment }); if (!ShowAppEvent) { list.Add(new FieldConditionDto { - Name = StorageConstaaa.Current.Log.Body, + Name = StorageConst.Current.Log.Body, Value = "Event", Type = ConditionTypes.NotRegex }); diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/App/Index.razor.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/App/Index.razor.cs index 0f7a9941..81dc8030 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/App/Index.razor.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/App/Index.razor.cs @@ -167,7 +167,7 @@ private bool IsSearchKeyword(object value) private async Task UserChange(Guid userId) { if (_userId == userId) - return; + return; ClearData(); _userId = userId; if (roles == null) @@ -239,7 +239,7 @@ private async Task LoadTrace(bool isPre = false, bool isNext = false, int second PageSize = 200, Conditions = new List { new FieldConditionDto{ - Name =StorageConst.UserId, + Name =StorageConst.Current.Trace.UserId, Type= ConditionTypes.Equal, Value =_userId.ToString().ToLower() } @@ -286,7 +286,7 @@ private async Task LoadService() Value="MAUI" } }, - Name = StorageConst.ServiceName, + Name = StorageConst.Current.ServiceName, Type = AggregateTypes.GroupBy }); if (data != null) @@ -361,14 +361,14 @@ private async Task LoadLog(List traceIds) PageSize = 200, Conditions = new List { new FieldConditionDto{ - Name=StorageConst.TraceId, + Name=StorageConst.Current.TraceId, Type = ConditionTypes.In, Value = traceIds.Distinct() } }, Sort = new FieldOrderDto { - Name = "@timestamp", + Name = StorageConst.Current.Timestimap, IsDesc = false } }; diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Teams/Team.razor.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Teams/Team.razor.cs index ab11afe5..c776612b 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Teams/Team.razor.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Teams/Team.razor.cs @@ -142,16 +142,16 @@ async Task GetErroOrWarningCountAsync(bool isError, params string[] appids) Type = AggregateTypes.Count, Start = ConfigurationRecord.StartTime.UtcDateTime, End = ConfigurationRecord.EndTime.UtcDateTime, - Name = StorageConst.ServiceName, + Name = StorageConst.Current.ServiceName, Conditions = new List { new FieldConditionDto{ - Name=StorageConst.LogLevelText, + Name=StorageConst.Current.Log.LogLevelText, Type= ConditionTypes.Equal, - Value=isError?StorageConst.LogErrorText:StorageConst.LogWarningText + Value=isError?StorageConst.Current.Log.LogErrorText:StorageConst.Current.Log.LogWarningText }, new FieldConditionDto { - Name=StorageConst.ServiceName, + Name=StorageConst.Current.ServiceName, Type= ConditionTypes.In, Value=appids } 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 28d1ecc7..d743bc60 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Shared/ApmComponentBase.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Shared/ApmComponentBase.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 Masa.Tsc.Storage.Contracts; - namespace Masa.Tsc.Web.Admin.Rcl.Shared.Apm; public partial class ApmComponentBase : MasaComponentBase @@ -36,14 +34,14 @@ public ApmComponentBase() protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); - if (StorageConstaaa.Current != null) return; + if (StorageConst.Current != null) return; var setting = await ApiCaller.SettingService.GetStorage(); if (setting == null) throw new Exception("Storage setting is null"); if (setting.IsClickhouse) - StorageConstaaa.Init(new ClickhouseStorageConst()); + StorageConst.Init(new ClickhouseStorageConst()); else if (setting.IsElasticsearch) - ;// + StorageConst.Init(new ElasticsearchStorageConst()); } protected override void OnInitialized() { diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/Shared/TscComponentBase.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/Shared/TscComponentBase.cs index 5c6f9995..b78f5d00 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/Shared/TscComponentBase.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/Shared/TscComponentBase.cs @@ -1,15 +1,10 @@ // Copyright (c) MASA Stack All rights reserved. // Licensed under the MIT License. See LICENSE.txt in the project root for license information. -using Masa.Tsc.Storage.Contracts; - namespace Masa.Tsc.Web.Admin.Rcl.Shared; public partial class TscComponentBase : MasaComponentBase, IAsyncDisposable { - //[CascadingParameter(Name = "Culture")] - //private string Culture { get; set; } = null!; - [Inject] public IUserContext UserContext { get; set; } @@ -19,15 +14,9 @@ public partial class TscComponentBase : MasaComponentBase, IAsyncDisposable [Inject] public JsInitVariables JsInitVariables { get; set; } - [Inject] - public IPopupService PopupService { get; set; } - [Inject] public TscCaller ApiCaller { get; set; } - [Inject] - public I18n I18n { get; set; } - public Guid CurrentUserId { get; private set; } private TimeZoneInfo _timeZoneInfo; @@ -61,14 +50,14 @@ protected override async Task OnInitializedAsync() protected async Task SetStorage() { await base.OnInitializedAsync(); - if (StorageConstaaa.Current != null) return; + if (StorageConst.Current != null) return; var setting = await ApiCaller.SettingService.GetStorage(); if (setting == null) throw new Exception("Storage setting is null"); if (setting.IsClickhouse) - StorageConstaaa.Init(new ClickhouseStorageConst()); + StorageConst.Init(new ClickhouseStorageConst()); else if (setting.IsElasticsearch) - ;// + StorageConst.Init(new ElasticsearchStorageConst()); } diff --git a/src/Web/Masa.Tsc.Web.Admin.Rcl/_Imports.cs b/src/Web/Masa.Tsc.Web.Admin.Rcl/_Imports.cs index a45852a6..f806a162 100644 --- a/src/Web/Masa.Tsc.Web.Admin.Rcl/_Imports.cs +++ b/src/Web/Masa.Tsc.Web.Admin.Rcl/_Imports.cs @@ -30,6 +30,7 @@ global using Masa.Tsc.Storage.Clickhouse.Apm.Models; global using Masa.Tsc.Storage.Clickhouse.Apm.Models.Request; global using Masa.Tsc.Storage.Clickhouse.Apm.Models.Response; +global using Masa.Tsc.Storage.Contracts; global using Masa.Tsc.Storage.Prometheus.Enums; global using Masa.Tsc.Storage.Prometheus.Model; global using Masa.Tsc.Web.Admin.Rcl.Components.Antvg6; @@ -68,3 +69,5 @@ global using System.Text.Json.Serialization; global using System.Text.RegularExpressions; global using System.Web; +global using Masa.Tsc.Storage.Clickhouse; +global using Masa.Tsc.Storage.Elasticsearch;