Skip to content

Commit

Permalink
fix: rename metric interface
Browse files Browse the repository at this point in the history
  • Loading branch information
vsukhin committed Mar 26, 2024
1 parent 7710679 commit f0853ec
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions internal/app/api/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ type Metrics struct {
TestWorkflowTemplateDeletes *prometheus.CounterVec
}

func (m Metrics) IncExecuteTest(execution testkube.Execution, dashboardURI string) {
func (m Metrics) IncAndObserveExecuteTest(execution testkube.Execution, dashboardURI string) {
status := ""
if execution.ExecutionResult != nil && execution.ExecutionResult.Status != nil {
status = string(*execution.ExecutionResult.Status)
Expand Down Expand Up @@ -188,7 +188,7 @@ func (m Metrics) IncExecuteTest(execution testkube.Execution, dashboardURI strin
}).Observe(float64(execution.DurationMs))
}

func (m Metrics) IncExecuteTestSuite(execution testkube.TestSuiteExecution, dashboardURI string) {
func (m Metrics) IncAndObserveExecuteTestSuite(execution testkube.TestSuiteExecution, dashboardURI string) {
name := ""
status := ""
if execution.TestSuite != nil {
Expand Down
10 changes: 5 additions & 5 deletions pkg/executor/client/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func NewJobExecutor(
images executor.Images,
templates executor.Templates,
serviceAccountNames map[string]string,
metrics ExecutionCounter,
metrics ExecutionMetric,
emiter *event.Emitter,
configMap config.Repository,
testsClient testsv3.Interface,
Expand Down Expand Up @@ -126,8 +126,8 @@ func NewJobExecutor(
}, nil
}

type ExecutionCounter interface {
IncExecuteTest(execution testkube.Execution, dashboardURI string)
type ExecutionMetric interface {
IncAndObserveExecuteTest(execution testkube.Execution, dashboardURI string)
}

// JobExecutor is container for managing job executor dependencies
Expand All @@ -139,7 +139,7 @@ type JobExecutor struct {
images executor.Images
templates executor.Templates
serviceAccountNames map[string]string
metrics ExecutionCounter
metrics ExecutionMetric
Emitter *event.Emitter
configMap config.Repository
testsClient testsv3.Interface
Expand Down Expand Up @@ -536,7 +536,7 @@ func (c *JobExecutor) stopExecution(ctx context.Context, l *zap.SugaredLogger, e
}
}

c.metrics.IncExecuteTest(*execution, c.dashboardURI)
c.metrics.IncAndObserveExecuteTest(*execution, c.dashboardURI)
c.Emitter.Notify(eventToSend)

telemetryEnabled, err := c.configMap.GetTelemetryEnabled(ctx)
Expand Down
10 changes: 5 additions & 5 deletions pkg/executor/containerexecutor/containerexecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func NewContainerExecutor(
templates executor.Templates,
imageInspector imageinspector.Inspector,
serviceAccountNames map[string]string,
metrics ExecutionCounter,
metrics ExecutionMetric,
emiter EventEmitter,
configMap config.Repository,
executorsClient executorsclientv1.Interface,
Expand Down Expand Up @@ -115,8 +115,8 @@ func NewContainerExecutor(
}, nil
}

type ExecutionCounter interface {
IncExecuteTest(execution testkube.Execution, dashboardURI string)
type ExecutionMetric interface {
IncAndObserveExecuteTest(execution testkube.Execution, dashboardURI string)
}

// ContainerExecutor is container for managing job executor dependencies
Expand All @@ -127,7 +127,7 @@ type ContainerExecutor struct {
images executor.Images
templates executor.Templates
imageInspector imageinspector.Inspector
metrics ExecutionCounter
metrics ExecutionMetric
emitter EventEmitter
configMap config.Repository
serviceAccountNames map[string]string
Expand Down Expand Up @@ -547,7 +547,7 @@ func (c *ContainerExecutor) stopExecution(ctx context.Context,

// metrics increase
execution.ExecutionResult = result
c.metrics.IncExecuteTest(*execution, c.dashboardURI)
c.metrics.IncAndObserveExecuteTest(*execution, c.dashboardURI)

test, err := c.testsClient.Get(execution.TestName)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/executor/containerexecutor/containerexecutor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestExecuteAsync(t *testing.T) {
clientSet: getFakeClient("1"),
log: logger(),
repository: FakeResultRepository{},
metrics: FakeMetricCounter{},
metrics: FakeExecutionMetric{},
emitter: FakeEmitter{},
configMap: FakeConfigRepository{},
testsClient: FakeTestsClient{},
Expand All @@ -60,7 +60,7 @@ func TestExecuteSync(t *testing.T) {
clientSet: getFakeClient("1"),
log: logger(),
repository: FakeResultRepository{},
metrics: FakeMetricCounter{},
metrics: FakeExecutionMetric{},
emitter: FakeEmitter{},
configMap: FakeConfigRepository{},
testsClient: FakeTestsClient{},
Expand Down Expand Up @@ -371,10 +371,10 @@ func getFakeClient(executionID string) *fake.Clientset {
return fakeClient
}

type FakeMetricCounter struct {
type FakeExecutionMetric struct {
}

func (FakeMetricCounter) IncExecuteTest(execution testkube.Execution, dashboardURI string) {
func (FakeExecutionMetric) IncAndObserveExecuteTest(execution testkube.Execution, dashboardURI string) {
}

type FakeEmitter struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/testsuite_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (s *Scheduler) runSteps(ctx context.Context, wg *sync.WaitGroup, testsuiteE
s.events.Notify(testkube.NewEventEndTestSuiteSuccess(testsuiteExecution))
}

s.metrics.IncExecuteTestSuite(*testsuiteExecution, s.dashboardURI)
s.metrics.IncAndObserveExecuteTestSuite(*testsuiteExecution, s.dashboardURI)

err = s.testsuiteResults.Update(ctx, *testsuiteExecution)
if err != nil {
Expand Down

0 comments on commit f0853ec

Please sign in to comment.