Skip to content

Commit 8430ef9

Browse files
patrickhuie19EasterTheBunny
authored andcommitted
adding orgID from labeler to metering report event
1 parent 574cad9 commit 8430ef9

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

core/services/workflows/events/emit.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ func buildWorkflowMetadata(kvs map[string]string, workflowExecutionID string) *e
457457
}
458458
}
459459

460+
m.OrgID = kvs[platform.KeyOrganizationID]
461+
460462
return m
461463
}
462464

core/services/workflows/metering/metering.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ func (r *Report) FormatReport() *protoEvents.MeteringReport {
532532
Trigger: &protoEvents.TriggerDetail{
533533
TriggerID: r.labels[platform.KeyTriggerID],
534534
},
535+
OrgID: r.labels[platform.KeyOrganizationID],
535536
},
536537
MeteringMode: r.meteringMode,
537538
}

core/services/workflows/metering/metering_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,38 @@ func Test_Report_FormatReport(t *testing.T) {
10561056
billingClient.AssertExpectations(t)
10571057
})
10581058

1059+
t.Run("includes orgID in metadata", func(t *testing.T) {
1060+
t.Parallel()
1061+
1062+
testOrgID := "org-123"
1063+
labels := map[string]string{
1064+
platform.KeyWorkflowOwner: "accountId",
1065+
platform.KeyWorkflowID: "workflowId",
1066+
platform.KeyWorkflowVersion: workflowV2,
1067+
platform.KeyWorkflowExecutionID: "workflowExecutionId",
1068+
platform.KeyDonID: "42",
1069+
platform.KeyDonF: "1",
1070+
platform.KeyDonN: "3",
1071+
platform.KeyP2PID: "peerId",
1072+
platform.KeyTriggerID: "triggerId",
1073+
platform.KeyOrganizationID: testOrgID,
1074+
}
1075+
1076+
billingClient := mocks.NewBillingClient(t)
1077+
billingClient.EXPECT().GetWorkflowExecutionRates(mock.Anything, mock.Anything).
1078+
Return(&billing.GetWorkflowExecutionRatesResponse{}, nil)
1079+
1080+
report, err := NewReport(t.Context(), labels, logger.Nop(), billingClient, defaultMetrics(t), dummyRegistryAddress, dummyChainSelector, workflowV2)
1081+
require.NoError(t, err)
1082+
1083+
billingClient.EXPECT().ReserveCredits(mock.Anything, mock.Anything).Return(&successReserveResponse, nil)
1084+
require.NoError(t, report.Reserve(t.Context()))
1085+
1086+
meteringReport := report.FormatReport()
1087+
require.Equal(t, testOrgID, meteringReport.Metadata.OrgID)
1088+
billingClient.AssertExpectations(t)
1089+
})
1090+
10591091
t.Run("contains all step data", func(t *testing.T) {
10601092
t.Parallel()
10611093

0 commit comments

Comments
 (0)