Skip to content

Commit

Permalink
[PROF-10235] Add new metadata fields to elf symbol upload (#49)
Browse files Browse the repository at this point in the history
Add symbol_source,origin,origin_version and filename.
Remove platform since it's not used on backend side.
  • Loading branch information
nsavoire authored Aug 9, 2024
1 parent e19abfc commit 63744cd
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions symbolication/datadog_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"net/url"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"time"
Expand Down Expand Up @@ -147,14 +148,17 @@ func (d *DatadogUploader) HandleExecutable(elfRef *pfelf.Reference, fileID libpf
}

type executableMetadata struct {
Arch string `json:"arch"`
GNUBuildID string `json:"gnu_build_id"`
GoBuildID string `json:"go_build_id"`
FileHash string `json:"file_hash"`
Platform string `json:"platform"`
Type string `json:"type"`

fileName string
Arch string `json:"arch"`
GNUBuildID string `json:"gnu_build_id"`
GoBuildID string `json:"go_build_id"`
FileHash string `json:"file_hash"`
Type string `json:"type"`
SymbolSource string `json:"symbol_source"`
Origin string `json:"origin"`
OriginVersion string `json:"origin_version"`
FileName string `json:"filename"`

filePath string
}

func newExecutableMetadata(fileName string, elf *pfelf.File,
Expand All @@ -177,21 +181,25 @@ func newExecutableMetadata(fileName string, elf *pfelf.File,
}

return &executableMetadata{
Arch: runtime.GOARCH,
GNUBuildID: buildID,
GoBuildID: goBuildID,
FileHash: fileID.StringNoQuotes(),
Platform: "elf",
Type: "elf_symbol_file",

fileName: fileName,
Arch: runtime.GOARCH,
GNUBuildID: buildID,
GoBuildID: goBuildID,
FileHash: fileID.StringNoQuotes(),
Type: "elf_symbol_file",
Origin: "otel-profiling-agent",
OriginVersion: strings.TrimLeft(vc.Version(), "v"),
SymbolSource: "debug_info",
FileName: filepath.Base(fileName),
filePath: fileName,
}, nil
}

func (e *executableMetadata) String() string {
return fmt.Sprintf(
"%s, arch=%s, gnu_build_id=%s, go_build_id=%s, file_hash=%s, platform=%s, type=%s",
e.fileName, e.Arch, e.GNUBuildID, e.GoBuildID, e.FileHash, e.Platform, e.Type,
"%s, filename=%s, arch=%s, gnu_build_id=%s, go_build_id=%s, file_hash=%s, type=%s"+
", symbol_source=%s, origin=%s, origin_version=%s",
e.filePath, e.FileName, e.Arch, e.GNUBuildID, e.GoBuildID, e.FileHash, e.Type,
e.SymbolSource, e.Origin, e.OriginVersion,
)
}

Expand Down

0 comments on commit 63744cd

Please sign in to comment.