Skip to content

Commit

Permalink
remove non enum attributes on metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
dmjb committed Jun 25, 2024
1 parent 83a02e8 commit eaf5228
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
8 changes: 4 additions & 4 deletions internal/engine/eval_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ func (e *Executor) createOrUpdateEvalStatus(
}

// Upsert evaluation details
entityID, entityType, err := ent.EntityFromIDs(params.RepoID.UUID, params.ArtifactID.UUID, params.PullRequestID.UUID)
_, entityType, err := ent.EntityFromIDs(params.RepoID.UUID, params.ArtifactID.UUID, params.PullRequestID.UUID)
if err != nil {
return err
}
status := evalerrors.ErrorAsEvalStatus(params.GetEvalErr())
e.metrics.CountEvalStatus(ctx, status, params.ProfileID, params.ProjectID, entityID, entityType)
e.metrics.CountEvalStatus(ctx, status, entityType)
_, err = e.querier.UpsertRuleDetailsEval(ctx, db.UpsertRuleDetailsEvalParams{
RuleEvalID: evalID,
Status: evalerrors.ErrorAsEvalStatus(params.GetEvalErr()),
Expand All @@ -175,7 +175,7 @@ func (e *Executor) createOrUpdateEvalStatus(

// Upsert remediation details
remediationStatus := evalerrors.ErrorAsRemediationStatus(params.GetActionsErr().RemediateErr)
e.metrics.CountRemediationStatus(ctx, remediationStatus, evalID, params.ProjectID)
e.metrics.CountRemediationStatus(ctx, remediationStatus)

_, err = e.querier.UpsertRuleDetailsRemediate(ctx, db.UpsertRuleDetailsRemediateParams{
RuleEvalID: evalID,
Expand All @@ -189,7 +189,7 @@ func (e *Executor) createOrUpdateEvalStatus(

// Upsert alert details
alertStatus := evalerrors.ErrorAsAlertStatus(params.GetActionsErr().AlertErr)
e.metrics.CountAlertStatus(ctx, alertStatus, evalID, params.ProjectID)
e.metrics.CountAlertStatus(ctx, alertStatus)

_, err = e.querier.UpsertRuleDetailsAlert(ctx, db.UpsertRuleDetailsAlertParams{
RuleEvalID: evalID,
Expand Down
15 changes: 0 additions & 15 deletions internal/engine/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"fmt"

"github.com/google/uuid"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"

Expand Down Expand Up @@ -68,15 +67,9 @@ func NewExecutorMetrics(meterFactory meters.MeterFactory) (*ExecutorMetrics, err
func (e *ExecutorMetrics) CountEvalStatus(
ctx context.Context,
status db.EvalStatusTypes,
profileID uuid.UUID,
projectID uuid.UUID,
entityID uuid.UUID,
entityType db.Entities,
) {
e.evalCounter.Add(ctx, 1, metric.WithAttributes(
attribute.String("profile_id", profileID.String()),
attribute.String("project_id", projectID.String()),
attribute.String("entity_id", entityID.String()),
attribute.String("entity_type", string(entityType)),
attribute.String("status", string(status)),
))
Expand All @@ -86,12 +79,8 @@ func (e *ExecutorMetrics) CountEvalStatus(
func (e *ExecutorMetrics) CountRemediationStatus(
ctx context.Context,
status db.RemediationStatusTypes,
evalID uuid.UUID,
projectID uuid.UUID,
) {
e.evalCounter.Add(ctx, 1, metric.WithAttributes(
attribute.String("profile_id", evalID.String()),
attribute.String("project_id", projectID.String()),
attribute.String("status", string(status)),
))
}
Expand All @@ -100,12 +89,8 @@ func (e *ExecutorMetrics) CountRemediationStatus(
func (e *ExecutorMetrics) CountAlertStatus(
ctx context.Context,
status db.AlertStatusTypes,
evalID uuid.UUID,
projectID uuid.UUID,
) {
e.evalCounter.Add(ctx, 1, metric.WithAttributes(
attribute.String("profile_id", evalID.String()),
attribute.String("project_id", projectID.String()),
attribute.String("status", string(status)),
))
}

0 comments on commit eaf5228

Please sign in to comment.