public static string GetTracerNativeDLLPath() { var tracerHome = GetTracerHomePath(); var(extension, dir) = (EnvironmentTools.GetOS(), EnvironmentTools.GetPlatform()) switch { ("win", "X64") => ("dll", "win-x64"), ("win", "X86") => ("dll", "win-x86"), ("linux", "X64") => ("so", null), ("linux", "Arm64") => ("so", null), ("osx", _) => ("dylib", null), _ => throw new PlatformNotSupportedException() }; var fileName = $"Datadog.Trace.ClrProfiler.Native.{extension}"; var path = dir is null ? Path.Combine(tracerHome, fileName) : Path.Combine(tracerHome, dir, fileName); if (!File.Exists(path)) { throw new Exception($"Unable to find profiler at {path}"); } return(path); }
public string GetSampleApplicationOutputDirectory(string packageVersion = "", string framework = "") { var targetFramework = string.IsNullOrEmpty(framework) ? GetTargetFramework() : framework; var binDir = Path.Combine( GetSampleProjectDirectory(), "bin"); string outputDir; if (_samplesDirectory.Contains("aspnet")) { outputDir = binDir; } else if (EnvironmentTools.GetOS() == "win") { outputDir = Path.Combine( binDir, packageVersion, EnvironmentTools.GetPlatform(), EnvironmentTools.GetBuildConfiguration(), targetFramework); } else { outputDir = Path.Combine( binDir, packageVersion, EnvironmentTools.GetBuildConfiguration(), targetFramework, "publish"); } return(outputDir); }
public string GetProfilerPath() { if (_profilerFileLocation == null) { string extension = EnvironmentTools.GetOS() switch { "win" => "dll", "linux" => "so", "osx" => "dylib", _ => throw new PlatformNotSupportedException() }; string fileName = $"Datadog.Trace.ClrProfiler.Native.{extension}"; var directory = GetSampleApplicationOutputDirectory(); var relativePath = Path.Combine( "profiler-lib", fileName); _profilerFileLocation = Path.Combine( directory, relativePath); // TODO: get rid of the fallback options when we have a consistent convention if (!File.Exists(_profilerFileLocation)) { _output?.WriteLine($"Attempt 1: Unable to find profiler at {_profilerFileLocation}."); // Let's try the executing directory, as dotnet publish ignores the Copy attributes we currently use _profilerFileLocation = Path.Combine( GetExecutingProjectBin(), relativePath); } if (!File.Exists(_profilerFileLocation)) { _output?.WriteLine($"Attempt 2: Unable to find profiler at {_profilerFileLocation}."); // One last attempt at the actual native project directory _profilerFileLocation = Path.Combine( GetProfilerProjectBin(), fileName); } if (!File.Exists(_profilerFileLocation)) { throw new Exception($"Attempt 3: Unable to find profiler at {_profilerFileLocation}"); } _output?.WriteLine($"Found profiler at {_profilerFileLocation}."); } return(_profilerFileLocation); }
public static string GetNativeLoaderPath() { var monitoringHome = GetMonitoringHomePath(); string fileName = (EnvironmentTools.GetOS(), EnvironmentTools.GetPlatform()) switch { ("win", "X64") => "Datadog.AutoInstrumentation.NativeLoader.x64.dll", ("win", "X86") => "Datadog.AutoInstrumentation.NativeLoader.x86.dll", ("linux", "X64") => "Datadog.AutoInstrumentation.NativeLoader.so", ("linux", "Arm64") => "Datadog.AutoInstrumentation.NativeLoader.so", ("osx", _) => throw new PlatformNotSupportedException("The Native Loader is not yet supported on osx"), _ => throw new PlatformNotSupportedException() }; var path = Path.Combine(monitoringHome, fileName); if (!File.Exists(path)) { throw new Exception($"Unable to find Native Loader at {path}"); } return(path); }
public static string GetRuntimeIdentifier() { return(IsCoreClr() ? string.Empty : $"{EnvironmentTools.GetOS()}-{EnvironmentTools.GetPlatform()}"); }