Exemplo n.º 1
0
    public string GetProfilerPath()
    {
        if (_profilerFileLocation != null)
        {
            return(_profilerFileLocation);
        }

        string extension = EnvironmentTools.GetOS() switch
        {
            "win" => "dll",
            "linux" => "so",
            "osx" => "dylib",
            _ => throw new PlatformNotSupportedException()
        };

        string fileName     = $"OpenTelemetry.AutoInstrumentation.Native.{extension}";
        string nukeOutput   = GetNukeBuildOutput();
        string profilerPath = EnvironmentTools.IsWindows()
            ? Path.Combine(nukeOutput, $"win-{EnvironmentTools.GetPlatform().ToLower()}", fileName)
            : Path.Combine(nukeOutput, fileName);

        if (File.Exists(profilerPath))
        {
            _profilerFileLocation = profilerPath;
            _output?.WriteLine($"Found profiler at {_profilerFileLocation}.");
            return(_profilerFileLocation);
        }

        throw new Exception($"Unable to find profiler at: {profilerPath}");
    }