Skip to content

Commit

Permalink
fixbug: Update commandName in RunAndEmitStats (runatlantis#3437)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertorm95 authored and ijames-gc committed Feb 13, 2024
1 parent 7f67170 commit 9d23875
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions server/events/instrumented_project_command_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,31 @@ func NewInstrumentedProjectCommandRunner(scope tally.Scope, projectCommandRunner
}

func (p *InstrumentedProjectCommandRunner) Plan(ctx command.ProjectContext) command.ProjectResult {
return RunAndEmitStats("plan", ctx, p.projectCommandRunner.Plan, p.scope)
return RunAndEmitStats(ctx, p.projectCommandRunner.Plan, p.scope)
}

func (p *InstrumentedProjectCommandRunner) PolicyCheck(ctx command.ProjectContext) command.ProjectResult {
return RunAndEmitStats("policy check", ctx, p.projectCommandRunner.PolicyCheck, p.scope)
return RunAndEmitStats(ctx, p.projectCommandRunner.PolicyCheck, p.scope)
}

func (p *InstrumentedProjectCommandRunner) Apply(ctx command.ProjectContext) command.ProjectResult {
return RunAndEmitStats("apply", ctx, p.projectCommandRunner.Apply, p.scope)
return RunAndEmitStats(ctx, p.projectCommandRunner.Apply, p.scope)
}

func (p *InstrumentedProjectCommandRunner) ApprovePolicies(ctx command.ProjectContext) command.ProjectResult {
return RunAndEmitStats("approve policies", ctx, p.projectCommandRunner.ApprovePolicies, p.scope)
return RunAndEmitStats(ctx, p.projectCommandRunner.ApprovePolicies, p.scope)
}

func (p *InstrumentedProjectCommandRunner) Import(ctx command.ProjectContext) command.ProjectResult {
return RunAndEmitStats("import", ctx, p.projectCommandRunner.Import, p.scope)
return RunAndEmitStats(ctx, p.projectCommandRunner.Import, p.scope)
}

func (p *InstrumentedProjectCommandRunner) StateRm(ctx command.ProjectContext) command.ProjectResult {
return RunAndEmitStats("state rm", ctx, p.projectCommandRunner.StateRm, p.scope)
return RunAndEmitStats(ctx, p.projectCommandRunner.StateRm, p.scope)
}

func RunAndEmitStats(commandName string, ctx command.ProjectContext, execute func(ctx command.ProjectContext) command.ProjectResult, scope tally.Scope) command.ProjectResult {
func RunAndEmitStats(ctx command.ProjectContext, execute func(ctx command.ProjectContext) command.ProjectResult, scope tally.Scope) command.ProjectResult {
commandName := ctx.CommandName.String()
// ensures we are differentiating between project level command and overall command
scope = ctx.SetProjectScopeTags(scope).SubScope(commandName)
logger := ctx.Log
Expand Down

0 comments on commit 9d23875

Please sign in to comment.