Skip to content

Commit c5f9e7e

Browse files
authored
Merge branch 'main' into other/add-mongodb-3x-support
2 parents b339434 + 6737414 commit c5f9e7e

42 files changed

Lines changed: 173 additions & 257 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/all_solutions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ jobs:
444444

445445
env:
446446
integration_tests_shared_project: ${{ github.workspace }}/tests/Agent/IntegrationTests/Shared
447-
unbounded_tests_path: ${{ github.workspace }}/tests/Agent/IntegrationTests/UnboundedIntegrationTests/bin/Release/net481
447+
unbounded_tests_path: ${{ github.workspace }}/tests/Agent/IntegrationTests/UnboundedIntegrationTests/bin/Release/net9.0
448448
NR_DOTNET_TEST_SAVE_WORKING_DIRECTORY: 1
449449
# Make this variable true to enable extra data-gathering and logging to help troubleshoot test failures, at the cost of additional time and resources
450450
enhanced_logging: false

src/Agent/NewRelic/Agent/Core/AgentInstallConfiguration.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private static bool GetIsNetCore30OrAbove()
163163
private static string GetNewRelicHome()
164164
{
165165
var newRelicHome = EnvironmentVariableProxy.GetEnvironmentVariableFromList(NewRelicHomeEnvironmentVariables);
166-
if (newRelicHome != null && DirectoryWrapper.Instance.Exists(newRelicHome)) return Path.GetFullPath(newRelicHome);
166+
if (newRelicHome != null && Directory.Exists(newRelicHome)) return Path.GetFullPath(newRelicHome);
167167
#if NETFRAMEWORK
168168
var key = Registry.LocalMachine.OpenSubKey(@"Software\New Relic\.NET Agent");
169169
if (key != null) newRelicHome = (string)key.GetValue("NewRelicHome");
@@ -177,7 +177,7 @@ private static string GetNewRelicInstallPath()
177177
if (newRelicInstallPath != null)
178178
{
179179
newRelicInstallPath = Path.Combine(newRelicInstallPath, RuntimeDirectoryName);
180-
if (DirectoryWrapper.Instance.Exists(newRelicInstallPath)) return newRelicInstallPath;
180+
if (Directory.Exists(newRelicInstallPath)) return newRelicInstallPath;
181181
}
182182

183183
newRelicInstallPath = EnvironmentVariableProxy.GetEnvironmentVariableFromList(NewRelicHomeEnvironmentVariables);
@@ -194,11 +194,11 @@ public static AgentInfo GetAgentInfo()
194194

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

197-
if (FileWrapper.Instance.Exists(agentInfoPath))
197+
if (File.Exists(agentInfoPath))
198198
{
199199
try
200200
{
201-
return JsonConvert.DeserializeObject<AgentInfo>(FileWrapper.Instance.ReadAllText(agentInfoPath));
201+
return JsonConvert.DeserializeObject<AgentInfo>(File.ReadAllText(agentInfoPath));
202202
}
203203
catch (Exception e)
204204
{

src/Agent/NewRelic/Agent/Core/Config/BootstrapConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class BootstrapConfiguration : IBootstrapConfiguration
5151
private BootstrapConfiguration()
5252
{
5353
_agentEnabledWithProvenance = new ValueWithProvenance<bool>(true, "Default value");
54-
LogConfig = new BootstrapLogConfig(new configurationLog(), new ProcessStatic(), DirectoryWrapper.Instance.Exists, Path.GetFullPath);
54+
LogConfig = new BootstrapLogConfig(new configurationLog(), new ProcessStatic(), Directory.Exists, Path.GetFullPath);
5555
}
5656

5757
/// <summary>
@@ -60,7 +60,7 @@ private BootstrapConfiguration()
6060
/// <param name="localConfiguration">The local configuration object to use.</param>
6161
/// <param name="configurationFileName">The name and path of the local configuration file.</param>
6262
public BootstrapConfiguration(configuration localConfiguration, string configurationFileName)
63-
: this(localConfiguration, configurationFileName, ConfigurationLoader.GetWebConfigAppSetting, new ConfigurationManagerStatic(), new ProcessStatic(), DirectoryWrapper.Instance.Exists, Path.GetFullPath)
63+
: this(localConfiguration, configurationFileName, ConfigurationLoader.GetWebConfigAppSetting, new ConfigurationManagerStatic(), new ProcessStatic(), Directory.Exists, Path.GetFullPath)
6464
{ }
6565

6666
/// <summary>

src/Agent/NewRelic/Agent/Core/Config/ConfigurationLoader.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ private static string InternalGetAppDomainName()
6464
public static Func<string> GetAppDomainName = InternalGetAppDomainName;
6565
#endif
6666

67-
public static Func<string, bool> FileExists = FileWrapper.Instance.Exists;
68-
public static Func<string, string> FileReadAllText = FileWrapper.Instance.ReadAllText;
67+
public static Func<string, bool> FileExists = File.Exists;
68+
public static Func<string, string> FileReadAllText = File.ReadAllText;
6969

7070
public static Func<string, string> PathGetDirectoryName = Path.GetDirectoryName;
7171
public static Func<string, string> GetEnvironmentVar = System.Environment.GetEnvironmentVariable;
@@ -217,7 +217,7 @@ private static string TryGetAgentConfigFileFromAppRoot()
217217
}
218218
}
219219

220-
var currentDirectory = DirectoryWrapper.Instance.GetCurrentDirectory();
220+
var currentDirectory = Directory.GetCurrentDirectory();
221221
filename = Path.Combine(currentDirectory, NewRelicConfigFileName);
222222
if (FileExists(filename))
223223
{

src/Agent/NewRelic/Agent/Core/Configuration/AppSettingsConfigResolveWhenUsed.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private static IConfigurationRoot InitializeConfiguration()
3737
catch (AppDomainUnloadedException)
3838
{
3939
// Fall back to previous behavior of agents <=8.35.0
40-
applicationDirectory = DirectoryWrapper.Instance.GetCurrentDirectory();
40+
applicationDirectory = Directory.GetCurrentDirectory();
4141
}
4242

4343
// add default appsettings.json files to config builder

src/Agent/NewRelic/Agent/Core/DataTransport/ConnectionHandler.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ public class ConnectionHandler : ConfigurationBasedService, IConnectionHandler
5050
private readonly Environment _environment;
5151
private readonly IAgentHealthReporter _agentHealthReporter;
5252
private readonly IEnvironment _environmentVariableHelper;
53+
private readonly IFileWrapper _fileWrapper;
5354

54-
public ConnectionHandler(ISerializer serializer, ICollectorWireFactory collectorWireFactory, IProcessStatic processStatic, IDnsStatic dnsStatic, ILabelsService labelsService, Environment environment, ISystemInfo systemInfo, IAgentHealthReporter agentHealthReporter, IEnvironment environmentVariableHelper, ICollectorWire dataRequestWire = null)
55+
public ConnectionHandler(ISerializer serializer, ICollectorWireFactory collectorWireFactory, IProcessStatic processStatic, IDnsStatic dnsStatic, ILabelsService labelsService, Environment environment, ISystemInfo systemInfo, IAgentHealthReporter agentHealthReporter, IEnvironment environmentVariableHelper, IFileWrapper fileWrapper, ICollectorWire dataRequestWire = null)
5556
{
5657
_serializer = serializer;
5758
_collectorWireFactory = collectorWireFactory;
@@ -62,6 +63,7 @@ public ConnectionHandler(ISerializer serializer, ICollectorWireFactory collector
6263
_systemInfo = systemInfo;
6364
_agentHealthReporter = agentHealthReporter;
6465
_environmentVariableHelper = environmentVariableHelper;
66+
_fileWrapper = fileWrapper;
6567

6668
_connectionInfo = new ConnectionInfo(_configuration);
6769
_dataRequestWire = dataRequestWire ?? new NoOpCollectorWire();
@@ -314,7 +316,7 @@ private ConnectModel GetConnectParameters()
314316
identifier,
315317
_labelsService.Labels,
316318
metadata ?? new Dictionary<string, string>(),
317-
new UtilizationStore(_systemInfo, _dnsStatic, _configuration, _agentHealthReporter).GetUtilizationSettings(),
319+
new UtilizationStore(_systemInfo, _dnsStatic, _configuration, _agentHealthReporter, _fileWrapper).GetUtilizationSettings(),
318320
_configuration.CollectorSendEnvironmentInfo ? _environment : null,
319321
_configuration.SecurityPoliciesTokenExists ? new SecurityPoliciesSettingsModel(_configuration) : null,
320322
new EventHarvestConfigModel(_configuration),

src/Agent/NewRelic/Agent/Core/Logging/LoggerBootstrapper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ private static LoggerConfiguration ConfigureRollingLogSink(this LoggerConfigurat
260260
{
261261
// Create the directory if necessary
262262
var directory = Path.GetDirectoryName(fileName);
263-
if (!DirectoryWrapper.Instance.Exists(directory))
264-
DirectoryWrapper.Instance.CreateDirectory(directory);
265-
using (FileWrapper.Instance.Open(fileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write)) { }
263+
if (!Directory.Exists(directory))
264+
Directory.CreateDirectory(directory);
265+
using (File.Open(fileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write)) { }
266266
}
267267
catch (Exception exception)
268268
{

src/Agent/NewRelic/Agent/Core/RuntimeEnvironmentInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ private static DistroInfo LoadDistroInfo()
127127

128128
try
129129
{
130-
if (FileWrapper.Instance.Exists("/etc/os-release"))
130+
if (File.Exists("/etc/os-release"))
131131
{
132-
var lines = FileWrapper.Instance.ReadAllLines("/etc/os-release");
132+
var lines = File.ReadAllLines("/etc/os-release");
133133
result = new DistroInfo();
134134
foreach (var line in lines)
135135
{

src/Agent/NewRelic/Agent/Core/Utilities/DirectoryWrapper.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ public interface IDirectoryWrapper
1919
[NrExcludeFromCodeCoverage]
2020
public class DirectoryWrapper : IDirectoryWrapper
2121
{
22-
public static IDirectoryWrapper Instance { get; } = new DirectoryWrapper();
23-
2422
public bool Exists(string path) => Directory.Exists(path);
2523

2624
public string[] GetFiles(string path, string searchPattern, SearchOption searchOption = SearchOption.TopDirectoryOnly) => Directory.GetFiles(path, searchPattern, searchOption);

src/Agent/NewRelic/Agent/Core/Utilities/ExtensionsLoader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ public static IEnumerable<IWrapper> LoadWrappers()
158158

159159
private static List<string> GetAssemblyFilesFromFolder(string folder)
160160
{
161-
if (folder == null || !DirectoryWrapper.Instance.Exists(folder))
161+
if (folder == null || !Directory.Exists(folder))
162162
{
163163
return new List<string>();
164164
}
165165

166-
var assemblyPaths = DirectoryWrapper.Instance.GetFiles(folder, "*.dll", SearchOption.TopDirectoryOnly);
166+
var assemblyPaths = Directory.GetFiles(folder, "*.dll", SearchOption.TopDirectoryOnly);
167167

168168
return assemblyPaths.ToList();
169169
}

0 commit comments

Comments
 (0)