datadog-lambda-js
Advanced tools
Comparing version
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.STREAM_RESPONSE = exports.HANDLER_STREAMING = exports.datadogLambdaVersion = void 0; | ||
exports.datadogLambdaVersion = "9.117.0"; | ||
exports.datadogLambdaVersion = "9.118.0"; | ||
// Response streaming functions | ||
@@ -6,0 +6,0 @@ exports.HANDLER_STREAMING = Symbol.for("aws.lambda.runtime.handler.streaming"); |
@@ -65,2 +65,3 @@ import { Context } from "aws-lambda"; | ||
private lambdaSpanParentContext?; | ||
private spanPointerAttributesList; | ||
get currentTraceHeaders(): Partial<import(".").DatadogTraceHeaders>; | ||
@@ -67,0 +68,0 @@ constructor(config: TraceConfig); |
@@ -49,2 +49,13 @@ "use strict"; | ||
}; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -68,2 +79,3 @@ exports.TraceListener = void 0; | ||
var http_1 = require("./context/extractors/http"); | ||
var span_pointers_1 = require("../utils/span-pointers"); | ||
var TraceListener = /** @class */ (function () { | ||
@@ -86,3 +98,3 @@ function TraceListener(config) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var tracerInitialized, spanContextWrapper, parentSpanContext; | ||
var tracerInitialized, spanContextWrapper, parentSpanContext, eventSource; | ||
return __generator(this, function (_b) { | ||
@@ -125,4 +137,6 @@ switch (_b.label) { | ||
this.context = context; | ||
this.triggerTags = (0, trigger_1.extractTriggerTags)(event, context); | ||
eventSource = (0, trigger_1.parseEventSource)(event); | ||
this.triggerTags = (0, trigger_1.extractTriggerTags)(event, context, eventSource); | ||
this.stepFunctionContext = step_function_service_1.StepFunctionContextService.instance().context; | ||
this.spanPointerAttributesList = (0, span_pointers_1.getSpanPointerAttributes)(eventSource, event); | ||
return [2 /*return*/]; | ||
@@ -144,3 +158,4 @@ } | ||
TraceListener.prototype.onEndingInvocation = function (event, result, isResponseStreamFunction) { | ||
var _a, _b; | ||
var e_1, _a; | ||
var _b, _c; | ||
// Guard clause if something has gone horribly wrong | ||
@@ -162,4 +177,4 @@ // so we won't crash user code. | ||
: this.wrappedCurrentSpan, | ||
lambdaFunctionName: (_a = this.context) === null || _a === void 0 ? void 0 : _a.functionName, | ||
currentSpanStartTime: (_b = this.wrappedCurrentSpan) === null || _b === void 0 ? void 0 : _b.startTime(), | ||
lambdaFunctionName: (_b = this.context) === null || _b === void 0 ? void 0 : _b.functionName, | ||
currentSpanStartTime: (_c = this.wrappedCurrentSpan) === null || _c === void 0 ? void 0 : _c.startTime(), | ||
minDuration: this.config.minColdStartTraceDuration, | ||
@@ -188,2 +203,17 @@ ignoreLibs: this.config.coldStartTraceSkipLib, | ||
} | ||
if (this.wrappedCurrentSpan && this.spanPointerAttributesList) { | ||
try { | ||
for (var _d = __values(this.spanPointerAttributesList), _e = _d.next(); !_e.done; _e = _d.next()) { | ||
var attributes = _e.value; | ||
this.wrappedCurrentSpan.span.addSpanPointer(attributes.kind, attributes.direction, attributes.hash); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_e && !_e.done && (_a = _d.return)) _a.call(_d); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
} | ||
return false; | ||
@@ -190,0 +220,0 @@ }; |
import { SpanContextWrapper } from "./span-context-wrapper"; | ||
interface NestedStepFunctionContext { | ||
execution_id: string; | ||
redrive_count: string; | ||
state_entered_time: string; | ||
@@ -11,2 +12,3 @@ state_name: string; | ||
execution_id: string; | ||
redrive_count: string; | ||
state_entered_time: string; | ||
@@ -20,2 +22,3 @@ state_name: string; | ||
execution_id: string; | ||
redrive_count: string; | ||
state_entered_time: string; | ||
@@ -22,0 +25,0 @@ state_name: string; |
@@ -65,3 +65,3 @@ "use strict"; | ||
return; | ||
var execution_id = stateMachineContext.execution_id, state_entered_time = stateMachineContext.state_entered_time, state_name = stateMachineContext.state_name; | ||
var execution_id = stateMachineContext.execution_id, redrive_count = stateMachineContext.redrive_count, state_entered_time = stateMachineContext.state_entered_time, state_name = stateMachineContext.state_name; | ||
if (typeof event["serverless-version"] === "string" && event["serverless-version"] === "v1") { | ||
@@ -71,2 +71,3 @@ if (typeof event.RootExecutionId === "string") { | ||
execution_id: execution_id, | ||
redrive_count: redrive_count, | ||
state_entered_time: state_entered_time, | ||
@@ -81,2 +82,3 @@ state_name: state_name, | ||
execution_id: execution_id, | ||
redrive_count: redrive_count, | ||
state_entered_time: state_entered_time, | ||
@@ -91,3 +93,3 @@ state_name: state_name, | ||
else { | ||
this.context = { execution_id: execution_id, state_entered_time: state_entered_time, state_name: state_name }; | ||
this.context = { execution_id: execution_id, redrive_count: redrive_count, state_entered_time: state_entered_time, state_name: state_name }; | ||
} | ||
@@ -117,3 +119,9 @@ }; | ||
} | ||
var parentId = this.deterministicSha256HashToBigIntString(this.context.execution_id + "#" + this.context.state_name + "#" + this.context.state_entered_time, exports.PARENT_ID); | ||
var redrivePostfix = this.context.redrive_count === "0" ? "" : "#".concat(this.context.redrive_count); | ||
var parentId = this.deterministicSha256HashToBigIntString(this.context.execution_id + | ||
"#" + | ||
this.context.state_name + | ||
"#" + | ||
this.context.state_entered_time + | ||
redrivePostfix, exports.PARENT_ID); | ||
var sampleMode = trace_context_service_1.SampleMode.AUTO_KEEP; | ||
@@ -174,2 +182,3 @@ try { | ||
execution_id: event.Execution.Id, | ||
redrive_count: event.Execution.RedriveCount.toString(), | ||
state_entered_time: event.State.EnteredTime, | ||
@@ -183,6 +192,7 @@ state_name: event.State.Name, | ||
StepFunctionContextService.prototype.isValidContextObject = function (context) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d; | ||
return (typeof ((_a = context === null || context === void 0 ? void 0 : context.Execution) === null || _a === void 0 ? void 0 : _a.Id) === "string" && | ||
typeof ((_b = context === null || context === void 0 ? void 0 : context.State) === null || _b === void 0 ? void 0 : _b.EnteredTime) === "string" && | ||
typeof ((_c = context === null || context === void 0 ? void 0 : context.State) === null || _c === void 0 ? void 0 : _c.Name) === "string"); | ||
typeof ((_b = context === null || context === void 0 ? void 0 : context.Execution) === null || _b === void 0 ? void 0 : _b.RedriveCount) === "number" && | ||
typeof ((_c = context === null || context === void 0 ? void 0 : context.State) === null || _c === void 0 ? void 0 : _c.EnteredTime) === "string" && | ||
typeof ((_d = context === null || context === void 0 ? void 0 : context.State) === null || _d === void 0 ? void 0 : _d.Name) === "string"); | ||
}; | ||
@@ -189,0 +199,0 @@ /** |
@@ -40,3 +40,3 @@ import { Context } from "aws-lambda"; | ||
*/ | ||
export declare function extractTriggerTags(event: any, context: Context): { | ||
export declare function extractTriggerTags(event: any, context: Context, eventSource: eventTypes | undefined): { | ||
[key: string]: string; | ||
@@ -43,0 +43,0 @@ }; |
@@ -312,5 +312,4 @@ "use strict"; | ||
*/ | ||
function extractTriggerTags(event, context) { | ||
function extractTriggerTags(event, context, eventSource) { | ||
var triggerTags = {}; | ||
var eventSource = parseEventSource(event); | ||
if (eventSource) { | ||
@@ -317,0 +316,0 @@ triggerTags["function_trigger.event_source"] = eventSource; |
{ | ||
"name": "datadog-lambda-js", | ||
"version": "9.117.0", | ||
"version": "9.118.0", | ||
"description": "Lambda client library that supports hybrid tracing in node js", | ||
@@ -31,3 +31,3 @@ "main": "dist/index.js", | ||
"@types/shimmer": "^1.0.1", | ||
"dd-trace": "^4.50.0", | ||
"dd-trace": "^4.53.0", | ||
"jest": "^27.0.1", | ||
@@ -34,0 +34,0 @@ "mock-fs": "4.14.0", |
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
558541
2.96%242
1.68%7651
3.27%