Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@janiscommerce/log

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@janiscommerce/log - npm Package Compare versions

Comparing version 5.0.4 to 5.0.5

34

lib/firehose-instance.js

@@ -130,30 +130,30 @@ /* eslint-disable max-len */

return this.put();
}
const initialBatchSize = this.batchSize[1];
/**
* @private
*/
async put(retry = 1) {
const promises = [];
const recordsLength = this.recordsToPut.length;
for(let offset = 0; offset < logs.length; offset += initialBatchSize)
promises.push(this.putBatch(logs.slice(offset, offset + initialBatchSize)));
if(!recordsLength)
return; // no hay más records para enviar (se enviaron ok o fallaron el máximo de veces posible)
await Promise.allSettled(promises);
}
const batchRecords = this.recordsToPut.slice(0, this.batchSize[retry]);
async putBatch(batch, attemptNumber = 1) {
const response = await this.putRecordBatch(batchRecords);
const response = await this.putRecordBatch(batch);
if(response?.FailedPutCount) {
if(this.batchSize[retry + 1])
return this.put(retry + 1);
const nextBatchSize = this.batchSize[attemptNumber + 1];
logger.error(`Error creating #${batchRecords.length} Trace logs - retry #${retry}/5 - ${response.Message || 'retry limit reached'}}`);
}
if(!nextBatchSize)
return logger.error('Failed to create a log');
this.recordsToPut = this.recordsToPut.slice(this.batchSize[retry]); // elimina el batch, funcionó o falló el máximo de veces, para intentear enviar lo que queda en this.recordsToPut
const promises = [];
return this.put(); // no se envía retry porque funciono o no, pero ese bloque ya no se envía más
for(let offset = 0; offset < batch.length; offset += nextBatchSize)
promises.push(this.putBatch(batch.slice(offset, offset + nextBatchSize), attemptNumber + 1));
await Promise.allSettled(promises);
}
}

@@ -160,0 +160,0 @@

@@ -40,2 +40,4 @@ 'use strict';

const MAX_LOGS_PER_LOCAL_BATCH = 100;
module.exports = class Log {

@@ -92,3 +94,3 @@

if(process.env.JANIS_TRACE_EXTENSION_ENABLED)
if(process.env.JANIS_TRACE_EXTENSION_ENABLED && logs.length < MAX_LOGS_PER_LOCAL_BATCH)
return this.addLogsLocally(logs, client);

@@ -122,21 +124,15 @@

const MAX_LOGS_PER_BATCH = 100;
const formattedLogs = this.getValidatedLogs(logs, client);
for(let offset = 0; offset < logs.length; offset += MAX_LOGS_PER_BATCH) {
try {
const formattedLogs = this.getValidatedLogs(logs.slice(offset, offset + MAX_LOGS_PER_BATCH), client);
// Local server implemented in Trace Lambda Layer
await axios.post('http://127.0.0.1:8585/logs', { logs: formattedLogs }, { timeout: 300 });
try {
} catch(err) {
// Local server implemented in Trace Lambda Layer
await axios.post('http://127.0.0.1:8585/logs', { logs: formattedLogs }, { timeout: 300 });
// If local server fails, go straight to Firehose
logger.error(`Failed to save ${logs.length} logs locally. Fallbacking to Firehose.`, err);
} catch(err) {
// If local server fails, go straight to Firehose
logger.error(`Failed to save ${logs.length} logs locally. Fallbacking to Firehose.`, err);
await this.putFirehoseRecords(formattedLogs);
}
await this.putFirehoseRecords(formattedLogs);
}

@@ -143,0 +139,0 @@

{
"name": "@janiscommerce/log",
"version": "5.0.4",
"version": "5.0.5",
"description": "A package for creating logs in Janis Trace Service",

@@ -5,0 +5,0 @@ "main": "lib/log.js",

@@ -42,7 +42,4 @@ export = FirehoseInstance;

private recordsToPut;
putBatch(batch: any, attemptNumber?: number): Promise<any>;
/**
* @private
*/
private put;
/**
* @param {LogData[]} records

@@ -49,0 +46,0 @@ * @private

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc