@depup/elastic-apm-node 4.15.0-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/LICENSE +26 -0
  2. package/NOTICE.md +442 -0
  3. package/README.md +48 -0
  4. package/changes.json +78 -0
  5. package/index.d.ts +398 -0
  6. package/index.js +11 -0
  7. package/lib/InflightEventSet.js +53 -0
  8. package/lib/activation-method.js +119 -0
  9. package/lib/agent.js +941 -0
  10. package/lib/apm-client/apm-client.js +313 -0
  11. package/lib/apm-client/http-apm-client/CHANGELOG.md +271 -0
  12. package/lib/apm-client/http-apm-client/README.md +485 -0
  13. package/lib/apm-client/http-apm-client/central-config.js +41 -0
  14. package/lib/apm-client/http-apm-client/container-info.js +111 -0
  15. package/lib/apm-client/http-apm-client/detect-hostname.js +96 -0
  16. package/lib/apm-client/http-apm-client/index.js +1975 -0
  17. package/lib/apm-client/http-apm-client/logging.js +31 -0
  18. package/lib/apm-client/http-apm-client/ndjson.js +20 -0
  19. package/lib/apm-client/http-apm-client/truncate.js +434 -0
  20. package/lib/apm-client/noop-apm-client.js +73 -0
  21. package/lib/async-hooks-polyfill.js +58 -0
  22. package/lib/cloud-metadata/aws.js +175 -0
  23. package/lib/cloud-metadata/azure.js +123 -0
  24. package/lib/cloud-metadata/callback-coordination.js +159 -0
  25. package/lib/cloud-metadata/gcp.js +133 -0
  26. package/lib/cloud-metadata/index.js +175 -0
  27. package/lib/config/config.js +458 -0
  28. package/lib/config/normalizers.js +701 -0
  29. package/lib/config/schema.js +1007 -0
  30. package/lib/constants.js +35 -0
  31. package/lib/errors.js +303 -0
  32. package/lib/filters/sanitize-field-names.js +69 -0
  33. package/lib/http-request.js +249 -0
  34. package/lib/instrumentation/azure-functions.js +519 -0
  35. package/lib/instrumentation/context.js +56 -0
  36. package/lib/instrumentation/dropped-spans-stats.js +112 -0
  37. package/lib/instrumentation/elasticsearch-shared.js +63 -0
  38. package/lib/instrumentation/express-utils.js +91 -0
  39. package/lib/instrumentation/generic-span.js +322 -0
  40. package/lib/instrumentation/http-shared.js +424 -0
  41. package/lib/instrumentation/ids.js +39 -0
  42. package/lib/instrumentation/index.js +1127 -0
  43. package/lib/instrumentation/modules/@apollo/server.js +30 -0
  44. package/lib/instrumentation/modules/@aws-sdk/client-dynamodb.js +143 -0
  45. package/lib/instrumentation/modules/@aws-sdk/client-s3.js +230 -0
  46. package/lib/instrumentation/modules/@aws-sdk/client-sns.js +197 -0
  47. package/lib/instrumentation/modules/@aws-sdk/client-sqs.js +336 -0
  48. package/lib/instrumentation/modules/@elastic/elasticsearch.js +343 -0
  49. package/lib/instrumentation/modules/@hapi/hapi.js +221 -0
  50. package/lib/instrumentation/modules/@opentelemetry/api.js +86 -0
  51. package/lib/instrumentation/modules/@opentelemetry/sdk-metrics.js +79 -0
  52. package/lib/instrumentation/modules/@redis/client/dist/lib/client/commands-queue.js +178 -0
  53. package/lib/instrumentation/modules/@redis/client/dist/lib/client/index.js +49 -0
  54. package/lib/instrumentation/modules/@smithy/smithy-client.js +198 -0
  55. package/lib/instrumentation/modules/_lambda-handler.js +40 -0
  56. package/lib/instrumentation/modules/apollo-server-core.js +49 -0
  57. package/lib/instrumentation/modules/aws-sdk/dynamodb.js +155 -0
  58. package/lib/instrumentation/modules/aws-sdk/s3.js +184 -0
  59. package/lib/instrumentation/modules/aws-sdk/sns.js +232 -0
  60. package/lib/instrumentation/modules/aws-sdk/sqs.js +361 -0
  61. package/lib/instrumentation/modules/aws-sdk.js +76 -0
  62. package/lib/instrumentation/modules/bluebird.js +93 -0
  63. package/lib/instrumentation/modules/cassandra-driver.js +280 -0
  64. package/lib/instrumentation/modules/elasticsearch.js +191 -0
  65. package/lib/instrumentation/modules/express-graphql.js +66 -0
  66. package/lib/instrumentation/modules/express-queue.js +28 -0
  67. package/lib/instrumentation/modules/express.js +162 -0
  68. package/lib/instrumentation/modules/fastify.js +172 -0
  69. package/lib/instrumentation/modules/finalhandler.js +41 -0
  70. package/lib/instrumentation/modules/generic-pool.js +85 -0
  71. package/lib/instrumentation/modules/graphql.js +256 -0
  72. package/lib/instrumentation/modules/handlebars.js +22 -0
  73. package/lib/instrumentation/modules/http.js +112 -0
  74. package/lib/instrumentation/modules/http2.js +320 -0
  75. package/lib/instrumentation/modules/https.js +68 -0
  76. package/lib/instrumentation/modules/ioredis.js +94 -0
  77. package/lib/instrumentation/modules/jade.js +18 -0
  78. package/lib/instrumentation/modules/kafkajs.js +476 -0
  79. package/lib/instrumentation/modules/knex.js +91 -0
  80. package/lib/instrumentation/modules/koa-router.js +74 -0
  81. package/lib/instrumentation/modules/koa.js +15 -0
  82. package/lib/instrumentation/modules/memcached.js +99 -0
  83. package/lib/instrumentation/modules/mimic-response.js +45 -0
  84. package/lib/instrumentation/modules/mongodb/lib/cmap/connection_pool.js +40 -0
  85. package/lib/instrumentation/modules/mongodb-core.js +206 -0
  86. package/lib/instrumentation/modules/mongodb.js +259 -0
  87. package/lib/instrumentation/modules/mysql.js +200 -0
  88. package/lib/instrumentation/modules/mysql2.js +140 -0
  89. package/lib/instrumentation/modules/pg.js +148 -0
  90. package/lib/instrumentation/modules/pug.js +18 -0
  91. package/lib/instrumentation/modules/redis.js +176 -0
  92. package/lib/instrumentation/modules/restify.js +52 -0
  93. package/lib/instrumentation/modules/tedious.js +159 -0
  94. package/lib/instrumentation/modules/undici.js +270 -0
  95. package/lib/instrumentation/modules/ws.js +59 -0
  96. package/lib/instrumentation/noop-transaction.js +81 -0
  97. package/lib/instrumentation/run-context/AbstractRunContextManager.js +215 -0
  98. package/lib/instrumentation/run-context/AsyncHooksRunContextManager.js +106 -0
  99. package/lib/instrumentation/run-context/AsyncLocalStorageRunContextManager.js +73 -0
  100. package/lib/instrumentation/run-context/BasicRunContextManager.js +82 -0
  101. package/lib/instrumentation/run-context/RunContext.js +151 -0
  102. package/lib/instrumentation/run-context/index.js +23 -0
  103. package/lib/instrumentation/shimmer.js +123 -0
  104. package/lib/instrumentation/span-compression.js +239 -0
  105. package/lib/instrumentation/span.js +621 -0
  106. package/lib/instrumentation/template-shared.js +43 -0
  107. package/lib/instrumentation/timer.js +84 -0
  108. package/lib/instrumentation/transaction.js +571 -0
  109. package/lib/lambda.js +992 -0
  110. package/lib/load-source-map.js +100 -0
  111. package/lib/logging.js +212 -0
  112. package/lib/metrics/index.js +92 -0
  113. package/lib/metrics/platforms/generic/index.js +40 -0
  114. package/lib/metrics/platforms/generic/process-cpu.js +22 -0
  115. package/lib/metrics/platforms/generic/process-top.js +157 -0
  116. package/lib/metrics/platforms/generic/stats.js +34 -0
  117. package/lib/metrics/platforms/generic/system-cpu.js +51 -0
  118. package/lib/metrics/platforms/linux/index.js +19 -0
  119. package/lib/metrics/platforms/linux/stats.js +213 -0
  120. package/lib/metrics/queue.js +90 -0
  121. package/lib/metrics/registry.js +52 -0
  122. package/lib/metrics/reporter.js +119 -0
  123. package/lib/metrics/runtime.js +77 -0
  124. package/lib/middleware/connect.js +16 -0
  125. package/lib/opentelemetry-bridge/OTelBridgeNonRecordingSpan.js +150 -0
  126. package/lib/opentelemetry-bridge/OTelBridgeRunContext.js +124 -0
  127. package/lib/opentelemetry-bridge/OTelContextManager.js +82 -0
  128. package/lib/opentelemetry-bridge/OTelSpan.js +344 -0
  129. package/lib/opentelemetry-bridge/OTelTracer.js +201 -0
  130. package/lib/opentelemetry-bridge/OTelTracerProvider.js +25 -0
  131. package/lib/opentelemetry-bridge/README.md +244 -0
  132. package/lib/opentelemetry-bridge/index.js +15 -0
  133. package/lib/opentelemetry-bridge/oblog.js +23 -0
  134. package/lib/opentelemetry-bridge/opentelemetry-core-mini/README.md +3 -0
  135. package/lib/opentelemetry-bridge/opentelemetry-core-mini/internal/validators.js +52 -0
  136. package/lib/opentelemetry-bridge/opentelemetry-core-mini/trace/TraceState.js +109 -0
  137. package/lib/opentelemetry-bridge/otelutils.js +99 -0
  138. package/lib/opentelemetry-bridge/setup.js +76 -0
  139. package/lib/opentelemetry-metrics/ElasticApmMetricExporter.js +285 -0
  140. package/lib/opentelemetry-metrics/index.js +50 -0
  141. package/lib/parsers.js +225 -0
  142. package/lib/propwrap.js +147 -0
  143. package/lib/stacktraces.js +537 -0
  144. package/lib/symbols.js +15 -0
  145. package/lib/tracecontext/index.js +118 -0
  146. package/lib/tracecontext/traceparent.js +185 -0
  147. package/lib/tracecontext/tracestate.js +388 -0
  148. package/lib/wildcard-matcher.js +52 -0
  149. package/loader.mjs +7 -0
  150. package/package.json +299 -0
  151. package/start.d.ts +8 -0
  152. package/start.js +29 -0
  153. package/types/aws-lambda.d.ts +98 -0
  154. package/types/connect.d.ts +23 -0
package/package.json ADDED
@@ -0,0 +1,299 @@
1
+ {
2
+ "name": "@depup/elastic-apm-node",
3
+ "version": "4.15.0-depup.0",
4
+ "description": "The official Elastic APM agent for Node.js (with updated dependencies)",
5
+ "type": "commonjs",
6
+ "main": "index.js",
7
+ "types": "index.d.ts",
8
+ "scripts": {
9
+ "docs:open": "PREVIEW=1 npm run docs:build",
10
+ "docs:build": "./docs/scripts/build_docs.sh apm-agent-nodejs ./docs ./build",
11
+ "lint": "npm run lint:eslint && npm run lint:license-files && npm run lint:yaml-files && npm run lint:tav",
12
+ "lint:eslint": "eslint . # requires node >=18.18.0",
13
+ "lint:eslint-nostyle": "eslint --rule 'prettier/prettier: off' . # lint without checking style, not normally used; requires node>=18.18.0",
14
+ "lint:fix": "eslint --fix . # requires node >=18.18.0",
15
+ "lint:license-files": "./dev-utils/gen-notice.sh --lint . # requires node >=16",
16
+ "lint:yaml-files": "./dev-utils/lint-yaml-files.sh # requires node >=10",
17
+ "lint:tav": "./dev-utils/lint-tav-json.js",
18
+ "test": "./test/script/run_tests.sh",
19
+ "test:deps": "dependency-check index.js start.js 'lib/**/*.js' 'test/**/*.js' '!test/activation-method/fixtures' '!test/instrumentation/azure-functions/fixtures' '!test/opentelemetry-bridge' '!test/opentelemetry-metrics/fixtures' --no-dev -i async_hooks -i perf_hooks -i node:http -i @azure/functions-core -i worker_threads -i timers",
20
+ "test:tav": "(cd test/opentelemetry-metrics/fixtures && tav --quiet) && (cd test/opentelemetry-bridge && tav --quiet) && tav --quiet",
21
+ "test:types": "tsc --project test/types/tsconfig.json && tsc --project test/types/transpile/tsconfig.json && node test/types/transpile/index.js && tsc --project test/types/transpile-default/tsconfig.json && node test/types/transpile-default/index.js # requires node >=14.17",
22
+ "test:babel": "babel test/babel/src.js --out-file test/babel/out.js && cd test/babel && node out.js",
23
+ "bench": "./test/benchmarks/scripts/run-benchmarks.sh",
24
+ "bench:ci": "./test/benchmarks/scripts/run-benchmarks-ci.sh",
25
+ "local:start": "./test/script/local-deps-start.sh",
26
+ "local:stop": "./test/script/local-deps-stop.sh",
27
+ "docker:start": "docker compose -f ./test/docker-compose.yml up -d",
28
+ "docker:stop": "docker compose -f ./test/docker-compose.yml down",
29
+ "docker:clean": "./test/script/docker/cleanup.sh",
30
+ "docker:dev": "docker compose -f ./dev-utils/docker-compose.yml run --workdir=/agent nodejs-agent"
31
+ },
32
+ "directories": {
33
+ "test": "test"
34
+ },
35
+ "files": [
36
+ "NOTICE.md",
37
+ "lib",
38
+ "types",
39
+ "start.js",
40
+ "loader.mjs",
41
+ "index.d.ts",
42
+ "start.d.ts",
43
+ "changes.json",
44
+ "README.md"
45
+ ],
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git://github.com/elastic/apm-agent-nodejs.git"
49
+ },
50
+ "engines": {
51
+ "node": ">=14.17.0"
52
+ },
53
+ "keywords": [
54
+ "elastic-apm-node",
55
+ "depup",
56
+ "updated-dependencies",
57
+ "security",
58
+ "latest",
59
+ "patched",
60
+ "opbeat",
61
+ "elastic",
62
+ "elasticapm",
63
+ "elasticsearch",
64
+ "log",
65
+ "logging",
66
+ "bug",
67
+ "bugs",
68
+ "error",
69
+ "errors",
70
+ "exception",
71
+ "exceptions",
72
+ "catch",
73
+ "monitor",
74
+ "monitoring",
75
+ "alert",
76
+ "alerts",
77
+ "performance",
78
+ "apm",
79
+ "ops",
80
+ "devops",
81
+ "stacktrace",
82
+ "trace",
83
+ "tracing",
84
+ "distributedtracing",
85
+ "distributed-tracing"
86
+ ],
87
+ "author": "Thomas Watson Steen <w@tson.dk> (https://twitter.com/wa7son)",
88
+ "contributors": [
89
+ "Elastic Observability <https://www.elastic.co/observability>"
90
+ ],
91
+ "license": "BSD-2-Clause",
92
+ "bugs": {
93
+ "url": "https://github.com/elastic/apm-agent-nodejs/issues"
94
+ },
95
+ "homepage": "https://github.com/elastic/apm-agent-nodejs",
96
+ "dependencies": {
97
+ "@elastic/ecs-pino-format": "^1.5.0",
98
+ "@opentelemetry/api": "^1.9.0",
99
+ "@opentelemetry/core": "^2.6.0",
100
+ "@opentelemetry/sdk-metrics": "^2.6.0",
101
+ "after-all-results": "^2.0.0",
102
+ "agentkeepalive": "^4.6.0",
103
+ "async-value-promise": "^1.1.1",
104
+ "basic-auth": "^2.0.1",
105
+ "breadth-filter": "^2.0.0",
106
+ "cookie": "^1.1.1",
107
+ "core-util-is": "^1.0.3",
108
+ "end-of-stream": "^1.4.5",
109
+ "error-callsites": "^2.0.4",
110
+ "error-stack-parser": "^2.1.4",
111
+ "escape-string-regexp": "^5.0.0",
112
+ "fast-safe-stringify": "^2.1.1",
113
+ "fast-stream-to-buffer": "^1.0.0",
114
+ "http-headers": "^3.0.2",
115
+ "import-in-the-middle": "^3.0.0",
116
+ "json-bigint": "^1.0.0",
117
+ "lru-cache": "^11.2.7",
118
+ "measured-reporting": "^2.0.0",
119
+ "module-details-from-path": "^1.0.4",
120
+ "monitor-event-loop-delay": "^1.0.0",
121
+ "object-filter-sequence": "^1.0.0",
122
+ "object-identity-map": "^1.0.2",
123
+ "original-url": "^1.2.3",
124
+ "pino": "^10.3.1",
125
+ "readable-stream": "^4.7.0",
126
+ "relative-microtime": "^2.0.0",
127
+ "require-in-the-middle": "^8.0.1",
128
+ "semver": "^7.7.4",
129
+ "shallow-clone-shim": "^2.0.0",
130
+ "source-map": "^0.8.0-beta.0",
131
+ "sql-summary": "^1.0.1",
132
+ "stream-chopper": "^3.0.1",
133
+ "unicode-byte-truncate": "^1.0.0"
134
+ },
135
+ "devDependencies": {
136
+ "@apollo/server": "^4.2.2",
137
+ "@aws-sdk/client-dynamodb": "^3.379.1",
138
+ "@aws-sdk/client-s3": "^3.379.1",
139
+ "@aws-sdk/client-sns": "^3.379.1",
140
+ "@aws-sdk/client-sqs": "^3.379.1",
141
+ "@aws-sdk/s3-request-presigner": "^3.379.1",
142
+ "@babel/cli": "^7.8.4",
143
+ "@babel/core": "^7.8.4",
144
+ "@babel/preset-env": "^7.8.4",
145
+ "@elastic/elasticsearch": "^9.0.0",
146
+ "@fastify/formbody": "^8.0.1",
147
+ "@hapi/hapi": "^21.0.0",
148
+ "@koa/router": "^13.0.1",
149
+ "@types/node": "^24.0.1",
150
+ "ajv": "^8.12.0",
151
+ "apollo-server-core": "^3.0.0",
152
+ "apollo-server-express": "^3.0.0",
153
+ "aws-sdk": "^2.1400.0",
154
+ "benchmark": "^2.1.4",
155
+ "bluebird": "^3.7.2",
156
+ "body-parser": "^1.19.0",
157
+ "cassandra-driver": "^4.4.0",
158
+ "columnify": "^1.5.4",
159
+ "connect": "^3.7.0",
160
+ "dashdash": "^2.0.0",
161
+ "dependency-check": "^4.1.0",
162
+ "diagnostics_channel": "^1.1.0",
163
+ "elasticsearch": "^16.7.3",
164
+ "eslint": "^9.0.0",
165
+ "eslint-config-prettier": "^10.0.1",
166
+ "eslint-plugin-import": "^2.28.0",
167
+ "eslint-plugin-license-header": "^0.8.0",
168
+ "eslint-plugin-n": "^17.2.0",
169
+ "eslint-plugin-prettier": "^5.0.0",
170
+ "eslint-plugin-promise": "^7.0.0",
171
+ "express": "^5.0.0",
172
+ "express-queue": "^0.0.13",
173
+ "fastify": "^5.0.0",
174
+ "finalhandler": "^2.1.0",
175
+ "generic-pool": "^3.7.1",
176
+ "get-port": "^5.1.1",
177
+ "glob": "^7.2.3",
178
+ "globals": "^16.3.0",
179
+ "got": "^11.8.5",
180
+ "graphql": "^16.6.0",
181
+ "handlebars": "^4.7.3",
182
+ "ioredis": "^5.1.0",
183
+ "js-yaml": "^4.1.0",
184
+ "json": "^11.0.0",
185
+ "kafkajs": "^2.2.4",
186
+ "knex": "^3.0.1",
187
+ "koa": "^3.0.1",
188
+ "koa-bodyparser": "^4.3.0",
189
+ "koa-router": "^13.0.1",
190
+ "lambda-local": "^2.0.2",
191
+ "memcached": "^2.2.2",
192
+ "mimic-response": "1.0.0",
193
+ "mkdirp": "^3.0.1",
194
+ "mongodb": "^6.0.0",
195
+ "mongodb-core": "^3.2.7",
196
+ "mysql": "^2.18.1",
197
+ "mysql2": "^3.2.4",
198
+ "ndjson": "^2.0.0",
199
+ "numeral": "^2.0.6",
200
+ "once": "^1.4.0",
201
+ "pg": "^8.7.1",
202
+ "prettier": "^3.0.0",
203
+ "pug": "^3.0.1",
204
+ "redis": "^4.3.0",
205
+ "restify": "^11.0.0",
206
+ "rimraf": "^3.0.2",
207
+ "tape": "^5.0.0",
208
+ "tedious": "^19.0.0",
209
+ "test-all-versions": "^6.1.0",
210
+ "thunky": "^1.1.0",
211
+ "tree-kill": "^1.2.2",
212
+ "typescript": "^5.0.2",
213
+ "undici": "^7.0.0",
214
+ "vasync": "^2.2.0",
215
+ "wait-on": "^9.0.1",
216
+ "ws": "^7.2.1"
217
+ },
218
+ "depup": {
219
+ "changes": {
220
+ "@opentelemetry/api": {
221
+ "from": "^1.4.1",
222
+ "to": "^1.9.0"
223
+ },
224
+ "@opentelemetry/core": {
225
+ "from": "^1.11.0",
226
+ "to": "^2.6.0"
227
+ },
228
+ "@opentelemetry/sdk-metrics": {
229
+ "from": "^1.12.0",
230
+ "to": "^2.6.0"
231
+ },
232
+ "agentkeepalive": {
233
+ "from": "^4.2.1",
234
+ "to": "^4.6.0"
235
+ },
236
+ "cookie": {
237
+ "from": "^0.7.1",
238
+ "to": "^1.1.1"
239
+ },
240
+ "core-util-is": {
241
+ "from": "^1.0.2",
242
+ "to": "^1.0.3"
243
+ },
244
+ "end-of-stream": {
245
+ "from": "^1.4.4",
246
+ "to": "^1.4.5"
247
+ },
248
+ "error-stack-parser": {
249
+ "from": "^2.0.6",
250
+ "to": "^2.1.4"
251
+ },
252
+ "escape-string-regexp": {
253
+ "from": "^4.0.0",
254
+ "to": "^5.0.0"
255
+ },
256
+ "fast-safe-stringify": {
257
+ "from": "^2.0.7",
258
+ "to": "^2.1.1"
259
+ },
260
+ "import-in-the-middle": {
261
+ "from": "1.14.4",
262
+ "to": "^3.0.0"
263
+ },
264
+ "lru-cache": {
265
+ "from": "10.2.0",
266
+ "to": "^11.2.7"
267
+ },
268
+ "measured-reporting": {
269
+ "from": "^1.51.1",
270
+ "to": "^2.0.0"
271
+ },
272
+ "module-details-from-path": {
273
+ "from": "^1.0.3",
274
+ "to": "^1.0.4"
275
+ },
276
+ "pino": {
277
+ "from": "^8.15.0",
278
+ "to": "^10.3.1"
279
+ },
280
+ "readable-stream": {
281
+ "from": "^3.6.2",
282
+ "to": "^4.7.0"
283
+ },
284
+ "require-in-the-middle": {
285
+ "from": "^8.0.0",
286
+ "to": "^8.0.1"
287
+ },
288
+ "semver": {
289
+ "from": "^7.5.4",
290
+ "to": "^7.7.4"
291
+ }
292
+ },
293
+ "depsUpdated": 18,
294
+ "originalPackage": "elastic-apm-node",
295
+ "originalVersion": "4.15.0",
296
+ "processedAt": "2026-03-19T03:31:07.781Z",
297
+ "smokeTest": "failed"
298
+ }
299
+ }
package/start.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and other contributors where applicable.
3
+ * Licensed under the BSD 2-Clause License; you may not use this file except in
4
+ * compliance with the BSD 2-Clause License.
5
+ */
6
+
7
+ import * as agent from './';
8
+ export = agent;
package/start.js ADDED
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and other contributors where applicable.
3
+ * Licensed under the BSD 2-Clause License; you may not use this file except in
4
+ * compliance with the BSD 2-Clause License.
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ // Load and start the APM agent.
10
+ //
11
+ // Note: Currently this will *not* start the agent in Worker threads because
12
+ // that is arguably not desired default behavior when using:
13
+ // node --require=elastic-apm-node/start.js ...
14
+
15
+ const apm = require('./');
16
+
17
+ var isMainThread;
18
+ try {
19
+ var workerThreads = require('worker_threads');
20
+ isMainThread = workerThreads.isMainThread;
21
+ } catch (_importErr) {
22
+ // worker_threads were added in node 12 and behind a flag in node ^10.5.0.
23
+ isMainThread = true;
24
+ }
25
+ if (isMainThread) {
26
+ apm.start();
27
+ }
28
+
29
+ module.exports = apm;
@@ -0,0 +1,98 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and other contributors where applicable.
3
+ * Licensed under the BSD 2-Clause License; you may not use this file except in
4
+ * compliance with the BSD 2-Clause License.
5
+ */
6
+
7
+ // Inlined from @types/aws-lambda
8
+ //
9
+ // These types are inlined, rather than being used from `@types/aws-lambda`
10
+ // directly, as a trade-off. It avoids needing an additional entry in
11
+ // "dependencies" just for types. It avoids TypeScript users of
12
+ // elastic-apm-node needing to manually `npm install @types/aws-lambda`.
13
+ //
14
+ // https://github.com/elastic/apm-agent-nodejs/issues/2331#issuecomment-921251030
15
+
16
+ /**
17
+ * This project is licensed under the MIT license.
18
+ * Copyrights are respective of each contributor listed at the beginning of each definition file.
19
+ *
20
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
21
+ * of this software and associated documentation files (the "Software"), to deal
22
+ * in the Software without restriction, including without limitation the rights
23
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24
+ * copies of the Software, and to permit persons to whom the Software is
25
+ * furnished to do so, subject to the following conditions:
26
+ *
27
+ * The above copyright notice and this permission notice shall be included in
28
+ * all copies or substantial portions of the Software.
29
+ *
30
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36
+ * SOFTWARE.
37
+ */
38
+
39
+ export declare namespace AwsLambda {
40
+ interface CognitoIdentity {
41
+ cognitoIdentityId: string;
42
+ cognitoIdentityPoolId: string;
43
+ }
44
+
45
+ interface ClientContext {
46
+ client: ClientContextClient;
47
+ custom?: any;
48
+ env: ClientContextEnv;
49
+ }
50
+
51
+ interface ClientContextClient {
52
+ installationId: string;
53
+ appTitle: string;
54
+ appVersionName: string;
55
+ appVersionCode: string;
56
+ appPackageName: string;
57
+ }
58
+
59
+ interface ClientContextEnv {
60
+ platformVersion: string;
61
+ platform: string;
62
+ make: string;
63
+ model: string;
64
+ locale: string;
65
+ }
66
+
67
+ type Callback<TResult = any> = (error?: Error | null | string, result?: TResult) => void;
68
+
69
+ interface Context {
70
+ // Properties
71
+ callbackWaitsForEmptyEventLoop: boolean;
72
+ functionName: string;
73
+ functionVersion: string;
74
+ invokedFunctionArn: string;
75
+ memoryLimitInMB: string;
76
+ awsRequestId: string;
77
+ logGroupName: string;
78
+ logStreamName: string;
79
+ identity?: CognitoIdentity;
80
+ clientContext?: ClientContext;
81
+
82
+ // Functions
83
+ getRemainingTimeInMillis(): number;
84
+
85
+ // Functions for compatibility with earlier Node.js Runtime v0.10.42
86
+ // For more details see http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-using-old-runtime.html#nodejs-prog-model-oldruntime-context-methods
87
+ done(error?: Error, result?: any): void;
88
+ fail(error: Error | string): void;
89
+ succeed(messageOrObject: any): void;
90
+ succeed(message: string, object: any): void;
91
+ }
92
+
93
+ type Handler<TEvent = any, TResult = any> = (
94
+ event: TEvent,
95
+ context: Context,
96
+ callback: Callback<TResult>,
97
+ ) => void | Promise<TResult>;
98
+ }
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and other contributors where applicable.
3
+ * Licensed under the BSD 2-Clause License; you may not use this file except in
4
+ * compliance with the BSD 2-Clause License.
5
+ */
6
+
7
+ /// <reference types="node" />
8
+
9
+ // Inlined from @types/connect
10
+ //
11
+ // These types are inlined, rather than being used from `@types/connect`
12
+ // directly, as a trade-off. It avoids needing an additional entry in
13
+ // "dependencies" just for types. It avoids TypeScript users of
14
+ // elastic-apm-node needing to manually `npm install @types/connect`.
15
+ //
16
+ // https://github.com/elastic/apm-agent-nodejs/issues/2331#issuecomment-921251030
17
+
18
+ import type { IncomingMessage, ServerResponse } from 'http';
19
+
20
+ export declare namespace Connect {
21
+ type NextFunction = (err?: any) => void;
22
+ type ErrorHandleFunction = (err: any, req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
23
+ }