Skip to content

Commit

Permalink
chore: lint fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik committed Mar 26, 2024
1 parent d10e813 commit b4266e1
Show file tree
Hide file tree
Showing 62 changed files with 311 additions and 310 deletions.
30 changes: 15 additions & 15 deletions benchmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const cdkV2Handler = require('../src/cdk/v2/handler');

const supportedDestinations = ['algolia', 'pinterest_tag'];

logger.info();
logger.infow();

const command = new Commander.Command();
command
Expand Down Expand Up @@ -52,10 +52,10 @@ const getTestData = (intgList, fileNameSuffixes) => {
}),
);
} catch (err) {
// logger.error(
// logger.errorw(
// `Unable to load the data for: "${intg}" suffix: "${fileNameSuffix}"`
// );
// logger.error(`Raw error: "${err}"`);
// logger.errorw(`Raw error: "${err}"`);
}
});
});
Expand All @@ -69,8 +69,8 @@ const destinationsList = cmdOpts.destinations
.split(',')
.map((x) => x.trim())
.filter((x) => x !== '');
logger.info('Destinations:', destinationsList, 'feature:', cmdOpts.feature);
logger.info();
logger.infow('Destinations:', destinationsList, 'feature:', cmdOpts.feature);
logger.infow();
const destDataset = getTestData(destinationsList, ['_input', '']);

const nativeDestHandlers = {};
Expand Down Expand Up @@ -99,9 +99,9 @@ async function initializeHandlers() {
}

async function runDataset(suitDesc, input, intg, params) {
logger.info('==========================================');
logger.info(suitDesc);
logger.info('==========================================');
logger.infow('==========================================');
logger.infow(suitDesc);
logger.infow('==========================================');

const results = {};
const suite = new Benchmark(suitDesc, benchmarkType);
Expand All @@ -113,7 +113,7 @@ async function runDataset(suitDesc, input, intg, params) {
try {
await handler(...args);
} catch (err) {
// logger.info(err);
// logger.infow(err);
// Do nothing
}
});
Expand All @@ -124,31 +124,31 @@ async function runDataset(suitDesc, input, intg, params) {
results[result.end.name] = { stats: result.end.stats };
})
.on('complete', (result) => {
logger.info(
logger.infow(
benchmarkType === 'Operations' ? 'Fastest: ' : 'Memory intensive: ',
`"${result.end.name}"`,
);
logger.info();
logger.infow();
Object.keys(results).forEach((impl) => {
logger.info(`"${impl}" - `, suite.formatStats(results[impl].stats));
logger.infow(`"${impl}" - `, suite.formatStats(results[impl].stats));

if (result.end.name !== impl) {
if (benchmarkType === 'Operations') {
logger.info(
logger.infow(
`-> "${result.end.name}" is faster by ${(
results[impl].stats.mean / result.end.stats.mean
).toFixed(1)} times to "${impl}"`,
);
} else {
logger.info(
logger.infow(
`-> "${result.end.name}" consumed ${(
result.end.stats.mean / results[impl].stats.mean
).toFixed(1)} times memory compared to "${impl}"`,
);
}
}

logger.info();
logger.infow();
});
});

Expand Down
6 changes: 3 additions & 3 deletions benchmark/metaLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ logger.setLogLevel(Number.POSITIVE_INFINITY);

const debug = (...args) => {
logger.setLogLevel(logger.levelDebug);
logger.debug(...args);
logger.debugw(...args);
logger.setLogLevel(Number.POSITIVE_INFINITY);
};

const info = (...args) => {
logger.setLogLevel(logger.levelInfo);
logger.info(...args);
logger.infow(...args);
logger.setLogLevel(Number.POSITIVE_INFINITY);
};

Expand All @@ -24,7 +24,7 @@ const warn = (...args) => {

const error = (...args) => {
logger.setLogLevel(logger.levelError);
logger.error(...args);
logger.errorw(...args);
logger.setLogLevel(Number.POSITIVE_INFINITY);
};

Expand Down
2 changes: 1 addition & 1 deletion src/adapters/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const lodash = require('lodash');
const http = require('http');
const https = require('https');
const axios = require('axios');
const log = require('../logger');
const log = require('@rudderstack/integrations-lib/build/structured-logger');
const stats = require('../util/stats');
const { removeUndefinedValues } = require('../v0/util');
const { processAxiosResponse } = require('./utils/networkUtils');
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path';
import fs from 'fs/promises';
import { WorkflowExecutionError, WorkflowCreationError } from '@rudderstack/workflow-engine';
import { PlatformError } from '@rudderstack/integrations-lib';
import logger from '../../logger';
import logger from '@rudderstack/integrations-lib/build/structured-logger';
import { generateErrorObject } from '../../v0/util';
import tags from '../../v0/util/tags';
import { CatchErr } from '../../util/types';
Expand Down
32 changes: 16 additions & 16 deletions src/controllers/bulkUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const getReqMetadata = (ctx) => {
};

export const fileUpload = async (ctx) => {
logger.debug(
logger.debugw(
'Native(Bulk-Upload): Request to transformer:: /fileUpload route',
JSON.stringify(ctx.request.body),
ctx.request.body,
);
const getReqMetadataFileUpload = () => {
try {
Expand Down Expand Up @@ -69,17 +69,17 @@ export const fileUpload = async (ctx) => {
});
}
ctx.body = response;
logger.debug(
logger.debugw(
'Native(Bulk-Upload): Response from transformer:: /fileUpload route',
JSON.stringify(ctx.body),
ctx.body,
);
return ctx.body;
};

export const pollStatus = async (ctx) => {
logger.debug(
logger.debugw(
'Native(Bulk-Upload): Request to transformer:: /pollStatus route',
JSON.stringify(ctx.request.body),
ctx.request.body,
);

const { destType }: ContextBodySimple = ctx.request.body;
Expand All @@ -104,17 +104,17 @@ export const pollStatus = async (ctx) => {
});
}
ctx.body = response;
logger.debug(
logger.debugw(
'Native(Bulk-Upload): Request from transformer:: /pollStatus route',
JSON.stringify(ctx.body),
ctx.body,
);
return ctx.body;
};

export const getWarnJobStatus = async (ctx) => {
logger.debug(
logger.debugw(
'Native(Bulk-Upload): Request to transformer:: /getWarningJobs route',
JSON.stringify(ctx.request.body),
ctx.request.body,
);

const { destType }: ContextBodySimple = ctx.request.body;
Expand All @@ -140,17 +140,17 @@ export const getWarnJobStatus = async (ctx) => {
});
}
ctx.body = response;
logger.debug(
logger.debugw(
'Native(Bulk-Upload): Request from transformer:: /getWarningJobs route',
JSON.stringify(ctx.body),
ctx.body,
);
return ctx.body;
};

export const getFailedJobStatus = async (ctx) => {
logger.debug(
logger.debugw(
'Native(Bulk-Upload): Request to transformer:: /getFailedJobs route',
JSON.stringify(ctx.request.body),
ctx.request.body,
);

const { destType }: ContextBodySimple = ctx.request.body;
Expand All @@ -176,9 +176,9 @@ export const getFailedJobStatus = async (ctx) => {
});
}
ctx.body = response;
logger.debug(
logger.debugw(
'Native(Bulk-Upload): Request from transformer:: /getFailedJobs route',
JSON.stringify(ctx.body),
ctx.body,
);
return ctx.body;
};
12 changes: 6 additions & 6 deletions src/controllers/delivery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const NON_DETERMINABLE = 'Non-determinable';

export class DeliveryController {
public static async deliverToDestination(ctx: Context) {
logger.debug('Native(Delivery):: Request to transformer::', JSON.stringify(ctx.request.body));
logger.debug('Native(Delivery):: Request to transformer::', ctx.request.body);
let deliveryResponse: DeliveryResponse;
const requestMetadata = MiscService.getRequestMetadata(ctx);
const deliveryRequest = ctx.request.body as ProxyDeliveryRequest;
Expand Down Expand Up @@ -51,12 +51,12 @@ export class DeliveryController {
ctx.body = { output: deliveryResponse };
ControllerUtility.deliveryPostProcess(ctx, deliveryResponse.status);

logger.debug('Native(Delivery):: Response from transformer::', JSON.stringify(ctx.body));
logger.debug('Native(Delivery):: Response from transformer::', ctx.body);
return ctx;
}

public static async deliverToDestinationV1(ctx: Context) {
logger.debug('Native(Delivery):: Request to transformer::', JSON.stringify(ctx.request.body));
logger.debug('Native(Delivery):: Request to transformer::', ctx.request.body);
let deliveryResponse: DeliveriesResponse;
const requestMetadata = MiscService.getRequestMetadata(ctx);
const deliveryRequest = ctx.request.body as ProxyDeliveriesRequest;
Expand Down Expand Up @@ -86,14 +86,14 @@ export class DeliveryController {
ctx.body = { output: deliveryResponse };
ControllerUtility.deliveryPostProcess(ctx, deliveryResponse.status);

logger.debug('Native(Delivery):: Response from transformer::', JSON.stringify(ctx.body));
logger.debug('Native(Delivery):: Response from transformer::', ctx.body);
return ctx;
}

public static async testDestinationDelivery(ctx: Context) {
logger.debug(
'Native(Delivery-Test):: Request to transformer::',
JSON.stringify(ctx.request.body),
ctx.request.body,
);
const { destination }: { destination: string } = ctx.params;
const { version }: { version: string } = ctx.params;
Expand All @@ -112,7 +112,7 @@ export class DeliveryController {
);
ctx.body = { output: response };
ControllerUtility.postProcess(ctx);
logger.debug('Native(Delivery-Test):: Response from transformer::', JSON.stringify(ctx.body));
logger.debug('Native(Delivery-Test):: Response from transformer::', ctx.body);
return ctx;
}
}
10 changes: 5 additions & 5 deletions src/controllers/destination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class DestinationController {
const startTime = new Date();
logger.info(
'Native(Process-Transform):: Requst to transformer::',
JSON.stringify(ctx.request.body),
ctx.request.body,
);
let resplist: ProcessorTransformationResponse[];
const requestMetadata = MiscService.getRequestMetadata(ctx);
Expand Down Expand Up @@ -70,7 +70,7 @@ export class DestinationController {
ControllerUtility.postProcess(ctx);
logger.info(
'Native(Process-Transform):: Response from transformer::',
JSON.stringify(ctx.body),
ctx.body,
);
stats.histogram('dest_transform_output_events', resplist.length, {
destination,
Expand Down Expand Up @@ -142,7 +142,7 @@ export class DestinationController {
});
logger.info(
'Native(Router-Transform):: Response from transformer::',
JSON.stringify(ctx.body),
ctx.body,
);
stats.timing('dest_transform_request_latency', startTime, {
destination,
Expand All @@ -156,7 +156,7 @@ export class DestinationController {
public static batchProcess(ctx: Context) {
logger.info(
'Native(Process-Transform-Batch):: Requst to transformer::',
JSON.stringify(ctx.request.body),
ctx.request.body,
);
const startTime = new Date();
const requestMetadata = MiscService.getRequestMetadata(ctx);
Expand Down Expand Up @@ -191,7 +191,7 @@ export class DestinationController {
ControllerUtility.postProcess(ctx);
logger.info(
'Native(Process-Transform-Batch):: Response from transformer::',
JSON.stringify(ctx.body),
ctx.body,
);
stats.timing('dest_transform_request_latency', startTime, {
destination,
Expand Down
20 changes: 10 additions & 10 deletions src/controllers/obs.delivery.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

const match = require('match-json');
const jsonDiff = require('json-diff');
const logger = require('@rudderstack/integrations-lib/build/structured-logger');
const networkHandlerFactory = require('../adapters/networkHandlerFactory');
const { getPayloadData } = require('../adapters/network');
const { generateErrorObject } = require('../v0/util');
const logger = require('../logger');
const tags = require('../v0/util/tags');
const stats = require('../util/stats');

Expand Down Expand Up @@ -60,26 +60,26 @@ const DestProxyController = {
destination,
});

logger.error(`[TransformerProxyTest] Destination request payload mismatch!`);
logger.error(
logger.errorw(`[TransformerProxyTest] Destination request payload mismatch!`);
logger.errorw(
`[TransformerProxyTest] Delivery payload (router): ${JSON.stringify(
routerDeliveryPayload,
)}`,
);
logger.error(
logger.errorw(
`[TransformerProxyTest] Destination request payload (router): ${JSON.stringify(
routerDestReqPayload,
)}`,
);
logger.error(
logger.errorw(
`[TransformerProxyTest] Destination request payload (proxy): ${JSON.stringify(
proxyDestReqPayload,
)} `,
);

// Compute output difference
const outputDiff = jsonDiff.diffString(routerDestReqPayload, proxyDestReqPayload);
logger.error(
logger.errorw(
`[TransformerProxyTest] Destination request payload difference: ${outputDiff}`,
);
response = {
Expand All @@ -102,14 +102,14 @@ const DestProxyController = {
[tags.TAG_NAMES.FEATURE]: tags.FEATURES.DATA_DELIVERY,
}, false);
response.message = `[TransformerProxyTest] Error occurred while testing proxy for destination ("${destination}"): "${err.message}"`;
logger.error(response.message);
logger.error(err);
logger.error(
logger.errorw(response.message);
logger.errorw(err);
logger.errorw(
`[TransformerProxyTest] Delivery payload (router): ${JSON.stringify(
routerDeliveryPayload,
)}`,
);
logger.error(
logger.errorw(
`[TransformerProxyTest] Destination request payload (router): ${JSON.stringify(
routerDestReqPayload,
)}`,
Expand Down
Loading

0 comments on commit b4266e1

Please sign in to comment.