@gasket/plugin-elastic-apm 7.5.1 → 8.0.0-next.1
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.
- package/lib/index.js +0 -3
- package/package.json +6 -13
- package/cjs/actions.cjs +0 -65
- package/cjs/configure.cjs +0 -36
- package/cjs/cookies.cjs +0 -48
- package/cjs/create.cjs +0 -33
- package/cjs/index.cjs +0 -109
- package/cjs/package.json +0 -1
- package/lib/create.js +0 -25
package/lib/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/// <reference types="create-gasket-app" />
|
|
2
1
|
/// <reference types="@gasket/plugin-metadata" />
|
|
3
2
|
|
|
4
3
|
import * as actions from './actions.js';
|
|
5
|
-
import create from './create.js';
|
|
6
4
|
import configure from './configure.js';
|
|
7
5
|
import packageJson from '../package.json' with { type: 'json' };
|
|
8
6
|
const { name, version, description } = packageJson;
|
|
@@ -15,7 +13,6 @@ const plugin = {
|
|
|
15
13
|
actions,
|
|
16
14
|
hooks: {
|
|
17
15
|
configure,
|
|
18
|
-
create,
|
|
19
16
|
metadata(gasket, meta) {
|
|
20
17
|
return {
|
|
21
18
|
...meta,
|
package/package.json
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gasket/plugin-elastic-apm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-next.1",
|
|
4
4
|
"description": "Adds Elastic APM instrumentation to your application",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"lib",
|
|
9
|
-
"cjs",
|
|
10
9
|
"EXAMPLES.md"
|
|
11
10
|
],
|
|
12
11
|
"exports": {
|
|
13
12
|
".": {
|
|
14
13
|
"types": "./lib/index.d.ts",
|
|
15
|
-
"import": "./lib/index.js"
|
|
16
|
-
"require": "./cjs/index.cjs",
|
|
17
|
-
"default": "./cjs/index.cjs"
|
|
14
|
+
"import": "./lib/index.js"
|
|
18
15
|
},
|
|
19
16
|
"./package.json": "./package.json"
|
|
20
17
|
},
|
|
@@ -33,20 +30,16 @@
|
|
|
33
30
|
"bugs": "https://github.com/godaddy/gasket/issues",
|
|
34
31
|
"homepage": "https://github.com/godaddy/gasket/tree/main/packages/gasket-plugin-elastic-apm",
|
|
35
32
|
"dependencies": {
|
|
36
|
-
"@gasket/request": "^
|
|
33
|
+
"@gasket/request": "^8.0.0-next.1"
|
|
37
34
|
},
|
|
38
35
|
"devDependencies": {
|
|
39
|
-
"dotenv": "^16.4.7",
|
|
40
36
|
"elastic-apm-node": "^4.11.0",
|
|
41
37
|
"vitest": "^3.2.0",
|
|
42
|
-
"@gasket/
|
|
43
|
-
"@gasket/
|
|
44
|
-
"
|
|
45
|
-
"create-gasket-app": "^7.4.17"
|
|
38
|
+
"@gasket/core": "^8.0.0-next.1",
|
|
39
|
+
"@gasket/plugin-metadata": "^8.0.0-next.1",
|
|
40
|
+
"create-gasket-app": "^8.0.0-next.1"
|
|
46
41
|
},
|
|
47
42
|
"scripts": {
|
|
48
|
-
"build": "gasket-cjs ./lib",
|
|
49
|
-
"build:watch": "pnpm run build --watch",
|
|
50
43
|
"lint": "eslint .",
|
|
51
44
|
"lint:fix": "pnpm run lint --fix",
|
|
52
45
|
"posttest": "pnpm run lint && pnpm run typecheck",
|
package/cjs/actions.cjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2
|
-
value: true
|
|
3
|
-
});
|
|
4
|
-
Object.defineProperty(exports, "getApmTransaction", {
|
|
5
|
-
enumerable: true,
|
|
6
|
-
get: function() {
|
|
7
|
-
return getApmTransaction;
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
const _request = require("@gasket/request");
|
|
11
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
12
|
-
if (typeof WeakMap !== "function") return null;
|
|
13
|
-
var cacheBabelInterop = new WeakMap();
|
|
14
|
-
var cacheNodeInterop = new WeakMap();
|
|
15
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
16
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
17
|
-
})(nodeInterop);
|
|
18
|
-
}
|
|
19
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
20
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
21
|
-
return obj;
|
|
22
|
-
}
|
|
23
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
24
|
-
return {
|
|
25
|
-
default: obj
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
29
|
-
if (cache && cache.has(obj)) {
|
|
30
|
-
return cache.get(obj);
|
|
31
|
-
}
|
|
32
|
-
var newObj = {
|
|
33
|
-
__proto__: null
|
|
34
|
-
};
|
|
35
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
36
|
-
for(var key in obj){
|
|
37
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
38
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
39
|
-
if (desc && (desc.get || desc.set)) {
|
|
40
|
-
Object.defineProperty(newObj, key, desc);
|
|
41
|
-
} else {
|
|
42
|
-
newObj[key] = obj[key];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
newObj.default = obj;
|
|
47
|
-
if (cache) {
|
|
48
|
-
cache.set(obj, newObj);
|
|
49
|
-
}
|
|
50
|
-
return newObj;
|
|
51
|
-
}
|
|
52
|
-
const getApmTransaction = (0, _request.withGasketRequestCache)(async function getApmTransaction(gasket, req) {
|
|
53
|
-
const apm = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("elastic-apm-node")));
|
|
54
|
-
if (!apm?.default?.isStarted()) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const transaction = apm.default.currentTransaction;
|
|
58
|
-
if (!transaction) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
await gasket.exec('apmTransaction', transaction, {
|
|
62
|
-
req
|
|
63
|
-
});
|
|
64
|
-
return transaction;
|
|
65
|
-
});
|
package/cjs/configure.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Determines if the Elastic APM agent has sufficient config to be active
|
|
3
|
-
* @param {import('./index.js').ExtendedAgentConfigOptions} config Apm agent config
|
|
4
|
-
* @param {Record<string, string | undefined>} env Environment variables
|
|
5
|
-
* @returns {boolean} A combined config object
|
|
6
|
-
*/ Object.defineProperty(exports, "__esModule", {
|
|
7
|
-
value: true
|
|
8
|
-
});
|
|
9
|
-
Object.defineProperty(exports, /** @type {import('@gasket/core').HookHandler<'configure'>} */ "default", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function() {
|
|
12
|
-
return configure;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
const isActive = (config, env)=>{
|
|
16
|
-
const { active, serverUrl, secretToken } = config;
|
|
17
|
-
if (active || env.ELASTIC_APM_ACTIVE) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
const combined = {
|
|
21
|
-
serverUrl: serverUrl || env.ELASTIC_APM_SERVER_URL,
|
|
22
|
-
secretToken: secretToken || env.ELASTIC_APM_SECRET_TOKEN
|
|
23
|
-
};
|
|
24
|
-
if (combined.serverUrl && combined.secretToken) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
};
|
|
29
|
-
function configure(gasket, config) {
|
|
30
|
-
config.elasticAPM = config.elasticAPM || {};
|
|
31
|
-
// eslint-disable-next-line no-process-env
|
|
32
|
-
config.elasticAPM.active = isActive(config.elasticAPM, process.env);
|
|
33
|
-
return {
|
|
34
|
-
...config
|
|
35
|
-
};
|
|
36
|
-
}
|
package/cjs/cookies.cjs
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns an array of cookie names which are considered sensitive because they
|
|
3
|
-
* may contain session credential or PII
|
|
4
|
-
* @param {import('@gasket/core').GasketConfig} config the Gasket config
|
|
5
|
-
* @returns {string[]} an array of cookie names
|
|
6
|
-
*/ Object.defineProperty(exports, "__esModule", {
|
|
7
|
-
value: true
|
|
8
|
-
});
|
|
9
|
-
function _export(target, all) {
|
|
10
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: all[name]
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
_export(exports, {
|
|
16
|
-
filterSensitiveCookies: function() {
|
|
17
|
-
return filterSensitiveCookies;
|
|
18
|
-
},
|
|
19
|
-
sensitiveCookies: function() {
|
|
20
|
-
return sensitiveCookies;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const sensitiveCookies = (config)=>{
|
|
24
|
-
if (typeof config.elasticAPM === 'undefined' || typeof config.elasticAPM.sensitiveCookies === 'undefined') {
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
return config.elasticAPM.sensitiveCookies;
|
|
28
|
-
};
|
|
29
|
-
const filterSensitiveCookies = function(config) {
|
|
30
|
-
return function(payload) {
|
|
31
|
-
const cookiesToRedact = sensitiveCookies(config);
|
|
32
|
-
if (payload.context && payload.context.request && payload.context.request.headers && payload.context.request.headers.cookie) {
|
|
33
|
-
let cookie = payload.context.request.headers.cookie;
|
|
34
|
-
cookiesToRedact.forEach((sc)=>{
|
|
35
|
-
cookie = cookie.replace(new RegExp(sc + '=([^;]+)'), sc + '=[REDACTED]');
|
|
36
|
-
});
|
|
37
|
-
payload.context.request.headers.cookie = cookie;
|
|
38
|
-
}
|
|
39
|
-
if (payload.context && payload.context.request && payload.context.request.cookies) {
|
|
40
|
-
cookiesToRedact.forEach((sc)=>{
|
|
41
|
-
if (sc in payload.context.request.cookies) {
|
|
42
|
-
payload.context.request.cookies[sc] = '[REDACTED]';
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return payload;
|
|
47
|
-
};
|
|
48
|
-
};
|
package/cjs/create.cjs
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2
|
-
value: true
|
|
3
|
-
});
|
|
4
|
-
Object.defineProperty(exports, /** @type {import('@gasket/core').HookHandler<'create'>} */ "default", {
|
|
5
|
-
enumerable: true,
|
|
6
|
-
get: function() {
|
|
7
|
-
return create;
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
|
|
11
|
-
function _interop_require_default(obj) {
|
|
12
|
-
return obj && obj.__esModule ? obj : {
|
|
13
|
-
default: obj
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
const { name, version, devDependencies } = _packagejson.default;
|
|
17
|
-
function create(gasket, { pkg, files, gasketConfig }) {
|
|
18
|
-
const generatorDir = new URL('../generator', require("url").pathToFileURL(__filename).toString()).pathname;
|
|
19
|
-
gasketConfig.addPlugin('pluginElasticApm', name);
|
|
20
|
-
pkg.add('dependencies', {
|
|
21
|
-
[name]: `^${version}`,
|
|
22
|
-
'dotenv': devDependencies.dotenv,
|
|
23
|
-
'elastic-apm-node': devDependencies['elastic-apm-node']
|
|
24
|
-
});
|
|
25
|
-
pkg.extend((current)=>{
|
|
26
|
-
return {
|
|
27
|
-
scripts: {
|
|
28
|
-
start: `NODE_OPTIONS=--import=./setup.js ${current.scripts.start}`
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
files.add(`${generatorDir}/*`);
|
|
33
|
-
}
|
package/cjs/index.cjs
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/// <reference types="create-gasket-app" />
|
|
2
|
-
/// <reference types="@gasket/plugin-metadata" />
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "default", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function() {
|
|
9
|
-
return _default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
const _actions = /*#__PURE__*/ _interop_require_wildcard(require("./actions.cjs"));
|
|
13
|
-
const _create = /*#__PURE__*/ _interop_require_default(require("./create.cjs"));
|
|
14
|
-
const _configure = /*#__PURE__*/ _interop_require_default(require("./configure.cjs"));
|
|
15
|
-
const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
|
|
16
|
-
function _interop_require_default(obj) {
|
|
17
|
-
return obj && obj.__esModule ? obj : {
|
|
18
|
-
default: obj
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
22
|
-
if (typeof WeakMap !== "function") return null;
|
|
23
|
-
var cacheBabelInterop = new WeakMap();
|
|
24
|
-
var cacheNodeInterop = new WeakMap();
|
|
25
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
26
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
27
|
-
})(nodeInterop);
|
|
28
|
-
}
|
|
29
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
30
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
31
|
-
return obj;
|
|
32
|
-
}
|
|
33
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
34
|
-
return {
|
|
35
|
-
default: obj
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
39
|
-
if (cache && cache.has(obj)) {
|
|
40
|
-
return cache.get(obj);
|
|
41
|
-
}
|
|
42
|
-
var newObj = {
|
|
43
|
-
__proto__: null
|
|
44
|
-
};
|
|
45
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
46
|
-
for(var key in obj){
|
|
47
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
48
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
49
|
-
if (desc && (desc.get || desc.set)) {
|
|
50
|
-
Object.defineProperty(newObj, key, desc);
|
|
51
|
-
} else {
|
|
52
|
-
newObj[key] = obj[key];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
newObj.default = obj;
|
|
57
|
-
if (cache) {
|
|
58
|
-
cache.set(obj, newObj);
|
|
59
|
-
}
|
|
60
|
-
return newObj;
|
|
61
|
-
}
|
|
62
|
-
const { name, version, description } = _packagejson.default;
|
|
63
|
-
/** @type {import('@gasket/core').Plugin} */ const plugin = {
|
|
64
|
-
name,
|
|
65
|
-
version,
|
|
66
|
-
description,
|
|
67
|
-
actions: _actions,
|
|
68
|
-
hooks: {
|
|
69
|
-
configure: _configure.default,
|
|
70
|
-
create: _create.default,
|
|
71
|
-
metadata (gasket, meta) {
|
|
72
|
-
return {
|
|
73
|
-
...meta,
|
|
74
|
-
actions: [
|
|
75
|
-
{
|
|
76
|
-
name: 'getApmTransaction',
|
|
77
|
-
description: 'Get the APM transaction data',
|
|
78
|
-
link: 'README.md#getApmTransaction'
|
|
79
|
-
}
|
|
80
|
-
],
|
|
81
|
-
configurations: [
|
|
82
|
-
{
|
|
83
|
-
name: 'elasticAPM',
|
|
84
|
-
link: 'README.md#configuration',
|
|
85
|
-
description: 'Configuration to provide additional setup helpers',
|
|
86
|
-
type: 'object'
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: 'elasticAPM.sensitiveCookies',
|
|
90
|
-
link: 'README.md#configuration',
|
|
91
|
-
description: 'List of sensitive cookies to filter',
|
|
92
|
-
type: 'string[]',
|
|
93
|
-
default: '[]'
|
|
94
|
-
}
|
|
95
|
-
],
|
|
96
|
-
lifecycles: [
|
|
97
|
-
{
|
|
98
|
-
name: 'apmTransaction',
|
|
99
|
-
method: 'exec',
|
|
100
|
-
description: 'Modify the APM transaction',
|
|
101
|
-
link: 'README.md#apmtransaction',
|
|
102
|
-
parent: 'middleware'
|
|
103
|
-
}
|
|
104
|
-
]
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
const _default = plugin;
|
package/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
package/lib/create.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import packageJson from '../package.json' with { type: 'json' };
|
|
2
|
-
const { name, version, devDependencies } = packageJson;
|
|
3
|
-
|
|
4
|
-
/** @type {import('@gasket/core').HookHandler<'create'>} */
|
|
5
|
-
export default function create(gasket, { pkg, files, gasketConfig }) {
|
|
6
|
-
const generatorDir = new URL('../generator', import.meta.url).pathname;
|
|
7
|
-
|
|
8
|
-
gasketConfig.addPlugin('pluginElasticApm', name);
|
|
9
|
-
|
|
10
|
-
pkg.add('dependencies', {
|
|
11
|
-
[name]: `^${version}`,
|
|
12
|
-
'dotenv': devDependencies.dotenv,
|
|
13
|
-
'elastic-apm-node': devDependencies['elastic-apm-node']
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
pkg.extend((current) => {
|
|
17
|
-
return {
|
|
18
|
-
scripts: {
|
|
19
|
-
start: `NODE_OPTIONS=--import=./setup.js ${current.scripts.start}`
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
files.add(`${generatorDir}/*`);
|
|
25
|
-
}
|