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
117
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 8.111.0 to 9.112.0

2

dist/constants.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.STREAM_RESPONSE = exports.HANDLER_STREAMING = exports.datadogLambdaVersion = void 0;
exports.datadogLambdaVersion = "8.111.0";
exports.datadogLambdaVersion = "9.112.0";
// Response streaming functions

@@ -6,0 +6,0 @@ exports.HANDLER_STREAMING = Symbol.for("aws.lambda.runtime.handler.streaming");

@@ -14,2 +14,5 @@ import { SpanContextWrapper } from "./span-context-wrapper";

}
export declare const TRACE_ID = "traceId";
export declare const PARENT_ID = "spanId";
export declare const DD_P_TID = "_dd.p.tid";
export declare class StepFunctionContextService {

@@ -23,6 +26,6 @@ private static _instance;

get spanContext(): SpanContextWrapper | null;
private deterministicMd5HashToBigIntString;
private deterministicMd5HashInBinary;
private hexToBinary;
private deterministicSha256HashToBigIntString;
private deterministicSha256Hash;
private numberToBinaryString;
}
//# sourceMappingURL=step-function-service.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StepFunctionContextService = void 0;
var ts_md5_1 = require("ts-md5");
exports.StepFunctionContextService = exports.DD_P_TID = exports.PARENT_ID = exports.TRACE_ID = void 0;
var utils_1 = require("../utils");
var trace_context_service_1 = require("./trace-context-service");
var span_context_wrapper_1 = require("./span-context-wrapper");
var sha256_js_1 = require("@aws-crypto/sha256-js");
exports.TRACE_ID = "traceId";
exports.PARENT_ID = "spanId";
exports.DD_P_TID = "_dd.p.tid";
var StepFunctionContextService = /** @class */ (function () {

@@ -105,19 +108,31 @@ function StepFunctionContextService(event) {

return null;
var traceId = this.deterministicMd5HashToBigIntString(this.context["step_function.execution_id"]);
var parentId = this.deterministicMd5HashToBigIntString(this.context["step_function.execution_id"] +
var traceId = this.deterministicSha256HashToBigIntString(this.context["step_function.execution_id"], exports.TRACE_ID);
var parentId = this.deterministicSha256HashToBigIntString(this.context["step_function.execution_id"] +
"#" +
this.context["step_function.state_name"] +
"#" +
this.context["step_function.state_entered_time"]);
this.context["step_function.state_entered_time"], exports.PARENT_ID);
var sampleMode = trace_context_service_1.SampleMode.AUTO_KEEP;
var spanContext = span_context_wrapper_1.SpanContextWrapper.fromTraceContext({
traceId: traceId,
parentId: parentId,
sampleMode: sampleMode,
source: trace_context_service_1.TraceSource.Event,
});
if (spanContext === null)
try {
// Try requiring class from the tracer.
var _DatadogSpanContext = require("dd-trace/packages/dd-trace/src/opentracing/span_context");
var id = require("dd-trace/packages/dd-trace/src/id");
var ddSpanContext = new _DatadogSpanContext({
traceId: id(traceId, 10),
spanId: id(parentId, 10),
sampling: { priority: sampleMode.toString(2) },
});
var ptid = this.deterministicSha256HashToBigIntString(this.context["step_function.execution_id"], exports.DD_P_TID);
ddSpanContext._trace.tags["_dd.p.tid"] = id(ptid, 10).toString(16);
if (ddSpanContext === null)
return null;
(0, utils_1.logDebug)("Extracted trace context from StepFunctionContext", { traceContext: ddSpanContext });
return new span_context_wrapper_1.SpanContextWrapper(ddSpanContext, trace_context_service_1.TraceSource.Event);
}
catch (error) {
if (error instanceof Error) {
(0, utils_1.logDebug)("Couldn't generate SpanContext with tracer.", error);
}
return null;
(0, utils_1.logDebug)("Extracted trace context from StepFunctionContext", { traceContext: this.context });
return spanContext;
}
},

@@ -127,15 +142,19 @@ enumerable: false,

});
StepFunctionContextService.prototype.deterministicMd5HashToBigIntString = function (s) {
var binaryString = this.deterministicMd5HashInBinary(s);
StepFunctionContextService.prototype.deterministicSha256HashToBigIntString = function (s, type) {
var binaryString = this.deterministicSha256Hash(s, type);
return BigInt("0b" + binaryString).toString();
};
StepFunctionContextService.prototype.deterministicMd5HashInBinary = function (s) {
// Md5 here is used here because we don't need a cryptographically secure hashing method but to generate the same trace/span ids as the backend does
var hex = ts_md5_1.Md5.hashStr(s);
var binary = "";
for (var i = 0; i < hex.length; i++) {
var ch = hex.charAt(i);
binary = binary + this.hexToBinary(ch);
StepFunctionContextService.prototype.deterministicSha256Hash = function (s, type) {
// returns 128 bits hash unless mostSignificant64Bits options is set to true.
var _this = this;
var hash = new sha256_js_1.Sha256();
hash.update(s);
var uint8Array = hash.digestSync();
// type === SPAN_ID || type === DD_P_TID
var intArray = uint8Array.subarray(0, 8);
if (type === exports.TRACE_ID) {
intArray = uint8Array.subarray(8, 16);
}
var res = "0" + binary.substring(1, 64);
var binaryString = intArray.reduce(function (acc, num) { return acc + _this.numberToBinaryString(num); }, "");
var res = "0" + binaryString.substring(1, 64);
if (res === "0".repeat(64)) {

@@ -146,4 +165,4 @@ return "1";

};
StepFunctionContextService.prototype.hexToBinary = function (hex) {
return parseInt(hex, 16).toString(2).padStart(4, "0");
StepFunctionContextService.prototype.numberToBinaryString = function (num) {
return num.toString(2).padStart(8, "0");
};

@@ -150,0 +169,0 @@ return StepFunctionContextService;

{
"name": "datadog-lambda-js",
"version": "8.111.0",
"version": "9.112.0",
"description": "Lambda client library that supports hybrid tracing in node js",

@@ -28,3 +28,3 @@ "main": "dist/index.js",

"@types/mock-fs": "4.13.0",
"@types/node": "^15.6.1",
"@types/node": "^20.12.10",
"@types/promise-retry": "^1.1.3",

@@ -42,2 +42,3 @@ "@types/shimmer": "^1.0.1",

"dependencies": {
"@aws-crypto/sha256-js": "5.2.0",
"dc-polyfill": "^0.1.3",

@@ -47,4 +48,3 @@ "hot-shots": "8.5.0",

"serialize-error": "^8.1.0",
"shimmer": "1.2.1",
"ts-md5": "1.3.1"
"shimmer": "1.2.1"
},

@@ -51,0 +51,0 @@ "jest": {

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