Skip to content

Commit

Permalink
chore: Add Install Type to environment variables that BMDS can captur…
Browse files Browse the repository at this point in the history
…e. (#2126)
  • Loading branch information
tippmar-nr authored Dec 8, 2023
1 parent 3c21fe9 commit 13846dd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
20 changes: 3 additions & 17 deletions src/Agent/NewRelic/Agent/Core/AgentHealth/AgentHealthReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ private void LogPeriodicReport()
{
Log.Debug(logMessage);
}

List<string> events = new List<string>();
foreach (var counter in _agentHealthEventCounters)
{
Expand Down Expand Up @@ -226,20 +225,7 @@ public void ReportErrorEventsSent(int count)

public void ReportAgentInfo()
{
if (AgentInstallConfiguration.AgentInfo == null)
{
TrySend(_metricBuilder.TryBuildInstallTypeMetric("Unknown"));
return;
}

if (AgentInstallConfiguration.AgentInfo.AzureSiteExtension)
{
TrySend(_metricBuilder.TryBuildInstallTypeMetric((AgentInstallConfiguration.AgentInfo.InstallType ?? "Unknown") + "SiteExtension"));
}
else
{
TrySend(_metricBuilder.TryBuildInstallTypeMetric(AgentInstallConfiguration.AgentInfo.InstallType ?? "Unknown"));
}
TrySend(_metricBuilder.TryBuildInstallTypeMetric(AgentInstallConfiguration.AgentInfo?.ToString() ?? "Unknown"));
}

public void ReportTransactionGarbageCollected(TransactionMetricName transactionMetricName, string lastStartedSegmentName, string lastFinishedSegmentName)
Expand Down Expand Up @@ -661,7 +647,7 @@ public void ReportLoggingEventsSent(int count)
_agentHealthEventCounters[AgentHealthEvent.Log]?.Add(count);
}

public void ReportLoggingEventsDropped(int droppedCount)=> TrySend(_metricBuilder.TryBuildSupportabilityLoggingEventsDroppedMetric(droppedCount));
public void ReportLoggingEventsDropped(int droppedCount) => TrySend(_metricBuilder.TryBuildSupportabilityLoggingEventsDroppedMetric(droppedCount));

public void ReportIfAppDomainCachingDisabled()
{
Expand All @@ -678,7 +664,7 @@ public void ReportLogForwardingConfiguredValues()
ReportSupportabilityCountMetric(MetricNames.GetSupportabilityLogDecoratingConfiguredName(_configuration.LogDecoratorEnabled));
}

#endregion
#endregion

public void ReportSupportabilityPayloadsDroppeDueToMaxPayloadSizeLimit(string endpoint)
{
Expand Down
5 changes: 5 additions & 0 deletions src/Agent/NewRelic/Agent/Core/AgentHealth/AgentInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ public class AgentInfo

[JsonProperty(PropertyName = "azure_site_extension", NullValueHandling = NullValueHandling.Ignore)]
public bool AzureSiteExtension { get; set; }

public override string ToString()
{
return $"{InstallType ?? "Unknown"}{(AzureSiteExtension ? "SiteExtension" : "")}";
}
}
}
2 changes: 1 addition & 1 deletion src/Agent/NewRelic/Agent/Core/AgentInstallConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private static string GetNewRelicLogLevel()
return System.Environment.GetEnvironmentVariable(NewRelicLogLevelEnvironmentVariable);
}

private static AgentInfo GetAgentInfo()
public static AgentInfo GetAgentInfo()
{
var agentInfoPath = $@"{NewRelicHome}\agentinfo.json";
if (File.Exists(agentInfoPath))
Expand Down
3 changes: 3 additions & 0 deletions src/Agent/NewRelic/Agent/Core/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ public Environment(ISystemInfo systemInfo, IProcessStatic processStatic, IConfig
AddVariable("Physical Processors", () => managementObject["NumberOfProcessors"]);
AddVariable("Logical Processors", () => managementObject["NumberOfLogicalProcessors"]);
}

#endif

AddVariable("Install Type", () => AgentInstallConfiguration.GetAgentInfo()?.ToString() ?? "Unknown");
}
catch (Exception ex)
{
Expand Down

0 comments on commit 13846dd

Please sign in to comment.