Skip to content

Commit

Permalink
chore: Detect Azure Function and AWS Lambda and report as custom inst…
Browse files Browse the repository at this point in the history
…all type
  • Loading branch information
tippmar-nr committed Sep 18, 2024
1 parent 80cf9ef commit 0b37308
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Agent/NewRelic/Agent/Core/AgentInstallConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,37 @@ public static AgentInfo GetAgentInfo()
}
}
else
{
if (TryGetAzureFunctionInstallType(out var agentInfo))
return agentInfo;

if (TryGetLambdaServerlessInstallType(out agentInfo))
return agentInfo;

Log.Debug($"Could not get agent info from {agentInfoPath}. File does not exist.");
}

return null;
}

private static bool TryGetLambdaServerlessInstallType(out AgentInfo agentInfo)
{
agentInfo = null;
if (System.Environment.GetEnvironmentVariable("AWS_LAMBDA_FUNCTION_NAME") != null)
{
agentInfo = new AgentInfo { InstallType = "Lambda" };
}
return agentInfo != null;
}

private static bool TryGetAzureFunctionInstallType(out AgentInfo agentInfo)
{
agentInfo = null;
if (System.Environment.GetEnvironmentVariable("FUNCTIONS_WORKER_RUNTIME") != null)
{
agentInfo = new AgentInfo { InstallType = "AzureFunction" };
}
return agentInfo != null;
}
}
}

0 comments on commit 0b37308

Please sign in to comment.