diff --git a/core/services/workflows/events/emit.go b/core/services/workflows/events/emit.go index 372879c3fb3..4505f822d01 100644 --- a/core/services/workflows/events/emit.go +++ b/core/services/workflows/events/emit.go @@ -457,6 +457,8 @@ func buildWorkflowMetadata(kvs map[string]string, workflowExecutionID string) *e } } + m.OrgID = kvs[platform.KeyOrganizationID] + return m } diff --git a/core/services/workflows/metering/metering.go b/core/services/workflows/metering/metering.go index 943176cfc78..1e7a573ab3a 100644 --- a/core/services/workflows/metering/metering.go +++ b/core/services/workflows/metering/metering.go @@ -532,6 +532,7 @@ func (r *Report) FormatReport() *protoEvents.MeteringReport { Trigger: &protoEvents.TriggerDetail{ TriggerID: r.labels[platform.KeyTriggerID], }, + OrgID: r.labels[platform.KeyOrganizationID], }, MeteringMode: r.meteringMode, } diff --git a/core/services/workflows/metering/metering_test.go b/core/services/workflows/metering/metering_test.go index 35019e7f3b2..f7736109867 100644 --- a/core/services/workflows/metering/metering_test.go +++ b/core/services/workflows/metering/metering_test.go @@ -1056,6 +1056,38 @@ func Test_Report_FormatReport(t *testing.T) { billingClient.AssertExpectations(t) }) + t.Run("includes orgID in metadata", func(t *testing.T) { + t.Parallel() + + testOrgID := "org-123" + labels := map[string]string{ + platform.KeyWorkflowOwner: "accountId", + platform.KeyWorkflowID: "workflowId", + platform.KeyWorkflowVersion: workflowV2, + platform.KeyWorkflowExecutionID: "workflowExecutionId", + platform.KeyDonID: "42", + platform.KeyDonF: "1", + platform.KeyDonN: "3", + platform.KeyP2PID: "peerId", + platform.KeyTriggerID: "triggerId", + platform.KeyOrganizationID: testOrgID, + } + + billingClient := mocks.NewBillingClient(t) + billingClient.EXPECT().GetWorkflowExecutionRates(mock.Anything, mock.Anything). + Return(&billing.GetWorkflowExecutionRatesResponse{}, nil) + + report, err := NewReport(t.Context(), labels, logger.Nop(), billingClient, defaultMetrics(t), dummyRegistryAddress, dummyChainSelector, workflowV2) + require.NoError(t, err) + + billingClient.EXPECT().ReserveCredits(mock.Anything, mock.Anything).Return(&successReserveResponse, nil) + require.NoError(t, report.Reserve(t.Context())) + + meteringReport := report.FormatReport() + require.Equal(t, testOrgID, meteringReport.Metadata.OrgID) + billingClient.AssertExpectations(t) + }) + t.Run("contains all step data", func(t *testing.T) { t.Parallel()