From d9a3e56bc27d5e613884addbdfe5dfe23f30e51a Mon Sep 17 00:00:00 2001 From: Laurin Quast Date: Wed, 28 Aug 2024 09:51:10 +0200 Subject: [PATCH] fix metrics --- .../services/usage/src/usage-processor-2.ts | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/packages/services/usage/src/usage-processor-2.ts b/packages/services/usage/src/usage-processor-2.ts index fa59a7575c..437da385d8 100644 --- a/packages/services/usage/src/usage-processor-2.ts +++ b/packages/services/usage/src/usage-processor-2.ts @@ -79,12 +79,28 @@ export function usageProcessorV2( const operationMapRecord = incoming.map[operationMapKey] as OperationMapRecord | undefined; if (!operationMapRecord) { + logger.warn( + `Detected invalid operation. Operation map key could not be found. (target=%s): %s`, + token.target, + operationMapKey, + ); + invalidRawOperations + .labels({ + reason: 'operation_map_key_not_found', + }) + .inc(1); return null; } let newOperationMapKey = newKeyMappings.get(operationMapRecord); if (!isValidOperationBody(operationMapRecord.operation)) { + logger.warn(`Detected invalid operation (target=%s): %s`, operationMapKey); + invalidRawOperations + .labels({ + reason: 'invalid_operation_body', + }) + .inc(1); return null; } @@ -115,16 +131,6 @@ export function usageProcessorV2( // if the record does not exist -> skip the operation if (operationMapKey === null) { - logger.warn( - `Detected invalid operation. Operation map key could not be found. (target=%s): %s`, - token.target, - operation.operationMapKey, - ); - invalidRawOperations - .labels({ - reason: 'operation_map_key_not_found', - }) - .inc(1); continue; } @@ -163,16 +169,6 @@ export function usageProcessorV2( // if the record does not exist -> skip the operation if (operationMapKey === null) { - logger.warn( - `Detected invalid operation. Operation map key could not be found. (target=%s): %s`, - token.target, - operation.operationMapKey, - ); - invalidRawOperations - .labels({ - reason: 'operation_map_key_not_found', - }) - .inc(1); continue; }