From 7fe85aca9fd8ddd2961b78046a56096cfe9424bc Mon Sep 17 00:00:00 2001 From: Nimrod Avni Date: Thu, 6 Jun 2024 17:42:06 +0300 Subject: [PATCH] fix ts errors --- .../packages/cx-wrapper/aws/aws-user-function.d.ts | 3 +++ nodejs/packages/cx-wrapper/index.ts | 12 ++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 nodejs/packages/cx-wrapper/aws/aws-user-function.d.ts diff --git a/nodejs/packages/cx-wrapper/aws/aws-user-function.d.ts b/nodejs/packages/cx-wrapper/aws/aws-user-function.d.ts new file mode 100644 index 0000000000..c1f6a5c740 --- /dev/null +++ b/nodejs/packages/cx-wrapper/aws/aws-user-function.d.ts @@ -0,0 +1,3 @@ +import {Handler} from "aws-lambda/handler"; + +export function load(taskRoot?: string, originalHandler?: string): Handler; diff --git a/nodejs/packages/cx-wrapper/index.ts b/nodejs/packages/cx-wrapper/index.ts index c09225323a..0af35a44a6 100644 --- a/nodejs/packages/cx-wrapper/index.ts +++ b/nodejs/packages/cx-wrapper/index.ts @@ -3,7 +3,6 @@ import { load } from './aws/aws-user-function.js'; import { Callback, Context, - Handler, } from 'aws-lambda'; import { AwsLambdaInstrumentation } from '@opentelemetry/instrumentation-aws-lambda'; @@ -12,15 +11,12 @@ import { defaultTextMapGetter, Context as OtelContext, diag, - DiagConsoleLogger, - DiagLogLevel, propagation, - Span, trace, - metrics, } from '@opentelemetry/api'; import { AwsLambdaInstrumentationConfig } from '@opentelemetry/instrumentation-aws-lambda'; +import {Handler} from "aws-lambda/handler"; const parseIntEnvvar = (envName: string): number | undefined => { const envVar = process.env?.[envName]; @@ -30,7 +26,7 @@ const parseIntEnvvar = (envName: string): number | undefined => { return numericEnvvar; }; -const RPC_REQUEST_PAYLOAD: 'rpc.request.payload'; +const RPC_REQUEST_PAYLOAD = 'rpc.request.payload'; const DEFAULT_OTEL_PAYLOAD_SIZE_LIMIT = 50 * 1024; const OTEL_PAYLOAD_SIZE_LIMIT: number = parseIntEnvvar('OTEL_PAYLOAD_SIZE_LIMIT') ?? DEFAULT_OTEL_PAYLOAD_SIZE_LIMIT; @@ -115,6 +111,6 @@ export const handler = async (event: any, context: Context, callback: Callback) process.env.CX_ORIGINAL_HANDLER ); - const patchedHandler = instrumentation.getPatchHandler(originalHandler) + const patchedHandler = instrumentation.getPatchHandler(originalHandler) as any as Handler; patchedHandler(event, context, callback) -} \ No newline at end of file +}