-
Notifications
You must be signed in to change notification settings - Fork 2
CCM-17047 Add client , campaign and supplier name to Grafana dashboard #543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0699b82
3e690b4
e26fa97
3b75bb4
6e722e4
e5377f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -144,6 +144,27 @@ function emitMetrics( | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| function emitSupCampaignClientMetric( | ||||||
| letterEvent: PreparedEvents, | ||||||
| supplier: string, | ||||||
| status: string, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming Q: Is this status as in supplier status? Looks like it's used for metric key? |
||||||
| deps: Deps, | ||||||
| ) { | ||||||
| const namespace = "supplier-allocator"; | ||||||
| const { campaignId, clientId } = letterEvent.data; | ||||||
| const dimensions: Record<string, string> = { | ||||||
| Supplier: supplier, | ||||||
| ClientId: clientId, | ||||||
| CampaignId: campaignId || "unknown", | ||||||
| }; | ||||||
| const metric: MetricEntry = { | ||||||
| key: status, | ||||||
| value: 1, | ||||||
| unit: Unit.Count, | ||||||
| }; | ||||||
| deps.logger.info(buildEMFObject(namespace, dimensions, metric)); | ||||||
| } | ||||||
|
|
||||||
| export default function createSupplierAllocatorHandler(deps: Deps): SQSHandler { | ||||||
| return async (event: SQSEvent) => { | ||||||
| const batchItemFailures: SQSBatchItemFailure[] = []; | ||||||
|
|
@@ -153,8 +174,9 @@ export default function createSupplierAllocatorHandler(deps: Deps): SQSHandler { | |||||
| const tasks = event.Records.map(async (record) => { | ||||||
| let supplier = "unknown"; | ||||||
| let priority = "unknown"; | ||||||
| let letterEvent: PreparedEvents | undefined; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can letterEvent ever be undefined, with the "as PreparedEvents" assertion below?
Suggested change
|
||||||
| try { | ||||||
| const letterEvent: unknown = JSON.parse(record.body); | ||||||
| letterEvent = JSON.parse(record.body) as PreparedEvents; | ||||||
|
|
||||||
| deps.logger.info({ | ||||||
| description: "Extracted letter event", | ||||||
|
|
@@ -163,8 +185,8 @@ export default function createSupplierAllocatorHandler(deps: Deps): SQSHandler { | |||||
|
|
||||||
| validateType(letterEvent); | ||||||
|
|
||||||
| const supplierSpec = getSupplier(letterEvent as PreparedEvents, deps); | ||||||
| await getSupplierFromConfig(letterEvent as PreparedEvents, deps); | ||||||
| const supplierSpec = getSupplier(letterEvent, deps); | ||||||
| await getSupplierFromConfig(letterEvent, deps); | ||||||
|
|
||||||
| supplier = supplierSpec.supplierId; | ||||||
| priority = String(supplierSpec.priority); | ||||||
|
|
@@ -199,6 +221,12 @@ export default function createSupplierAllocatorHandler(deps: Deps): SQSHandler { | |||||
| ); | ||||||
|
|
||||||
| incrementMetric(perAllocationSuccess, supplier, priority); | ||||||
| emitSupCampaignClientMetric( | ||||||
| letterEvent, | ||||||
| supplier, | ||||||
| "supplier_Campaign_Client", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this supposed to be a "constant" value? |
||||||
| deps, | ||||||
| ); | ||||||
| } catch (error) { | ||||||
| deps.logger.error({ | ||||||
| description: "Error processing allocation of record", | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this has already gone in to main?