summaryrefslogtreecommitdiff
path: root/internal/flamegraph/nativesvg.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-24 21:15:20 +0200
committerPaul Buetow <paul@buetow.org>2026-02-24 21:15:20 +0200
commit93d587a6f5ae453907de3d5556866b60bac405cb (patch)
treee177a5758b486e75fc66552fb0874b95bb145726 /internal/flamegraph/nativesvg.go
parent8361fd22d45e4fbf6b24309aaa1b6d49d9010759 (diff)
flamegraph: improve interactive zoom and serve svg over embedded http
Diffstat (limited to 'internal/flamegraph/nativesvg.go')
-rw-r--r--internal/flamegraph/nativesvg.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/internal/flamegraph/nativesvg.go b/internal/flamegraph/nativesvg.go
index 2c76a7d..de0364b 100644
--- a/internal/flamegraph/nativesvg.go
+++ b/internal/flamegraph/nativesvg.go
@@ -23,7 +23,7 @@ func NewNativeSVG(fields []string, countField string) NativeSVG {
}
}
-func (n NativeSVG) WriteSVGFromFile(iorDataFile string) error {
+func (n NativeSVG) WriteSVGFromFile(iorDataFile string) (string, error) {
outFile := fmt.Sprintf("%s.%s-by-%s.svg",
strings.TrimSuffix(iorDataFile, ".ior.zst"),
strings.Join(n.fields, ":"),
@@ -32,16 +32,19 @@ func (n NativeSVG) WriteSVGFromFile(iorDataFile string) error {
iod, err := newIorDataFromFile(iorDataFile)
if err != nil {
- return fmt.Errorf("read ior data: %w", err)
+ return outFile, fmt.Errorf("read ior data: %w", err)
}
fd, err := os.Create(outFile)
if err != nil {
- return fmt.Errorf("create output %s: %w", outFile, err)
+ return outFile, fmt.Errorf("create output %s: %w", outFile, err)
}
defer fd.Close()
- return n.WriteSVGFromIter(iod.iter(), fd)
+ if err := n.WriteSVGFromIter(iod.iter(), fd); err != nil {
+ return outFile, err
+ }
+ return outFile, nil
}
func (n NativeSVG) WriteSVGFromIter(records iter.Seq[IterRecord], w io.Writer) error {