Core

/app/lib/telemetry/process.go (792 B)

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package telemetry

import (
"context"
"io"

"{{{ .Package }}}/app/util"
)

func RunProcess(ctx context.Context, cmd string, path string, in io.Reader, out io.Writer, er io.Writer, logger util.Logger) (int, error) {
exec, _ := util.StringSplit(cmd, ' ', true)
_, span, _ := StartSpan(ctx, "process:"+exec, logger)
defer span.Complete()
span.Attribute("cmd", cmd)
span.Attribute("path", path)
return util.RunProcess(cmd, path, in, out, er)
}

func RunProcessSimple(ctx context.Context, cmd string, path string, logger util.Logger) (int, string, error) {
exec, _ := util.StringSplit(cmd, ' ', true)
_, span, _ := StartSpan(ctx, "process-simple:"+exec, logger)
defer span.Complete()
span.Attribute("cmd", cmd)
span.Attribute("path", path)
return util.RunProcessSimple(cmd, path)
}