Skip to content

Commit

Permalink
Improve logs and fix postprocessing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Siegrift committed Sep 25, 2023
1 parent 82fdf02 commit 43b678c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/api/src/in-memory-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const putAll = async (signedDataArray: SignedData[]) => {
// performance reasons, because it only looks to prune the data that for beacons that have been just inserted.
export const prune = async (signedDataArray: SignedData[], maxIgnoreAfterTimestamp: number) => {
const beaconsToPrune = uniqBy(signedDataArray, 'beaconId');
logger.debug('Pruning signed data', { beaconsToPrune, maxIgnoreAfterTimestamp });
logger.debug('Pruning signed data', { maxIgnoreAfterTimestamp });
const signedDataCache = getCache();

for (const beacon of beaconsToPrune) {
Expand All @@ -86,7 +86,7 @@ export const prune = async (signedDataArray: SignedData[], maxIgnoreAfterTimesta
// It is enough to keep only the freshest signed data for each beacon.
const removeCount = Math.max(0, signedDatas.length - 1);
if (removeCount) {
logger.debug('Pruning signed data for beacon', { beacon, signedDatas });
logger.debug('Pruning signed data for beacon', { beacon, signedDatas, removeCount });
signedDataCache[airnode]![templateId] = allSignedDatas.slice(removeCount);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/data-pusher/config/pusher.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"postProcessingSpecifications": [
{
"environment": "Node",
"value": "const output = input.data[input.parameters.name].value;",
"value": "const output = input[endpointParameters.name].value;",
"timeoutMs": 5000
}
]
Expand Down
9 changes: 5 additions & 4 deletions packages/data-pusher/src/api-requests/data-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ type TemplateResponse = [TemplateId, node.HttpGatewayApiCallSuccessResponse];
type TemplateResponses = TemplateResponse[];

export const callApi = async (payload: node.ApiCallPayload) => {
getLogger().debug('Preprocessing API call payload', payload);
getLogger().debug('Preprocessing API call payload', { aggregateApiCall: payload.aggregatedApiCall });
const processedPayload = await preProcessApiSpecifications(payload);
getLogger().debug('Performing API call', processedPayload);
getLogger().debug('Performing API call', { aggregateApiCall: payload.aggregatedApiCall });
return node.api.performApiCall(processedPayload);
};

Expand Down Expand Up @@ -72,12 +72,13 @@ export const makeTemplateRequests = async (signedApiUpdate: SignedApiUpdate): Pr
aggregatedApiCall,
};

getLogger().debug('Processing successful API call', { apiCallResponse });
getLogger().debug('Processing successful API call', { templateId, operationTemplateId });
const [_, response] = await node.api.processSuccessfulApiCall(payload, apiCallResponse);

if (!response.success) {
const message = `Failed to post process successful API call`;
getLogger().warn(message, { templateId, operationTemplateId });
getLogger().warn(message, { templateId, operationTemplateId, errorMessage: response.errorMessage });
process.exit(1);
return null;
}
return [templateId, response];
Expand Down
4 changes: 2 additions & 2 deletions packages/data-pusher/src/api-requests/signed-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export const postSignedApiData = async (group: SignedApiNameUpdateDelayGroup) =>

if (!goRes.success) {
getLogger().warn(
`Failed to post payload to update signed API.`,
// See: https://axios-http.com/docs/handling_errors
`Failed to post payload to update signed API. Err: ${goRes.error}, axios response: ${goRes.error.response}`,
logContext
{ ...logContext, axiosResponse: goRes.error.response }
);
return;
}
Expand Down
5 changes: 2 additions & 3 deletions packages/data-pusher/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import { initializeLogger } from './logger';

export async function main() {
const config = await loadConfig();
const logger = initializeLogger(config);
const state = initializeState(config);
logger.info('Initalized state', { config, state });
initializeLogger(config);
initializeState(config);

initializeWallet();
initiateFetchingBeaconData();
Expand Down

0 comments on commit 43b678c

Please sign in to comment.