Skip to content

Commit dd0e239

Browse files
(fix): Remove WF Execution ID from incrementWorkflowMissingMeteringReport (#17678)
* (fix): Remove WF Execution ID from incrementWorkflowMissingMeteringReport * Remove setting metric labels on start, handled in constructor
1 parent 1a0b9f2 commit dd0e239

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

core/services/workflows/engine.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@ func (e *Engine) Start(_ context.Context) error {
157157
// validate if adding another workflow would exceed either the global or per owner engine count limit
158158
ownerAllow, globalAllow := e.workflowLimits.Allow(e.workflow.owner)
159159
if !globalAllow {
160-
e.metrics.with(platform.KeyWorkflowID, e.workflow.id, platform.KeyWorkflowOwner, e.workflow.owner).incrementWorkflowLimitGlobalCounter(ctx)
160+
e.metrics.incrementWorkflowLimitGlobalCounter(ctx)
161161
logCustMsg(ctx, e.cma.With(platform.KeyWorkflowID, e.workflow.id, platform.KeyWorkflowOwner, e.workflow.owner), types.ErrGlobalWorkflowCountLimitReached.Error(), e.logger)
162162
return types.ErrGlobalWorkflowCountLimitReached
163163
}
164164

165165
if !ownerAllow {
166-
e.metrics.with(platform.KeyWorkflowID, e.workflow.id, platform.KeyWorkflowOwner, e.workflow.owner).incrementWorkflowLimitPerOwnerCounter(ctx)
166+
e.metrics.incrementWorkflowLimitPerOwnerCounter(ctx)
167167
logCustMsg(ctx, e.cma.With(platform.KeyWorkflowID, e.workflow.id, platform.KeyWorkflowOwner, e.workflow.owner), types.ErrPerOwnerWorkflowCountLimitReached.Error(), e.logger)
168168
return types.ErrPerOwnerWorkflowCountLimitReached
169169
}
@@ -649,13 +649,13 @@ func (e *Engine) finishExecution(ctx context.Context, cma custmsg.MessageEmitter
649649
if exists {
650650
// send metering report to beholder
651651
if err = events.EmitMeteringReport(ctx, cma, report.Message()); err != nil {
652-
e.metrics.with(platform.KeyWorkflowID, e.workflow.id, platform.KeyWorkflowExecutionID, executionID).incrementWorkflowMissingMeteringReport(ctx)
652+
e.metrics.incrementWorkflowMissingMeteringReport(ctx)
653653
l.Warn(fmt.Sprintf("metering report send to beholder error %s", err))
654654
}
655655

656656
// send metering report to billing if billing client is not nil
657657
if err = e.sendMeteringReportToBilling(ctx, report, e.workflow.id, executionID); err != nil {
658-
e.metrics.with(platform.KeyWorkflowID, e.workflow.id, platform.KeyWorkflowExecutionID, executionID).incrementWorkflowMissingMeteringReport(ctx)
658+
e.metrics.incrementWorkflowMissingMeteringReport(ctx)
659659
l.Warn(fmt.Sprintf("metering report send to billing error %s", err))
660660
}
661661
}
@@ -735,14 +735,14 @@ func (e *Engine) worker(ctx context.Context) {
735735
e.onRateLimit(executionID)
736736
e.logger.With(platform.KeyWorkflowID, e.workflow.id, platform.KeyWorkflowOwner, e.workflow.owner, platform.KeyWorkflowExecutionID, executionID).Errorf("failed to start execution: per sender rate limit exceeded")
737737
logCustMsg(ctx, e.cma.With(platform.KeyCapabilityID, te.ID), "failed to start execution: per sender rate limit exceeded", e.logger)
738-
e.metrics.with(platform.KeyWorkflowID, e.workflow.id, platform.KeyWorkflowExecutionID, executionID, platform.KeyTriggerID, te.ID, platform.KeyWorkflowOwner, e.workflow.owner).incrementWorkflowExecutionRateLimitPerUserCounter(ctx)
738+
e.metrics.with(platform.KeyTriggerID, te.ID).incrementWorkflowExecutionRateLimitPerUserCounter(ctx)
739739
continue
740740
}
741741
if !globalAllowed {
742742
e.onRateLimit(executionID)
743743
e.logger.With(platform.KeyWorkflowID, e.workflow.id, platform.KeyWorkflowOwner, e.workflow.owner, platform.KeyWorkflowExecutionID, executionID).Errorf("failed to start execution: global rate limit exceeded")
744744
logCustMsg(ctx, e.cma.With(platform.KeyCapabilityID, te.ID), "failed to start execution: global rate limit exceeded", e.logger)
745-
e.metrics.with(platform.KeyWorkflowID, e.workflow.id, platform.KeyWorkflowExecutionID, executionID, platform.KeyTriggerID, te.ID, platform.KeyWorkflowOwner, e.workflow.owner).incrementWorkflowExecutionRateLimitGlobalCounter(ctx)
745+
e.metrics.with(platform.KeyTriggerID, te.ID).incrementWorkflowExecutionRateLimitGlobalCounter(ctx)
746746
continue
747747
}
748748

@@ -830,9 +830,9 @@ func (e *Engine) workerForStepRequest(ctx context.Context, msg stepRequest) {
830830
if err := rpt.SetStep(MeteringReportStepRef(stepState.Ref), meteringSteps); err != nil {
831831
l.Error(fmt.Sprintf("failed to set metering report step for ref %s: %s", stepState.Ref, err))
832832
}
833-
e.metrics.with(platform.KeyWorkflowID, e.workflow.id, platform.KeyWorkflowExecutionID, msg.state.ExecutionID).incrementWorkflowMissingMeteringReport(ctx)
833+
e.metrics.with(platform.KeyWorkflowID, e.workflow.id).incrementWorkflowMissingMeteringReport(ctx)
834834
} else {
835-
e.metrics.with(platform.KeyWorkflowID, e.workflow.id, platform.KeyWorkflowExecutionID, msg.state.ExecutionID).incrementWorkflowMissingMeteringReport(ctx)
835+
e.metrics.with(platform.KeyWorkflowID, e.workflow.id).incrementWorkflowMissingMeteringReport(ctx)
836836
// TODO: to be bumped to error if all capabilities must implement metering
837837
l.Warnf("no metering report found for %v", msg.state.ExecutionID)
838838
}

0 commit comments

Comments
 (0)