diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/ActivityContext.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/ActivityContext.cs index 7c232671e7..f6bb8e7e50 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/ActivityContext.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/ActivityContext.cs @@ -65,6 +65,30 @@ public class ActivityContext return false; } + public void SetSolutionPath(string solutionPath) + { + if (solutionPath == SolutionPath) + { + return; + } + + ExtraProperties[ActivityPropertyNames.SolutionPath] = solutionPath; + + if(Current.ContainsKey(ActivityPropertyNames.SolutionPath)) + { + Current[ActivityPropertyNames.SolutionPath] = solutionPath; + } + + if (Current.TryGetValue(ActivityPropertyNames.AdditionalProperties, out var additionalPropertiesObj) && + additionalPropertiesObj is Dictionary additionalPropertiesDict) + { + if (additionalPropertiesDict.ContainsKey(ActivityPropertyNames.SolutionPath)) + { + additionalPropertiesDict[ActivityPropertyNames.SolutionPath] = solutionPath; + } + } + } + public void Terminate() { IsTerminated = true; diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/Providers/TelemetrySolutionInfoEnricher.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/Providers/TelemetrySolutionInfoEnricher.cs index 97e487585a..97a2eba926 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/Providers/TelemetrySolutionInfoEnricher.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/Providers/TelemetrySolutionInfoEnricher.cs @@ -49,7 +49,7 @@ internal sealed class TelemetrySolutionInfoEnricher : TelemetryActivityEventEnri return Task.CompletedTask; } - context.ExtraProperties[ActivityPropertyNames.SolutionPath] = correctSolutionPath; + context.SetSolutionPath(correctSolutionPath); var jsonContent = File.ReadAllText(context.SolutionPath!); using var doc = JsonDocument.Parse(jsonContent, new JsonDocumentOptions @@ -178,37 +178,27 @@ internal sealed class TelemetrySolutionInfoEnricher : TelemetryActivityEventEnri { return solutionPath; } + + var possibleExtensions = new[] + { + ".sln", + ".slnx" + }; - if (solutionPath.EndsWith(".sln")) + foreach (var extension in possibleExtensions) { - solutionPath = solutionPath.RemovePostFix(".sln") + ".abpsln"; - if (File.Exists(solutionPath)) + if (!solutionPath.EndsWith(extension)) { - return solutionPath; + continue; } - } - - if (solutionPath.EndsWith(".slnx")) - { - solutionPath = solutionPath.RemovePostFix(".slnx") + ".abpsln"; - if (File.Exists(solutionPath)) + + var abpSlnPath = solutionPath.Substring(0, solutionPath.Length - extension.Length) + ".abpsln"; + if (File.Exists(abpSlnPath)) { - return solutionPath; + return abpSlnPath; } } - - var dir = Path.GetDirectoryName(solutionPath); - if (dir.IsNullOrEmpty()) - { - return null; - } - - var abpSolutionFiles = Directory.GetFiles(dir, "*.abpsln", SearchOption.TopDirectoryOnly); - return abpSolutionFiles.Length switch - { - 1 => abpSolutionFiles[0], - _ => null - }; + return null; } } \ No newline at end of file