Skip to content

feat(vcs): add .NET source finder - #6092

Open
ankit373 wants to merge 2 commits into
grafana:mainfrom
ankit373:feat/dotnet-source-finder
Open

ankit373 wants to merge 2 commits into
grafana:mainfrom
ankit373:feat/dotnet-source-finder

Conversation

@ankit373

@ankit373 ankit373 commented Nov 11, 2026 •

Copy link
Copy Markdown

part of #6058

this adds a source finder for .net. real file paths only show up once grafana/pyroscope-dotnet#484 lands, so this is the pyroscope side, ready for when it does.

what changed:

  • new language: dotnet value for .pyroscope.yaml mappings.
  • new find_dotnet.go. it handles .cs, .fs and .vb files. it strips the matched path prefix from the build-time pdb path (for example /src/src/Web/Controllers/OrderController.cs with prefix /src/src) and fetches the rest from the mapped source. if no mapping matches, it tries the path relative to the repo, same as javascript.
  • today the profiler sends the assembly name (for example MyApp.Web) as the filename. a filename without a .net source extension means there is no source, so the finder returns not found and does not fetch anything.
  • find.go sends language: dotnet mappings and .cs/.fs/.vb files to the new finder.
  • windows pdb paths (C:\build\shop\Program.cs) are turned into forward slashes before mapping lookup, so write windows prefixes as C:/build/shop.
  • paths from deterministic builds start with /_/ (the repo root). the relative fallback strips it.
  • docs: dotnet added to the list of language values.

lines: the profiler only sends Function.start_line, Line.line stays 0. the finder only returns file content, so nothing here depends on line numbers. opening at start_line is up to the view.

example mapping:

source_code:
  mappings:
    - path:
        - prefix: /src/src
      language: dotnet
      source:
        local:
          path: src

testing

  • CGO_ENABLED=0 go test ./pkg/frontend/vcs/... passes.
  • new table cases in find_test.go: pdb path with a prefix mapping for .cs, .fs and .vb, relative path, assembly name with a mapping, and an absolute path with no mapping.
  • find_dotnet_test.go checks that assembly names never call the vcs client.
  • sdk-pdb-path and pathmap-root use paths captured from pyroscope-dotnet with debug info on. windows-pdb-path, pathmap-root and pathmap-root-windows fail without the fix.
  • the mapped cases fail on main, since dotnet is not a valid language there.
  • golangci-lint run (v2.2.2, as in the makefile) on pkg/frontend/vcs/...: 0 issues.

Resolve .cs, .fs and .vb files for .NET profiles. Build-time PDB
paths are mapped with .pyroscope.yaml path prefixes (language: dotnet),
with a repository-relative fallback. Filenames without a source
extension are assembly names and are reported as not found without
fetching anything.

Part of grafana#6058.

Signed-off-by: Ankit Jha <jhaankit373@gmail.com>
@ankit373
ankit373 requested review from a team, bryanhuhta and marcsanmi as code owners November 11, 2026 19:24
@jake-kramer

Copy link
Copy Markdown
Contributor

Thanks for your contribution @ankit373. I don't feel comfortable merging this until we're able to test end-to-end with the .NET SDK. I'm not confident in some of the logic: I would imagine we would say backslashes (not forward slashes) in the paths, for example.

A pdb built on Windows stores paths like C:\build\shop\Program.cs, and a
deterministic build roots them at /_/. Turn backslashes into forward
slashes before mapping lookup, and strip /_/ in the relative fallback.

Tests use paths captured from pyroscope-dotnet with debug info on.

Signed-off-by: Ankit Jha <jhaankit373@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants