Skip to content

Commit

Permalink
adds doc comments to metrics methods
Browse files Browse the repository at this point in the history
  • Loading branch information
hrishin committed Oct 16, 2019
1 parent 9c1cea6 commit 24afa9b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 8 additions & 0 deletions pkg/reconciler/pipelinerun/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type Recorder struct {
status tag.Key
}


// NewRecorder creates a new metrics recorder instance
// to log the PipelineRun related metrics
func NewRecorder() (*Recorder, error) {
r := &Recorder{
initialized: true,
Expand Down Expand Up @@ -98,6 +101,9 @@ func NewRecorder() (*Recorder, error) {
return r, nil
}

// DurationAndCount logs the duration of PipelineRun execution and
// count for number of PipelineRuns succeed or failed
// returns an error if its failed to log the metrics
func (r *Recorder) DurationAndCount(pr *v1alpha1.PipelineRun) error {
if !r.initialized {
return fmt.Errorf("ignoring the metrics recording for %s , failed to initialize the metrics recorder", pr.Name)
Expand Down Expand Up @@ -131,6 +137,8 @@ func (r *Recorder) DurationAndCount(pr *v1alpha1.PipelineRun) error {
return nil
}

// RunningPipelineRuns logs the number of PipelineRuns running right now
// returns an error if its failed to log the metrics
func (r *Recorder) RunningPipelineRuns(lister listers.PipelineRunLister) error {
if !r.initialized {
return errors.New("ignoring the metrics recording, failed to initialize the metrics recorder")
Expand Down
13 changes: 9 additions & 4 deletions pkg/reconciler/taskrun/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ type Recorder struct {
pod tag.Key
}

//NewRecorder creates a new instance of metrics recorder to
//to log the TaskRun related metrics
// NewRecorder creates a new metrics recorder instance
// to log the TaskRun related metrics
func NewRecorder() (*Recorder, error) {
r := &Recorder{
initialized: true,
Expand Down Expand Up @@ -144,8 +144,9 @@ func NewRecorder() (*Recorder, error) {
return r, nil
}

//DurationAndCount logs the duration of TaskRun execution and
//count for number of TaskRuns succeed or failed
// DurationAndCount logs the duration of TaskRun execution and
// count for number of TaskRuns succeed or failed
// returns an error if its failed to log the metrics
func (r *Recorder) DurationAndCount(tr *v1alpha1.TaskRun) error {
if !r.initialized {
return fmt.Errorf("ignoring the metrics recording for %s , failed to initialize the metrics recorder", tr.Name)
Expand Down Expand Up @@ -203,6 +204,8 @@ func (r *Recorder) DurationAndCount(tr *v1alpha1.TaskRun) error {
return nil
}

// RunningTaskRuns logs the number of TaskRuns running right now
// returns an error if its failed to log the metrics
func (r *Recorder) RunningTaskRuns(lister listers.TaskRunLister) error {
if !r.initialized {
return errors.New("ignoring the metrics recording, failed to initialize the metrics recorder")
Expand Down Expand Up @@ -231,6 +234,8 @@ func (r *Recorder) RunningTaskRuns(lister listers.TaskRunLister) error {
return nil
}

// RecordPodLatency logs the duration required to schedule the pod for TaskRun
// returns an error if its failed to log the metrics
func (r *Recorder) RecordPodLatency(pod *corev1.Pod, tr *v1alpha1.TaskRun) error {
if !r.initialized {
return errors.New("ignoring the metrics recording for pod , failed to initialize the metrics recorder")
Expand Down

0 comments on commit 24afa9b

Please sign in to comment.