Skip to content

Commit 30497e0

Browse files
committed
bundle autoinstrumentation package with webpack
1 parent 7017193 commit 30497e0

File tree

5 files changed

+909
-54
lines changed

5 files changed

+909
-54
lines changed

aws-distro-opentelemetry-node-autoinstrumentation/package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
"repository": "aws-observability/aws-otel-js-instrumentation",
2323
"scripts": {
2424
"clean": "rimraf build/*",
25-
"compile": "tsc -p .",
25+
"compile:tsc": "tsc -p .",
26+
"compile:webpack": "webpack",
27+
"compile": "npm run compile:webpack",
2628
"lint": "eslint . --ext .ts",
2729
"lint:fix": "eslint . --ext .ts --fix",
2830
"create-version": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
@@ -88,8 +90,11 @@
8890
"nyc": "15.1.0",
8991
"rimraf": "5.0.5",
9092
"sinon": "15.2.0",
93+
"ts-loader": "^9.5.2",
9194
"ts-mocha": "10.0.0",
92-
"typescript": "4.4.4"
95+
"typescript": "4.4.4",
96+
"webpack": "^5.98.0",
97+
"webpack-cli": "^6.0.1"
9398
},
9499
"dependencies": {
95100
"@opentelemetry/api": "1.9.0",
@@ -105,7 +110,7 @@
105110
"@opentelemetry/instrumentation-aws-sdk": "0.44.0",
106111
"@opentelemetry/otlp-transformer": "0.53.0",
107112
"@opentelemetry/propagator-aws-xray": "1.26.0",
108-
"@opentelemetry/resource-detector-aws": "1.6.1",
113+
"@opentelemetry/resource-detector-aws": "1.12.0",
109114
"@opentelemetry/resources": "1.26.0",
110115
"@opentelemetry/sdk-metrics": "1.26.0",
111116
"@opentelemetry/sdk-node": "0.53.0",
@@ -114,8 +119,8 @@
114119
},
115120
"files": [
116121
"build/src/**/*.js",
117-
"build/src/**/*.js.map",
118122
"build/src/**/*.d.ts",
119-
"build/src/**/*.json"
123+
"build/src/**/*.d.ts.map",
124+
"build/workspace/node_modules/**"
120125
]
121126
}

aws-distro-opentelemetry-node-autoinstrumentation/test/patches/instrumentation-patch.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { AWSXRAY_TRACE_ID_HEADER, AWSXRayPropagator } from '@opentelemetry/propa
2424
import { Context } from 'aws-lambda';
2525
import { SinonStub } from 'sinon';
2626
import { S3 } from '@aws-sdk/client-s3';
27-
import nock = require('nock');
27+
import * as nock from 'nock';
2828
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
2929
import { getTestSpans, registerInstrumentationTesting } from '@opentelemetry/contrib-test-utils';
3030
import { AwsSdkInstrumentationExtended } from '../../src/patches/extended-instrumentations/aws-sdk-instrumentation-extended';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "es2020",
5+
"target": "es2020",
6+
"moduleResolution": "node",
7+
},
8+
"exclude": [
9+
"node_modules",
10+
]
11+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
entry: './src/register.ts',
5+
target: 'node',
6+
mode: 'production',
7+
externalsPresets: { node: true },
8+
externals: [
9+
'import-in-the-middle',
10+
],
11+
output: {
12+
path: path.resolve('./build/src'),
13+
filename: 'register.js',
14+
library: {
15+
type: 'commonjs2',
16+
}
17+
},
18+
resolve: {
19+
extensions: ['.ts', '.js'],
20+
modules: [
21+
path.resolve('./src'),
22+
'node_modules',
23+
],
24+
},
25+
module: {
26+
rules: [
27+
{
28+
test: /\.ts$/,
29+
use: [
30+
{
31+
loader: 'ts-loader',
32+
options: {
33+
configFile: 'tsconfig.webpack.json'
34+
},
35+
}
36+
],
37+
exclude: /node_modules/,
38+
},
39+
],
40+
},
41+
optimization: {
42+
minimize: true,
43+
providedExports: true,
44+
usedExports: true,
45+
},
46+
};

0 commit comments

Comments
 (0)