Skip to main content

Upload Source

In order to be able to use the source view feature of Polar Signals Cloud, an archive that includes the source code needs to be uploaded for each Build ID of a binary.

We recommend doing the following in a CI/CD pipeline.

Source View

Note: At the moment this only works for compiled binaries, not for just-in-time compiled or interpreted code.

Prerequisites

Install parca-debuginfo

Download it:

curl -sL https://github.com/parca-dev/parca-debuginfo/releases/download/v0.11.0/parca-debuginfo_0.11.0_`uname -s`_`uname -m`.tar.gz > parca-debuginfo_0.11.0_`uname -s`_`uname -m`.tar.gz

Verify the checksum:

curl -sL https://github.com/parca-dev/parca-debuginfo/releases/download/v0.11.0/checksums.txt | shasum --ignore-missing -a 256 --check

And unpack it:

tar -xzf parca-debuginfo_0.11.0_`uname -s`_`uname -m`.tar.gz parca-debuginfo

If you want to move the CLI to a path in your `$PATH` you can move the binary (adjust to your preferred location):

mv parca-debuginfo /usr/local/bin/parca-debuginfo

Note: For the purpose of demonstration we'll be using this example repository with the Go compiler. You can use the pre-built binary checked into the repository, or build it with: GOOS=linux GOARCH=amd64 go build main.go.

Build & Upload Source Archives

First, we need to build the source archive. The parca-debuginfo command reads the files referenced in the debuginfo of the given binary and produces an archive with all the files referenced.

parca-debuginfo source ./main

Now we're ready to upload it, also using parca-debuginfo.

parca-debuginfo upload 
--store-address=grpc.polarsignals.com:443
--bearer-token=<your token>
--build-id="$(parca-debuginfo buildid ./main)"
--type=sources
source.tar.zstd

Let's look at each of those flags:

  • --store-address=grpc.polarsignals.com:443: This is the Polar Signals Cloud endpoint that accepts the upload request.
  • --bearer-token=<your token>: This is the authentication token (see here how to obtain it).
  • --build-id="$(parca-debuginfo buildid ./main)": We need to associate the source code with the binary, that is done using the binary's Build ID. The parca-debuginfo utility can read the Build ID, which is what we're doing here.
  • --type=sources: The parca-debuginfo tool can upload debuginfo, executables and source code. In this case we're specifying that we're uploading source code.
  • source.tar.zstd is the file we previously generated above.

And you're done! Now when looking at profiling data of that Build ID, you'll be able to open the source view and see profiling data inlined with your code. 🎉