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

@opentelemetry/instrumentation-aws-lambda

Package Overview
Dependencies
Maintainers
4
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-aws-lambda - npm Package Compare versions

Comparing version 0.23.0 to 0.24.0

build/src/index.js.map

1

build/src/instrumentation.d.ts

@@ -18,4 +18,5 @@ import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';

private static _extractAccountId;
private static _defaultEventContextExtractor;
private static _determineParent;
}
//# sourceMappingURL=instrumentation.d.ts.map

30

build/src/instrumentation.js

@@ -93,4 +93,5 @@ "use strict";

event, context, callback) {
const httpHeaders = typeof event.headers === 'object' ? event.headers : {};
const parent = AwsLambdaInstrumentation._determineParent(httpHeaders, plugin._config.disableAwsContextPropagation === true);
const config = plugin._config;
const parent = AwsLambdaInstrumentation._determineParent(event, config.disableAwsContextPropagation === true, config.eventContextExtractor ||
AwsLambdaInstrumentation._defaultEventContextExtractor);
const name = context.functionName;

@@ -101,8 +102,8 @@ const span = plugin.tracer.startSpan(name, {

[semantic_conventions_1.SemanticAttributes.FAAS_EXECUTION]: context.awsRequestId,
[semantic_conventions_1.ResourceAttributes.FAAS_ID]: context.invokedFunctionArn,
[semantic_conventions_1.ResourceAttributes.CLOUD_ACCOUNT_ID]: AwsLambdaInstrumentation._extractAccountId(context.invokedFunctionArn),
[semantic_conventions_1.SemanticResourceAttributes.FAAS_ID]: context.invokedFunctionArn,
[semantic_conventions_1.SemanticResourceAttributes.CLOUD_ACCOUNT_ID]: AwsLambdaInstrumentation._extractAccountId(context.invokedFunctionArn),
},
}, parent);
if (plugin._config.requestHook) {
instrumentation_1.safeExecuteInTheMiddle(() => plugin._config.requestHook(span, { event, context }), e => {
if (config.requestHook) {
instrumentation_1.safeExecuteInTheMiddle(() => config.requestHook(span, { event, context }), e => {
if (e)

@@ -197,3 +198,8 @@ api_1.diag.error('aws-lambda instrumentation: requestHook error', e);

}
static _determineParent(httpHeaders, disableAwsContextPropagation) {
static _defaultEventContextExtractor(event) {
// The default extractor tries to get sampled trace header from HTTP headers.
const httpHeaders = event.headers || {};
return api_1.propagation.extract(api_1.context.active(), httpHeaders, headerGetter);
}
static _determineParent(event, disableAwsContextPropagation, eventContextExtractor) {
var _a, _b;

@@ -217,6 +223,8 @@ let parent = undefined;

}
// There was not a sampled trace header from Lambda so try from HTTP headers.
const httpContext = api_1.propagation.extract(api_1.context.active(), httpHeaders, headerGetter);
if ((_b = api_1.trace.getSpan(httpContext)) === null || _b === void 0 ? void 0 : _b.spanContext()) {
return httpContext;
const extractedContext = instrumentation_1.safeExecuteInTheMiddle(() => eventContextExtractor(event), e => {
if (e)
api_1.diag.error('aws-lambda instrumentation: eventContextExtractor error', e);
}, true);
if ((_b = api_1.trace.getSpan(extractedContext)) === null || _b === void 0 ? void 0 : _b.spanContext()) {
return extractedContext;
}

@@ -223,0 +231,0 @@ if (!parent) {

@@ -1,2 +0,2 @@

import { Span } from '@opentelemetry/api';
import { Span, Context as OtelContext } from '@opentelemetry/api';
import { InstrumentationConfig } from '@opentelemetry/instrumentation';

@@ -13,2 +13,3 @@ import { Handler, Context } from 'aws-lambda';

}) => void;
export declare type EventContextExtractor = (event: any) => OtelContext;
export interface AwsLambdaInstrumentationConfig extends InstrumentationConfig {

@@ -18,3 +19,4 @@ requestHook?: RequestHook;

disableAwsContextPropagation?: boolean;
eventContextExtractor?: EventContextExtractor;
}
//# sourceMappingURL=types.d.ts.map

@@ -1,2 +0,2 @@

export declare const VERSION = "0.23.0";
export declare const VERSION = "0.24.0";
//# sourceMappingURL=version.d.ts.map

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

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.23.0';
exports.VERSION = '0.24.0';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/instrumentation-aws-lambda",
"version": "0.23.0",
"version": "0.24.0",
"description": "OpenTelemetry AWS Lambda automatic instrumentation package.",

@@ -35,2 +35,3 @@ "main": "build/src/index.js",

"build/src/**/*.js",
"build/src/**/*.js.map",
"build/src/**/*.d.ts",

@@ -49,7 +50,7 @@ "doc",

"@opentelemetry/api": "1.0.1",
"@opentelemetry/core": "0.23.0",
"@opentelemetry/node": "0.23.0",
"@opentelemetry/core": "0.24.0",
"@opentelemetry/node": "0.24.0",
"@types/mocha": "7.0.2",
"@types/node": "14.17.4",
"codecov": "3.8.2",
"@types/node": "14.17.5",
"codecov": "3.8.3",
"gts": "3.1.0",

@@ -63,10 +64,10 @@ "mocha": "7.2.0",

"dependencies": {
"@opentelemetry/instrumentation": "^0.23.0",
"@opentelemetry/propagator-aws-xray": "^0.23.0",
"@opentelemetry/resources": "^0.23.0",
"@opentelemetry/semantic-conventions": "^0.23.0",
"@opentelemetry/tracing": "^0.23.0",
"@types/aws-lambda": "8.10.77"
"@opentelemetry/instrumentation": "^0.24.0",
"@opentelemetry/propagator-aws-xray": "^0.24.0",
"@opentelemetry/resources": "^0.24.0",
"@opentelemetry/semantic-conventions": "^0.24.0",
"@opentelemetry/tracing": "^0.24.0",
"@types/aws-lambda": "8.10.80"
},
"gitHead": "eea5f3ef0382c3c8f6d5aca796e3babf7ad4a6c8"
"gitHead": "e4757035a7b4012703a98b5609b8ac0f859e9726"
}

@@ -50,2 +50,3 @@ # OpenTelemetry AWS Lambda Instrumentation for Node.js

| `disableAwsContextPropagation` | `boolean` | By default, this instrumentation will try to read the context from the `_X_AMZN_TRACE_ID` environment variable set by Lambda, set this to `true` to disable this behavior |
| `eventContextExtractor` | `EventContextExtractor` (function) | Function for providing custom context extractor in order to support different event types that are handled by AWS Lambda (e.g., SQS, CloudWatch, Kinesis, API Gateway). Applied only when `disableAwsContextPropagation` is set to `true`. Receives params: `event` |

@@ -52,0 +53,0 @@ ### Hooks Usage Example

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