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

datadog-lambda-js

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datadog-lambda-js - npm Package Compare versions

Comparing version 3.56.0 to 3.57.0

2

dist/constants.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.datadogLambdaVersion = void 0;
exports.datadogLambdaVersion = "3.56.0";
exports.datadogLambdaVersion = "v3.57.0";
//# sourceMappingURL=constants.js.map

@@ -155,3 +155,3 @@ "use strict";

err_1 = _a.sent();
utils_1.logDebug("Failed to start listeners with error " + err_1);
utils_1.logDebug("Failed to start listeners", err_1);
return [3 /*break*/, 5];

@@ -211,3 +211,3 @@ case 5:

err_3 = _a.sent();
utils_1.logDebug("Failed to complete listeners with error " + err_3);
utils_1.logDebug("Failed to complete listeners", err_3);
return [3 /*break*/, 13];

@@ -214,0 +214,0 @@ case 13:

@@ -69,10 +69,10 @@ "use strict";

if (!utils_1.isHTTPError(e_1)) {
utils_1.logDebug("Failed to send metrics " + e_1);
utils_1.logDebug("Failed to send metrics", e_1);
throw e_1;
}
if (e_1.type === utils_1.HTTPErrorType.BadAuth) {
utils_1.logDebug("authorization failed with api key of length " + this.apiKey.length + " characters");
utils_1.logDebug("authorization failed with api key of length " + this.apiKey.length + " characters", e_1);
}
if (e_1.type === utils_1.HTTPErrorType.FailedSend) {
utils_1.logDebug("Failed to send metrics " + e_1.message);
utils_1.logDebug("Failed to send metrics", e_1);
throw Error("Failed to send metrics: " + e_1.message);

@@ -79,0 +79,0 @@ }

@@ -73,3 +73,3 @@ "use strict";

e_1 = _a.sent();
utils_1.logDebug("Agent is not running, returned with error " + JSON.stringify(e_1));
utils_1.logDebug("Agent is not running, returned with error", e_1);
return [2 /*return*/, false];

@@ -98,3 +98,3 @@ case 5: return [2 /*return*/, true];

e_2 = _a.sent();
utils_1.logDebug("Failed to flush agent, returned with error " + e_2);
utils_1.logDebug("Failed to flush agent, returned with error", e_2);
return [2 /*return*/, false];

@@ -101,0 +101,0 @@ case 4: return [2 /*return*/, true];

export declare class KMSService {
private kms?;
constructor();
decrypt(value: string): Promise<string>;
}
//# sourceMappingURL=kms-service.d.ts.map
"use strict";
// In order to avoid the layer adding the 40mb aws-sdk to a deployment, (which is always available
// in the lambda environment anyway), we use require to import the sdk, and return an error if someone
// tries to decrypt a value.
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -41,14 +44,4 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

var utils_1 = require("../utils");
// In order to avoid the layer adding the 40mb aws-sdk to a deployment, (which is always available
// in the lambda environment anyway), we use require to import the sdk, and return an error if someone
// tries to decrypt a value.
var KMSService = /** @class */ (function () {
function KMSService() {
try {
var kmsType = require("aws-sdk").KMS;
this.kms = new kmsType();
}
catch (_a) {
utils_1.logError("optional dependency aws-sdk not installed. KMS key decryption will not work");
}
}

@@ -58,20 +51,27 @@ KMSService.prototype.decrypt = function (value) {

return __awaiter(this, void 0, void 0, function () {
var buffer, encryptionContext, result;
var kmsType, kms, buffer, encryptionContext, result, err_1, errorMsg;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (this.kms === undefined) {
// This error should only occur if the user is running this code outside of the lambda environment,
// (say a local development environment).
throw Error("optional dependency aws-sdk not installed. KMS key decryption will not work");
}
_b.trys.push([0, 2, , 3]);
kmsType = require("aws-sdk/clients/kms");
kms = new kmsType();
buffer = Buffer.from(value, "base64");
encryptionContext = { LambdaFunctionName: (_a = process.env.AWS_LAMBDA_FUNCTION_NAME) !== null && _a !== void 0 ? _a : "" };
return [4 /*yield*/, this.kms.decrypt({ CiphertextBlob: buffer, EncryptionContext: encryptionContext }).promise()];
return [4 /*yield*/, kms.decrypt({ CiphertextBlob: buffer, EncryptionContext: encryptionContext }).promise()];
case 1:
result = _b.sent();
if (result.Plaintext === undefined) {
throw Error("Couldn't decrypt value");
throw Error();
}
return [2 /*return*/, result.Plaintext.toString("ascii")];
case 2:
err_1 = _b.sent();
if (err_1.code === "MODULE_NOT_FOUND") {
errorMsg = "optional dependency aws-sdk not installed. KMS key decryption will not work";
utils_1.logError(errorMsg);
throw Error(errorMsg);
}
throw Error("Couldn't decrypt value");
case 3: return [2 /*return*/];
}

@@ -78,0 +78,0 @@ });

@@ -154,3 +154,3 @@ "use strict";

// to KMS key decryption failing.
utils_1.logError("failed to flush metrics", { innerError: error_1 });
utils_1.logError("failed to flush metrics", error_1);
return [3 /*break*/, 8];

@@ -168,3 +168,3 @@ case 8:

error_2 = _a.sent();
utils_1.logError("failed to flush extension", { innerError: error_2 });
utils_1.logError("failed to flush extension", error_2);
return [3 /*break*/, 12];

@@ -243,3 +243,3 @@ case 12:

error_3 = _a.sent();
utils_1.logError("couldn't decrypt kms api key", { innerError: error_3 });
utils_1.logError("couldn't decrypt kms api key", error_3);
return [3 /*break*/, 4];

@@ -246,0 +246,0 @@ case 4: return [3 /*break*/, 6];

@@ -49,3 +49,3 @@ "use strict";

catch (error) {
utils_1.logError("custom extractor function failed", { error: error });
utils_1.logError("custom extractor function failed", error);
}

@@ -65,3 +65,3 @@ }

catch (error) {
utils_1.logError("couldn't add step function metadata to xray", { innerError: error });
utils_1.logError("couldn't add step function metadata to xray", error);
}

@@ -76,3 +76,3 @@ }

// This might fail if running in an environment where xray isn't set up, (like for local development).
utils_1.logError("couldn't add trace context to xray metadata", { innerError: error });
utils_1.logError("couldn't add trace context to xray metadata", error);
}

@@ -163,3 +163,3 @@ return trace;

client === null || client === void 0 ? void 0 : client.close();
utils_1.logDebug("Error occurred submitting to xray daemon", { error: error });
utils_1.logDebug("Error occurred submitting to xray daemon", error);
}

@@ -206,10 +206,26 @@ }

function readTraceFromLambdaContext(context) {
var _a, _b;
var _a;
if (!context || typeof context !== "object") {
return;
}
var traceData = (_b = (_a = context.clientContext) === null || _a === void 0 ? void 0 : _a.custom) === null || _b === void 0 ? void 0 : _b._datadog;
if (!traceData || typeof traceData !== "object") {
var custom = (_a = context.clientContext) === null || _a === void 0 ? void 0 : _a.custom;
if (!custom || typeof custom !== "object") {
return;
}
var traceData = null;
if (custom.hasOwnProperty("_datadog") &&
typeof custom._datadog === "object" &&
custom._datadog.hasOwnProperty(constants_1.traceIDHeader) &&
custom._datadog.hasOwnProperty(constants_1.parentIDHeader) &&
custom._datadog.hasOwnProperty(constants_1.samplingPriorityHeader)) {
traceData = custom._datadog;
}
else if (custom.hasOwnProperty(constants_1.traceIDHeader) &&
custom.hasOwnProperty(constants_1.parentIDHeader) &&
custom.hasOwnProperty(constants_1.samplingPriorityHeader)) {
traceData = custom;
}
else {
return;
}
var traceID = traceData[constants_1.traceIDHeader];

@@ -216,0 +232,0 @@ if (typeof traceID !== "string") {

@@ -39,4 +39,4 @@ "use strict";

}
catch (_a) {
utils_1.logDebug("Couldn't require dd-trace from main");
catch (err) {
utils_1.logDebug("Couldn't require dd-trace from main", err);
}

@@ -43,0 +43,0 @@ }

@@ -41,3 +41,2 @@ "use strict";

var log_1 = require("./log");
var serialize_error_1 = require("serialize-error");
/**

@@ -50,3 +49,3 @@ * Wraps a lambda handler function, adding an onStart and onComplete hook.

return function (event, context) { return __awaiter(_this, void 0, void 0, function () {
var error_1, innerError, result, handlerError, wrappedHandler, innerError, error_2, error_3, innerError;
var error_1, result, handlerError, wrappedHandler, error_2, error_3;
return __generator(this, function (_a) {

@@ -62,4 +61,4 @@ switch (_a.label) {

error_1 = _a.sent();
innerError = serialize_error_1.serializeError(error_1);
log_1.logError("Pre-lambda hook threw error", { innerError: innerError });
// Swallow the error and continue processing.
log_1.logError("Pre-lambda hook threw error", error_1);
return [3 /*break*/, 3];

@@ -74,4 +73,3 @@ case 3:

catch (error) {
innerError = serialize_error_1.serializeError(error);
log_1.logError("Failed to apply wrap to handler function " + innerError);
log_1.logError("Failed to apply wrap to handler function", error);
}

@@ -103,4 +101,4 @@ _a.label = 4;

error_3 = _a.sent();
innerError = serialize_error_1.serializeError(error_3);
log_1.logError("Post-lambda hook threw error", { innerError: innerError });
// Swallow the error and continue processing.
log_1.logError("Post-lambda hook threw error", error_3);
return [3 /*break*/, 13];

@@ -107,0 +105,0 @@ case 13: return [7 /*endfinally*/];

@@ -13,4 +13,4 @@ export declare enum LogLevel {

export declare function getLogLevel(): LogLevel;
export declare function logDebug(message: string, metadata?: object): void;
export declare function logError(message: string, metadata?: object): void;
export declare function logDebug(message: string, metadata?: Error | object, error?: Error): void;
export declare function logError(message: string, metadata?: Error | object, error?: Error): void;
//# sourceMappingURL=log.d.ts.map

@@ -15,2 +15,3 @@ "use strict";

exports.logError = exports.logDebug = exports.getLogLevel = exports.setLogLevel = exports.setLogger = exports.LogLevel = void 0;
var serialize_error_1 = require("serialize-error");
var LogLevel;

@@ -36,28 +37,33 @@ (function (LogLevel) {

exports.getLogLevel = getLogLevel;
function logDebug(message, metadata) {
function logDebug(message, metadata, error) {
if (logLevel > LogLevel.DEBUG) {
return;
}
message = "datadog:" + message;
if (metadata === undefined) {
logger.debug(JSON.stringify({ status: "debug", message: message }));
}
else {
logger.debug(JSON.stringify(__assign(__assign({}, metadata), { status: "debug", message: message })));
}
emitLog(logger.debug, "debug", message, metadata, error);
}
exports.logDebug = logDebug;
function logError(message, metadata) {
function logError(message, metadata, error) {
if (logLevel > LogLevel.ERROR) {
return;
}
emitLog(logger.error, "error", message, metadata, error);
}
exports.logError = logError;
function emitLog(outputter, status, message, metadata, error) {
message = "datadog:" + message;
if (metadata === undefined) {
logger.error(JSON.stringify({ status: "error", message: message }));
var output = { status: status, message: message };
if (metadata instanceof Error && error === undefined) {
// allow for log*(message), log*("message", metadata), log*("message", error), and log*("message", metadata, error)
error = metadata;
metadata = undefined;
}
else {
logger.error(JSON.stringify(__assign(__assign({}, metadata), { status: "error", message: message })));
if (metadata !== undefined) {
output = __assign(__assign({}, output), metadata);
}
if (error !== undefined) {
var errorInfo = serialize_error_1.serializeError(error);
output = __assign(__assign({}, output), errorInfo);
}
outputter(JSON.stringify(output));
}
exports.logError = logError;
//# sourceMappingURL=log.js.map
{
"name": "datadog-lambda-js",
"version": "3.56.0",
"version": "v3.57.0",
"description": "Lambda client library that supports hybrid tracing in node js",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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