|
1 |
| -// Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/cc7eff47e2e7bad7678241b766753d5bd6dbc85f/packages/instrumentation-aws-lambda/src/instrumentation.ts |
| 1 | +// Vendored and modified from: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/cc7eff47e2e7bad7678241b766753d5bd6dbc85f/packages/instrumentation-aws-lambda/src/instrumentation.ts |
| 2 | +// Modifications: |
| 3 | +// - Added Sentry `wrapHandler` around the OTel patch handler. |
| 4 | +// - Cancel init when handler string is invalid (TS) |
| 5 | +// - Hardcoded package version and name |
2 | 6 | /* eslint-disable */
|
3 | 7 | /*
|
4 | 8 | * Copyright The OpenTelemetry Authors
|
@@ -52,10 +56,11 @@ import * as path from 'path';
|
52 | 56 | import type { LambdaModule } from './internal-types';
|
53 | 57 | import { ATTR_FAAS_COLDSTART } from './semconv';
|
54 | 58 | import type { AwsLambdaInstrumentationConfig, EventContextExtractor } from './types';
|
55 |
| -/** @knipignore */ |
56 |
| -import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; |
57 | 59 | import { wrapHandler } from '../../sdk';
|
58 | 60 |
|
| 61 | +const PACKAGE_VERSION = '0.54.0'; |
| 62 | +const PACKAGE_NAME = '@opentelemetry/instrumentation-aws-lambda'; |
| 63 | + |
59 | 64 | const headerGetter: TextMapGetter<APIGatewayProxyEventHeaders> = {
|
60 | 65 | keys(carrier): string[] {
|
61 | 66 | return Object.keys(carrier);
|
@@ -100,7 +105,12 @@ export class AwsLambdaInstrumentation extends InstrumentationBase<AwsLambdaInstr
|
100 | 105 | const [module, functionName] = handler.split('.', 2);
|
101 | 106 |
|
102 | 107 | if (!module || !functionName) {
|
103 |
| - throw new Error('Invalid handler definition'); |
| 108 | + this._diag.warn('Invalid handler definition', { |
| 109 | + handler, |
| 110 | + moduleRoot, |
| 111 | + module, |
| 112 | + }); |
| 113 | + return []; |
104 | 114 | }
|
105 | 115 |
|
106 | 116 | // Lambda loads user function using an absolute path.
|
|
0 commit comments