Skip to content

Commit

Permalink
Merge pull request #432 from overmindtech/tracing
Browse files Browse the repository at this point in the history
Force authentication info into the root trace if available
  • Loading branch information
DavidS-ovm authored Jun 21, 2024
2 parents 5a88b40 + 04e2c14 commit 6373b69
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
14 changes: 7 additions & 7 deletions cmd/tea_ensuretoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"golang.org/x/oauth2"
)

Expand Down Expand Up @@ -486,12 +485,13 @@ func getOauthToken(ctx context.Context, oi OvermindInstance, requiredScopes []st
os.Exit(1)
}

span := trace.SpanFromContext(ctx)
span.SetAttributes(
attribute.Bool("ovm.cli.authenticated", true),
attribute.String("ovm.cli.accountName", customClaims.AccountName),
attribute.String("ovm.cli.userId", out.Subject),
)
if cmdSpan != nil {
cmdSpan.SetAttributes(
attribute.Bool("ovm.cli.authenticated", true),
attribute.String("ovm.cli.accountName", customClaims.AccountName),
attribute.String("ovm.cli.userId", out.Subject),
)
}

// Save the token locally
if home, err := os.UserHomeDir(); err == nil {
Expand Down
13 changes: 7 additions & 6 deletions cmd/tea_terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,13 @@ func (m *cmdModel) tokenChecks(token *oauth2.Token) tea.Cmd {
return fatalError{err: fmt.Errorf("received unparsable token: %w", err)}
}

span := trace.SpanFromContext(m.ctx)
span.SetAttributes(
attribute.Bool("ovm.cli.authenticated", true),
attribute.String("ovm.cli.accountName", customClaims.AccountName),
attribute.String("ovm.cli.userId", out.Subject),
)
if cmdSpan != nil {
cmdSpan.SetAttributes(
attribute.Bool("ovm.cli.authenticated", true),
attribute.String("ovm.cli.accountName", customClaims.AccountName),
attribute.String("ovm.cli.userId", out.Subject),
)
}

return loadSourcesConfigMsg{
ctx: m.ctx,
Expand Down

0 comments on commit 6373b69

Please sign in to comment.