datadog-lambda-js
Advanced tools
Comparing version 5.75.0 to 5.76.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.datadogLambdaVersion = void 0; | ||
exports.datadogLambdaVersion = "5.75.0"; | ||
exports.datadogLambdaVersion = "5.76.0"; | ||
//# sourceMappingURL=constants.js.map |
@@ -8,4 +8,5 @@ import { Context, SNSMessage } from "aws-lambda"; | ||
createInferredSpan(event: any, context: Context | undefined, parentSpanContext: SpanContext | undefined): any; | ||
isApiGatewayAsync(event: any): boolean; | ||
isApiGatewayAsync(event: any): string; | ||
createInferredSpanForApiGateway(event: any, context: Context | undefined, parentSpanContext: SpanContext | undefined): SpanWrapper; | ||
createInferredSpanForLambdaUrl(event: any, context: Context | undefined): any; | ||
createInferredSpanForDynamoDBStreamEvent(event: any, context: Context | undefined, parentSpanContext: SpanContext | undefined): SpanWrapper; | ||
@@ -12,0 +13,0 @@ createInferredSpanForSns(event: any, context: Context | undefined, parentSpanContext: SpanContext | undefined): SpanWrapper; |
@@ -28,2 +28,5 @@ "use strict"; | ||
var eventSource = (0, trigger_1.parseEventSource)(event); | ||
if (eventSource === trigger_1.eventSources.lambdaUrl) { | ||
return this.createInferredSpanForLambdaUrl(event, context); | ||
} | ||
if (eventSource === trigger_1.eventSources.apiGateway) { | ||
@@ -52,3 +55,6 @@ return this.createInferredSpanForApiGateway(event, context, parentSpanContext); | ||
SpanInferrer.prototype.isApiGatewayAsync = function (event) { | ||
return (event.headers && event.headers["X-Amz-Invocation-Type"] && event.headers["X-Amz-Invocation-Type"] === "Event"); | ||
if (event.headers && event.headers["X-Amz-Invocation-Type"] && event.headers["X-Amz-Invocation-Type"] === "Event") { | ||
return "async"; | ||
} | ||
return "sync"; | ||
}; | ||
@@ -101,6 +107,39 @@ SpanInferrer.prototype.createInferredSpanForApiGateway = function (event, context, parentSpanContext) { | ||
var spanWrapperOptions = { | ||
isAsync: this.isApiGatewayAsync(event), | ||
isAsync: this.isApiGatewayAsync(event) === "async", | ||
}; | ||
return new span_wrapper_1.SpanWrapper(this.traceWrapper.startSpan("aws.apigateway", options), spanWrapperOptions); | ||
}; | ||
SpanInferrer.prototype.createInferredSpanForLambdaUrl = function (event, context) { | ||
var options = {}; | ||
var domain = event.requestContext.domainName; | ||
var path = event.rawPath; | ||
var method; | ||
if (event.requestContext.httpMethod) { | ||
method = event.requestContext.httpMethod; | ||
} | ||
else if (event.requestContext.http) { | ||
method = event.requestContext.http.method; | ||
} | ||
var resourceName = [method || domain, path].join(" "); | ||
options.tags = { | ||
operation_name: "aws.lambda.url", | ||
"http.url": domain + path, | ||
endpoint: path, | ||
"http.method": event.requestContext.http.method, | ||
resource_names: resourceName, | ||
request_id: context === null || context === void 0 ? void 0 : context.awsRequestId, | ||
"span.type": "http", | ||
"resource.name": resourceName, | ||
"service.name": domain, | ||
_inferred_span: { | ||
tag_source: "self", | ||
synchronicity: "sync", | ||
}, | ||
}; | ||
options.startTime = event.requestContext.timeEpoch; | ||
var spanWrapperOptions = { | ||
isAsync: false, | ||
}; | ||
return new span_wrapper_1.SpanWrapper(this.traceWrapper.startSpan("aws.lambda.url", options), spanWrapperOptions); | ||
}; | ||
SpanInferrer.prototype.createInferredSpanForDynamoDBStreamEvent = function (event, context, parentSpanContext) { | ||
@@ -107,0 +146,0 @@ var _a; |
@@ -12,2 +12,3 @@ import { Context } from "aws-lambda"; | ||
kinesis = "kinesis", | ||
lambdaUrl = "lambda-function-url", | ||
s3 = "s3", | ||
@@ -23,3 +24,3 @@ sns = "sns", | ||
*/ | ||
export declare function parseEventSource(event: any): eventSources.apiGateway | eventSources.applicationLoadBalancer | eventSources.cloudFront | eventSources.cloudWatchEvents | eventSources.cloudWatchLogs | eventSources.dynamoDB | eventSources.eventBridge | eventSources.kinesis | eventSources.s3 | eventSources.sns | eventSources.sqs | undefined; | ||
export declare function parseEventSource(event: any): eventSources.apiGateway | eventSources.applicationLoadBalancer | eventSources.cloudFront | eventSources.cloudWatchEvents | eventSources.cloudWatchLogs | eventSources.dynamoDB | eventSources.eventBridge | eventSources.kinesis | eventSources.lambdaUrl | eventSources.s3 | eventSources.sns | eventSources.sqs | undefined; | ||
/** | ||
@@ -26,0 +27,0 @@ * parseEventSourceARN parses the triggering event to determine the event source's |
@@ -99,2 +99,3 @@ "use strict"; | ||
eventSources["kinesis"] = "kinesis"; | ||
eventSources["lambdaUrl"] = "lambda-function-url"; | ||
eventSources["s3"] = "s3"; | ||
@@ -111,2 +112,5 @@ eventSources["sns"] = "sns"; | ||
function parseEventSource(event) { | ||
if (eventType.isLambdaUrlEvent(event)) { | ||
return eventSources.lambdaUrl; | ||
} | ||
if (eventType.isAPIGatewayEvent(event) || | ||
@@ -212,3 +216,3 @@ eventType.isAPIGatewayEventV2(event) || | ||
function extractHTTPTags(event) { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
var httpTags = {}; | ||
@@ -245,2 +249,14 @@ if (eventType.isAPIGatewayEvent(event)) { | ||
} | ||
if (eventType.isLambdaUrlEvent(event)) { | ||
var requestContext = event.requestContext; | ||
if (requestContext.domainName) { | ||
httpTags["http.url"] = requestContext.domainName; | ||
} | ||
httpTags["http.url_details.path"] = requestContext.http.path; | ||
httpTags["http.method"] = requestContext.http.method; | ||
if ((_c = event.headers) === null || _c === void 0 ? void 0 : _c.Referer) { | ||
httpTags["http.referer"] = event.headers.Referer; | ||
} | ||
return httpTags; | ||
} | ||
} | ||
@@ -247,0 +263,0 @@ /** |
@@ -17,2 +17,3 @@ import { APIGatewayEvent, APIGatewayProxyEventV2, AppSyncResolverEvent, ALBEvent, CloudWatchLogsEvent, ScheduledEvent, CloudFrontRequestEvent, DynamoDBStreamEvent, KinesisStreamEvent, S3Event, SNSEvent, SQSEvent, EventBridgeEvent } from "aws-lambda"; | ||
export declare function isEventBridgeEvent(event: any): event is EventBridgeEvent<any, any>; | ||
export declare function isLambdaUrlEvent(event: any): boolean; | ||
//# sourceMappingURL=event-type-guards.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isEventBridgeEvent = exports.isAppSyncResolverEvent = exports.isSNSSQSEvent = exports.isSQSEvent = exports.isSNSEvent = exports.isS3Event = exports.isKinesisStreamEvent = exports.isDynamoDBStreamEvent = exports.isCloudFrontRequestEvent = exports.isCloudWatchEvent = exports.isCloudWatchLogsEvent = exports.isALBEvent = exports.isAPIGatewayWebsocketEvent = exports.isAPIGatewayEventV2 = exports.isAPIGatewayEvent = void 0; | ||
exports.isLambdaUrlEvent = exports.isEventBridgeEvent = exports.isAppSyncResolverEvent = exports.isSNSSQSEvent = exports.isSQSEvent = exports.isSNSEvent = exports.isS3Event = exports.isKinesisStreamEvent = exports.isDynamoDBStreamEvent = exports.isCloudFrontRequestEvent = exports.isCloudWatchEvent = exports.isCloudWatchLogsEvent = exports.isALBEvent = exports.isAPIGatewayWebsocketEvent = exports.isAPIGatewayEventV2 = exports.isAPIGatewayEvent = void 0; | ||
var constants_1 = require("../trace/constants"); | ||
@@ -80,2 +80,7 @@ function isAPIGatewayEvent(event) { | ||
exports.isEventBridgeEvent = isEventBridgeEvent; | ||
function isLambdaUrlEvent(event) { | ||
var _a, _b; | ||
return (_b = (_a = event === null || event === void 0 ? void 0 : event.requestContext) === null || _a === void 0 ? void 0 : _a.domainName) === null || _b === void 0 ? void 0 : _b.includes("lambda-url"); | ||
} | ||
exports.isLambdaUrlEvent = isLambdaUrlEvent; | ||
//# sourceMappingURL=event-type-guards.js.map |
{ | ||
"name": "datadog-lambda-js", | ||
"version": "5.75.0", | ||
"version": "5.76.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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
379095
5307