Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@aws-sdk/client-s3": "^3.540.0",
"@aws-sdk/client-sqs": "^3.540.0",
"@lumigo/tracer": "^1.91.0",
"@opentelemetry/auto-instrumentations-node": "^0.78.0",
"@sentry/node": "^6.19.7",
"@smithy/node-http-handler": "^2.5.0",
"@types/aws-lambda": "^8.10.134",
Expand Down
30 changes: 15 additions & 15 deletions src/core/LambdaWrapper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as lumigo from '@lumigo/tracer';
// import * as lumigo from '@lumigo/tracer';

import { Context } from '../index';
import ResponseModel from '../models/ResponseModel';
Expand Down Expand Up @@ -65,7 +65,7 @@
handleUncaughtErrors = true,
} = options || {};

let wrapper = async (event: any, context: Context) => {

Check failure on line 68 in src/core/LambdaWrapper.ts

View workflow job for this annotation

GitHub Actions / Lint

'wrapper' is never reassigned. Use 'const' instead
const di = new DependencyInjection(this.config, event, context);
const request = di.get(RequestService);
const logger = di.get(LoggerService);
Expand Down Expand Up @@ -109,15 +109,15 @@
}
};

// If Lumigo is enabled, wrap the handler in the Lumigo wrapper
if (LambdaWrapper.isLumigoEnabled && !LambdaWrapper.isLumigoWrappingUs) {
const tracer = lumigo.initTracer({ token: process.env.LUMIGO_TRACER_TOKEN });
// // If Lumigo is enabled, wrap the handler in the Lumigo wrapper
// if (LambdaWrapper.isLumigoEnabled && !LambdaWrapper.isLumigoWrappingUs) {
// const tracer = lumigo.initTracer({ token: process.env.LUMIGO_TRACER_TOKEN });

// Lumigo's wrapper works with both callbacks or promises handlers, and
// the returned function behaves the same way as the original. For our
// promise-based handler we can safely coerce the type.
wrapper = tracer.trace(wrapper) as (event: any, context: Context) => Promise<any>;
}
// // Lumigo's wrapper works with both callbacks or promises handlers, and
// // the returned function behaves the same way as the original. For our
// // promise-based handler we can safely coerce the type.
// wrapper = tracer.trace(wrapper) as (event: any, context: Context) => Promise<any>;
// }

return wrapper;
}
Expand All @@ -128,8 +128,8 @@
* The `LUMIGO_TRACER_TOKEN` env var is present in both manually traced and
* auto-traced functions.
*/
static get isLumigoEnabled(): boolean {
return !!process.env.LUMIGO_TRACER_TOKEN;
static get isOpenTelemetryEnabled(): boolean {
return !!process.env.OPENTELEMETRY_COLLECTOR_CONFIG_URI;
}

/**
Expand All @@ -141,10 +141,10 @@
* wrapper, or handler redirection. Each method can be detected via its
* environment variables. Auto-trace uses the runtime wrapper.
*/
static get isLumigoWrappingUs(): boolean {
return this.isLumigoEnabled && (
process.env.AWS_LAMBDA_EXEC_WRAPPER === '/opt/lumigo_wrapper'
|| !!process.env.LUMIGO_ORIGINAL_HANDLER
static get isOpenTelemetryWrappingUs(): boolean {
return this.isOpenTelemetryEnabled && (
process.env.AWS_LAMBDA_EXEC_WRAPPER === '/opt/otel-handler'
|| !!process.env.OTEL_ORIGINAL_HANDLER
);
}

Expand Down
22 changes: 11 additions & 11 deletions src/services/LoggerService.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as lumigo from '@lumigo/tracer';
// import * as lumigo from '@lumigo/tracer';
import * as Sentry from '@sentry/node';
import { AxiosError } from 'axios';
import Winston from 'winston';

import DependencyAwareClass from '../core/DependencyAwareClass';
import DependencyInjection from '../core/DependencyInjection';
import LambdaWrapper from '../core/LambdaWrapper';
// import LambdaWrapper from '../core/LambdaWrapper';

const sentryIsAvailable = typeof process.env.RAVEN_DSN !== 'undefined' && typeof process.env.RAVEN_DSN === 'string' && process.env.RAVEN_DSN !== 'undefined';

Expand Down Expand Up @@ -171,9 +171,9 @@ export default class LoggerService extends DependencyAwareClass {
Sentry.captureException(error);
}

if (LambdaWrapper.isLumigoEnabled && error instanceof Error) {
lumigo.error(message || error.message, { err: error });
}
// if (LambdaWrapper.isLumigoEnabled && error instanceof Error) {
// lumigo.error(message || error.message, { err: error });
// }

this.logger.log('error', message, { error: LoggerService.processMessage(error) });
this.label('error', true);
Expand Down Expand Up @@ -216,9 +216,9 @@ export default class LoggerService extends DependencyAwareClass {
* @param silent If `false`, the label will also be logged. (default: false)
*/
label(descriptor: string, silent = false) {
if (LambdaWrapper.isLumigoEnabled) {
lumigo.addExecutionTag(descriptor, true);
}
// if (LambdaWrapper.isLumigoEnabled) {
// lumigo.addExecutionTag(descriptor, true);
// }

if (!silent) {
this.logger.log('info', `label - ${descriptor}`);
Expand All @@ -233,9 +233,9 @@ export default class LoggerService extends DependencyAwareClass {
* @param silent If `false`, the metric will also be logged. (default: false)
*/
metric(descriptor: string, stat: number | string, silent = false) {
if (LambdaWrapper.isLumigoEnabled) {
lumigo.addExecutionTag(descriptor, stat);
}
// if (LambdaWrapper.isLumigoEnabled) {
// lumigo.addExecutionTag(descriptor, stat);
// }

if (silent === false) {
this.logger.log('info', `metric - ${descriptor} - ${stat}`);
Expand Down
Loading
Loading