From 4c3312554945c928cfde1ef94b7903f279907b55 Mon Sep 17 00:00:00 2001 From: Giordano Ricci Date: Tue, 19 Nov 2024 10:30:23 +0000 Subject: [PATCH] feat: add conclusion label to generated metrics (#165) * feat: add conclusion label to generated metrics * push to GAR * Add aborted job status (#166) * make generate * Remove parentheses * Add more job conclusions * add basic logging for debugging * add run_id, id, name & workflow_name to log * rename metric * Fix tests * Revert "push to GAR" This reverts commit 1f12b1ab130c592682ae3a8e82ff92af5619d84a. --------- Co-authored-by: dsotirakis --- .../githubactionsreceiver/documentation.md | 5 +- .../internal/metadata/generated_config.go | 4 +- .../metadata/generated_config_test.go | 4 +- .../internal/metadata/generated_metrics.go | 85 +++++++++++++++---- .../metadata/generated_metrics_test.go | 11 ++- .../internal/metadata/testdata/config.yaml | 4 +- receiver/githubactionsreceiver/metadata.yaml | 16 +++- .../metric_event_handling.go | 79 ++++++++++------- .../githubactionsreceiver/receiver_test.go | 8 +- 9 files changed, 154 insertions(+), 62 deletions(-) diff --git a/receiver/githubactionsreceiver/documentation.md b/receiver/githubactionsreceiver/documentation.md index 305cbbe..85b91c9 100644 --- a/receiver/githubactionsreceiver/documentation.md +++ b/receiver/githubactionsreceiver/documentation.md @@ -12,7 +12,7 @@ metrics: enabled: false ``` -### workflow_jobs_total +### workflow.jobs.count Number of jobs. @@ -26,4 +26,5 @@ Number of jobs. | ---- | ----------- | ------ | | vcs.repository.name | Repository name | Any Str | | ci.github.workflow.job.labels | Job labels. | Any Str | -| ci.github.workflow.job.status | Job status | Str: ``completed``, ``in_progress``, ``queued``, ``waiting`` | +| ci.github.workflow.job.status | Job status | Str: ``completed``, ``in_progress``, ``queued``, ``waiting``, ``aborted`` | +| ci.github.workflow.job.conclusion | Job Conclusion | Str: ``success``, ``failure``, ``cancelled``, ``neutral``, ``null``, ``skipped``, ``timed_out``, ``action_required`` | diff --git a/receiver/githubactionsreceiver/internal/metadata/generated_config.go b/receiver/githubactionsreceiver/internal/metadata/generated_config.go index 1287c97..e53ac65 100644 --- a/receiver/githubactionsreceiver/internal/metadata/generated_config.go +++ b/receiver/githubactionsreceiver/internal/metadata/generated_config.go @@ -27,12 +27,12 @@ func (ms *MetricConfig) Unmarshal(parser *confmap.Conf) error { // MetricsConfig provides config for githubactions metrics. type MetricsConfig struct { - WorkflowJobsTotal MetricConfig `mapstructure:"workflow_jobs_total"` + WorkflowJobsCount MetricConfig `mapstructure:"workflow.jobs.count"` } func DefaultMetricsConfig() MetricsConfig { return MetricsConfig{ - WorkflowJobsTotal: MetricConfig{ + WorkflowJobsCount: MetricConfig{ Enabled: true, }, } diff --git a/receiver/githubactionsreceiver/internal/metadata/generated_config_test.go b/receiver/githubactionsreceiver/internal/metadata/generated_config_test.go index c560001..9dce75a 100644 --- a/receiver/githubactionsreceiver/internal/metadata/generated_config_test.go +++ b/receiver/githubactionsreceiver/internal/metadata/generated_config_test.go @@ -25,7 +25,7 @@ func TestMetricsBuilderConfig(t *testing.T) { name: "all_set", want: MetricsBuilderConfig{ Metrics: MetricsConfig{ - WorkflowJobsTotal: MetricConfig{Enabled: true}, + WorkflowJobsCount: MetricConfig{Enabled: true}, }, }, }, @@ -33,7 +33,7 @@ func TestMetricsBuilderConfig(t *testing.T) { name: "none_set", want: MetricsBuilderConfig{ Metrics: MetricsConfig{ - WorkflowJobsTotal: MetricConfig{Enabled: false}, + WorkflowJobsCount: MetricConfig{Enabled: false}, }, }, }, diff --git a/receiver/githubactionsreceiver/internal/metadata/generated_metrics.go b/receiver/githubactionsreceiver/internal/metadata/generated_metrics.go index f8d5c75..3a9ed0e 100644 --- a/receiver/githubactionsreceiver/internal/metadata/generated_metrics.go +++ b/receiver/githubactionsreceiver/internal/metadata/generated_metrics.go @@ -11,6 +11,56 @@ import ( "go.opentelemetry.io/collector/receiver" ) +// AttributeCiGithubWorkflowJobConclusion specifies the a value ci.github.workflow.job.conclusion attribute. +type AttributeCiGithubWorkflowJobConclusion int + +const ( + _ AttributeCiGithubWorkflowJobConclusion = iota + AttributeCiGithubWorkflowJobConclusionSuccess + AttributeCiGithubWorkflowJobConclusionFailure + AttributeCiGithubWorkflowJobConclusionCancelled + AttributeCiGithubWorkflowJobConclusionNeutral + AttributeCiGithubWorkflowJobConclusionNull + AttributeCiGithubWorkflowJobConclusionSkipped + AttributeCiGithubWorkflowJobConclusionTimedOut + AttributeCiGithubWorkflowJobConclusionActionRequired +) + +// String returns the string representation of the AttributeCiGithubWorkflowJobConclusion. +func (av AttributeCiGithubWorkflowJobConclusion) String() string { + switch av { + case AttributeCiGithubWorkflowJobConclusionSuccess: + return "success" + case AttributeCiGithubWorkflowJobConclusionFailure: + return "failure" + case AttributeCiGithubWorkflowJobConclusionCancelled: + return "cancelled" + case AttributeCiGithubWorkflowJobConclusionNeutral: + return "neutral" + case AttributeCiGithubWorkflowJobConclusionNull: + return "null" + case AttributeCiGithubWorkflowJobConclusionSkipped: + return "skipped" + case AttributeCiGithubWorkflowJobConclusionTimedOut: + return "timed_out" + case AttributeCiGithubWorkflowJobConclusionActionRequired: + return "action_required" + } + return "" +} + +// MapAttributeCiGithubWorkflowJobConclusion is a helper map of string to AttributeCiGithubWorkflowJobConclusion attribute value. +var MapAttributeCiGithubWorkflowJobConclusion = map[string]AttributeCiGithubWorkflowJobConclusion{ + "success": AttributeCiGithubWorkflowJobConclusionSuccess, + "failure": AttributeCiGithubWorkflowJobConclusionFailure, + "cancelled": AttributeCiGithubWorkflowJobConclusionCancelled, + "neutral": AttributeCiGithubWorkflowJobConclusionNeutral, + "null": AttributeCiGithubWorkflowJobConclusionNull, + "skipped": AttributeCiGithubWorkflowJobConclusionSkipped, + "timed_out": AttributeCiGithubWorkflowJobConclusionTimedOut, + "action_required": AttributeCiGithubWorkflowJobConclusionActionRequired, +} + // AttributeCiGithubWorkflowJobStatus specifies the a value ci.github.workflow.job.status attribute. type AttributeCiGithubWorkflowJobStatus int @@ -20,6 +70,7 @@ const ( AttributeCiGithubWorkflowJobStatusInProgress AttributeCiGithubWorkflowJobStatusQueued AttributeCiGithubWorkflowJobStatusWaiting + AttributeCiGithubWorkflowJobStatusAborted ) // String returns the string representation of the AttributeCiGithubWorkflowJobStatus. @@ -33,6 +84,8 @@ func (av AttributeCiGithubWorkflowJobStatus) String() string { return "queued" case AttributeCiGithubWorkflowJobStatusWaiting: return "waiting" + case AttributeCiGithubWorkflowJobStatusAborted: + return "aborted" } return "" } @@ -43,17 +96,18 @@ var MapAttributeCiGithubWorkflowJobStatus = map[string]AttributeCiGithubWorkflow "in_progress": AttributeCiGithubWorkflowJobStatusInProgress, "queued": AttributeCiGithubWorkflowJobStatusQueued, "waiting": AttributeCiGithubWorkflowJobStatusWaiting, + "aborted": AttributeCiGithubWorkflowJobStatusAborted, } -type metricWorkflowJobsTotal struct { +type metricWorkflowJobsCount struct { data pmetric.Metric // data buffer for generated metric. config MetricConfig // metric config provided by user. capacity int // max observed number of data points added to the metric. } -// init fills workflow_jobs_total metric with initial data. -func (m *metricWorkflowJobsTotal) init() { - m.data.SetName("workflow_jobs_total") +// init fills workflow.jobs.count metric with initial data. +func (m *metricWorkflowJobsCount) init() { + m.data.SetName("workflow.jobs.count") m.data.SetDescription("Number of jobs.") m.data.SetUnit("{job}") m.data.SetEmptySum() @@ -62,7 +116,7 @@ func (m *metricWorkflowJobsTotal) init() { m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricWorkflowJobsTotal) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, vcsRepositoryNameAttributeValue string, ciGithubWorkflowJobLabelsAttributeValue string, ciGithubWorkflowJobStatusAttributeValue string) { +func (m *metricWorkflowJobsCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, vcsRepositoryNameAttributeValue string, ciGithubWorkflowJobLabelsAttributeValue string, ciGithubWorkflowJobStatusAttributeValue string, ciGithubWorkflowJobConclusionAttributeValue string) { if !m.config.Enabled { return } @@ -73,17 +127,18 @@ func (m *metricWorkflowJobsTotal) recordDataPoint(start pcommon.Timestamp, ts pc dp.Attributes().PutStr("vcs.repository.name", vcsRepositoryNameAttributeValue) dp.Attributes().PutStr("ci.github.workflow.job.labels", ciGithubWorkflowJobLabelsAttributeValue) dp.Attributes().PutStr("ci.github.workflow.job.status", ciGithubWorkflowJobStatusAttributeValue) + dp.Attributes().PutStr("ci.github.workflow.job.conclusion", ciGithubWorkflowJobConclusionAttributeValue) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. -func (m *metricWorkflowJobsTotal) updateCapacity() { +func (m *metricWorkflowJobsCount) updateCapacity() { if m.data.Sum().DataPoints().Len() > m.capacity { m.capacity = m.data.Sum().DataPoints().Len() } } // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. -func (m *metricWorkflowJobsTotal) emit(metrics pmetric.MetricSlice) { +func (m *metricWorkflowJobsCount) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) @@ -91,8 +146,8 @@ func (m *metricWorkflowJobsTotal) emit(metrics pmetric.MetricSlice) { } } -func newMetricWorkflowJobsTotal(cfg MetricConfig) metricWorkflowJobsTotal { - m := metricWorkflowJobsTotal{config: cfg} +func newMetricWorkflowJobsCount(cfg MetricConfig) metricWorkflowJobsCount { + m := metricWorkflowJobsCount{config: cfg} if cfg.Enabled { m.data = pmetric.NewMetric() m.init() @@ -108,7 +163,7 @@ type MetricsBuilder struct { metricsCapacity int // maximum observed number of metrics per resource. metricsBuffer pmetric.Metrics // accumulates metrics data before emitting. buildInfo component.BuildInfo // contains version information. - metricWorkflowJobsTotal metricWorkflowJobsTotal + metricWorkflowJobsCount metricWorkflowJobsCount } // MetricBuilderOption applies changes to default metrics builder. @@ -135,7 +190,7 @@ func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.Settings, opt startTime: pcommon.NewTimestampFromTime(time.Now()), metricsBuffer: pmetric.NewMetrics(), buildInfo: settings.BuildInfo, - metricWorkflowJobsTotal: newMetricWorkflowJobsTotal(mbc.Metrics.WorkflowJobsTotal), + metricWorkflowJobsCount: newMetricWorkflowJobsCount(mbc.Metrics.WorkflowJobsCount), } for _, op := range options { @@ -201,7 +256,7 @@ func (mb *MetricsBuilder) EmitForResource(options ...ResourceMetricsOption) { ils.Scope().SetName("github.com/grafana/grafana-ci-otel-collector/receiver/githubactionsreceiver") ils.Scope().SetVersion(mb.buildInfo.Version) ils.Metrics().EnsureCapacity(mb.metricsCapacity) - mb.metricWorkflowJobsTotal.emit(ils.Metrics()) + mb.metricWorkflowJobsCount.emit(ils.Metrics()) for _, op := range options { op.apply(rm) @@ -223,9 +278,9 @@ func (mb *MetricsBuilder) Emit(options ...ResourceMetricsOption) pmetric.Metrics return metrics } -// RecordWorkflowJobsTotalDataPoint adds a data point to workflow_jobs_total metric. -func (mb *MetricsBuilder) RecordWorkflowJobsTotalDataPoint(ts pcommon.Timestamp, val int64, vcsRepositoryNameAttributeValue string, ciGithubWorkflowJobLabelsAttributeValue string, ciGithubWorkflowJobStatusAttributeValue AttributeCiGithubWorkflowJobStatus) { - mb.metricWorkflowJobsTotal.recordDataPoint(mb.startTime, ts, val, vcsRepositoryNameAttributeValue, ciGithubWorkflowJobLabelsAttributeValue, ciGithubWorkflowJobStatusAttributeValue.String()) +// RecordWorkflowJobsCountDataPoint adds a data point to workflow.jobs.count metric. +func (mb *MetricsBuilder) RecordWorkflowJobsCountDataPoint(ts pcommon.Timestamp, val int64, vcsRepositoryNameAttributeValue string, ciGithubWorkflowJobLabelsAttributeValue string, ciGithubWorkflowJobStatusAttributeValue AttributeCiGithubWorkflowJobStatus, ciGithubWorkflowJobConclusionAttributeValue AttributeCiGithubWorkflowJobConclusion) { + mb.metricWorkflowJobsCount.recordDataPoint(mb.startTime, ts, val, vcsRepositoryNameAttributeValue, ciGithubWorkflowJobLabelsAttributeValue, ciGithubWorkflowJobStatusAttributeValue.String(), ciGithubWorkflowJobConclusionAttributeValue.String()) } // Reset resets metrics builder to its initial state. It should be used when external metrics source is restarted, diff --git a/receiver/githubactionsreceiver/internal/metadata/generated_metrics_test.go b/receiver/githubactionsreceiver/internal/metadata/generated_metrics_test.go index 71e68a8..b1b19d9 100644 --- a/receiver/githubactionsreceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/githubactionsreceiver/internal/metadata/generated_metrics_test.go @@ -61,7 +61,7 @@ func TestMetricsBuilder(t *testing.T) { defaultMetricsCount++ allMetricsCount++ - mb.RecordWorkflowJobsTotalDataPoint(ts, 1, "vcs.repository.name-val", "ci.github.workflow.job.labels-val", AttributeCiGithubWorkflowJobStatusCompleted) + mb.RecordWorkflowJobsCountDataPoint(ts, 1, "vcs.repository.name-val", "ci.github.workflow.job.labels-val", AttributeCiGithubWorkflowJobStatusCompleted, AttributeCiGithubWorkflowJobConclusionSuccess) res := pcommon.NewResource() metrics := mb.Emit(WithResource(res)) @@ -85,9 +85,9 @@ func TestMetricsBuilder(t *testing.T) { validatedMetrics := make(map[string]bool) for i := 0; i < ms.Len(); i++ { switch ms.At(i).Name() { - case "workflow_jobs_total": - assert.False(t, validatedMetrics["workflow_jobs_total"], "Found a duplicate in the metrics slice: workflow_jobs_total") - validatedMetrics["workflow_jobs_total"] = true + case "workflow.jobs.count": + assert.False(t, validatedMetrics["workflow.jobs.count"], "Found a duplicate in the metrics slice: workflow.jobs.count") + validatedMetrics["workflow.jobs.count"] = true assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) assert.Equal(t, "Number of jobs.", ms.At(i).Description()) @@ -108,6 +108,9 @@ func TestMetricsBuilder(t *testing.T) { attrVal, ok = dp.Attributes().Get("ci.github.workflow.job.status") assert.True(t, ok) assert.EqualValues(t, "completed", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("ci.github.workflow.job.conclusion") + assert.True(t, ok) + assert.EqualValues(t, "success", attrVal.Str()) } } }) diff --git a/receiver/githubactionsreceiver/internal/metadata/testdata/config.yaml b/receiver/githubactionsreceiver/internal/metadata/testdata/config.yaml index e2cec61..d582f95 100644 --- a/receiver/githubactionsreceiver/internal/metadata/testdata/config.yaml +++ b/receiver/githubactionsreceiver/internal/metadata/testdata/config.yaml @@ -1,9 +1,9 @@ default: all_set: metrics: - workflow_jobs_total: + workflow.jobs.count: enabled: true none_set: metrics: - workflow_jobs_total: + workflow.jobs.count: enabled: false diff --git a/receiver/githubactionsreceiver/metadata.yaml b/receiver/githubactionsreceiver/metadata.yaml index e172cad..aa780e4 100644 --- a/receiver/githubactionsreceiver/metadata.yaml +++ b/receiver/githubactionsreceiver/metadata.yaml @@ -28,10 +28,23 @@ attributes: - in_progress - queued - waiting + - aborted + type: string + ci.github.workflow.job.conclusion: + description: Job Conclusion + enum: + - success + - failure + - cancelled + - neutral + - "null" + - skipped + - timed_out + - action_required type: string metrics: - workflow_jobs_total: + workflow.jobs.count: enabled: true description: Number of jobs. unit: "{job}" @@ -44,4 +57,5 @@ metrics: vcs.repository.name, ci.github.workflow.job.labels, ci.github.workflow.job.status, + ci.github.workflow.job.conclusion, ] diff --git a/receiver/githubactionsreceiver/metric_event_handling.go b/receiver/githubactionsreceiver/metric_event_handling.go index 6a83e57..05978fb 100644 --- a/receiver/githubactionsreceiver/metric_event_handling.go +++ b/receiver/githubactionsreceiver/metric_event_handling.go @@ -22,7 +22,7 @@ type metricsHandler struct { logger *zap.Logger } -var mCache = sync.Map{} +var repoMap = sync.Map{} func newMetricsHandler(settings receiver.Settings, cfg *Config, logger *zap.Logger) *metricsHandler { return &metricsHandler{ @@ -34,19 +34,6 @@ func newMetricsHandler(settings receiver.Settings, cfg *Config, logger *zap.Logg } func (m *metricsHandler) eventToMetrics(event *github.WorkflowJobEvent) pmetric.Metrics { - if event.GetWorkflowJob().GetConclusion() == "skipped" || - // Check runs are also reported via WorkflowJobEvent, we want to skip them when generating metrics. - // We do so by checking if the runner ID is 0, which is the zero value for the field. - // see https://github.com/actions/actions-runner-controller/issues/2118. - // NOTE: This also applies to cancelled jobs which have not been started. - (event.GetAction() == "completed" && event.GetWorkflowJob().GetRunnerID() == 0) { - return m.mb.Emit() - } - - if event.GetWorkflowJob().GetName() == "eslint" && event.GetRepo().GetFullName() == "grafana/deployment_tools" { - m.logger.Info("CHECK OUT THIS", zap.Any("event", event)) - } - repo := event.GetRepo().GetFullName() labels := "" @@ -61,50 +48,82 @@ func (m *metricsHandler) eventToMetrics(event *github.WorkflowJobEvent) pmetric. labels = "no labels" } + m.logger.Info("Processing workflow_job event", + zap.String("repo", repo), + zap.Int64("run_id", event.GetWorkflowJob().GetRunID()), + zap.Int64("id", event.GetWorkflowJob().GetID()), + zap.String("name", event.GetWorkflowJob().GetName()), + zap.String("workflow_name", event.GetWorkflowJob().GetWorkflowName()), + zap.String("action", event.GetAction()), + zap.String("status", event.GetWorkflowJob().GetStatus()), + zap.String("conclusion", event.GetWorkflowJob().GetConclusion()), + zap.String("labels", labels), + zap.Any("steps", event.GetWorkflowJob().Steps), + zap.Int64("runner", event.GetWorkflowJob().GetRunnerID()), + ) + now := pcommon.NewTimestampFromTime(time.Now()) - if status, ok := metadata.MapAttributeCiGithubWorkflowJobStatus[event.GetAction()]; ok { - curVal, found := loadFromCache(repo, labels, status) + status, actionOk := metadata.MapAttributeCiGithubWorkflowJobStatus[event.GetAction()] + conclusion, conclusionOk := metadata.MapAttributeCiGithubWorkflowJobConclusion[event.GetWorkflowJob().GetConclusion()] + if status == metadata.AttributeCiGithubWorkflowJobStatusCompleted && conclusion == metadata.AttributeCiGithubWorkflowJobConclusionCancelled && len(event.GetWorkflowJob().Steps) == 1 { + status = metadata.AttributeCiGithubWorkflowJobStatusAborted + } + if !conclusionOk { + conclusion = metadata.AttributeCiGithubWorkflowJobConclusionNull + } + + if actionOk { + curVal, found := loadFromCache(repo, labels, status, conclusion) // If the value was not found in the cache, we record a 0 value for all other possible statuses // so that all counters for a given labels combination are always present and reset at the same time. if !found { for _, s := range metadata.MapAttributeCiGithubWorkflowJobStatus { - if s == status { - continue + for _, c := range metadata.MapAttributeCiGithubWorkflowJobConclusion { + if s == status && c == conclusion { + continue + } + + storeInCache(repo, labels, s, c, 0) + m.mb.RecordWorkflowJobsCountDataPoint(now, 0, repo, labels, s, c) } - storeInCache(repo, labels, s, 0) - m.mb.RecordWorkflowJobsTotalDataPoint(now, 0, repo, labels, s) } } - storeInCache(repo, labels, status, curVal+1) - m.mb.RecordWorkflowJobsTotalDataPoint(now, curVal+1, repo, labels, status) + storeInCache(repo, labels, status, conclusion, curVal+1) + m.mb.RecordWorkflowJobsCountDataPoint(now, curVal+1, repo, labels, status, conclusion) } return m.mb.Emit() } -func storeInCache(repo, labels string, status metadata.AttributeCiGithubWorkflowJobStatus, value int64) { - middleMap, _ := mCache.LoadOrStore(repo, &sync.Map{}) - innerMap, _ := middleMap.(*sync.Map).LoadOrStore(labels, &sync.Map{}) - innerMap.(*sync.Map).Store(status, value) +func storeInCache(repo, labels string, status metadata.AttributeCiGithubWorkflowJobStatus, conclusion metadata.AttributeCiGithubWorkflowJobConclusion, value int64) { + labelsMap, _ := repoMap.LoadOrStore(repo, &sync.Map{}) + statusesMap, _ := labelsMap.(*sync.Map).LoadOrStore(labels, &sync.Map{}) + conclusionsMap, _ := statusesMap.(*sync.Map).LoadOrStore(status, &sync.Map{}) + conclusionsMap.(*sync.Map).Store(conclusion, value) } // Helper function to load values from the nested sync.Map structure -func loadFromCache(repo, labels string, status metadata.AttributeCiGithubWorkflowJobStatus) (int64, bool) { - middleMap, ok := mCache.Load(repo) +func loadFromCache(repo, labels string, status metadata.AttributeCiGithubWorkflowJobStatus, conclusion metadata.AttributeCiGithubWorkflowJobConclusion) (int64, bool) { + labelsMap, ok := repoMap.Load(repo) + if !ok { + return 0, false + } + + statusesMap, ok := labelsMap.(*sync.Map).Load(labels) if !ok { return 0, false } - innerMap, ok := middleMap.(*sync.Map).Load(labels) + conclusionsMap, ok := statusesMap.(*sync.Map).Load(status) if !ok { return 0, false } - value, ok := innerMap.(*sync.Map).Load(status) + value, ok := conclusionsMap.(*sync.Map).Load(conclusion) if !ok { return 0, false } diff --git a/receiver/githubactionsreceiver/receiver_test.go b/receiver/githubactionsreceiver/receiver_test.go index 9ccfb32..25e78c5 100644 --- a/receiver/githubactionsreceiver/receiver_test.go +++ b/receiver/githubactionsreceiver/receiver_test.go @@ -122,14 +122,14 @@ func TestEventToMetrics(t *testing.T) { payloadFilePath: "./testdata/queued/1_workflow_job_queued.json", eventType: "workflow_job", expectedMetrics: 1, - expectedDataPoints: len(metadata.MapAttributeCiGithubWorkflowJobStatus), + expectedDataPoints: len(metadata.MapAttributeCiGithubWorkflowJobStatus) * len(metadata.MapAttributeCiGithubWorkflowJobConclusion), }, { desc: "WorkflowJobEvent (check run) processing", payloadFilePath: "./testdata/completed/5_workflow_job_check-run_completed.json", eventType: "workflow_job", - expectedMetrics: 0, - expectedDataPoints: 0, + expectedMetrics: 1, + expectedDataPoints: len(metadata.MapAttributeCiGithubWorkflowJobStatus) * len(metadata.MapAttributeCiGithubWorkflowJobConclusion), }, } @@ -145,7 +145,7 @@ func TestEventToMetrics(t *testing.T) { mh := newMetricsHandler(receivertest.NewNopSettings(), &Config{ MetricsBuilderConfig: metadata.MetricsBuilderConfig{ Metrics: metadata.MetricsConfig{ - WorkflowJobsTotal: metadata.MetricConfig{ + WorkflowJobsCount: metadata.MetricConfig{ Enabled: true, }, },