Skip to content

Cleanup CRE metics, dedupe accidental duplication and remove unnecessary if guard on label#21352

Merged
nolag merged 1 commit intodevelopfrom
rtinianov_dedupeMetrics
Mar 2, 2026
Merged

Cleanup CRE metics, dedupe accidental duplication and remove unnecessary if guard on label#21352
nolag merged 1 commit intodevelopfrom
rtinianov_dedupeMetrics

Conversation

@nolag
Copy link
Contributor

@nolag nolag commented Mar 2, 2026

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

I see you updated files related to core. Please run make gocs in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

✅ No conflicts with other open PRs targeting develop

@nolag nolag marked this pull request as ready for review March 2, 2026 16:33
@nolag nolag requested a review from a team as a code owner March 2, 2026 16:33
Copilot AI review requested due to automatic review settings March 2, 2026 16:33
@nolag nolag enabled auto-merge March 2, 2026 16:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Cleans up workflow engine (CRE) observability by simplifying label construction and removing duplicate/unused metrics instruments and increments.

Changes:

  • Simplifies engine label construction and makes the SDK label consistently included in logger/metrics label sets.
  • Removes the legacy platform_engine_subscriptions / platform_engine_executions counters and their increment sites.
  • Removes the corresponding unit test that only exercised the deleted counters.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
core/services/workflows/v2/engine.go Simplifies label building, always includes SDK label, and removes duplicate subscription/execution counter increments.
core/services/workflows/monitoring/monitoring.go Deletes unused subscriptions/executions counters and associated labeler methods.
core/services/workflows/monitoring/monitoring_test.go Removes the test for the deleted counters and cleans up imports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -706,7 +700,6 @@ func (e *Engine) startExecution(ctx context.Context, wrappedTriggerEvent enqueue
e.lggr.Errorf("failed to ACK trigger event (eventID=%s): %v", triggerEvent.ID, err)
}
e.metrics.With("workflowID", e.cfg.WorkflowID, "workflowName", e.cfg.WorkflowName.String()).IncrementWorkflowExecutionStartedCounter(ctx)
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.metrics is already constructed in NewEngine() with workflowID, workflowOwner, workflowName, and sdk labels. The extra With("workflowID", ..., "workflowName", ...) here is redundant (and uses string literals instead of platform.Key* constants), which adds avoidable allocations and makes label keys easier to drift. Consider dropping the With(...) call entirely (or at least switching to platform.KeyWorkflowID / platform.KeyWorkflowName).

Suggested change
e.metrics.With("workflowID", e.cfg.WorkflowID, "workflowName", e.cfg.WorkflowName.String()).IncrementWorkflowExecutionStartedCounter(ctx)
e.metrics.IncrementWorkflowExecutionStartedCounter(ctx)

Copilot uses AI. Check for mistakes.
@cl-sonarqube-production
Copy link

@Moses-main
Copy link

Hi team,

I'll help clean up the CRE metrics and remove the accidental duplication. I'll analyze the codebase and ensure a clean implementation.

My approach:

  1. Identify duplicate metrics
  2. Remove unnecessary code
  3. Ensure proper labeling
  4. Test the changes

Please assign!

c.em.subscriptions.Add(ctx, 1, metric.WithAttributes(otelLabels...))
}

func (c WorkflowsMetricLabeler) IncrementExecutionsCounter(ctx context.Context) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope now, but why are all of the methods declared with value receivers instead of pointers? Seems like a lot of unnecessary memory allocs. We even return a pointer from the constructor.

@nolag nolag added this pull request to the merge queue Mar 2, 2026
Merged via the queue into develop with commit 8fa5411 Mar 2, 2026
221 of 224 checks passed
@nolag nolag deleted the rtinianov_dedupeMetrics branch March 2, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants