@cratis/pi 7.101.0 → 7.103.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/corpus/harnesses/copilot/instructions/github-actions.instructions.md +17 -0
- package/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +10 -1
- package/package/corpus/harnesses/copilot/instructions/pull-requests.instructions.md +2 -0
- package/package/corpus/harnesses/copilot/instructions/secrets.instructions.md +4 -0
- package/package/corpus/hooks/README.md +11 -1
- package/package/corpus/hooks/scripts/cratis-check-pr.mjs +12 -1
- package/package/corpus/hooks/scripts/cratis-guard-secrets.sh +79 -23
- package/package/corpus/hooks/scripts/cratis-guard-writes.sh +145 -40
- package/package/corpus/rules/github-actions.md +17 -0
- package/package/corpus/rules/profiles.md +10 -1
- package/package/corpus/rules/pull-requests.md +2 -0
- package/package/corpus/rules/secrets.md +4 -0
- package/package/corpus/skills/analyzing-dotnet-performance/LICENSE +23 -0
- package/package/corpus/skills/analyzing-dotnet-performance/NOTICE +36 -0
- package/package/corpus/skills/analyzing-dotnet-performance/SKILL.md +214 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/async-patterns.md +122 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/collections-and-linq.md +220 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/critical-patterns.md +291 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/io-and-serialization.md +135 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/memory-and-strings.md +219 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/regex-patterns.md +95 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/structural-patterns.md +38 -0
- package/package/corpus/skills/binlog-generation/LICENSE +23 -0
- package/package/corpus/skills/binlog-generation/NOTICE +22 -0
- package/package/corpus/skills/binlog-generation/SKILL.md +129 -0
- package/package/corpus/skills/check-bin-obj-clash/LICENSE +23 -0
- package/package/corpus/skills/check-bin-obj-clash/NOTICE +27 -0
- package/package/corpus/skills/check-bin-obj-clash/SKILL.md +127 -0
- package/package/corpus/skills/check-bin-obj-clash/references/common-causes-and-fixes.md +206 -0
- package/package/corpus/skills/coverage-analysis/LICENSE +23 -0
- package/package/corpus/skills/coverage-analysis/NOTICE +32 -0
- package/package/corpus/skills/coverage-analysis/SKILL.md +198 -0
- package/package/corpus/skills/coverage-analysis/references/guidelines.md +68 -0
- package/package/corpus/skills/coverage-analysis/references/output-format.md +91 -0
- package/package/corpus/skills/coverage-analysis/references/report-generation.md +58 -0
- package/package/corpus/skills/coverage-analysis/references/setup-discovery.md +307 -0
- package/package/corpus/skills/coverage-analysis/scripts/Compute-CrapScores.ps1 +80 -0
- package/package/corpus/skills/coverage-analysis/scripts/CoverageData.ps1 +272 -0
- package/package/corpus/skills/coverage-analysis/scripts/Extract-MethodCoverage.ps1 +65 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/LICENSE +2 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/SKILL.md +201 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/build-once-and-shard.md +158 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/caching.md +86 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/flaky-and-hung-jobs.md +70 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/publish-pipelines.md +67 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/required-checks-and-path-filters.md +117 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/runner-sizing-and-images.md +65 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/security-and-pinning.md +73 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/sources.md +33 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/test-setup-cost.md +82 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/ci-timings.sh +356 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/fixtures/jobs/1003.json +79 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/fixtures/jobs/1007.json +79 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/fixtures/jobs/1010.json +79 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/fixtures/runs.json +102 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/LICENSE +2 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/SKILL.md +244 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/docker-images.md +86 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/dotnet-nuget.md +87 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/go-jvm-python-elixir.md +83 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/npm-yarn.md +78 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/other-environments.md +60 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/worked-examples.md +97 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/scripts/cratis-local-packages.sh +778 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/scripts/npm-restore-check.cjs +109 -0
- package/package/corpus/skills/csharp-refactoring/LICENSE +23 -0
- package/package/corpus/skills/csharp-refactoring/NOTICE +22 -0
- package/package/corpus/skills/csharp-refactoring/SKILL.md +175 -0
- package/package/corpus/skills/csharp-refactoring/references/operation-catalog.md +37 -0
- package/package/corpus/skills/directory-build-organization/LICENSE +23 -0
- package/package/corpus/skills/directory-build-organization/NOTICE +21 -0
- package/package/corpus/skills/directory-build-organization/SKILL.md +205 -0
- package/package/corpus/skills/directory-build-organization/references/common-patterns.md +56 -0
- package/package/corpus/skills/directory-build-organization/references/multi-level-examples.md +167 -0
- package/package/corpus/skills/directory-build-organization/references/targetframework-props-pitfall.md +54 -0
- package/package/corpus/skills/dotnet-aot-compat/LICENSE +23 -0
- package/package/corpus/skills/dotnet-aot-compat/NOTICE +18 -0
- package/package/corpus/skills/dotnet-aot-compat/SKILL.md +265 -0
- package/package/corpus/skills/dotnet-aot-compat/references/polyfills.md +43 -0
- package/package/corpus/skills/dotnet-trace-collect/LICENSE +23 -0
- package/package/corpus/skills/dotnet-trace-collect/NOTICE +65 -0
- package/package/corpus/skills/dotnet-trace-collect/SKILL.md +116 -0
- package/package/corpus/skills/dotnet-trace-collect/references/dotnet-monitor.md +97 -0
- package/package/corpus/skills/dotnet-trace-collect/references/dotnet-trace-collect-linux.md +84 -0
- package/package/corpus/skills/dotnet-trace-collect/references/dotnet-trace-collect.md +91 -0
- package/package/corpus/skills/dotnet-trace-collect/references/perfcollect.md +200 -0
- package/package/corpus/skills/dotnet-trace-collect/references/perfview.md +141 -0
- package/package/corpus/skills/dotnet-trace-collect/references/tool-selection.md +160 -0
- package/package/corpus/skills/dump-collect/LICENSE +23 -0
- package/package/corpus/skills/dump-collect/NOTICE +40 -0
- package/package/corpus/skills/dump-collect/SKILL.md +97 -0
- package/package/corpus/skills/dump-collect/references/container-dumps.md +412 -0
- package/package/corpus/skills/dump-collect/references/coreclr-dumps.md +108 -0
- package/package/corpus/skills/dump-collect/references/nativeaot-dumps.md +280 -0
- package/package/corpus/skills/eliminate-redundant-restores/LICENSE +23 -0
- package/package/corpus/skills/eliminate-redundant-restores/NOTICE +19 -0
- package/package/corpus/skills/eliminate-redundant-restores/SKILL.md +112 -0
- package/package/corpus/skills/extension-points/LICENSE +23 -0
- package/package/corpus/skills/extension-points/NOTICE +18 -0
- package/package/corpus/skills/extension-points/SKILL.md +248 -0
- package/package/corpus/skills/filter-syntax/LICENSE +23 -0
- package/package/corpus/skills/filter-syntax/NOTICE +17 -0
- package/package/corpus/skills/filter-syntax/SKILL.md +179 -0
- package/package/corpus/skills/including-generated-files/LICENSE +23 -0
- package/package/corpus/skills/including-generated-files/NOTICE +17 -0
- package/package/corpus/skills/including-generated-files/SKILL.md +139 -0
- package/package/corpus/skills/microbenchmarking/LICENSE +23 -0
- package/package/corpus/skills/microbenchmarking/NOTICE +36 -0
- package/package/corpus/skills/microbenchmarking/SKILL.md +131 -0
- package/package/corpus/skills/microbenchmarking/references/bdn-internals-and-tuning.md +143 -0
- package/package/corpus/skills/microbenchmarking/references/comparison-strategies.md +200 -0
- package/package/corpus/skills/microbenchmarking/references/diagnosers-and-exporters.md +150 -0
- package/package/corpus/skills/microbenchmarking/references/project-setup-and-running.md +189 -0
- package/package/corpus/skills/microbenchmarking/references/writing-benchmarks.md +310 -0
- package/package/corpus/skills/msbuild/LICENSE +23 -0
- package/package/corpus/skills/msbuild/NOTICE +55 -0
- package/package/corpus/skills/msbuild/SKILL.md +117 -0
- package/package/corpus/skills/msbuild/references/antipatterns/additional-antipatterns.md +291 -0
- package/package/corpus/skills/msbuild/references/antipatterns/incremental-build-inputs-outputs.md +57 -0
- package/package/corpus/skills/msbuild/references/antipatterns/private-assets.md +29 -0
- package/package/corpus/skills/msbuild/references/binlog-failure-analysis.md +85 -0
- package/package/corpus/skills/msbuild/references/binlog-generation.md +69 -0
- package/package/corpus/skills/msbuild/references/build-perf-baseline.md +493 -0
- package/package/corpus/skills/msbuild/references/build-perf-diagnostics.md +268 -0
- package/package/corpus/skills/msbuild/references/copy-to-output-directory.md +183 -0
- package/package/corpus/skills/msbuild/references/eval-performance.md +190 -0
- package/package/corpus/skills/msbuild/references/extension-points.md +281 -0
- package/package/corpus/skills/msbuild/references/incremental-build.md +365 -0
- package/package/corpus/skills/msbuild/references/msbuild-antipatterns.md +401 -0
- package/package/corpus/skills/orleans/LICENSE +21 -0
- package/package/corpus/skills/orleans/NOTICE +64 -0
- package/package/corpus/skills/orleans/SKILL.md +140 -0
- package/package/corpus/skills/orleans/references/anti-patterns.md +660 -0
- package/package/corpus/skills/orleans/references/configuration-api.md +933 -0
- package/package/corpus/skills/orleans/references/examples.md +66 -0
- package/package/corpus/skills/orleans/references/grain-api.md +784 -0
- package/package/corpus/skills/orleans/references/grains.md +75 -0
- package/package/corpus/skills/orleans/references/hosting.md +71 -0
- package/package/corpus/skills/orleans/references/implementation.md +591 -0
- package/package/corpus/skills/orleans/references/official-docs-index.md +250 -0
- package/package/corpus/skills/orleans/references/patterns.md +811 -0
- package/package/corpus/skills/orleans/references/persistence-api.md +495 -0
- package/package/corpus/skills/orleans/references/primitive-selection.md +35 -0
- package/package/corpus/skills/orleans/references/scheduling-and-services.md +295 -0
- package/package/corpus/skills/orleans/references/serialization-api.md +299 -0
- package/package/corpus/skills/orleans/references/streaming-api.md +396 -0
- package/package/corpus/skills/orleans/references/testing-patterns.md +210 -0
- package/package/corpus/skills/platform-detection/LICENSE +23 -0
- package/package/corpus/skills/platform-detection/NOTICE +17 -0
- package/package/corpus/skills/platform-detection/SKILL.md +230 -0
- package/package/corpus/skills/platform-detection/references/command-mode.md +27 -0
- package/package/corpus/skills/profiling/LICENSE +21 -0
- package/package/corpus/skills/profiling/NOTICE +50 -0
- package/package/corpus/skills/profiling/SKILL.md +144 -0
- package/package/corpus/skills/profiling/references/commands.md +439 -0
- package/package/corpus/skills/profiling/references/patterns.md +586 -0
- package/package/corpus/skills/profiling/references/profiling.md +190 -0
- package/package/corpus/skills/run-tests/LICENSE +23 -0
- package/package/corpus/skills/run-tests/NOTICE +19 -0
- package/package/corpus/skills/run-tests/SKILL.md +305 -0
- package/package/corpus/skills/target-authoring/LICENSE +23 -0
- package/package/corpus/skills/target-authoring/NOTICE +17 -0
- package/package/corpus/skills/target-authoring/SKILL.md +165 -0
- package/package/corpus/skills/vectorization/LICENSE +23 -0
- package/package/corpus/skills/vectorization/NOTICE +17 -0
- package/package/corpus/skills/vectorization/SKILL.md +189 -0
- package/package/profile-catalog.json +87 -1
- package/package.json +3 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
.NET Trace Collect
|
|
2
|
+
Copyright (c) .NET Foundation and Contributors
|
|
3
|
+
Licensed under the MIT License. See LICENSE.
|
|
4
|
+
|
|
5
|
+
Upstream source: https://github.com/dotnet/skills/blob/a6bf43ab61967c30919334986515163ab24d7635/plugins/dotnet-diag/skills/dotnet-trace-collect/SKILL.md
|
|
6
|
+
|
|
7
|
+
Changes made by Cratis:
|
|
8
|
+
|
|
9
|
+
LICENSE:
|
|
10
|
+
- Copy upstream MIT license and copyright verbatim.
|
|
11
|
+
|
|
12
|
+
SKILL.md:
|
|
13
|
+
- Normalize frontmatter serialization, add MIT license where absent; preserve name and description.
|
|
14
|
+
- Add marked modification/source comment and applicability/Cratis precedence line.
|
|
15
|
+
- Prefix official tool downloads/installs with marked approval/pinned-version guidance and privileged/perfcollect examples with explicit root/container-security approval, where present.
|
|
16
|
+
- Move the complete ### Step 2: Recommend diagnostic tools section verbatim into references/tool-selection.md to fit the body limit; leave a direct pointer.
|
|
17
|
+
- Add direct conditional pointers for all otherwise-indirect reference/script/asset files: references/dotnet-monitor.md, references/dotnet-trace-collect-linux.md, references/dotnet-trace-collect.md, references/perfcollect.md, references/perfview.md.
|
|
18
|
+
- Place approval guards immediately before complete Markdown tables so original rows remain intact.
|
|
19
|
+
- Rewrite the description to the Cratis shape (what it does, Use when, Not for) and drop references to skills that are not part of this corpus.
|
|
20
|
+
|
|
21
|
+
references/dotnet-monitor.md:
|
|
22
|
+
- Quote the dotnet-monitor trace URL containing ampersand.
|
|
23
|
+
- Prefix official tool downloads/installs with marked approval/pinned-version guidance and privileged/perfcollect examples with explicit root/container-security approval, where present.
|
|
24
|
+
|
|
25
|
+
references/dotnet-trace-collect.md:
|
|
26
|
+
- Prefix official tool downloads/installs with marked approval/pinned-version guidance and privileged/perfcollect examples with explicit root/container-security approval, where present.
|
|
27
|
+
|
|
28
|
+
references/perfcollect.md:
|
|
29
|
+
- Prefix official tool downloads/installs with marked approval/pinned-version guidance and privileged/perfcollect examples with explicit root/container-security approval, where present.
|
|
30
|
+
- Add or normalize the top Contents list from existing headings; preserve section content.
|
|
31
|
+
- Place approval guards immediately before complete Markdown tables so original rows remain intact.
|
|
32
|
+
|
|
33
|
+
references/perfview.md:
|
|
34
|
+
- Prefix official tool downloads/installs with marked approval/pinned-version guidance and privileged/perfcollect examples with explicit root/container-security approval, where present.
|
|
35
|
+
- Add or normalize the top Contents list from existing headings; preserve section content.
|
|
36
|
+
- Add marked approval and pinned-version guidance before the official direct-download/source-build fallback.
|
|
37
|
+
|
|
38
|
+
references/tool-selection.md:
|
|
39
|
+
- Adjust the moved reference-relative Markdown links to preserve their targets.
|
|
40
|
+
- Contain the section moved verbatim from SKILL.md, with a reference H1 title.
|
|
41
|
+
- Add or normalize the top Contents list from existing headings; preserve section content.
|
|
42
|
+
|
|
43
|
+
NOTICE: Add this attribution, change list, and any download/execution disclosure.
|
|
44
|
+
|
|
45
|
+
Executes or downloads (instructions retained, not executed by this import):
|
|
46
|
+
- references/tool-selection.md: 3. **`perfcollect`** — inside the container when native stacks are needed on pre-.NET 10 (requires `SYS_ADMIN` / `--privileged`).
|
|
47
|
+
- SKILL.md: 1. **Installation**: How to install the tool if it is not already available (e.g. `dotnet tool install -g dotnet-trace`). **When recommending multiple tools, provide installation and usage instructions for each one** — do not mention a tool without showing how to install and use it.
|
|
48
|
+
- SKILL.md: | `perfcollect` in container without `SYS_ADMIN` | Containers drop `SYS_ADMIN` by default. Run with `--privileged` or add `SYS_ADMIN` capability, or fall back to `dotnet-trace`. |
|
|
49
|
+
- SKILL.md: | Forgetting to install tools in container image | Add `dotnet tool install` to your Dockerfile, or use `dotnet-monitor` as a sidecar to avoid modifying the app image. |
|
|
50
|
+
- references/dotnet-monitor.md: dotnet tool install -g dotnet-monitor
|
|
51
|
+
- references/dotnet-trace-collect.md: dotnet tool install -g dotnet-trace
|
|
52
|
+
- references/dotnet-trace-collect.md: curl -JL https://aka.ms/dotnet-trace/linux-x64 -o dotnet-trace
|
|
53
|
+
- references/dotnet-trace-collect.md: curl -JL https://aka.ms/dotnet-trace/linux-arm64 -o dotnet-trace
|
|
54
|
+
- references/dotnet-trace-collect.md: curl -JL https://aka.ms/dotnet-trace/linux-musl-x64 -o dotnet-trace
|
|
55
|
+
- references/dotnet-trace-collect.md: curl -JL https://aka.ms/dotnet-trace/win-x64 -o dotnet-trace.exe
|
|
56
|
+
- references/perfcollect.md: | Container | Needs `SYS_ADMIN` / `--privileged` |
|
|
57
|
+
- references/perfcollect.md: curl -OL https://aka.ms/perfcollect
|
|
58
|
+
- references/perfcollect.md: sudo ./perfcollect install
|
|
59
|
+
- references/perfcollect.md: docker run --privileged ...
|
|
60
|
+
- references/perfcollect.md: privileged: true
|
|
61
|
+
- references/perfcollect.md: allowPrivilegeEscalation: true
|
|
62
|
+
- references/perfcollect.md: ./perfcollect install
|
|
63
|
+
- references/perfcollect.md: - ❌ In containers, requires `SYS_ADMIN` or `--privileged`
|
|
64
|
+
- references/perfview.md: Download from [https://github.com/microsoft/perfview/releases](https://github.com/microsoft/perfview/releases). PerfView is a standalone `.exe` — no installation required.
|
|
65
|
+
- references/perfview.md: > **PerfView inside containers**: `PerfView.exe` does not run in many slimmed-down Windows container images. To run PerfView inside a container (needed for the merge step in process-isolation, or for direct collection in Hyper-V), build **PerfViewCollect** from [https://github.com/microsoft/perfview](https://github.com/microsoft/perfview) as a self-contained publish, then copy the output binaries into the container.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dotnet-trace-collect
|
|
3
|
+
description: 'Guides capturing diagnostic artifacts to diagnose production .NET performance problems: choosing tools, collecting performance data, and understanding trade-offs across Windows and Linux, .NET Framework and modern .NET, and container and non-container environments. Use when the user needs help choosing a diagnostic tool or collecting performance data for a .NET process. Not for crash dumps (use dump-collect), repository-level profiling workflows (use profiling), or analyzing collected traces.'
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<!-- Modified by Cratis from dotnet's original (MIT): frontmatter, applicability, navigation and the changes listed in NOTICE. Upstream: https://github.com/dotnet/skills (plugins/dotnet-diag/skills/dotnet-trace-collect/SKILL.md; see NOTICE) -->
|
|
8
|
+
|
|
9
|
+
# .NET Trace Collect
|
|
10
|
+
|
|
11
|
+
Cratis rules in `.cratis/ai/rules/` (including `csharp.md`, `specs.csharp.md`, and `orleans.md`) and the `cratis-*` skills win where they differ.
|
|
12
|
+
|
|
13
|
+
This skill helps developers diagnose production performance issues by recommending the right diagnostic tools for their environment, guiding data collection, and suggesting analysis approaches. It does not analyze code for anti-patterns or perform the analysis itself.
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
- A developer needs to investigate a production performance issue (high CPU, memory leak, slow requests, excessive GC, networking errors, etc.)
|
|
18
|
+
- Choosing the right diagnostic tool for a specific runtime, OS, or deployment topology
|
|
19
|
+
- Setting up and running diagnostic tool commands for data collection
|
|
20
|
+
- Understanding trade-offs between available tools (e.g. PerfView vs dotnet-trace)
|
|
21
|
+
- Collecting diagnostics from containerized or Kubernetes workloads
|
|
22
|
+
|
|
23
|
+
## When Not to Use
|
|
24
|
+
|
|
25
|
+
- Reviewing source code for performance anti-patterns (use a code review skill instead)
|
|
26
|
+
- Benchmarking during development (e.g. BenchmarkDotNet setup)
|
|
27
|
+
- Analyzing collected trace or dump files (this skill recommends tools for analysis, but does not perform it)
|
|
28
|
+
|
|
29
|
+
## Inputs
|
|
30
|
+
|
|
31
|
+
| Input | Required | Description |
|
|
32
|
+
|-------|----------|-------------|
|
|
33
|
+
| Symptom | Yes | What the developer is observing (high CPU, memory growth, slow requests, hangs, excessive GC, HTTP 5xx errors, networking timeouts, connection failures, assembly loading failures, etc.) |
|
|
34
|
+
| Runtime | Yes | .NET Framework or modern .NET (and version, especially whether .NET 10+) |
|
|
35
|
+
| OS | Yes | Windows or Linux |
|
|
36
|
+
| Deployment | Yes | Non-container, container, or Kubernetes |
|
|
37
|
+
| Admin privileges | Recommended | Whether the developer has admin/root access on the target machine |
|
|
38
|
+
| Repro characteristics | Recommended | Whether the issue is easy to reproduce or requires a long time to manifest |
|
|
39
|
+
|
|
40
|
+
## Workflow
|
|
41
|
+
|
|
42
|
+
### Step 1: Understand the environment
|
|
43
|
+
|
|
44
|
+
Determine or ask the developer to clarify:
|
|
45
|
+
|
|
46
|
+
1. **Symptom**: What they are observing (high CPU, memory leak, slow requests, hangs, excessive GC, HTTP 5xx errors, networking timeouts, connection failures, assembly loading failures, etc.)
|
|
47
|
+
2. **Runtime**: .NET Framework or modern .NET? If modern .NET, which version? (Especially whether .NET 10 or later.)
|
|
48
|
+
3. **OS**: Windows or Linux?
|
|
49
|
+
4. **Deployment**: Running directly on the host, in a container, or in Kubernetes?
|
|
50
|
+
5. **Admin privileges**: Do they have admin/root access on the target machine or container?
|
|
51
|
+
6. **Repro characteristics**: Does the issue reproduce quickly, or does it take a long time to manifest?
|
|
52
|
+
7. **Workload context**: Determine or ask the user if you are running in the context of the workload (i.e., on the same machine or connected to the same environment where the issue is occurring). If so, you can run diagnostic commands directly on their behalf. If not, provide the commands as guidance for the user to run themselves.
|
|
53
|
+
|
|
54
|
+
Use this information to select the right tool in Step 2.
|
|
55
|
+
|
|
56
|
+
Read references/tool-selection.md when selecting the relevant diagnostic workflow.
|
|
57
|
+
|
|
58
|
+
### Step 3: Guide data collection
|
|
59
|
+
|
|
60
|
+
Provide the specific commands for the recommended tool. Load the appropriate reference file from the [tool reference lookup](references/tool-selection.md#tool-reference-lookup) table for detailed command-line examples.
|
|
61
|
+
|
|
62
|
+
Key guidance to include:
|
|
63
|
+
|
|
64
|
+
> **Cratis:** Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
65
|
+
1. **Installation**: How to install the tool if it is not already available (e.g. `dotnet tool install -g dotnet-trace`). **When recommending multiple tools, provide installation and usage instructions for each one** — do not mention a tool without showing how to install and use it.
|
|
66
|
+
2. **PID discovery (required before any `-p <PID>` command)**: Verify the target process first (for example: `dotnet-trace ps`, `curl <monitor-endpoint>/processes`, or `ps` inside a container). If the app is expected to be PID 1 in a container, still verify before collecting.
|
|
67
|
+
3. **Collection command**: The exact command to run, including relevant providers, output format, and duration.
|
|
68
|
+
4. **Container considerations**:
|
|
69
|
+
- Collecting from **inside** the container: ensure the tool is installed in the image or use `kubectl cp` to copy it in.
|
|
70
|
+
- Collecting from **outside** the container: use `dotnet-monitor` as a sidecar with a shared diagnostic port (Unix domain socket in `/tmp`).
|
|
71
|
+
- Kubernetes: `dotnet-monitor` as a sidecar container, or `kubectl debug` for ephemeral debug containers.
|
|
72
|
+
5. **Long-running repros** (Windows/PerfView): show how to use trigger arguments and circular buffer settings.
|
|
73
|
+
6. **Output location**: Where the collected file will be saved and how to copy it off the target for analysis.
|
|
74
|
+
7. **Artifact handoff checklist**: Include runtime version, OS/kernel, container image tag or build SHA, PID/process name, UTC collection start/end timestamps, exact command used, and final artifact path when handing traces to someone else for analysis.
|
|
75
|
+
|
|
76
|
+
### Step 4: Recommend analysis approach
|
|
77
|
+
|
|
78
|
+
After data is collected, recommend the appropriate tool for analysis. Do **not** perform the analysis — just point the developer to the right tool and documentation.
|
|
79
|
+
|
|
80
|
+
| Collected Data | Analysis Tool | Notes |
|
|
81
|
+
|----------------|---------------|-------|
|
|
82
|
+
| `.nettrace` file | PerfView (Windows), Speedscope (web) | PerfView gives the richest view on Windows |
|
|
83
|
+
| `.etl` / `.etl.zip` file | PerfView | ETW traces from PerfView or perfcollect |
|
|
84
|
+
| `perf.data.nl` from perfcollect | PerfView (Windows) | Copy the file to a Windows machine and open with PerfView |
|
|
85
|
+
|
|
86
|
+
## Validation
|
|
87
|
+
|
|
88
|
+
- [ ] The recommended tool is compatible with the developer's runtime, OS, and deployment topology
|
|
89
|
+
- [ ] The collection command runs without errors
|
|
90
|
+
- [ ] The output file is generated in the expected location
|
|
91
|
+
- [ ] The developer knows which analysis tool to use for the collected data
|
|
92
|
+
|
|
93
|
+
## Common Pitfalls
|
|
94
|
+
|
|
95
|
+
> **Cratis:** Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
96
|
+
> **Cratis:** Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
97
|
+
|
|
98
|
+
| Pitfall | Solution |
|
|
99
|
+
|---------|----------|
|
|
100
|
+
| Using `dotnet-trace` on .NET Framework | `dotnet-trace` only works with modern .NET (.NET Core 3.0+). Use PerfView for .NET Framework. |
|
|
101
|
+
| PerfView without admin privileges | PerfView requires admin for ETW tracing. Fall back to `dotnet-trace` if admin is not available. |
|
|
102
|
+
| `perfcollect` in container without `SYS_ADMIN` | Containers drop `SYS_ADMIN` by default. Run with `--privileged` or add `SYS_ADMIN` capability, or fall back to `dotnet-trace`. |
|
|
103
|
+
| Huge trace files from long repros | On Windows, use PerfView `/StopOn` triggers that fire on the symptom you want to capture (e.g., `/StopOnPerfCounter`, `/StopOnGCEvent`, `/StopOnException`) with `/CircularMB` and `/BufferSizeMB`. **Never trigger on recovery** — the circular buffer continuously overwrites old data, so the interesting behavior may be lost by the time collection stops. |
|
|
104
|
+
| Diagnostic port not accessible in container | Mount `/tmp` as a shared volume between the app container and `dotnet-monitor` sidecar for the diagnostic Unix domain socket. |
|
|
105
|
+
| Forgetting to install tools in container image | Add `dotnet tool install` to your Dockerfile, or use `dotnet-monitor` as a sidecar to avoid modifying the app image. |
|
|
106
|
+
| Exposing `dotnet-monitor` with `--no-auth` in production | Keep auth enabled, bind to localhost, and use `kubectl port-forward` for access. Use `--no-auth` only for short-lived isolated debugging. |
|
|
107
|
+
| Collecting only CPU/thread-time trace for networking issues | CPU and thread-time traces alone do not show HTTP status codes, DNS timing, or connection pool behavior. Add the networking providers (`System.Net.Http`, `System.Net.NameResolution`, `System.Net.Security`, `System.Net.Sockets`) alongside the thread-time trace. |
|
|
108
|
+
| Enabling all networking providers when only one is needed | Each networking provider adds overhead. If the issue is clearly HTTP-level (5xx status codes), `System.Net.Http` alone may be sufficient. Add DNS, TLS, and socket providers when the root cause is unclear. |
|
|
109
|
+
|
|
110
|
+
## Reference navigation
|
|
111
|
+
|
|
112
|
+
- Read references/dotnet-monitor.md when working on dotnet monitor.
|
|
113
|
+
- Read references/dotnet-trace-collect-linux.md when working on dotnet trace collect linux.
|
|
114
|
+
- Read references/dotnet-trace-collect.md when working on dotnet trace collect.
|
|
115
|
+
- Read references/perfcollect.md when working on perfcollect.
|
|
116
|
+
- Read references/perfview.md when working on perfview.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# dotnet-monitor
|
|
2
|
+
|
|
3
|
+
**Purpose**: REST API-based diagnostics collection, designed for container and Kubernetes environments.
|
|
4
|
+
|
|
5
|
+
| Attribute | Value |
|
|
6
|
+
|-----------|-------|
|
|
7
|
+
| OS | Windows, Linux, macOS |
|
|
8
|
+
| Runtime | Modern .NET (.NET Core 3.1+) |
|
|
9
|
+
| .NET Framework | ❌ Not supported |
|
|
10
|
+
| Admin required | No |
|
|
11
|
+
| Container | ✅ Designed for containers/K8s — runs as a sidecar |
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# As a global tool
|
|
17
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
18
|
+
dotnet tool install -g dotnet-monitor
|
|
19
|
+
|
|
20
|
+
# As a container image (for K8s sidecar)
|
|
21
|
+
# mcr.microsoft.com/dotnet/monitor
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Common Commands
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Production-safe default: keep auth enabled (default) and bind to loopback
|
|
28
|
+
dotnet-monitor collect --urls http://127.0.0.1:52323 --metricUrls http://127.0.0.1:52325
|
|
29
|
+
|
|
30
|
+
# Dev-only shortcut in isolated environments (avoid in production)
|
|
31
|
+
dotnet-monitor collect --urls http://127.0.0.1:52323 --no-auth
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Security Guidance (Production)
|
|
35
|
+
|
|
36
|
+
- Do **not** run `dotnet-monitor` with `--no-auth` on production workloads.
|
|
37
|
+
- Bind to localhost (`127.0.0.1`) and access through `kubectl port-forward` (or another local-only tunnel).
|
|
38
|
+
- If remote access is required, keep auth enabled and restrict network exposure to trusted operators.
|
|
39
|
+
|
|
40
|
+
## REST API Endpoints
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Access via local tunnel (recommended in Kubernetes)
|
|
44
|
+
kubectl port-forward pod/<pod-name> 52323:52323
|
|
45
|
+
|
|
46
|
+
# List processes (auth enabled by default)
|
|
47
|
+
curl -H "Authorization: Bearer <monitor-token>" http://localhost:52323/processes
|
|
48
|
+
|
|
49
|
+
# Collect a trace
|
|
50
|
+
curl -H "Authorization: Bearer <monitor-token>" -o trace.nettrace "http://localhost:52323/trace?pid=<PID>&durationSeconds=30"
|
|
51
|
+
|
|
52
|
+
# Collect GC trace
|
|
53
|
+
curl -H "Authorization: Bearer <monitor-token>" -o trace.nettrace "http://localhost:52323/trace?pid=<PID>&profile=gc-verbose&durationSeconds=30"
|
|
54
|
+
|
|
55
|
+
# Collect trace with networking providers (HTTP status codes, DNS, TLS, sockets)
|
|
56
|
+
curl -H "Authorization: Bearer <monitor-token>" -o trace.nettrace "http://localhost:52323/trace?pid=<PID>&durationSeconds=30&providers=System.Net.Http,System.Net.NameResolution,System.Net.Security,System.Net.Sockets"
|
|
57
|
+
|
|
58
|
+
# Get live metrics
|
|
59
|
+
curl -H "Authorization: Bearer <monitor-token>" http://localhost:52323/livemetrics?pid=<PID>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Kubernetes Sidecar Setup
|
|
63
|
+
|
|
64
|
+
```yaml
|
|
65
|
+
# Pod spec with dotnet-monitor as sidecar
|
|
66
|
+
spec:
|
|
67
|
+
containers:
|
|
68
|
+
- name: app
|
|
69
|
+
image: myapp:latest
|
|
70
|
+
volumeMounts:
|
|
71
|
+
- name: diag
|
|
72
|
+
mountPath: /tmp
|
|
73
|
+
- name: monitor
|
|
74
|
+
image: mcr.microsoft.com/dotnet/monitor:latest
|
|
75
|
+
args: ["collect", "--urls", "http://127.0.0.1:52323", "--metricUrls", "http://127.0.0.1:52325"]
|
|
76
|
+
volumeMounts:
|
|
77
|
+
- name: diag
|
|
78
|
+
mountPath: /tmp
|
|
79
|
+
ports:
|
|
80
|
+
- containerPort: 52323
|
|
81
|
+
volumes:
|
|
82
|
+
- name: diag
|
|
83
|
+
emptyDir: {}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The shared `/tmp` volume allows `dotnet-monitor` to access the app's diagnostic Unix domain socket.
|
|
87
|
+
Keep auth enabled (default), and access the API via `kubectl port-forward` rather than exposing a public Service unless you have explicit authentication and network controls in place.
|
|
88
|
+
|
|
89
|
+
## Trade-offs
|
|
90
|
+
|
|
91
|
+
- ✅ Purpose-built for containers and Kubernetes
|
|
92
|
+
- ✅ No tools needed inside the app container
|
|
93
|
+
- ✅ REST API is easy to automate and integrate
|
|
94
|
+
- ❌ Requires sidecar setup and shared volume
|
|
95
|
+
- ❌ Additional resource overhead from sidecar container
|
|
96
|
+
- ❌ Requires authentication setup (API key or `--no-auth` flag)
|
|
97
|
+
- ⚠️ **When running in the workload context** (console access to the container), prefer console-based tools (`dotnet-trace`, `dotnet-trace collect-linux`) to avoid authentication setup. Use `dotnet-monitor` when console access is not available or when it is already deployed.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# dotnet-trace collect-linux (.NET 10+)
|
|
2
|
+
|
|
3
|
+
**Purpose**: Collects diagnostic traces using `perf_events`, a Linux OS technology. Provides native call stacks, kernel events, and machine-wide tracing that standard `dotnet-trace collect` cannot.
|
|
4
|
+
|
|
5
|
+
| Attribute | Value |
|
|
6
|
+
|-----------|-------|
|
|
7
|
+
| OS | Linux only (kernel >= 6.4 with `CONFIG_USER_EVENTS=y`) |
|
|
8
|
+
| Runtime | .NET 10+ only |
|
|
9
|
+
| .NET Framework | ❌ Not supported |
|
|
10
|
+
| Admin required | Yes (root) |
|
|
11
|
+
| Container | Works inside container (requires root) |
|
|
12
|
+
| glibc | >= 2.35 (not supported on Alpine 3.22, CentOS Stream 9, or RHEL 9-based distros) |
|
|
13
|
+
|
|
14
|
+
## Key Differences from `dotnet-trace collect`
|
|
15
|
+
|
|
16
|
+
| Feature | `collect` | `collect-linux` |
|
|
17
|
+
|---------|-----------|-----------------|
|
|
18
|
+
| Trace all processes simultaneously | No | Yes (default — no PID required) |
|
|
19
|
+
| Capture native library and kernel events | No | Yes |
|
|
20
|
+
| Event callstacks include native frames | No | Yes |
|
|
21
|
+
| Requires admin/root | No | Yes |
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Machine-wide trace (all processes, no PID needed)
|
|
27
|
+
sudo dotnet-trace collect-linux
|
|
28
|
+
|
|
29
|
+
# Trace a specific process
|
|
30
|
+
sudo dotnet-trace collect-linux -p <PID>
|
|
31
|
+
|
|
32
|
+
# Trace a process by name
|
|
33
|
+
sudo dotnet-trace collect-linux -n <process-name>
|
|
34
|
+
|
|
35
|
+
# Trace for a specific duration
|
|
36
|
+
sudo dotnet-trace collect-linux --duration 00:00:30
|
|
37
|
+
|
|
38
|
+
# Trace with specific providers
|
|
39
|
+
sudo dotnet-trace collect-linux --providers Microsoft-Windows-DotNETRuntime
|
|
40
|
+
|
|
41
|
+
# Trace with networking providers (HTTP status codes, DNS, TLS, sockets)
|
|
42
|
+
sudo dotnet-trace collect-linux --providers System.Net.Http,System.Net.NameResolution,System.Net.Security,System.Net.Sockets
|
|
43
|
+
|
|
44
|
+
# Trace with networking providers and thread-time profile
|
|
45
|
+
sudo dotnet-trace collect-linux --profile thread-time --providers System.Net.Http,System.Net.NameResolution,System.Net.Security,System.Net.Sockets
|
|
46
|
+
|
|
47
|
+
# Trace with specific profiles
|
|
48
|
+
sudo dotnet-trace collect-linux --profile gc-verbose
|
|
49
|
+
sudo dotnet-trace collect-linux --profile thread-time
|
|
50
|
+
|
|
51
|
+
# Trace with additional Linux perf events
|
|
52
|
+
sudo dotnet-trace collect-linux --perf-events <list-of-perf-events>
|
|
53
|
+
|
|
54
|
+
# Output to a specific file
|
|
55
|
+
sudo dotnet-trace collect-linux -o /tmp/trace.nettrace
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
When `--providers`, `--profile`, `--clrevents`, and `--perf-events` are not specified, `collect-linux` enables these profiles by default: `dotnet-common` (lightweight .NET runtime diagnostics) and `cpu-sampling` (kernel CPU sampling).
|
|
59
|
+
|
|
60
|
+
## Container Usage
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Inside container (machine-wide — captures all processes in the container)
|
|
64
|
+
sudo dotnet-trace collect-linux -o /tmp/trace.nettrace
|
|
65
|
+
|
|
66
|
+
# Inside container (specific process)
|
|
67
|
+
sudo dotnet-trace collect-linux -p 1 -o /tmp/trace.nettrace
|
|
68
|
+
|
|
69
|
+
# Copy trace out
|
|
70
|
+
kubectl cp <pod>:/tmp/trace.nettrace ./trace.nettrace
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Trade-offs
|
|
74
|
+
|
|
75
|
+
- ✅ Machine-wide tracing without specifying a PID
|
|
76
|
+
- ✅ Native (unmanaged) call stacks — essential for diagnosing native interop or runtime issues
|
|
77
|
+
- ✅ Captures kernel events and native library events
|
|
78
|
+
- ✅ Designed for Linux-first workflows
|
|
79
|
+
- ❌ Requires root privileges
|
|
80
|
+
- ❌ Only available on .NET 10 and later
|
|
81
|
+
- ❌ Linux only (kernel >= 6.4)
|
|
82
|
+
- ❌ Requires glibc >= 2.35 (not all supported Linux distros qualify)
|
|
83
|
+
- ❌ Native code symbols must be present on disk next to the binary (or in a standard location) during trace capture for symbol resolution
|
|
84
|
+
- ❌ Unable to trace cross-namespace processes
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# dotnet-trace collect
|
|
2
|
+
|
|
3
|
+
**Purpose**: Collect EventPipe traces for CPU profiling, event analysis, and runtime diagnostics.
|
|
4
|
+
|
|
5
|
+
| Attribute | Value |
|
|
6
|
+
|-----------|-------|
|
|
7
|
+
| OS | Windows, Linux, macOS |
|
|
8
|
+
| Runtime | Modern .NET (.NET Core 3.0+) |
|
|
9
|
+
| .NET Framework | ❌ Not supported |
|
|
10
|
+
| Admin required | No |
|
|
11
|
+
| Container | Works inside container; use `--diagnostic-port` for sidecar |
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# As a .NET global tool (requires .NET SDK)
|
|
17
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
18
|
+
dotnet tool install -g dotnet-trace
|
|
19
|
+
|
|
20
|
+
# Direct download via aka.ms (no SDK required — useful in containers)
|
|
21
|
+
# Linux x64
|
|
22
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
23
|
+
curl -JL https://aka.ms/dotnet-trace/linux-x64 -o dotnet-trace
|
|
24
|
+
chmod +x dotnet-trace
|
|
25
|
+
|
|
26
|
+
# Linux Arm64
|
|
27
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
28
|
+
curl -JL https://aka.ms/dotnet-trace/linux-arm64 -o dotnet-trace
|
|
29
|
+
chmod +x dotnet-trace
|
|
30
|
+
|
|
31
|
+
# Linux musl x64 (Alpine)
|
|
32
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
33
|
+
curl -JL https://aka.ms/dotnet-trace/linux-musl-x64 -o dotnet-trace
|
|
34
|
+
chmod +x dotnet-trace
|
|
35
|
+
|
|
36
|
+
# Windows x64
|
|
37
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
38
|
+
curl -JL https://aka.ms/dotnet-trace/win-x64 -o dotnet-trace.exe
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Common Commands
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# List running .NET processes
|
|
45
|
+
dotnet-trace ps
|
|
46
|
+
|
|
47
|
+
# Collect a trace with the default profiles (dotnet-common and dotnet-sampled-thread-time)
|
|
48
|
+
dotnet-trace collect -p <PID>
|
|
49
|
+
|
|
50
|
+
# Collect with a specific profile
|
|
51
|
+
dotnet-trace collect -p <PID> --profile dotnet-sampled-thread-time
|
|
52
|
+
dotnet-trace collect -p <PID> --profile gc-verbose
|
|
53
|
+
|
|
54
|
+
# Collect with specific providers
|
|
55
|
+
dotnet-trace collect -p <PID> --providers Microsoft-DotNETCore-SampleProfiler,Microsoft-Windows-DotNETRuntime
|
|
56
|
+
|
|
57
|
+
# Collect with networking providers (HTTP status codes, DNS, TLS, sockets)
|
|
58
|
+
dotnet-trace collect -p <PID> --providers System.Net.Http,System.Net.NameResolution,System.Net.Security,System.Net.Sockets
|
|
59
|
+
|
|
60
|
+
# Collect for a fixed duration (time span in hh:mm:ss format)
|
|
61
|
+
dotnet-trace collect -p <PID> --duration 00:00:30
|
|
62
|
+
|
|
63
|
+
# Output in Speedscope format for web-based viewing
|
|
64
|
+
dotnet-trace collect -p <PID> --format speedscope
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Output Formats
|
|
68
|
+
|
|
69
|
+
| Format | Extension | Analysis Tool |
|
|
70
|
+
|--------|-----------|---------------|
|
|
71
|
+
| `nettrace` (default) | `.nettrace` | PerfView, Visual Studio, `dotnet-trace report` |
|
|
72
|
+
| `speedscope` | `.speedscope.json` | Speedscope |
|
|
73
|
+
| `chromium` | `.chromium.json` | Chrome DevTools (chrome://tracing) |
|
|
74
|
+
|
|
75
|
+
## Container Usage
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Inside container (process is typically PID 1)
|
|
79
|
+
dotnet-trace collect -p 1 -o /tmp/trace.nettrace
|
|
80
|
+
|
|
81
|
+
# Copy trace out of container
|
|
82
|
+
kubectl cp <pod>:/tmp/trace.nettrace ./trace.nettrace
|
|
83
|
+
# or
|
|
84
|
+
docker cp <container>:/tmp/trace.nettrace ./trace.nettrace
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Trade-offs
|
|
88
|
+
|
|
89
|
+
- ✅ Cross-platform, no admin needed, lightweight
|
|
90
|
+
- ❌ No native (unmanaged) call stacks — only managed frames
|
|
91
|
+
- ❌ Less system-level detail than ETW (PerfView) or perf (perfcollect)
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# perfcollect
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Installation
|
|
6
|
+
- Common Commands
|
|
7
|
+
- Container Usage
|
|
8
|
+
- Kubernetes Usage
|
|
9
|
+
- Analyzing perfcollect Output
|
|
10
|
+
- Trade-offs
|
|
11
|
+
|
|
12
|
+
**Purpose**: Wrapper script for `perf` and `LTTng` on Linux. Collects CPU profiles with native call stacks.
|
|
13
|
+
|
|
14
|
+
> **Cratis:** Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
15
|
+
|
|
16
|
+
| Attribute | Value |
|
|
17
|
+
|-----------|-------|
|
|
18
|
+
| OS | Linux only |
|
|
19
|
+
| Runtime | Modern .NET (.NET Core 2.0+) |
|
|
20
|
+
| .NET Framework | ❌ Not supported |
|
|
21
|
+
| Admin required | Yes (root) |
|
|
22
|
+
| Container | Needs `SYS_ADMIN` / `--privileged` |
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Download the script
|
|
28
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
29
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
30
|
+
curl -OL https://aka.ms/perfcollect
|
|
31
|
+
chmod +x perfcollect
|
|
32
|
+
|
|
33
|
+
# Install prerequisites (perf, LTTng)
|
|
34
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
35
|
+
sudo ./perfcollect install
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Common Commands
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Collect a trace (runs until Ctrl+C)
|
|
42
|
+
sudo ./perfcollect collect mytrace
|
|
43
|
+
|
|
44
|
+
# Collect for a specific duration
|
|
45
|
+
sudo timeout 30 ./perfcollect collect mytrace
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Container Usage
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Docker — run with privileged mode
|
|
52
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
53
|
+
docker run --privileged ...
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Kubernetes Usage
|
|
57
|
+
|
|
58
|
+
In Kubernetes, use a **diagnostics sidecar container** to avoid modifying your application image. The sidecar runs alongside your app, shares its process namespace and `/tmp` directory, and contains the diagnostic tools.
|
|
59
|
+
|
|
60
|
+
### Step 1: Add a privileged diagnostics sidecar
|
|
61
|
+
|
|
62
|
+
Add a diagnostics container to your deployment and mark it as privileged:
|
|
63
|
+
|
|
64
|
+
```yaml
|
|
65
|
+
- name: diagnostics-container
|
|
66
|
+
image: ubuntu
|
|
67
|
+
command: ["/bin/sh", "-c", "sleep infinity"]
|
|
68
|
+
securityContext:
|
|
69
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
70
|
+
privileged: true
|
|
71
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
72
|
+
allowPrivilegeEscalation: true
|
|
73
|
+
volumeMounts:
|
|
74
|
+
- name: shared-tmp
|
|
75
|
+
mountPath: /tmp
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Step 2: Enable shared process namespace
|
|
79
|
+
|
|
80
|
+
Set `shareProcessNamespace: true` in the pod spec so the sidecar can see and profile the app's processes:
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
spec:
|
|
84
|
+
shareProcessNamespace: true
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Step 3: Share /tmp between containers
|
|
88
|
+
|
|
89
|
+
Create an `emptyDir` volume mounted at `/tmp` in both the app and sidecar containers. This is needed for perf map files (`perf-$pid.map`), perfcollect logs, and other profiling artifacts:
|
|
90
|
+
|
|
91
|
+
```yaml
|
|
92
|
+
volumes:
|
|
93
|
+
- name: shared-tmp
|
|
94
|
+
emptyDir: {}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Mount it in both containers:
|
|
98
|
+
|
|
99
|
+
```yaml
|
|
100
|
+
volumeMounts:
|
|
101
|
+
- name: shared-tmp
|
|
102
|
+
mountPath: /tmp
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Step 4: Set environment variables in the app container
|
|
106
|
+
|
|
107
|
+
Enable perf map generation and LTTng event logging in the application container:
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
env:
|
|
111
|
+
- name: COMPlus_PerfMapEnabled
|
|
112
|
+
value: "1"
|
|
113
|
+
- name: COMPlus_EnableEventLog
|
|
114
|
+
value: "1"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Step 5: Collect the trace
|
|
118
|
+
|
|
119
|
+
Connect to the cluster node, exec into the diagnostics sidecar, install perfcollect, and capture:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Exec into the diagnostics sidecar
|
|
123
|
+
kubectl exec -it <pod-name> -c diagnostics-container -- /bin/bash
|
|
124
|
+
|
|
125
|
+
# Inside the sidecar: install perfcollect
|
|
126
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
127
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
128
|
+
curl -OL https://aka.ms/perfcollect
|
|
129
|
+
chmod +x perfcollect
|
|
130
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
131
|
+
./perfcollect install
|
|
132
|
+
|
|
133
|
+
# Capture a trace
|
|
134
|
+
./perfcollect collect mytrace
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
This produces `mytrace.trace.zip`, which can be copied out and analyzed.
|
|
138
|
+
|
|
139
|
+
### End-to-end Kubernetes deployment example
|
|
140
|
+
|
|
141
|
+
```yaml
|
|
142
|
+
apiVersion: apps/v1
|
|
143
|
+
kind: Deployment
|
|
144
|
+
metadata:
|
|
145
|
+
name: sample
|
|
146
|
+
spec:
|
|
147
|
+
replicas: 1
|
|
148
|
+
selector:
|
|
149
|
+
matchLabels:
|
|
150
|
+
app: sample
|
|
151
|
+
template:
|
|
152
|
+
metadata:
|
|
153
|
+
labels:
|
|
154
|
+
app: sample
|
|
155
|
+
spec:
|
|
156
|
+
shareProcessNamespace: true
|
|
157
|
+
volumes:
|
|
158
|
+
- name: shared-tmp
|
|
159
|
+
emptyDir: {}
|
|
160
|
+
containers:
|
|
161
|
+
- name: sample-app
|
|
162
|
+
image: myapp:latest
|
|
163
|
+
ports:
|
|
164
|
+
- containerPort: 80
|
|
165
|
+
env:
|
|
166
|
+
- name: COMPlus_PerfMapEnabled
|
|
167
|
+
value: "1"
|
|
168
|
+
- name: COMPlus_EnableEventLog
|
|
169
|
+
value: "1"
|
|
170
|
+
volumeMounts:
|
|
171
|
+
- name: shared-tmp
|
|
172
|
+
mountPath: /tmp
|
|
173
|
+
- name: diagnostics-container
|
|
174
|
+
image: ubuntu
|
|
175
|
+
command: ["/bin/sh", "-c", "sleep infinity"]
|
|
176
|
+
securityContext:
|
|
177
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
178
|
+
privileged: true
|
|
179
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
180
|
+
allowPrivilegeEscalation: true
|
|
181
|
+
volumeMounts:
|
|
182
|
+
- name: shared-tmp
|
|
183
|
+
mountPath: /tmp
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Analyzing perfcollect Output
|
|
187
|
+
|
|
188
|
+
The output is a `*.trace.zip` file containing `perf.data.nl`. To analyze:
|
|
189
|
+
|
|
190
|
+
1. Copy the `.trace.zip` to a Windows machine
|
|
191
|
+
2. Open with PerfView — it can read perfcollect output and display flame graphs
|
|
192
|
+
|
|
193
|
+
## Trade-offs
|
|
194
|
+
|
|
195
|
+
- ✅ Captures native (unmanaged) call stacks — essential for diagnosing native interop or runtime issues
|
|
196
|
+
- ✅ Uses kernel-level `perf` for accurate CPU profiling
|
|
197
|
+
- ❌ Requires root/admin privileges
|
|
198
|
+
- ❌ Linux only
|
|
199
|
+
> **Cratis:** Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
200
|
+
- ❌ In containers, requires `SYS_ADMIN` or `--privileged`
|