Skip to content

Commit

Permalink
fix metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ru4l committed Aug 28, 2024
1 parent 7b01304 commit d9a3e56
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions packages/services/usage/src/usage-processor-2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit d9a3e56

Please sign in to comment.