diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs
index a96af52d..9d9da89c 100644
--- a/MP.Data/Controllers/MpSpecController.cs
+++ b/MP.Data/Controllers/MpSpecController.cs
@@ -1607,16 +1607,16 @@ namespace MP.Data.Controllers
///
///
///
- public bool MicroStatoMacchinaUpsert(MicroStatoMacchinaModel newRec)
+ public async Task MicroStatoMacchinaUpsert(MicroStatoMacchinaModel newRec)
{
bool fatto = false;
using (var dbCtx = new MoonProContext(_configuration))
{
- var actRec = dbCtx
+ var actRec = await dbCtx
.DbSetMicroStatoMacc
.Where(x => x.IdxMacchina == newRec.IdxMacchina)
.AsNoTracking()
- .FirstOrDefault();
+ .FirstOrDefaultAsync();
if (actRec == null)
{
dbCtx
@@ -1631,7 +1631,7 @@ namespace MP.Data.Controllers
dbCtx.Entry(actRec).State = EntityState.Modified;
}
- dbCtx.SaveChanges();
+ await dbCtx.SaveChangesAsync();
fatto = true;
}
return fatto;
@@ -1777,15 +1777,14 @@ namespace MP.Data.Controllers
///
///
///
- public ODLModel OdlGetByKey(int idxOdl)
+ public async Task OdlGetByKey(int idxOdl)
{
ODLModel dbResult = new ODLModel();
-
using (var dbCtx = new MoonProContext(_configuration))
{
- dbResult = dbCtx
+ dbResult = await dbCtx
.DbSetODL
- .FirstOrDefault(x => x.IdxOdl == idxOdl);
+ .FirstOrDefaultAsync(x => x.IdxOdl == idxOdl);
}
return dbResult;
}
diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs
index d640f5ef..ffb08dad 100644
--- a/MP.SPEC/Data/MpDataService.cs
+++ b/MP.SPEC/Data/MpDataService.cs
@@ -24,50 +24,70 @@ namespace MP.SPEC.Data
{
#region Public Constructors
- public MpDataService(IConfiguration configuration, ILogger logger)
+ public MpDataService(IConfiguration configuration)
{
- _logger = logger;
- _logger.LogInformation("Starting MpDataService INIT");
+ // fix oggetto configurazion
_configuration = configuration;
+ // Verifica conf trace...
+ traceEnabled = _configuration.GetValue("Otel:EnableTracing", false);
+ Log.Info($"MpDataService | INIT | Trace enabled: {traceEnabled}");
// setup compoenti REDIS
- redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
- redisConnAdmin = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("RedisAdmin"));
+ redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis") ?? "localhost:6379");
+ redisConnAdmin = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("RedisAdmin") ?? "localhost:6379");
redisDb = redisConn.GetDatabase();
- BroadastMsgPipe = new MessagePipe(redisConn, Constants.BROADCAST_M_PIPE);
// leggo cache lungo periodo
int.TryParse(_configuration.GetValue("ServerConf:redisLongTimeCache"), out redisLongTimeCache);
- _logger.LogInformation("Redis INIT");
+ // setup MsgPipe
+ BroadastMsgPipe = new MessagePipe(redisConn, Constants.BROADCAST_M_PIPE);
+ Log.Info("MpDataService | Redis OK");
// conf DB
- string connStr = _configuration.GetConnectionString("MP.Data");
+ string connStr = _configuration.GetConnectionString("MP.Data") ?? "";
if (string.IsNullOrEmpty(connStr))
{
- _logger.LogError("DbController: ConnString empty!");
+ Log.Error("DbController: ConnString empty!");
}
else
{
- dbController = new MP.Data.Controllers.MpSpecController(configuration);
- _logger.LogInformation("DbController OK");
+ dbController = new MpSpecController(configuration);
+ Log.Info("DbController OK");
}
// conf x lettura dati da area REDIS di MP-IO
- MpIoNS = _configuration.GetValue("ServerConf:MpIoNS");
+ MpIoNS = _configuration.GetValue("ServerConf:MpIoNS") ?? "";
// conf mongo...
- connStr = _configuration.GetConnectionString("mdbConnString");
+ connStr = _configuration.GetConnectionString("mdbConnString") ?? "";
if (string.IsNullOrEmpty(connStr))
{
- _logger.LogError("MongoController: ConnString empty!");
+ Log.Error("MongoController: ConnString empty!");
}
else
{
- mongoController = new MP.Data.Controllers.MpMongoController(configuration);
- _logger.LogInformation("MongoController OK");
+ mongoController = new MpMongoController(configuration);
+ Log.Info("MongoController OK");
}
+ Log.Info("MpDataService | INIT completed");
}
+ ///
+ /// Helper trace messaggio log (SE abilitato)
+ ///
+ ///
+ private void LogTrace(string traceMsg, NLog.LogLevel? reqLevel = null)
+ {
+ if (!traceEnabled)
+ return;
+
+ reqLevel ??= NLog.LogLevel.Debug;
+
+ // Loggo!
+ Log.Log(reqLevel, traceMsg);
+ }
+ private bool traceEnabled = false;
+
#endregion Public Constructors
#region Public Events
@@ -81,8 +101,8 @@ namespace MP.SPEC.Data
#region Public Properties
- public static MP.Data.Controllers.MpSpecController dbController { get; set; } = null!;
- public static MP.Data.Controllers.MpMongoController mongoController { get; set; } = null!;
+ public static MpSpecController dbController { get; set; } = null!;
+ public static MpMongoController mongoController { get; set; } = null!;
public MessagePipe BroadastMsgPipe { get; set; } = null!;
@@ -102,23 +122,21 @@ namespace MP.SPEC.Data
public async Task ActionGetReq()
{
using var activity = ActivitySource.StartActivity("ActionGetReq");
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
+ string source = "REDIS";
DisplayAction? result = null;
// cerco in redis...
RedisValue rawData = await redisDb.StringGetAsync(Utils.redisActionReq);
if (!string.IsNullOrEmpty($"{rawData}"))
{
result = JsonConvert.DeserializeObject($"{rawData}");
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ActionGetReq Read from REDIS: {ts.TotalMilliseconds}ms");
}
if (result == null)
{
result = new DisplayAction();
}
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ActionGetReq Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -130,17 +148,15 @@ namespace MP.SPEC.Data
public bool ActionSetReq(DisplayAction? act2save)
{
using var activity = ActivitySource.StartActivity("ActionSetReq");
+ string source = "REDIS";
bool fatto = false;
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
// cerco in redis...
string rawData = JsonConvert.SerializeObject(act2save);
// invio broadcast + salvo in redis
BroadastMsgPipe.saveAndSendMessage(Utils.redisActionReq, rawData);
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ActionSetReq REDIS send to broadcast + Write cache: {ts.TotalMilliseconds}ms");
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ActionSetReq {source} send to broadcast + Write cache: {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -153,12 +169,10 @@ namespace MP.SPEC.Data
using var activity = ActivitySource.StartActivity("AnagCountersGetNext");
AnagCountersModel result = new AnagCountersModel();
string source = "DB";
- Stopwatch sw = new Stopwatch();
- sw.Start();
result = dbController.AnagCountersGetNext(cntType);
- sw.Stop();
- Log.Debug($"AnagCountersGetNext | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"AnagCountersGetNext | {source} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -170,8 +184,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("AnagEventiGeneral");
string source = "DB";
- Stopwatch sw = new Stopwatch();
- sw.Start();
List? result = new List();
// cerco in redisConn...
string currKey = $"{Utils.redisEventList}:VSEB:GENERAL";
@@ -192,10 +204,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- sw.Stop();
- Log.Debug($"AnagEventiGeneral | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"AnagEventiGeneral | {source} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -207,8 +219,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("AnagEventiGetByMacch");
string source = "DB";
- Stopwatch sw = new Stopwatch();
- sw.Start();
List? result = new List();
// cerco in redisConn...
string currKey = $"{Utils.redisEventList}:VSEB:{IdxMacch}";
@@ -229,10 +239,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- sw.Stop();
- Log.Debug($"AnagEventiGetByMacch | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"AnagEventiGetByMacch | {source} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -244,16 +254,13 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("AnagGruppiDelete");
bool result = false;
- Stopwatch sw = new Stopwatch();
- sw.Start();
result = dbController.AnagGruppiDelete(updRec);
// elimino cache redis...
- RedisValue pattern = new RedisValue($"{Utils.redisAnagGruppi}:*");
+ string pattern = $"{Utils.redisAnagGruppi}:*";
bool answ = ExecFlushRedisPattern(pattern);
- sw.Stop();
- TimeSpan ts = sw.Elapsed;
- Log.Debug($"AnagGruppiDelete | CodGruppo {updRec.CodGruppo} | {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", "DB+REDIS");
+ activity?.Stop();
+ LogTrace($"AnagGruppiDelete | CodGruppo {updRec.CodGruppo} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -266,16 +273,13 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("AnagGruppiUpsert");
bool result = false;
- Stopwatch sw = new Stopwatch();
- sw.Start();
result = dbController.AnagGruppiUpsert(UpdRec);
// elimino cache redis...
- RedisValue pattern = new RedisValue($"{Utils.redisAnagGruppi}:*");
+ string pattern = $"{Utils.redisAnagGruppi}:*";
bool answ = ExecFlushRedisPattern(pattern);
- sw.Stop();
- TimeSpan ts = sw.Elapsed;
- Log.Debug($"AnagGruppiUpsert | CodGruppo {UpdRec.CodGruppo} | {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", "DB+REDIS");
+ activity?.Stop();
+ LogTrace($"AnagGruppiUpsert | CodGruppo {UpdRec.CodGruppo} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -287,8 +291,6 @@ namespace MP.SPEC.Data
{
// nuovo oggetto span activity
using var activity = ActivitySource.StartActivity("AnagKeyValGetAll");
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
List? result = new List();
// cerco in redis...
@@ -309,22 +311,16 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"AnagKeyValGetAll Read from {source}: {ts.TotalMilliseconds}ms");
-
- // 3. Aggiunta dei dati come "Tag" allo span, non come una stringa di testo (il tempo è implicito)
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
-
+ activity?.Stop();
+ LogTrace($"AnagKeyValGetAll Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
public async Task> AnagStatiComm()
{
using var activity = ActivitySource.StartActivity("AnagStatiComm");
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
List? result = new List();
// cerco in redis...
@@ -345,19 +341,16 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"AnagStatiComm Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"AnagStatiComm Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
public async Task> AnagTipoArtLV()
{
using var activity = ActivitySource.StartActivity("AnagStatiComm");
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
List? result = new List();
// cerco in redis...
@@ -378,11 +371,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"AnagTipoArtLV Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"AnagTipoArtLV Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -394,8 +386,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("ArticleWithDossier");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = Utils.redisArtByDossier;
// cerco in redis dato valore sel idxMaccSel...
@@ -416,11 +406,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ArticleWithDossier | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"ArticleWithDossier | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -432,9 +421,12 @@ namespace MP.SPEC.Data
public async Task ArticoliDeleteRecord(AnagArticoliModel currRec)
{
using var activity = ActivitySource.StartActivity("ArticoliDeleteRecord");
+ string source = "DB+REDIS";
bool fatto = await dbController.ArticoliDeleteRecord(currRec);
await resetCacheArticoli();
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ArticoliDeleteRecord | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -448,8 +440,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("ArticoliGetByTipo");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string sKey = string.IsNullOrEmpty(tipo) ? "ALL" : tipo;
string currKey = $"{Utils.redisArtList}:{azienda}:Tipo:{sKey}";
@@ -471,11 +461,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ArticoliGetByTipo | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"ArticoliGetByTipo | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -489,8 +478,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("ArticoliGetSearch");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string sKey = string.IsNullOrEmpty(searchVal) ? "***" : searchVal;
string currKey = $"{Utils.redisArtList}:{azienda}:{sKey}";
@@ -512,11 +499,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ArticoliGetSearch | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"ArticoliGetSearch | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -528,9 +514,12 @@ namespace MP.SPEC.Data
public async Task ArticoliUpdateRecord(AnagArticoliModel currRec)
{
using var activity = ActivitySource.StartActivity("ArticoliUpdateRecord");
+ string source = "DB+REDIS";
bool fatto = await dbController.ArticoliUpdateRecord(currRec);
await resetCacheArticoli();
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ArticoliUpdateRecord | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -543,6 +532,7 @@ namespace MP.SPEC.Data
public bool ArticoloDelEnabled(object CodArt)
{
using var activity = ActivitySource.StartActivity("ArticoloDelEnabled");
+ string source = "DB";
bool answ = false;
string codArticolo = $"{CodArt}";
int cacheCheckArtUsato = 1;
@@ -599,7 +589,9 @@ namespace MP.SPEC.Data
catch
{ }
}
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ArticoloDelEnabled | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -619,8 +611,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("ConfigGetAll");
string source = "REDIS";
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
List? result = new List();
// cerco in redis...
RedisValue rawData = redisDb.StringGet(Utils.redisConfKey);
@@ -640,10 +630,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- Log.Debug($"ConfigGetAll Read from {source}: {stopWatch.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"ConfigGetAll Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -655,8 +645,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("ConfigGetAllAsync");
string source = "REDIS";
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
List? result = new List();
// cerco in redis...
RedisValue rawData = await redisDb.StringGetAsync(Utils.redisConfKey);
@@ -676,10 +664,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- Log.Debug($"ConfigGetAllAsync Read from {source}: {stopWatch.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"ConfigGetAllAsync Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -690,8 +678,11 @@ namespace MP.SPEC.Data
public async Task ConfigResetCache()
{
using var activity = ActivitySource.StartActivity("ConfigResetCache");
+ string source = "REDIS";
await redisDb.StringSetAsync(Utils.redisConfKey, "");
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ConfigResetCache Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
}
///
@@ -701,8 +692,9 @@ namespace MP.SPEC.Data
///
public string ConfigTryGet(string keyName)
{
- using var activity = ActivitySource.StartActivity("ConfigTryGet");
string answ = "";
+ using var activity = ActivitySource.StartActivity("ConfigTryGet");
+ string source = "DB+REDIS";
// preselezione valori
if (configData == null || configData.Count == 0)
{
@@ -716,13 +708,14 @@ namespace MP.SPEC.Data
configData = ConfigGetAll();
currRec = configData.FirstOrDefault(x => x.Chiave == keyName);
}
-
// verifico se ci sia il dato...
if (currRec != null)
{
answ = currRec.Valore;
}
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ConfigTryGet Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -733,8 +726,9 @@ namespace MP.SPEC.Data
///
public async Task ConfigTryGetAsync(string keyName)
{
- using var activity = ActivitySource.StartActivity("ConfigTryGetAsync");
string answ = "";
+ using var activity = ActivitySource.StartActivity("ConfigTryGetAsync");
+ string source = "DB+REDIS";
// preselezione valori
if (configData == null || configData.Count == 0)
{
@@ -748,13 +742,14 @@ namespace MP.SPEC.Data
configData = await ConfigGetAllAsync();
currRec = configData.FirstOrDefault(x => x.Chiave == keyName);
}
-
// verifico se ci sia il dato...
if (currRec != null)
{
answ = currRec.Valore;
}
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ConfigTryGetAsync Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -762,12 +757,15 @@ namespace MP.SPEC.Data
/// Update chiave config
///
///
- public async Task ConfigUpdate(ConfigModel updRec)
+ public bool ConfigUpdate(ConfigModel updRec)
{
using var activity = ActivitySource.StartActivity("ConfigUpdate");
+ string source = "DB";
var updRes = dbController.ConfigUpdate(updRec);
- activity?.SetTag("data.source", "DB");
- return await Task.FromResult(updRes);
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ConfigUpdate Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
+ return updRes;
}
///
@@ -777,6 +775,7 @@ namespace MP.SPEC.Data
public Dictionary DbDedupStats()
{
using var activity = ActivitySource.StartActivity("DbDedupStats");
+ string source = "REDIS";
Dictionary actStats = new Dictionary();
string currKey = $"{Utils.redisStatsDbMaint}";
// recupero i record statistiche correnti
@@ -789,7 +788,9 @@ namespace MP.SPEC.Data
actStats = rawStats;
}
}
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"DbDedupStats Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return actStats;
}
@@ -813,16 +814,13 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("DossiersDeleteRecord");
bool result = false;
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
result = await dbController.DossiersDeleteRecord(selRecord);
// elimino cache redis...
RedisValue pattern = new RedisValue($"{Utils.redisDossByMac}:*");
bool answ = await ExecFlushRedisPatternAsync(pattern);
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"DossiersDeleteRecord | IdxMacchina {selRecord.IdxMacchina} | DtRif {selRecord.DtRif} | IdxODL {selRecord.IdxODL} | {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", "DB+REDIS");
+ activity?.Stop();
+ LogTrace($"DossiersDeleteRecord | IdxMacchina {selRecord.IdxMacchina} | DtRif {selRecord.DtRif} | IdxODL {selRecord.IdxODL} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -838,8 +836,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("DossiersGetLastFilt");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisDossByMac}:{IdxMacchina}:{CodArticolo}:{DtStart:yyyyMMddHHmm}:{DtEnd:yyyyMMddHHmm}";
// cerco in redis dato valore sel idxMaccSel...
@@ -860,11 +856,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"DossiersGetLastFilt | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"DossiersGetLastFilt | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -876,9 +871,12 @@ namespace MP.SPEC.Data
public async Task DossiersInsert(DossierModel currDoss)
{
using var activity = ActivitySource.StartActivity("DossiersInsert");
+ string source = "DB";
// aggiorno record sul DB
bool answ = await dbController.DossiersInsert(currDoss);
- activity?.SetTag("data.source", "DB");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"DossiersInsert | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -892,6 +890,7 @@ namespace MP.SPEC.Data
public async Task DossiersTakeParamsSnapshotLast(string IdxMacchina, DateTime dtMin, DateTime dtMax)
{
using var activity = ActivitySource.StartActivity("DossiersUpdateValore");
+ string source = "DB+REDIS";
bool answ = false;
Log.Info($"Richiesta snapshot per idxMaccSel {IdxMacchina} | periodo {dtMin} --> {dtMax}");
// chiamo stored x salvare parametri
@@ -899,8 +898,9 @@ namespace MP.SPEC.Data
// elimino cache redis...
RedisValue pattern = new RedisValue($"{Utils.redisDossByMac}:*");
answ = await ExecFlushRedisPatternAsync(pattern);
- Log.Info($"Svuotata cache dossier | {pattern}");
activity?.SetTag("data.source", "DB+REDIS");
+ activity?.Stop();
+ LogTrace($"DossiersTakeParamsSnapshotLast | Svuotata cache dossier | {pattern} | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -912,9 +912,12 @@ namespace MP.SPEC.Data
public async Task DossiersUpdateValore(DossierModel currDoss)
{
using var activity = ActivitySource.StartActivity("DossiersUpdateValore");
+ string source = "DB";
// aggiorno record sul DB
bool answ = await dbController.DossiersUpdateValore(currDoss);
- activity?.SetTag("data.source", "DB");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"DossiersUpdateValore | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -922,12 +925,15 @@ namespace MP.SPEC.Data
/// Restitusice elenco aziende
///
///
- public Task> ElencoAziende()
+ public List ElencoAziende()
{
using var activity = ActivitySource.StartActivity("ElencoAziende");
+ string source = "DB";
var listAz = dbController.AnagGruppiAziende();
- activity?.SetTag("data.source", "DB");
- return Task.FromResult(listAz);
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ElencoAziende | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
+ return listAz;
}
///
@@ -938,8 +944,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("ElencoGruppiFase");
List result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisAnagGruppi}:FASE";
// cerco in redis dato valore sel idxMaccSel...
@@ -964,20 +968,26 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ElencoGruppiFase | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"ElencoGruppiFase | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
- public Task> ElencoLink()
+ ///
+ /// Elenco link validi
+ ///
+ ///
+ public List ElencoLink()
{
using var activity = ActivitySource.StartActivity("ElencoLink");
+ string source = "DB";
var linkList = dbController.ElencoLink();
- activity?.SetTag("data.source", "DB");
- return Task.FromResult(linkList);
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ElencoLink | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
+ return linkList;
}
///
@@ -988,8 +998,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("ElencoRepartiDTO");
List result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisAnagGruppi}:REPARTO";
// cerco in redis dato valore sel idxMaccSel...
@@ -1014,11 +1022,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ElencoRepartiDTO | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"ElencoRepartiDTO | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1030,8 +1037,11 @@ namespace MP.SPEC.Data
public async Task EvListInsert(EventListModel newRec)
{
using var activity = ActivitySource.StartActivity("EvListInsert");
+ string source = "DB";
var result = await dbController.EvListInsert(newRec);
- activity?.SetTag("data.source", "DB");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"EvListInsert | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1043,6 +1053,7 @@ namespace MP.SPEC.Data
public bool ExecFlushRedisPattern(string pat2Flush)
{
using var activity = ActivitySource.StartActivity("ExecFlushRedisPattern");
+ string source = "REDIS";
bool answ = false;
var masterEndpoint = redisConn.GetEndPoints()
.Where(ep => redisConn.GetServer(ep).IsConnected && !redisConn.GetServer(ep).IsReplica)
@@ -1077,7 +1088,9 @@ namespace MP.SPEC.Data
redisDb.KeyDelete(item);
}
answ = true;
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ExecFlushRedisPattern | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -1088,8 +1101,9 @@ namespace MP.SPEC.Data
///
public async Task ExecFlushRedisPatternAsync(RedisValue pat2Flush)
{
- using var activity = ActivitySource.StartActivity("ExecFlushRedisPatternAsync");
bool answ = false;
+ using var activity = ActivitySource.StartActivity("ExecFlushRedisPatternAsync");
+ string source = "REDIS";
var masterEndpoint = redisConn.GetEndPoints()
.Where(ep => redisConn.GetServer(ep).IsConnected && !redisConn.GetServer(ep).IsReplica)
.FirstOrDefault();
@@ -1120,7 +1134,9 @@ namespace MP.SPEC.Data
}
}
answ = true;
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ExecFlushRedisPatternAsync | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -1132,6 +1148,7 @@ namespace MP.SPEC.Data
public DateTime ExpiryReloadParamGet()
{
using var activity = ActivitySource.StartActivity("ExpiryReloadParamGet");
+ string source = "REDIS";
DateTime dtRif = DateTime.Now;
string currKey = $"{Utils.redisParamPageExp}";
RedisValue rawData = redisDb.StringGet(currKey);
@@ -1139,7 +1156,9 @@ namespace MP.SPEC.Data
{
dtRif = JsonConvert.DeserializeObject($"{rawData}");
}
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ExpiryReloadParamGet | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return dtRif;
}
@@ -1151,21 +1170,27 @@ namespace MP.SPEC.Data
public bool ExpiryReloadParamSet(DateTime expTime)
{
using var activity = ActivitySource.StartActivity("ExpiryReloadParamSet");
+ string source = "REDIS";
bool fatto = false;
string currKey = $"{Utils.redisParamPageExp}";
string rawData = JsonConvert.SerializeObject(expTime);
fatto = redisDb.StringSet(currKey, rawData);
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ExpiryReloadParamSet | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
public async Task FlushCacheFluxLog()
{
using var activity = ActivitySource.StartActivity("FlushCacheFluxLog");
+ string source = "REDIS";
bool answ = false;
RedisValue pattern = new RedisValue($"{Utils.redisParetoFLKey}:*");
answ = await ExecFlushRedisPatternAsync(pattern);
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"FlushCacheFluxLog | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -1176,31 +1201,40 @@ namespace MP.SPEC.Data
public async Task FlushMpIoOdlCache()
{
using var activity = ActivitySource.StartActivity("FlushMpIoOdlCache");
+ string source = "REDIS";
// svuoto dalla cache REDIS del server IO...
bool ok01 = await ResetIoCache("CurrODL");
bool ok02 = await ResetIoCache("CurrOdlRow");
bool ok03 = await ResetIoCache("CurrStatoMacc");
bool ok04 = await ResetIoCache("DtMac");
activity?.SetTag("data.source", "REDIS");
+ activity?.Stop();
+ LogTrace($"FlushMpIoOdlCache | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return ok01 && ok02 && ok03 && ok04;
}
public async Task FlushRedisCache()
{
- await Task.Delay(1);
+ using var activity = ActivitySource.StartActivity("FlushRedisCache");
+ string source = "REDIS";
RedisValue pattern = Utils.RedValue("*");
bool answ = await ExecFlushRedisPatternAsync(pattern);
// rileggo vocabolario.,..
ObjVocabolario = VocabolarioGetAll();
+ activity?.Stop();
+ LogTrace($"FlushRedisCache | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
public async Task FlushRedisKey(string redKey)
{
using var activity = ActivitySource.StartActivity("FlushRedisKey");
+ string source = "REDIS";
RedisValue pattern = Utils.RedValue(redKey);
bool answ = await ExecFlushRedisPatternAsync(pattern);
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"FlushRedisKey | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -1217,12 +1251,15 @@ namespace MP.SPEC.Data
public async Task FluxLogDataRedux(string idxMaccSel, List fluxList, DtUtils.Periodo currPeriodo, Enums.ValSelection valMode, Enums.DataInterval intReq, int maxItem)
{
using var activity = ActivitySource.StartActivity("FluxLogDataRedux");
+ string source = "DB+REDIS";
List procStats = await dbController.FluxLogDataRedux(idxMaccSel, fluxList, currPeriodo, valMode, intReq, maxItem);
// effettuo merge statistiche...
ProcDedupStatMerge(procStats);
// svuoto cache
await FlushCacheFluxLog();
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"FluxLogDataRedux | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
}
public List FluxLogDtoGetByFlux(string Valore)
@@ -1260,8 +1297,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("FluxLogGetLastFilt");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisFluxLogFilt}:{IdxMacchina}:{CodFlux}:{MaxRec}:{DtMax:yyyyMMddHHmm}:{DtMin:yyyyMMddHHmm}";
// cerco in redis dato valore sel idxMaccSel...
@@ -1289,11 +1324,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"FluxLogGetLastFilt | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"FluxLogGetLastFilt | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1304,8 +1338,6 @@ namespace MP.SPEC.Data
public async Task> FluxLogPareto(string idxMacchina, DateTime dtFrom, DateTime dtTo)
{
using var activity = ActivitySource.StartActivity("FluxLogPareto");
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
List? result = new List();
// cerco in redis...
@@ -1327,11 +1359,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ParetoFluxLog Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"FluxLogPareto | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1348,14 +1379,15 @@ namespace MP.SPEC.Data
public async Task ForceDbMaint(bool doExec = true, bool doUpdStat = true, bool doSave = true, int minPgCnt = 1000, int minAvgFrag = 10, int maxAvgFragReb = 50)
{
using var activity = ActivitySource.StartActivity("ForceDbMaint");
- Stopwatch sw = Stopwatch.StartNew();
+ string source = "DB+REDIS";
await dbController.ForceDbMaint(doExec, doUpdStat, doSave, minPgCnt, minAvgFrag, maxAvgFragReb);
- sw.Stop();
- // registro statistiche esecuzione
- RecDbMaintStat(sw.Elapsed);
// svuoto cache
await FlushCacheFluxLog();
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ForceDbMaint | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
+ // registro statistiche esecuzione
+ RecDbMaintStat(activity?.Duration ?? TimeSpan.FromSeconds(1));
}
///
@@ -1367,15 +1399,12 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("Grp2MaccDelete");
bool result = false;
- Stopwatch sw = new Stopwatch();
- sw.Start();
result = dbController.Grp2MaccDelete(rec2del);
// elimino cache redis...
ResetMacGrpCache();
- sw.Stop();
- TimeSpan ts = sw.Elapsed;
- Log.Debug($"Grp2MaccDelete | CodGruppo {rec2del.CodGruppo} | IdxMacc {rec2del.IdxMacchina} | {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", "DB+REDIS");
+ activity?.Stop();
+ LogTrace($"Grp2MaccDelete | CodGruppo {rec2del.CodGruppo} | IdxMacc {rec2del.IdxMacchina} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1388,15 +1417,12 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("Grp2MaccInsert");
bool result = false;
- Stopwatch sw = new Stopwatch();
- sw.Start();
result = dbController.Grp2MaccInsert(upsRec);
// elimino cache redis...
ResetMacGrpCache();
- sw.Stop();
- TimeSpan ts = sw.Elapsed;
- Log.Debug($"Grp2MaccInsert | CodGruppo {upsRec.CodGruppo} | IdxMacc {upsRec.IdxMacchina} | {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", "DB+REDIS");
+ activity?.Stop();
+ LogTrace($"Grp2MaccInsert | CodGruppo {upsRec.CodGruppo} | IdxMacc {upsRec.IdxMacchina} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1409,15 +1435,12 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("Grp2OperDelete");
bool result = false;
- Stopwatch sw = new Stopwatch();
- sw.Start();
result = dbController.Grp2OperDelete(rec2del);
// elimino cache redis...
ResetOprGrpCache();
- sw.Stop();
- TimeSpan ts = sw.Elapsed;
- Log.Debug($"Grp2OperDelete | CodGruppo {rec2del.CodGruppo} | MatrOpr {rec2del.MatrOpr} | {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", "DB+REDIS");
+ activity?.Stop();
+ LogTrace($"Grp2OperDelete | CodGruppo {rec2del.CodGruppo} | MatrOpr {rec2del.MatrOpr} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1430,15 +1453,12 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("Grp2OperInsert");
bool result = false;
- Stopwatch sw = new Stopwatch();
- sw.Start();
result = dbController.Grp2OperInsert(upsRec);
// elimino cache redis...
ResetOprGrpCache();
- sw.Stop();
- TimeSpan ts = sw.Elapsed;
- Log.Debug($"Grp2OperInsert | CodGruppo {upsRec.CodGruppo} | MatrOpr {upsRec.MatrOpr} | {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", "DB+REDIS");
+ activity?.Stop();
+ LogTrace($"Grp2OperInsert | CodGruppo {upsRec.CodGruppo} | MatrOpr {upsRec.MatrOpr} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1463,8 +1483,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("IobInfo");
string source = "DB";
- Stopwatch sw = new Stopwatch();
- sw.Start();
IOB_data? result = new IOB_data();
// cerco in redis...
string currKey = redHashMpIO($"hM2IOB:{IdxMacchina}");
@@ -1484,11 +1502,11 @@ namespace MP.SPEC.Data
if (result == null)
{
result = new IOB_data();
- Log.Debug($"Init valore default | IdxMacchina: {IdxMacchina}");
+ LogTrace($"Init valore default | IdxMacchina: {IdxMacchina}");
}
- sw.Stop();
- Log.Debug($"IobInfo per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"IobInfo per {IdxMacchina} | {source} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1499,13 +1517,16 @@ namespace MP.SPEC.Data
public async Task IstKitDelete(IstanzeKitModel currRecord)
{
using var activity = ActivitySource.StartActivity("IstKitDelete");
+ string source = "DB+REDIS";
bool fatto = false;
// salvo
fatto = dbController.IstKitDelete(currRecord);
// svuoto cache
RedisValue pattern = $"{Utils.redisKitInst}:*";
await ExecFlushRedisPatternAsync(pattern);
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"IstKitDelete | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -1519,8 +1540,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("IstKitFilt");
string source = "DB";
- Stopwatch sw = new Stopwatch();
- sw.Start();
List? result = new List();
// cerco in redis...
string currKey = $"{Utils.redisKitInst}:{keyKit}:{keyExtOrd}";
@@ -1541,10 +1560,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- sw.Stop();
- Log.Debug($"IstKitFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"IstKitFilt | {source} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1557,6 +1576,7 @@ namespace MP.SPEC.Data
{
bool fatto = false;
using var activity = ActivitySource.StartActivity("IstKitInsertByWKS");
+ string source = "DB+REDIS";
// salvo
fatto = dbController.IstKitInsertByWKS(CodArtParent, KeyFilt);
// svuoto cache
@@ -1565,7 +1585,9 @@ namespace MP.SPEC.Data
//ExecFlushRedisPattern((RedisValue)$"{Utils.redisKitScore}:*");
//ExecFlushRedisPattern((RedisValue)$"{Utils.redisKitTempl}:*");
//ExecFlushRedisPattern((RedisValue)$"{Utils.redisKitWip}:*");
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"IstKitInsertByWKS | {source} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -1576,13 +1598,16 @@ namespace MP.SPEC.Data
public async Task IstKitUpsert(IstanzeKitModel currRecord)
{
using var activity = ActivitySource.StartActivity("IstKitUpsert");
+ string source = "DB+REDIS";
bool fatto = false;
// salvo
fatto = dbController.IstKitUpsert(currRecord);
// svuoto cache
RedisValue pattern = $"{Utils.redisKitInst}:*";
await ExecFlushRedisPatternAsync(pattern);
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"IstKitUpsert | {source} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -1594,8 +1619,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("ListGiacenze");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisGiacenzaList}:{IdxOdl}";
// cerco in redis dato valore sel idxMaccSel...
@@ -1616,11 +1639,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ListGiacenze | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"ListGiacenze | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1632,12 +1654,10 @@ namespace MP.SPEC.Data
///
public List ListPODL_ByCodArt(string CodArticolo, bool OnlyAvail)
{
- using var activity = ActivitySource.StartActivity("ListPODL_ByCodArt");
List result = new List();
if (!string.IsNullOrEmpty(CodArticolo))
{
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
+ using var activity = ActivitySource.StartActivity("ListPODL_ByCodArt");
string source = "DB";
string avType = OnlyAvail ? "Avail" : "ALL";
string currKey = $"{Utils.redisPOdlByCodArt}:{CodArticolo}:{avType}";
@@ -1663,11 +1683,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Trace($"ListPODL_ByCodArt | {source} | {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ Log.Trace($"ListPODL_ByCodArt | {source} | {activity?.Duration.TotalMilliseconds}ms");
}
else
{
@@ -1685,8 +1704,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("MacchineGetFilt");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string keyGrp = codGruppo != "*" ? codGruppo : "ALL";
string currKey = $"{Utils.redisMacList}:{keyGrp}";
@@ -1708,11 +1725,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"MacchineGetAll | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", 1);
+ activity?.Stop();
+ LogTrace($"MacchineGetAll | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1725,8 +1741,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("MacchineRecipeArchive");
string? result = "";
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisMacRecipePath}:{idxMacchina}";
// cerco in redis dato valore sel idxMaccSel...
@@ -1746,11 +1760,10 @@ namespace MP.SPEC.Data
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"MacchineRecipeArchive | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", 1);
+ activity?.Stop();
+ LogTrace($"MacchineRecipeArchive | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result ?? "";
}
@@ -1763,8 +1776,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("MacchineRecipeConf");
string? result = "";
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisMacRecipeConf}:{idxMacchina}";
// cerco in redis dato valore sel idxMaccSel...
@@ -1784,11 +1795,10 @@ namespace MP.SPEC.Data
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"MacchineRecipeConf | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", 1);
+ activity?.Stop();
+ LogTrace($"MacchineRecipeConf | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result ?? "";
}
@@ -1802,8 +1812,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("MacchineWithFlux");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisMacByFlux}:{dtStart:yyyyMMddHHmm}:{dtEnd:yyyyMMddHHmm}";
// cerco in redis dato valore sel idxMaccSel...
@@ -1824,11 +1832,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"MacchineWithFlux | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"MacchineWithFlux | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1840,9 +1847,7 @@ namespace MP.SPEC.Data
public Dictionary MachIobConf(string IdxMacchina)
{
using var activity = ActivitySource.StartActivity("MachIobConf");
- string source = "NA";
- Stopwatch sw = new Stopwatch();
- sw.Start();
+ string source = "DB";
Dictionary result = new Dictionary();
// cerco in redis...
string currKey = redHashMpIO($"IOB:{IdxMacchina}:MachIobConf");
@@ -1860,12 +1865,12 @@ namespace MP.SPEC.Data
if (result == null)
{
result = new Dictionary();
- Log.Debug($"Init valore default MachIobConf | IdxMacchina: {IdxMacchina}");
+ LogTrace($"Init valore default MachIobConf | IdxMacchina: {IdxMacchina}");
}
- sw.Stop();
- Log.Debug($"MachIobConf per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"MachIobConf per {IdxMacchina} | {source} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1893,9 +1898,7 @@ namespace MP.SPEC.Data
public async Task> MseGetAll(bool forceDb = false)
{
using var activity = ActivitySource.StartActivity("MseGetAll");
- Stopwatch sw = new Stopwatch();
string source = "DB";
- sw.Start();
List? result = new List();
// cerco in redisConn...
RedisValue rawData = redisDb.StringGet(Constants.redisMseKey);
@@ -1915,10 +1918,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- sw.Stop();
- Log.Debug($"MseGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"MseGetAll | {source} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1945,8 +1948,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("OdlByBatch");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = Utils.redisOdlByBatch;
// cerco in redis dato valore sel idxMaccSel...
@@ -1967,11 +1968,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"OdlByBatch | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"OdlByBatch | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -1984,14 +1984,11 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("OdlByKey");
ODLExpModel? result = new ODLExpModel();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
result = dbController.OdlByKey(IdxOdl);
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"OdlByKey | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"OdlByKey | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2005,6 +2002,7 @@ namespace MP.SPEC.Data
public async Task ODLClose(int idxOdl, string idxMacchina, int matrOpr, bool confPezzi)
{
using var activity = ActivitySource.StartActivity("ODLClose");
+ string source = "DB";
bool fatto = false;
// recupero dati x conf modalità conferma
var configData = await ConfigGetAllAsync();
@@ -2025,7 +2023,9 @@ namespace MP.SPEC.Data
// chiamo metodo conferma!
fatto = await dbController.ODLClose(idxOdl, idxMacchina, matrOpr, confPezzi, confRett, modoConfProd);
}
- activity?.SetTag("data.source", "DB");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ODLClose | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -2036,9 +2036,11 @@ namespace MP.SPEC.Data
public async Task OdlGetByKey(int IdxOdl)
{
using var activity = ActivitySource.StartActivity("OdlGetByKey");
- await Task.Delay(1);
- var dbResult = dbController.OdlGetByKey(IdxOdl);
- activity?.SetTag("data.source", "DB");
+ string source = "DB";
+ var dbResult = await dbController.OdlGetByKey(IdxOdl);
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"OdlGetByKey | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return dbResult;
}
@@ -2051,20 +2053,13 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("OdlGetCurrent");
List? dbResult = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisOdlCurrByMac}";
// cerco in redis dato valore sel idxMaccSel...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
{
- try
- {
- dbResult = JsonConvert.DeserializeObject>($"{rawData}");
- }
- catch
- { }
+ dbResult = JsonConvert.DeserializeObject>($"{rawData}");
source = "REDIS";
}
else
@@ -2077,11 +2072,10 @@ namespace MP.SPEC.Data
{
dbResult = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"OdlGetCurrent | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", dbResult.Count);
+ activity?.Stop();
+ LogTrace($"OdlGetCurrent | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return dbResult;
}
@@ -2094,14 +2088,11 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("OdlListAll");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
result = dbController.OdlListAll();
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"OdlListAll | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", "DB");
+ activity?.Stop();
+ LogTrace($"OdlListAll | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2120,8 +2111,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("OdlListGetFilt");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisOdlList}:{inCorso}:{codArt}:{keyRichPart}:{Reparto}:{IdxMacchina}:{startDate:yyyyMMdd_HHmmss}:{endDate:yyyyMMdd_HHmmss}";
// cerco in redis dato valore sel idxMaccSel...
@@ -2142,11 +2131,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"OdlListGetFilt | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"OdlListGetFilt | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2159,8 +2147,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("OperatoriGetFilt");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string keyGrp = codGruppo != "*" ? codGruppo : "ALL";
string currKey = $"{Utils.redisOprList}:{keyGrp}";
@@ -2182,10 +2168,9 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"OperatoriGetFilt | Read from {source}: {ts.TotalMilliseconds}ms"); activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"OperatoriGetFilt | Read from {source}: {activity?.Duration.TotalMilliseconds}ms"); activity?.SetTag("data.source", source);
return result;
}
@@ -2198,8 +2183,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("ParametriGetFilt");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisFluxByMac}:{IdxMacchina}";
// cerco in redis dato valore sel idxMaccSel...
@@ -2220,11 +2203,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ParametriGetFilt | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"ParametriGetFilt | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2236,10 +2218,13 @@ namespace MP.SPEC.Data
public async Task POdlDeleteRecord(PODLExpModel currRec)
{
using var activity = ActivitySource.StartActivity("POdlDeleteRecord");
+ string source = "DB+REDIS";
var dbResult = await dbController.PODLDeleteRecord(currRec);
// elimino cache redis...
await POdlFlushCache();
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"POdlDeleteRecord | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return dbResult;
}
@@ -2251,10 +2236,13 @@ namespace MP.SPEC.Data
public async Task POdlDoSetup(PODLExpModel currRec)
{
using var activity = ActivitySource.StartActivity("POdlDoSetup");
+ string source = "DB+REDIS";
var dbResult = await dbController.PODL_startSetup(currRec, 0, 1, 1, "", DateTime.Now);
// elimino cache redis...
await POdlFlushCache();
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"POdlDoSetup | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return dbResult;
}
@@ -2265,12 +2253,10 @@ namespace MP.SPEC.Data
///
public async Task POdlGetByKey(int idxPODL)
{
- using var activity = ActivitySource.StartActivity("POdlGetByKey");
PODLModel result = new PODLModel();
if (idxPODL != 0)
{
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
+ using var activity = ActivitySource.StartActivity("POdlGetByKey");
string source = "DB";
string currKey = $"{Utils.redisPOdlByPOdl}:{idxPODL}";
// cerco in redis dato valore sel idxMaccSel...
@@ -2295,11 +2281,10 @@ namespace MP.SPEC.Data
{
result = new PODLModel();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Trace($"POdlGetByKey | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", 1);
+ activity?.Stop();
+ Log.Trace($"POdlGetByKey | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
}
else
{
@@ -2315,12 +2300,10 @@ namespace MP.SPEC.Data
///
public PODLModel POdlGetByOdl(int idxODL)
{
- using var activity = ActivitySource.StartActivity("POdlGetByOdl");
PODLModel result = new PODLModel();
if (idxODL != 0)
{
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
+ using var activity = ActivitySource.StartActivity("POdlGetByOdl");
string source = "DB";
string currKey = $"{Utils.redisPOdlByOdl}:{idxODL}";
// cerco in redis dato valore sel idxMaccSel...
@@ -2345,11 +2328,10 @@ namespace MP.SPEC.Data
{
result = new PODLModel();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Trace($"POdlGetByOdl | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", 1);
+ activity?.Stop();
+ Log.Trace($"POdlGetByOdl | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
}
else
{
@@ -2387,8 +2369,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("POdlListByKitParent");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisPOdlList}_kit:ByParent:{IdxPodlParent}";
// cerco in redis dato valore sel idxMaccSel...
@@ -2409,11 +2389,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"POdlListByKitParent | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"POdlListByKitParent | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2431,8 +2410,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("POdlListGetFiltAsync");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisPOdlList}:{codGruppo}:{idxMacchina}:{keyRichPart}:{lanciato}:{startDate:yyyyMMdd_HHmmss}:{endDate:yyyyMMdd_HHmmss}";
// cerco in redis dato valore sel idxMaccSel...
@@ -2453,11 +2430,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"POdlListGetFiltAsync | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"POdlListGetFilt | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2475,8 +2451,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("POdlListGetFiltAsync");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisPOdlList}:{codGruppo}:{idxMacchina}:{keyRichPart}:{lanciato}:{startDate:yyyyMMdd_HHmmss}:{endDate:yyyyMMdd_HHmmss}";
// cerco in redis dato valore sel idxMaccSel...
@@ -2497,11 +2471,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"POdlListGetFiltAsync | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"POdlListGetFiltAsync | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2519,8 +2492,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("POdlToKitListGetFiltAsync");
List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
string source = "DB";
string currKey = $"{Utils.redisPOdlList}_kit:{codGruppo}:{idxMacchina}:{keyRichPart}:{lanciato}:{startDate:yyyyMMdd_HHmmss}:{endDate:yyyyMMdd_HHmmss}";
// cerco in redis dato valore sel idxMaccSel...
@@ -2541,11 +2512,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"POdlToKitListGetFiltAsync | Read from {source}: {ts.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"POdlToKitListGetFiltAsync | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2558,6 +2528,7 @@ namespace MP.SPEC.Data
public async Task POdlUpdateRecipe(int idxPODL, string recipeName)
{
using var activity = ActivitySource.StartActivity("POdlUpdateRecipe");
+ string source = "DB+REDIS";
bool answ = false;
answ = await dbController.PODL_updateRecipe(idxPODL, recipeName);
// reset redis...
@@ -2565,7 +2536,9 @@ namespace MP.SPEC.Data
{
await POdlFlushCache();
}
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"POdlUpdateRecipe | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -2577,10 +2550,13 @@ namespace MP.SPEC.Data
public async Task POdlUpdateRecord(PODLModel currRec)
{
using var activity = ActivitySource.StartActivity("POdlUpdateRecord");
+ string source = "DB+REDIS";
var dbResult = await dbController.PODLUpdateRecord(currRec);
// elimino cache redis...
await POdlFlushCache();
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"POdlUpdateRecord | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return dbResult;
}
@@ -2591,6 +2567,7 @@ namespace MP.SPEC.Data
public List ProcFLStats()
{
using var activity = ActivitySource.StartActivity("ProcFLStats");
+ string source = "REDIS";
List actStats = new List();
string currKey = $"{Utils.redisStatsProcFL}";
// recupero i record statistiche correnti
@@ -2603,7 +2580,9 @@ namespace MP.SPEC.Data
actStats = rawStats;
}
}
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ProcFLStats | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return actStats;
}
@@ -2614,16 +2593,13 @@ namespace MP.SPEC.Data
///
public async Task RecipeGetByPODL(int idxPODL)
{
- using var activity = ActivitySource.StartActivity("RecipeGetByPODL");
RecipeModel? result = null;
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
+ using var activity = ActivitySource.StartActivity("RecipeGetByPODL");
string source = "MongoDB";
result = await mongoController.RecipeGetByPODL(idxPODL);
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"RecipeGetByPODL | Read from {source}: {ts.TotalMilliseconds}ms");
- activity?.SetTag("data.source", "DB");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"RecipeGetByPODL | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2634,14 +2610,17 @@ namespace MP.SPEC.Data
///
public async Task RecipeSetByPODL(RecipeModel currRecord)
{
- using var activity = ActivitySource.StartActivity("RedisCountKey");
+ using var activity = ActivitySource.StartActivity("RecipeSetByPODL");
+ string source = "DB+REDIS";
bool answ = false;
answ = await mongoController.RecipeSetByPODL(currRecord);
if (answ)
{
await POdlFlushCache();
}
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"RecipeSetByPODL | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -2653,6 +2632,7 @@ namespace MP.SPEC.Data
public int RedisCountKey(string keyPattern)
{
using var activity = ActivitySource.StartActivity("RedisCountKey");
+ string source = "REDIS";
int num = 0;
keyPattern = (string.IsNullOrEmpty(keyPattern) ? "**" : keyPattern);
try
@@ -2671,7 +2651,9 @@ namespace MP.SPEC.Data
{
Log.Error($"Eccezione in RedisCountKey{Environment.NewLine}{arg}");
}
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"RedisCountKey | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return num;
}
@@ -2683,6 +2665,7 @@ namespace MP.SPEC.Data
public bool RedisDelKey(string keyVal)
{
using var activity = ActivitySource.StartActivity("RedisDelKey");
+ string source = "REDIS";
bool answ = false;
var listEndpoints = redisConnAdmin.GetEndPoints();
foreach (var endPoint in listEndpoints)
@@ -2694,7 +2677,9 @@ namespace MP.SPEC.Data
answ = true;
}
}
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"RedisDelKey | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -2705,7 +2690,8 @@ namespace MP.SPEC.Data
///
public async Task ResetIoCache(string baseMem)
{
- using var activity = ActivitySource.StartActivity("TemplateKitDelete");
+ using var activity = ActivitySource.StartActivity("ResetIoCache");
+ string source = "REDIS";
// patterna a partire da cache IO...
RedisValue pattern = new RedisValue($"{MpIoNS}:*");
if (!string.IsNullOrEmpty(baseMem))
@@ -2713,7 +2699,9 @@ namespace MP.SPEC.Data
pattern = new RedisValue($"{MpIoNS}:{baseMem}:*");
}
bool answ = await ExecFlushRedisPatternAsync(pattern);
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ResetIoCache | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -2723,6 +2711,8 @@ namespace MP.SPEC.Data
///
public async Task ResetMicrostatoMacchina(string idxMacchina)
{
+ using var activity = ActivitySource.StartActivity("ResetMicrostatoMacchina");
+ string source = "DB";
// salvo microstato 0...
MicroStatoMacchinaModel newRecMS = new MicroStatoMacchinaModel()
{
@@ -2731,8 +2721,10 @@ namespace MP.SPEC.Data
IdxMicroStato = 0,
Value = "FER"
};
- var result = dbController.MicroStatoMacchinaUpsert(newRecMS);
- await Task.Delay(1);
+ var result = await dbController.MicroStatoMacchinaUpsert(newRecMS);
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"ResetMicrostatoMacchina | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
}
///
@@ -2745,8 +2737,6 @@ namespace MP.SPEC.Data
using var activity = ActivitySource.StartActivity("StatoMacchina");
// setup parametri costanti
string source = "DB";
- Stopwatch sw = new Stopwatch();
- sw.Start();
StatoMacchineModel? result = new StatoMacchineModel();
// cerco in redisConn...
string currKey = $"{Utils.redisStatoMacch}:{idxMacchina}";
@@ -2767,10 +2757,9 @@ namespace MP.SPEC.Data
{
result = new StatoMacchineModel();
}
- sw.Stop();
- Log.Debug($"StatoMacchina | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
- activity?.SetTag("result.count", 1);
+ activity?.Stop();
+ LogTrace($"StatoMacchina | {source} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2780,7 +2769,13 @@ namespace MP.SPEC.Data
///
public Task> StatOdl(int IdxOdl)
{
- return dbController.OdlStart(IdxOdl);
+ using var activity = ActivitySource.StartActivity("StatOdl");
+ string source = "DB";
+ var result= dbController.OdlStart(IdxOdl);
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"StatOdl | {source} | {activity?.Duration.TotalMilliseconds}ms");
+ return result;
}
///
@@ -2791,12 +2786,17 @@ namespace MP.SPEC.Data
public string TagConfGetKey(string redKey)
{
string outVal = "";
+ using var activity = ActivitySource.StartActivity("TagConfGetKey");
+ string source = "REDIS";
// cerco in REDIS la conf x l'IOB
var rawData = redisDb.StringGet(redKey);
if (!string.IsNullOrEmpty(rawData))
{
outVal = $"{rawData}";
}
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"TagConfGetKey | {source} | {activity?.Duration.TotalMilliseconds}ms");
return outVal;
}
@@ -2804,9 +2804,9 @@ namespace MP.SPEC.Data
/// Elenco setup dei tag conf correnti
///
///
- public Task>> TagsGetAll()
+ public Dictionary> TagsGetAll()
{
- return Task.FromResult(currTagConf);
+ return currTagConf;
}
///
@@ -2816,13 +2816,16 @@ namespace MP.SPEC.Data
public async Task TemplateKitDelete(TemplateKitModel currRecord)
{
using var activity = ActivitySource.StartActivity("TemplateKitDelete");
+ string source = "DB+REDIS";
bool fatto = false;
// salvo
fatto = dbController.TemplateKitDelete(currRecord);
// svuoto cache
RedisValue pattern = $"{Utils.redisKitTempl}:*";
await ExecFlushRedisPatternAsync(pattern);
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"TemplateKitDelete | {source} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -2836,8 +2839,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("TemplateKitFilt");
string source = "DB";
- Stopwatch sw = new Stopwatch();
- sw.Start();
List? result = new List();
// cerco in redis...
string currKey = $"{Utils.redisKitTempl}:{codParent}:{codChild}";
@@ -2858,10 +2859,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- sw.Stop();
- Log.Debug($"TemplateKitFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"TemplateKitFilt | {source} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2873,13 +2874,16 @@ namespace MP.SPEC.Data
public async Task TemplateKitUpsert(TemplateKitModel currRecord, string codAzienda)
{
using var activity = ActivitySource.StartActivity("TemplateKitUpsert");
+ string source = "DB+REDIS";
bool fatto = false;
// salvo
fatto = dbController.TemplateKitUpsert(currRecord, codAzienda);
// svuoto cache
RedisValue pattern = $"{Utils.redisKitTempl}:*";
await ExecFlushRedisPatternAsync(pattern);
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"TemplateKitUpsert | {source} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -2894,8 +2898,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("TksScore");
string source = "DB";
- Stopwatch sw = new Stopwatch();
- sw.Start();
List? result = new List();
// cerco in redis...
string currKey = $"{Utils.redisKitScore}:{KeyFilt}:{MaxResult}";
@@ -2916,10 +2918,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- sw.Stop();
- Log.Debug($"TksScore | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"TksScore | {source} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2946,14 +2948,19 @@ namespace MP.SPEC.Data
return answ;
}
+ ///
+ /// Update valore Dossier
+ ///
+ ///
+ ///
+ ///
public async Task updateDossierValue(DossierModel currDoss, FluxLogDTO editFL)
{
using var activity = ActivitySource.StartActivity("updateDossierValue");
+ string source = "DB";
bool answ = false;
// recupero intero set valori dossier deserializzando...
var fluxLogList = FluxLogDtoGetByFlux(currDoss.Valore);
- await Task.Delay(1);
-
// se tutto ok
if (fluxLogList != null)
{
@@ -2983,7 +2990,9 @@ namespace MP.SPEC.Data
// aggiorno record sul DB
await dbController.DossiersUpdateValore(currDoss);
}
- activity?.SetTag("data.source", "DB+REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"updateDossierValue | {source} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -2993,10 +3002,8 @@ namespace MP.SPEC.Data
///
public List VocabolarioGetAll()
{
- using var activity = ActivitySource.StartActivity("VocabolarioGetAll");
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
List? result = new List();
+ using var activity = ActivitySource.StartActivity("VocabolarioGetAll");
string source = "REDIS";
// cerco in redis...
RedisValue rawData = redisDb.StringGet(Utils.redisVocabolario);
@@ -3012,15 +3019,14 @@ namespace MP.SPEC.Data
redisDb.StringSet(Utils.redisVocabolario, rawData, getRandTOut(redisLongTimeCache / 5));
source = "DB";
}
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"VocabolarioGetAll Read from {source}: {ts.TotalMilliseconds}ms");
if (result == null)
{
result = new List();
}
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"VocabolarioGetAll Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -3031,12 +3037,15 @@ namespace MP.SPEC.Data
public bool WipKitDelete(WipSetupKitModel currRecord)
{
using var activity = ActivitySource.StartActivity("WipKitDelete");
+ string source = "DB";
bool fatto = false;
// salvo
fatto = dbController.WipKitDelete(currRecord);
// svuoto cache
EmptyWipCache();
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"WipKitDelete Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -3047,12 +3056,15 @@ namespace MP.SPEC.Data
public bool WipKitDeleteGroup(string KeyFilt)
{
using var activity = ActivitySource.StartActivity("WipKitDeleteGroup");
+ string source = "DB";
bool fatto = false;
// salvo
fatto = dbController.WipKitDeleteGroup(KeyFilt);
// svuoto cache
EmptyWipCache();
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"WipKitDeleteGroup Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -3063,12 +3075,15 @@ namespace MP.SPEC.Data
public bool WipKitDeleteOlder(DateTime DateLimit)
{
using var activity = ActivitySource.StartActivity("WipKitDeleteOlder");
+ string source = "DB";
bool fatto = false;
// salvo
fatto = dbController.WipKitDeleteOlder(DateLimit);
// svuoto cache
EmptyWipCache();
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"WipKitDeleteOlder Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -3081,8 +3096,6 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("WipKitFilt");
string source = "DB";
- Stopwatch sw = new Stopwatch();
- sw.Start();
List? result = new List();
// cerco in redis...
string currKey = $"{Utils.redisKitWip}:{KeyFilt}";
@@ -3103,10 +3116,10 @@ namespace MP.SPEC.Data
{
result = new List();
}
- sw.Stop();
- Log.Debug($"WipKitFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
+ activity?.Stop();
+ LogTrace($"WipKitFilt | {source} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -3117,12 +3130,15 @@ namespace MP.SPEC.Data
public bool WipKitUpsert(WipSetupKitModel currRecord)
{
using var activity = ActivitySource.StartActivity("WipKitUpsert");
+ string source = "DB";
bool fatto = false;
// salvo
fatto = dbController.WipKitUpsert(currRecord);
// svuoto cache KitWip
EmptyWipCache();
- activity?.SetTag("data.source", "REDIS");
+ activity?.SetTag("data.source", source);
+ activity?.Stop();
+ LogTrace($"WipKitUpsert | {source} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -3226,8 +3242,6 @@ namespace MP.SPEC.Data
private static IConfiguration _configuration = null!;
- private static ILogger _logger = null!;
-
private static Logger Log = LogManager.GetCurrentClassLogger();
private string MpIoNS = "";
diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj
index d04d5588..512d9d23 100644
--- a/MP.SPEC/MP.SPEC.csproj
+++ b/MP.SPEC/MP.SPEC.csproj
@@ -5,7 +5,7 @@
enable
enable
MP.SPEC
- 6.16.2602.2419
+ 6.16.2602.2509
1800a78a-6ff1-40f9-b490-87fb8bfc1394
en
diff --git a/MP.SPEC/Pages/Articoli.razor.cs b/MP.SPEC/Pages/Articoli.razor.cs
index c5d84779..45c22baf 100644
--- a/MP.SPEC/Pages/Articoli.razor.cs
+++ b/MP.SPEC/Pages/Articoli.razor.cs
@@ -177,7 +177,7 @@ namespace MP.SPEC.Pages
{
selAzienda = "*";
}
- ListAziende = await MDService.ElencoAziende();
+ ListAziende = MDService.ElencoAziende();
ListTipoArt = await MDService.AnagTipoArtLV();
}
@@ -299,7 +299,7 @@ namespace MP.SPEC.Pages
Chiave = "AZIENDA",
Valore = value
};
- await MDService.ConfigUpdate(updRec);
+ MDService.ConfigUpdate(updRec);
await MDService.ConfigResetCache();
// ricarico
await Task.Delay(1);
diff --git a/MP.SPEC/Pages/Index.razor.cs b/MP.SPEC/Pages/Index.razor.cs
index 8d46c426..0dad9401 100644
--- a/MP.SPEC/Pages/Index.razor.cs
+++ b/MP.SPEC/Pages/Index.razor.cs
@@ -38,7 +38,7 @@ namespace MP.SPEC.Pages
protected override async Task OnInitializedAsync()
{
// recupero elenco link
- ElencoLink = await MDService.ElencoLink();
+ ElencoLink = MDService.ElencoLink();
currAzienda = await MDService.ConfigTryGetAsync("AZIENDA");
await Task.Delay(1);
}
diff --git a/MP.SPEC/Pages/PODL.razor.cs b/MP.SPEC/Pages/PODL.razor.cs
index 73f994a2..63ef69c5 100644
--- a/MP.SPEC/Pages/PODL.razor.cs
+++ b/MP.SPEC/Pages/PODL.razor.cs
@@ -124,7 +124,7 @@ namespace MP.SPEC.Pages
protected override async Task OnInitializedAsync()
{
await getReparto();
- ListAziende = await MDService.ElencoAziende();
+ ListAziende = MDService.ElencoAziende();
var allGruppiData = MDService.ElencoGruppiFase();
if (allGruppiData != null)
{
diff --git a/MP.SPEC/Program.cs b/MP.SPEC/Program.cs
index ae7e52d4..8c36172f 100644
--- a/MP.SPEC/Program.cs
+++ b/MP.SPEC/Program.cs
@@ -46,82 +46,167 @@ string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"))
// avvio oggetto shared x redis...
var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
-// Check develop e conseguente Uptrace setup
-// CONTROLLO GLOBALE: Tutto questo gira SOLO in Development
-if (builder.Environment.IsDevelopment())
-{
- var uptraceEndpoint = builder.Configuration["UptraceDev:Endpoint"];
- var uptraceDsn = builder.Configuration["UptraceDev:Dsn"];
- // Se le variabili di configurazione esistono nel json locale, attiviamo la magia
- if (!string.IsNullOrEmpty(uptraceEndpoint) && !string.IsNullOrEmpty(uptraceDsn))
+// ====================================================================
+// Setup Tracing e Telemetria...
+// ====================================================================
+
+// 1. Leggiamo la configurazione
+var otelEnabled = builder.Configuration.GetValue("Otel:EnableTracing", false);
+var otelEndpoint = builder.Configuration["Otel:Endpoint"];
+var otelDsn = builder.Configuration["Otel:Dsn"];
+
+if (otelEnabled)
+{
+ // ====================================================================
+ // SETUP OPENTELEMETRY BASE (Genera gli oggetti Activity)
+ // Questo gira per i Livelli 1, 2 e 3.
+ // ====================================================================
+ var appVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "1.0.0";
+
+ builder.Services.AddOpenTelemetry()
+ .WithTracing(tracerProviderBuilder =>
+ {
+ tracerProviderBuilder
+ .SetResourceBuilder(OpenTelemetry.Resources.ResourceBuilder.CreateDefault()
+ .AddService(serviceName: "MAPO.SPEC", serviceVersion: appVersion))
+ .AddSource("MP.DATA.Tracer")
+ .AddAspNetCoreInstrumentation(options => { options.Filter = ctx => !ctx.Request.Path.StartsWithSegments("/health"); })
+ .AddSqlClientInstrumentation(options => { options.RecordException = true; })
+ .AddRedisInstrumentation(redisMultiplexer);
+
+ // ====================================================================
+ // ESPORTAZIONE DI RETE (Solo Livelli 1 e 2)
+ // ====================================================================
+ if (!string.IsNullOrWhiteSpace(otelEndpoint))
+ {
+ tracerProviderBuilder.AddOtlpExporter(options =>
+ {
+ options.Endpoint = new Uri(otelEndpoint);
+ if (!string.IsNullOrWhiteSpace(otelDsn))
+ {
+ options.Headers = $"uptrace-dsn={otelDsn}";
+ }
+ options.Protocol = OpenTelemetry.Exporter.OtlpExportProtocol.Grpc;
+ });
+ }
+ // Se otelEndpoint è vuoto (Livello 3), le tracce nascono e muoiono in RAM.
+ });
+
+ // ====================================================================
+ // ESPORTAZIONE NLOG REALTIME (Solo Livelli 1 e 2)
+ // ====================================================================
+ if (!string.IsNullOrWhiteSpace(otelEndpoint))
{
- // ====================================================================
- // 1. SETUP NLOG (Per i log in tempo reale)
- // ====================================================================
var otlpTarget = new OtlpTarget
{
Name = "UptraceRealtime",
- Endpoint = uptraceEndpoint,
- ServiceName = "MP.DATA.Tracer",
- Headers = $"uptrace-dsn={uptraceDsn}"
+ Endpoint = otelEndpoint,
+ ServiceName = "MP.DATA.Tracer"
};
+ if (!string.IsNullOrWhiteSpace(otelDsn))
+ {
+ otlpTarget.Headers = $"uptrace-dsn={otelDsn}";
+ }
+
var config = LogManager.Configuration ?? new NLog.Config.LoggingConfiguration();
config.AddTarget(otlpTarget);
config.AddRule(NLog.LogLevel.Info, NLog.LogLevel.Fatal, otlpTarget);
LogManager.Configuration = config;
LogManager.ReconfigExistingLoggers();
- Console.WriteLine("🚀 NLog OTLP Target attivato per Uptrace in Development!");
-
- // ====================================================================
- // 2. SETUP OPENTELEMETRY (Per gli Span, HTTP, DB e Redis in tempo reale)
- // ====================================================================
- var appVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "1.0.0";
-
- builder.Services.AddOpenTelemetry()
- .WithTracing(tracerProviderBuilder =>
- {
- tracerProviderBuilder
- // Definiamo il nome e versione del servizio CORRENTE su Uptrace
- .SetResourceBuilder(ResourceBuilder.CreateDefault()
- .AddService(serviceName: "MAPO.SPEC", serviceVersion: appVersion))
-
- // Diciamo a OTel di ascoltare gli Span manuali generati
- .AddSource("MP.DATA.Tracer")
-
- // Strumentazione Automatica
- .AddAspNetCoreInstrumentation(options =>
- {
- options.Filter = (httpContext) => !httpContext.Request.Path.StartsWithSegments("/health");
- })
- .AddSqlClientInstrumentation(options =>
- {
- options.RecordException = true;
- })
- // Assicurati che redisMultiplexer sia inizializzato PRIMA di questo blocco
- .AddRedisInstrumentation(redisMultiplexer)
-
- // Esporta i dati verso Uptrace
- .AddOtlpExporter(options =>
- {
- options.Endpoint = new Uri(uptraceEndpoint);
- options.Headers = $"uptrace-dsn={uptraceDsn}";
- options.Protocol = OpenTelemetry.Exporter.OtlpExportProtocol.Grpc;
- });
-
- // Scommenta per testare in console
- // .AddConsoleExporter();
- });
-
- Console.WriteLine("🚀 OpenTelemetry Tracing attivato per Uptrace in Development!");
+ logger.Info($"🚀 NLog & OTel attivi e in invio verso: {otelEndpoint}");
}
else
{
- Console.WriteLine("⚠️ Variabili UptraceDev mancanti nel json. Telemetria realtime disabilitata.");
+ logger.Info("ℹ️ OTel attivo (Local mode). Esportazione di rete disabilitata.");
}
}
+else
+{
+ // ====================================================================
+ // LIVELLO 4: TUTTO SPENTO
+ // ====================================================================
+ logger.Info("⏸️ Telemetria e Tracing completamente disabilitati.");
+}
+
+//// Check develop e conseguente Uptrace setup
+//// CONTROLLO GLOBALE: Tutto questo gira SOLO in Development
+//if (builder.Environment.IsDevelopment())
+//{
+// var uptraceEndpoint = builder.Configuration["UptraceDev:Endpoint"];
+// var uptraceDsn = builder.Configuration["UptraceDev:Dsn"];
+
+// // Se le variabili di configurazione esistono nel json locale, attiviamo la magia
+// if (!string.IsNullOrEmpty(uptraceEndpoint) && !string.IsNullOrEmpty(uptraceDsn))
+// {
+// // ====================================================================
+// // 1. SETUP NLOG (Per i log in tempo reale)
+// // ====================================================================
+// var otlpTarget = new OtlpTarget
+// {
+// Name = "UptraceRealtime",
+// Endpoint = uptraceEndpoint,
+// ServiceName = "MP.DATA.Tracer",
+// Headers = $"uptrace-dsn={uptraceDsn}"
+// };
+
+// var config = LogManager.Configuration ?? new NLog.Config.LoggingConfiguration();
+// config.AddTarget(otlpTarget);
+// config.AddRule(NLog.LogLevel.Info, NLog.LogLevel.Fatal, otlpTarget);
+// LogManager.Configuration = config;
+// LogManager.ReconfigExistingLoggers();
+
+// Console.WriteLine("🚀 NLog OTLP Target attivato per Uptrace in Development!");
+
+// // ====================================================================
+// // 2. SETUP OPENTELEMETRY (Per gli Span, HTTP, DB e Redis in tempo reale)
+// // ====================================================================
+// var appVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "1.0.0";
+
+// builder.Services.AddOpenTelemetry()
+// .WithTracing(tracerProviderBuilder =>
+// {
+// tracerProviderBuilder
+// // Definiamo il nome e versione del servizio CORRENTE su Uptrace
+// .SetResourceBuilder(ResourceBuilder.CreateDefault()
+// .AddService(serviceName: "MAPO.SPEC", serviceVersion: appVersion))
+
+// // Diciamo a OTel di ascoltare gli Span manuali generati
+// .AddSource("MP.DATA.Tracer")
+
+// // Strumentazione Automatica
+// .AddAspNetCoreInstrumentation(options =>
+// {
+// options.Filter = (httpContext) => !httpContext.Request.Path.StartsWithSegments("/health");
+// })
+// .AddSqlClientInstrumentation(options =>
+// {
+// options.RecordException = true;
+// })
+// // Assicurati che redisMultiplexer sia inizializzato PRIMA di questo blocco
+// .AddRedisInstrumentation(redisMultiplexer)
+
+// // Esporta i dati verso Uptrace
+// .AddOtlpExporter(options =>
+// {
+// options.Endpoint = new Uri(uptraceEndpoint);
+// options.Headers = $"uptrace-dsn={uptraceDsn}";
+// options.Protocol = OpenTelemetry.Exporter.OtlpExportProtocol.Grpc;
+// });
+
+// // Scommenta per testare in console
+// // .AddConsoleExporter();
+// });
+
+// Console.WriteLine("🚀 OpenTelemetry Tracing attivato per Uptrace in Development!");
+// }
+// else
+// {
+// Console.WriteLine("⚠️ Variabili UptraceDev mancanti nel json. Telemetria realtime disabilitata.");
+// }
+//}
// Add services to the container.
diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html
index 460b9949..4498e7be 100644
--- a/MP.SPEC/Resources/ChangeLog.html
+++ b/MP.SPEC/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MAPOSPEC
- Versione: 6.16.2602.2419
+ Versione: 6.16.2602.2509
Note di rilascio:
-
diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt
index e7abbeec..bfb69c16 100644
--- a/MP.SPEC/Resources/VersNum.txt
+++ b/MP.SPEC/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2602.2419
+6.16.2602.2509
diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml
index 608968c3..122756be 100644
--- a/MP.SPEC/Resources/manifest.xml
+++ b/MP.SPEC/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2602.2419
+ 6.16.2602.2509
https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip
https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html
false
diff --git a/MP.SPEC/Shared/NavMenu.razor.cs b/MP.SPEC/Shared/NavMenu.razor.cs
index 91cf5404..4f30688e 100644
--- a/MP.SPEC/Shared/NavMenu.razor.cs
+++ b/MP.SPEC/Shared/NavMenu.razor.cs
@@ -41,12 +41,19 @@ namespace MP.SPEC.Shared
return MsgService.HasRole(Ruolo);
}
+ protected override void OnInitialized()
+ {
+ //base.OnInitialized();
+ ElencoLink = MDService.ElencoLink();
+ }
+
+#if false
protected override async Task OnInitializedAsync()
{
// recupero elenco JQM
- ElencoLink = await MDService.ElencoLink();
await Task.Delay(1);
- }
+ }
+#endif
protected void ToggleCompress()
{
diff --git a/MP.SPEC/appsettings.Development.json b/MP.SPEC/appsettings.Development.json
index 875ee554..de8e232d 100644
--- a/MP.SPEC/appsettings.Development.json
+++ b/MP.SPEC/appsettings.Development.json
@@ -6,11 +6,10 @@
"Microsoft.AspNetCore": "Warning"
}
},
- "UptraceDev": {
+ "Otel": {
+ "EnableTracing": true,
"Endpoint": "https://uptrace.egalware.com:14317",
"Dsn": "https://DC_iX71mEzg7KA7atQEBdQ@uptrace.egalware.com?grpc=14317"
- //"Endpoint": "http://upt.ovh:14317",
- //"Dsn": "http://DC_iX71mEzg7KA7atQEBdQ@upt.ovh?grpc=14317"
},
"ServerConf": {
"maxAge": "2000",
diff --git a/MP.SPEC/appsettings.Production.json b/MP.SPEC/appsettings.Production.json
index 3fdeaa5a..07c7752c 100644
--- a/MP.SPEC/appsettings.Production.json
+++ b/MP.SPEC/appsettings.Production.json
@@ -7,6 +7,11 @@
"Microsoft.Hosting.Lifetime": "Information"
}
},
+ "Otel": {
+ "EnableTracing": true,
+ "Endpoint": "",
+ "Dsn": ""
+ },
"AllowedHosts": "*",
"ConnectionStrings": {
"MP.All": "Server=localhost\\SQLEXPRESS;Database=MoonPro; User ID=steamware;Password=viadante16; integrated security=False; MultipleActiveResultSets=True; App=MP.SPEC;",
diff --git a/MP.SPEC/appsettings.Staging.json b/MP.SPEC/appsettings.Staging.json
index d3047013..d61f5682 100644
--- a/MP.SPEC/appsettings.Staging.json
+++ b/MP.SPEC/appsettings.Staging.json
@@ -6,6 +6,11 @@
"Microsoft.AspNetCore": "Warning"
}
},
+ "Otel": {
+ "EnableTracing": true,
+ "Endpoint": "http://localhost:4317",
+ "Dsn": ""
+ },
"ServerConf": {
"maxAge": "2000",
"cacheCheckArtUsato": 2,
diff --git a/MP.SPEC/appsettings.json b/MP.SPEC/appsettings.json
index 16254251..a2055c1b 100644
--- a/MP.SPEC/appsettings.json
+++ b/MP.SPEC/appsettings.json
@@ -46,6 +46,11 @@
}
]
},
+ "Otel": {
+ "EnableTracing": true,
+ "Endpoint": "https://uptrace.egalware.com:14317",
+ "Dsn": "https://DC_iX71mEzg7KA7atQEBdQ@uptrace.egalware.com?grpc=14317"
+ },
"AllowedHosts": "*",
"ConnectionStrings": {
"MP.All": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.SPEC;",