Skip to content

Commit

Permalink
Add metrics for chains to fix issue#1028
Browse files Browse the repository at this point in the history
  • Loading branch information
sudhishmk committed Jan 27, 2024
1 parent 4d53955 commit ae8465f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 0 additions & 2 deletions pkg/chains/signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ func (o *ObjectSigner) Sign(ctx context.Context, tektonObj objects.TektonObject)
}

func measureMetrics(metrictype string, mtr MetricsRecorder, ctx context.Context) {
logger := logging.FromContext(ctx)
logger.Debugf("Type of Metrics Recorder ", mtr, metrictype)
if mtr != nil {
mtr.RecordCountMetrics(metrictype, ctx)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/pipelinerunmetrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ func viewRegister() error {
)
}

func (r *Recorder) RecordCountMetrics(MetricType string, ctx context.Context) {
func (r *Recorder) RecordCountMetrics(metricType string, ctx context.Context) {
logger := logging.FromContext(ctx)
if !r.initialized {
logger.Errorf("Ignoring the metrics recording as recorder not initialized ")
return
}
switch mt := MetricType; mt {
switch mt := metricType; mt {
case chains.SignedMessagesCount:
r.countMetrics(ctx, sgCount)
case chains.PayloadUploadeCount:
Expand All @@ -134,7 +134,7 @@ func (r *Recorder) RecordCountMetrics(MetricType string, ctx context.Context) {
case chains.MarkedAsSignedCount:
r.countMetrics(ctx, mrCount)
default:
logger.Errorf("Ignoring the metrics recording as valid Metric type was not found")
logger.Errorf("Ignoring the metrics recording as valid Metric type matching %v was not found", mt)
}

}
Expand Down
6 changes: 3 additions & 3 deletions pkg/taskrunmetrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ func viewRegister() error {
)
}

func (r *Recorder) RecordCountMetrics(MetricType string, ctx context.Context) {
func (r *Recorder) RecordCountMetrics(metricType string, ctx context.Context) {
logger := logging.FromContext(ctx)

if !r.initialized {
logger.Errorf("ignoring the metrics recording as recorder not initialized ")
}
switch mt := MetricType; mt {
switch mt := metricType; mt {
case chains.SignedMessagesCount:
r.countMetrics(ctx, sgCount)
case chains.PayloadUploadeCount:
Expand All @@ -135,7 +135,7 @@ func (r *Recorder) RecordCountMetrics(MetricType string, ctx context.Context) {
case chains.MarkedAsSignedCount:
r.countMetrics(ctx, mrCount)
default:
logger.Errorf("Ignoring the metrics recording as valid Metric type was not found")
logger.Errorf("Ignoring the metrics recording as valid Metric type matching %v was not found", mt)
}

}
Expand Down

0 comments on commit ae8465f

Please sign in to comment.