Skip to content

Commit

Permalink
fix: Path to agentinfo.json was built incorrectly, leading to file no…
Browse files Browse the repository at this point in the history
…t found errors when running on Linux. (#2156) (#2157)
  • Loading branch information
tippmar-nr authored Dec 21, 2023
1 parent b392701 commit bd7e0c3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Agent/NewRelic/Agent/Core/AgentInstallConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,27 @@ private static string GetNewRelicLogLevel()

public static AgentInfo GetAgentInfo()
{
var agentInfoPath = $@"{NewRelicHome}\agentinfo.json";
if (string.IsNullOrEmpty(NewRelicHome))
{
Log.Debug($"Could not get agent info. NewRelicHome is null or empty.");
return null;
}

var agentInfoPath = Path.Combine(NewRelicHome, "agentinfo.json");

if (File.Exists(agentInfoPath))
{
try
{
return JsonConvert.DeserializeObject<AgentInfo>(File.ReadAllText(agentInfoPath));
}
catch
catch (Exception e)
{
// Fail silently
Log.Debug(e, $"Could not deserialize agent info from {agentInfoPath}.");
}
}
else
Log.Debug($"Could not get agent info from {agentInfoPath}. File does not exist.");

return null;
}
Expand Down

0 comments on commit bd7e0c3

Please sign in to comment.