Continuo ottimizzazione ed estensone emssaggi trace

This commit is contained in:
Samuele Locatelli
2026-03-07 09:26:09 +01:00
parent c989fa4a93
commit 9261a8a56e
7 changed files with 62 additions and 20 deletions
+2 -3
View File
@@ -184,7 +184,6 @@ namespace EgwCoreLib.Lux.Data.Services
var activity = ActivitySource.StartActivity(methodName ?? "UNDEF");
activity?.SetTag("host.name", Environment.MachineName);
return activity;
//return ActivitySource.StartActivity(methodName);
}
@@ -268,7 +267,7 @@ namespace EgwCoreLib.Lux.Data.Services
/// Helper trace messaggio log (SE abilitato)
/// </summary>
/// <param name="traceMsg"></param>
protected void LogTrace(string traceMsg, NLog.LogLevel? reqLevel = null)
protected void LogTrace(string traceMsg, NLog.LogLevel? reqLevel = null, [CallerMemberName] string? methodName = null)
{
if (!traceEnabled)
return;
@@ -276,7 +275,7 @@ namespace EgwCoreLib.Lux.Data.Services
reqLevel ??= NLog.LogLevel.Debug;
// Loggo!
Log.Log(reqLevel, traceMsg);
Log.Log(reqLevel, $"{methodName} | {traceMsg}");
}
#endregion Protected Methods
@@ -2306,6 +2306,8 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task SaveHmlAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawContent)
{
using var activity = StartActivity();
string source = "DB";
// salvo sul DB il risultato della BOM
if (!string.IsNullOrEmpty(rawContent))
{
@@ -2316,9 +2318,19 @@ namespace EgwCoreLib.Lux.Data.Services
}
catch (Exception exc)
{
Log.Error($"Eccezione durante SaveHmlAsync | uID: {uID}{Environment.NewLine}{exc}");
string exMsg = $"Eccezione durante SaveHmlAsync | uID: {uID} | envir: {execEnvironment}";
LogTrace($"{exMsg}{Environment.NewLine}{exc}", LogLevel.Error);
// traccio errore
activity?.SetStatus(ActivityStatusCode.Error, exc.Message);
activity?.AddEvent(new ActivityEvent("exception", tags: new ActivityTagsCollection {
{ "exception.type", exc.GetType().Name },
{ "exception.message", exc.Message },
{ "exception.stacktrace", exc.StackTrace }
}));
}
}
activity?.SetTag("data.source", source);
LogTrace($"SaveHmlAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
}
/// <summary>
@@ -2331,12 +2343,16 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task SaveProdBalanceAsync(string uID, string rGroup, Constants.EXECENVIRONMENTS execEnvironment, string balance)
{
using var activity = StartActivity();
string source = "DB";
// salvo sul DB il risultato della BOM
if (!string.IsNullOrEmpty(balance))
{
// salvo info balance nel record del DB relativo all'oggetto richiesto
await dbController.ProdGroupUpsertBalance(uID, rGroup, balance);
}
activity?.SetTag("data.source", source);
LogTrace($"SaveProdBalanceAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
}
/// <summary>
@@ -2348,12 +2364,16 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task SaveProdEstimateAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string prodEstim)
{
using var activity = StartActivity();
string source = "DB";
// salvo sul DB il risultato della BOM
if (!string.IsNullOrEmpty(prodEstim))
{
// salvo info balance nel record del DB relativo all'oggetto richiesto
await dbController.OrderRowUpsertProdEst(uID, prodEstim);
}
activity?.SetTag("data.source", source);
LogTrace($"SaveProdEstimateAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
}
/// <summary>
@@ -2365,6 +2385,8 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task SaveProfileListAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawContent)
{
using var activity = StartActivity();
string source = "DB";
// salvo sul DB il risultato della BOM
if (!string.IsNullOrEmpty(rawContent))
{
@@ -2375,8 +2397,18 @@ namespace EgwCoreLib.Lux.Data.Services
}
catch (Exception exc)
{
Log.Error($"Eccezione durante SaveProfileListAsync | uID: {uID}{Environment.NewLine}{exc}");
string exMsg = $"Eccezione durante SaveProfileListAsync | uID: {uID} | envir: {execEnvironment}";
LogTrace($"{exMsg}{Environment.NewLine}{exc}", LogLevel.Error);
// traccio errore
activity?.SetStatus(ActivityStatusCode.Error, exc.Message);
activity?.AddEvent(new ActivityEvent("exception", tags: new ActivityTagsCollection {
{ "exception.type", exc.GetType().Name },
{ "exception.message", exc.Message },
{ "exception.stacktrace", exc.StackTrace }
}));
}
activity?.SetTag("data.source", source);
LogTrace($"SaveProfileListAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
}
}
@@ -2390,6 +2422,8 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task SaveProfileThreshAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawThreshold, string rawData)
{
using var activity = StartActivity();
string source = "DB";
// salvo sul DB il risultato della BOM
if (!string.IsNullOrEmpty(rawThreshold))
{
@@ -2399,8 +2433,18 @@ namespace EgwCoreLib.Lux.Data.Services
}
catch (Exception exc)
{
Log.Error($"Eccezione durante SaveProfileThreshAsync | uID: {uID}{Environment.NewLine}{exc}");
string exMsg = $"Eccezione durante SaveProfileThreshAsync | uID: {uID} | envir: {execEnvironment}";
LogTrace($"{exMsg}{Environment.NewLine}{exc}", LogLevel.Error);
// traccio errore
activity?.SetStatus(ActivityStatusCode.Error, exc.Message);
activity?.AddEvent(new ActivityEvent("exception", tags: new ActivityTagsCollection {
{ "exception.type", exc.GetType().Name },
{ "exception.message", exc.Message },
{ "exception.stacktrace", exc.StackTrace }
}));
}
activity?.SetTag("data.source", source);
LogTrace($"SaveProfileThreshAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
}
}
@@ -2411,9 +2455,8 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<List<SellingItemModel>> SellingItemsByEnvirAsync(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir)
{
using var activity = StartActivity();
string source = "DB";
Stopwatch sw = new Stopwatch();
sw.Start();
List<SellingItemModel>? result = new List<SellingItemModel>();
// cerco in redis...
string currKey = $"{redisBaseKey}:SellingItem:{envir}";
@@ -2434,8 +2477,9 @@ namespace EgwCoreLib.Lux.Data.Services
{
result = new List<SellingItemModel>();
}
sw.Stop();
Log.Debug($"SellingItemsByEnvirAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
LogTrace($"SellingItemsByEnvirAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2469,7 +2513,6 @@ namespace EgwCoreLib.Lux.Data.Services
}
// aggiunta tags + log
activity?.SetTag("data.source", source);
//activity?.Stop();
LogTrace($"TagsGetAllAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2964,10 +3007,10 @@ namespace EgwCoreLib.Lux.Data.Services
// traccio errore
activity?.SetStatus(ActivityStatusCode.Error, exc.Message);
activity?.AddEvent(new ActivityEvent("exception", tags: new ActivityTagsCollection {
{ "exception.type", exc.GetType().Name },
{ "exception.message", exc.Message },
{ "exception.stacktrace", exc.StackTrace }
}));
{ "exception.type", exc.GetType().Name },
{ "exception.message", exc.Message },
{ "exception.stacktrace", exc.StackTrace }
}));
}
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.1.2603.0619</Version>
<Version>1.1.2603.0709</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
<Version>1.1.2603.0619</Version>
<Version>1.1.2603.0709</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 1.1.2603.0619</h4>
<h4>Versione: 1.1.2603.0709</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.1.2603.0619
1.1.2603.0709
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.1.2603.0619</version>
<version>1.1.2603.0709</version>
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>