Skip to content

Commit

Permalink
fixing the nesting of tracing (#2781)
Browse files Browse the repository at this point in the history
* fixing the nesting of tracing

Signed-off-by: ntishchauhan0022 <nitishchauhan0022@gmail.com>
---------

Signed-off-by: ntishchauhan0022 <nitishchauhan0022@gmail.com>
  • Loading branch information
nitishchauhan0022 committed Aug 31, 2023
1 parent 32c1f91 commit 8fbff53
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/porter/main.go
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)

var includeDocsCommand = false
Expand Down Expand Up @@ -188,7 +189,15 @@ Try our QuickStart https://getporter.org/quickstart to learn how to use Porter.
// Reload configuration with the now parsed cli flags
p.DataLoader = cli.LoadHierarchicalConfig(cmd)
ctx, err := p.Connect(cmd.Context())
cmd.SetContext(ctx)

// Extract the parent span from the main command
parentSpan := trace.SpanFromContext(cmd.Context())

// Create a context with the main command's span
ctxWithRootCmdSpan := trace.ContextWithSpan(ctx, parentSpan)

// Set the new context to the command
cmd.SetContext(ctxWithRootCmdSpan)
return err
},
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down

0 comments on commit 8fbff53

Please sign in to comment.