예제 #1
0
        private static async Task RunTrace(Pod pod)
        {
            try
            {
                await Kubectl.ExecEmbeddedSingleLineShellScript(pod, "install-dotnet-trace.sh");

                var filenamePrefix     = DateTimeOffset.UtcNow.ToString("yyyyMMdd-HHmmss");
                var nettraceFullPath   = $"/diagnostics/trace-{filenamePrefix}.nettrace";
                var speedscopeFullPath = $"/diagnostics/trace-{filenamePrefix}.speedscope.json";

                var traceArguments = new[]
                {
                    "dotnet", "/diagnostics/dotnet-trace/tools/netcoreapp2.1/any/dotnet-trace.dll", "collect",
                    "--format", "speedscope",
                    "--output", nettraceFullPath,
                    "--process-id", "1",
                    "--profile", "gc-collect"
                };

                await Kubectl.Exec2(pod, true, traceArguments);

                await Kubectl.DownloadFile(pod, nettraceFullPath);

                await Kubectl.DownloadFile(pod, speedscopeFullPath);
            }
            catch (KubectlException)
            {
            }
        }
예제 #2
0
        private static async Task RunCounters(Pod pod, CountersMode?mode, string[]?extraArgs)
        {
            try
            {
                await Kubectl.ExecEmbeddedSingleLineShellScript(pod, "install-dotnet-counters.sh");

                var countersArguments = new List <string>()
                {
                    "dotnet", "/diagnostics/dotnet-counters/tools/netcoreapp2.1/any/dotnet-counters.dll"
                };

                if (mode != null)
                {
                    switch (mode.Value)
                    {
                    case CountersMode.Monitor:
                        countersArguments.AddRange(new[] { "monitor", "--process-id", "1" });
                        break;

                    case CountersMode.Collect:
                        countersArguments.AddRange(new[] { "collect", "--process-id", "1" });
                        break;
                    }
                }

                if (extraArgs != null)
                {
                    countersArguments.AddRange(extraArgs);
                }

                await Kubectl.Exec(pod, true, countersArguments);
            }
            catch (KubectlException)
            {
            }
        }