Skip to content

Commit

Permalink
fix exec --traceparent-ignore-env to do what it says on the tin (#85)
Browse files Browse the repository at this point in the history
@edw-eqix was showing me some code and we noticed this bug, so here's a
PR.

Signed-off-by: Amy Tobey <atobey@equinix.com>
  • Loading branch information
Amy Tobey authored Sep 20, 2021
1 parent 79798b7 commit bbe3e8a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ func doExec(cmd *cobra.Command, args []string) {

// pass the existing env but add the latest TRACEPARENT carrier so e.g.
// otel-cli exec 'otel-cli exec sleep 1' will relate the spans automatically
child.Env = os.Environ()
child.Env = []string{}

// grab everything BUT the TRACEPARENT envvar
for _, env := range os.Environ() {
if !strings.HasPrefix(env, "TRACEPARENT=") {
child.Env = append(child.Env, env)
}
}

if !config.TraceparentIgnoreEnv {
child.Env = append(child.Env, fmt.Sprintf("TRACEPARENT=%s", getTraceparent(ctx)))
}
Expand Down

0 comments on commit bbe3e8a

Please sign in to comment.