@commercetools/ts-sdk-apm 3.0.0 → 3.2.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.
- package/CHANGELOG.md +12 -0
- package/dist/commercetools-ts-sdk-apm.browser.cjs.js +66 -1
- package/dist/commercetools-ts-sdk-apm.browser.esm.js +61 -1
- package/dist/commercetools-ts-sdk-apm.cjs.dev.js +66 -1
- package/dist/commercetools-ts-sdk-apm.cjs.prod.js +66 -1
- package/dist/commercetools-ts-sdk-apm.esm.js +61 -1
- package/dist/declarations/src/apm-legacy.d.ts +8 -0
- package/dist/declarations/src/apm-legacy.d.ts.map +1 -0
- package/dist/declarations/src/apm.d.ts.map +1 -1
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/index.d.ts.map +1 -1
- package/dist/declarations/types/types.d.ts +92 -55
- package/dist/newRelicHelper-2ce5bdaf.cjs.prod.js +14 -0
- package/dist/newRelicHelper-76fc4f4a.cjs.dev.js +14 -0
- package/dist/newRelicHelper-7e5ab5ea.browser.cjs.js +14 -0
- package/dist/newRelicHelper-b7df4fbe.esm.js +8 -0
- package/dist/newRelicHelper-ed9e1fad.browser.esm.js +8 -0
- package/package.json +10 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @commercetools/ts-sdk-apm
|
|
2
2
|
|
|
3
|
+
## 3.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#933](https://github.com/commercetools/commercetools-sdk-typescript/pull/933) [`be7e9d3`](https://github.com/commercetools/commercetools-sdk-typescript/commit/be7e9d39fb01c696ecb5c5056e50f1376900405d) Thanks [@ajimae](https://github.com/ajimae)! - Release latest typescript apm monitoring package
|
|
8
|
+
|
|
9
|
+
## 3.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#861](https://github.com/commercetools/commercetools-sdk-typescript/pull/861) [`e8a0e92`](https://github.com/commercetools/commercetools-sdk-typescript/commit/e8a0e928e2ab48bd47d6ff6384f385b24e485755) Thanks [@ajimae](https://github.com/ajimae)! - Add custom metric
|
|
14
|
+
|
|
3
15
|
## 3.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
|
@@ -2,6 +2,64 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var datadog = require('dd-trace');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var datadog__default = /*#__PURE__*/_interopDefault(datadog);
|
|
10
|
+
|
|
11
|
+
// Initialize datadog once
|
|
12
|
+
datadog__default["default"].init();
|
|
13
|
+
|
|
14
|
+
// Record metrics for datadog
|
|
15
|
+
const recordDatadog = (metric, tags) => {
|
|
16
|
+
datadog__default["default"].dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const time = () => performance.now();
|
|
20
|
+
|
|
21
|
+
function createTelemetryMiddleware$1(options) {
|
|
22
|
+
// trace
|
|
23
|
+
function trace() {
|
|
24
|
+
// validate apm and tracer
|
|
25
|
+
if (!(options?.apm && typeof options.apm == 'function')) {
|
|
26
|
+
options.apm = () => {};
|
|
27
|
+
}
|
|
28
|
+
if (!(options?.tracer && typeof options.tracer == 'function')) {
|
|
29
|
+
options.tracer = () => {};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
trace(); // expose tracing modules
|
|
33
|
+
|
|
34
|
+
return next => async request => {
|
|
35
|
+
// get start (high resolution milliseconds) timestamp
|
|
36
|
+
const start = time();
|
|
37
|
+
const nextRequest = {
|
|
38
|
+
...request,
|
|
39
|
+
...options
|
|
40
|
+
};
|
|
41
|
+
const response = await next(nextRequest);
|
|
42
|
+
const response_time = time() - start;
|
|
43
|
+
|
|
44
|
+
// send `response_time` to APM platforms
|
|
45
|
+
if (options?.customMetrics) {
|
|
46
|
+
if (options.customMetrics.datadog) {
|
|
47
|
+
recordDatadog(response_time, {
|
|
48
|
+
env: process.env.NODE_ENV || 'dev'
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (options.customMetrics.newrelic) {
|
|
52
|
+
// Lazy load New Relic only if necessary otherwise it will require to have set the env variable NEW_RELIC_APP_NAME
|
|
53
|
+
const {
|
|
54
|
+
recordNewRelic
|
|
55
|
+
} = await Promise.resolve().then(function () { return require('./newRelicHelper-7e5ab5ea.browser.cjs.js'); });
|
|
56
|
+
recordNewRelic(response_time);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return response;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
5
63
|
/**
|
|
6
64
|
* default newrelic APM and
|
|
7
65
|
* opentelemetry tracer modules
|
|
@@ -16,6 +74,12 @@ const defaultOptions = {
|
|
|
16
74
|
apm: () => {},
|
|
17
75
|
tracer: () => require('../opentelemetry')
|
|
18
76
|
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated use new `createTelemetryMiddleware`
|
|
80
|
+
* @param options
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
19
83
|
function createTelemetryMiddleware(options) {
|
|
20
84
|
// trace
|
|
21
85
|
function trace() {
|
|
@@ -39,4 +103,5 @@ function createTelemetryMiddleware(options) {
|
|
|
39
103
|
};
|
|
40
104
|
}
|
|
41
105
|
|
|
42
|
-
exports.createTelemetryMiddleware = createTelemetryMiddleware;
|
|
106
|
+
exports.createTelemetryMiddleware = createTelemetryMiddleware$1;
|
|
107
|
+
exports.createTelemetryMiddlewareLegacy = createTelemetryMiddleware;
|
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
import datadog from 'dd-trace';
|
|
2
|
+
|
|
3
|
+
// Initialize datadog once
|
|
4
|
+
datadog.init();
|
|
5
|
+
|
|
6
|
+
// Record metrics for datadog
|
|
7
|
+
const recordDatadog = (metric, tags) => {
|
|
8
|
+
datadog.dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const time = () => performance.now();
|
|
12
|
+
|
|
13
|
+
function createTelemetryMiddleware$1(options) {
|
|
14
|
+
// trace
|
|
15
|
+
function trace() {
|
|
16
|
+
// validate apm and tracer
|
|
17
|
+
if (!(options?.apm && typeof options.apm == 'function')) {
|
|
18
|
+
options.apm = () => {};
|
|
19
|
+
}
|
|
20
|
+
if (!(options?.tracer && typeof options.tracer == 'function')) {
|
|
21
|
+
options.tracer = () => {};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
trace(); // expose tracing modules
|
|
25
|
+
|
|
26
|
+
return next => async request => {
|
|
27
|
+
// get start (high resolution milliseconds) timestamp
|
|
28
|
+
const start = time();
|
|
29
|
+
const nextRequest = {
|
|
30
|
+
...request,
|
|
31
|
+
...options
|
|
32
|
+
};
|
|
33
|
+
const response = await next(nextRequest);
|
|
34
|
+
const response_time = time() - start;
|
|
35
|
+
|
|
36
|
+
// send `response_time` to APM platforms
|
|
37
|
+
if (options?.customMetrics) {
|
|
38
|
+
if (options.customMetrics.datadog) {
|
|
39
|
+
recordDatadog(response_time, {
|
|
40
|
+
env: process.env.NODE_ENV || 'dev'
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (options.customMetrics.newrelic) {
|
|
44
|
+
// Lazy load New Relic only if necessary otherwise it will require to have set the env variable NEW_RELIC_APP_NAME
|
|
45
|
+
const {
|
|
46
|
+
recordNewRelic
|
|
47
|
+
} = await import('./newRelicHelper-ed9e1fad.browser.esm.js');
|
|
48
|
+
recordNewRelic(response_time);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return response;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
1
55
|
/**
|
|
2
56
|
* default newrelic APM and
|
|
3
57
|
* opentelemetry tracer modules
|
|
@@ -12,6 +66,12 @@ const defaultOptions = {
|
|
|
12
66
|
apm: () => {},
|
|
13
67
|
tracer: () => require('../opentelemetry')
|
|
14
68
|
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @deprecated use new `createTelemetryMiddleware`
|
|
72
|
+
* @param options
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
15
75
|
function createTelemetryMiddleware(options) {
|
|
16
76
|
// trace
|
|
17
77
|
function trace() {
|
|
@@ -35,4 +95,4 @@ function createTelemetryMiddleware(options) {
|
|
|
35
95
|
};
|
|
36
96
|
}
|
|
37
97
|
|
|
38
|
-
export { createTelemetryMiddleware };
|
|
98
|
+
export { createTelemetryMiddleware$1 as createTelemetryMiddleware, createTelemetryMiddleware as createTelemetryMiddlewareLegacy };
|
|
@@ -2,6 +2,64 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var datadog = require('dd-trace');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var datadog__default = /*#__PURE__*/_interopDefault(datadog);
|
|
10
|
+
|
|
11
|
+
// Initialize datadog once
|
|
12
|
+
datadog__default["default"].init();
|
|
13
|
+
|
|
14
|
+
// Record metrics for datadog
|
|
15
|
+
const recordDatadog = (metric, tags) => {
|
|
16
|
+
datadog__default["default"].dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const time = () => performance.now();
|
|
20
|
+
|
|
21
|
+
function createTelemetryMiddleware$1(options) {
|
|
22
|
+
// trace
|
|
23
|
+
function trace() {
|
|
24
|
+
// validate apm and tracer
|
|
25
|
+
if (!(options?.apm && typeof options.apm == 'function')) {
|
|
26
|
+
options.apm = () => {};
|
|
27
|
+
}
|
|
28
|
+
if (!(options?.tracer && typeof options.tracer == 'function')) {
|
|
29
|
+
options.tracer = () => {};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
trace(); // expose tracing modules
|
|
33
|
+
|
|
34
|
+
return next => async request => {
|
|
35
|
+
// get start (high resolution milliseconds) timestamp
|
|
36
|
+
const start = time();
|
|
37
|
+
const nextRequest = {
|
|
38
|
+
...request,
|
|
39
|
+
...options
|
|
40
|
+
};
|
|
41
|
+
const response = await next(nextRequest);
|
|
42
|
+
const response_time = time() - start;
|
|
43
|
+
|
|
44
|
+
// send `response_time` to APM platforms
|
|
45
|
+
if (options?.customMetrics) {
|
|
46
|
+
if (options.customMetrics.datadog) {
|
|
47
|
+
recordDatadog(response_time, {
|
|
48
|
+
env: process.env.NODE_ENV || 'dev'
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (options.customMetrics.newrelic) {
|
|
52
|
+
// Lazy load New Relic only if necessary otherwise it will require to have set the env variable NEW_RELIC_APP_NAME
|
|
53
|
+
const {
|
|
54
|
+
recordNewRelic
|
|
55
|
+
} = await Promise.resolve().then(function () { return require('./newRelicHelper-76fc4f4a.cjs.dev.js'); });
|
|
56
|
+
recordNewRelic(response_time);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return response;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
5
63
|
/**
|
|
6
64
|
* default newrelic APM and
|
|
7
65
|
* opentelemetry tracer modules
|
|
@@ -16,6 +74,12 @@ const defaultOptions = {
|
|
|
16
74
|
apm: () => {},
|
|
17
75
|
tracer: () => require('../opentelemetry')
|
|
18
76
|
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated use new `createTelemetryMiddleware`
|
|
80
|
+
* @param options
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
19
83
|
function createTelemetryMiddleware(options) {
|
|
20
84
|
// trace
|
|
21
85
|
function trace() {
|
|
@@ -39,4 +103,5 @@ function createTelemetryMiddleware(options) {
|
|
|
39
103
|
};
|
|
40
104
|
}
|
|
41
105
|
|
|
42
|
-
exports.createTelemetryMiddleware = createTelemetryMiddleware;
|
|
106
|
+
exports.createTelemetryMiddleware = createTelemetryMiddleware$1;
|
|
107
|
+
exports.createTelemetryMiddlewareLegacy = createTelemetryMiddleware;
|
|
@@ -2,6 +2,64 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var datadog = require('dd-trace');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var datadog__default = /*#__PURE__*/_interopDefault(datadog);
|
|
10
|
+
|
|
11
|
+
// Initialize datadog once
|
|
12
|
+
datadog__default["default"].init();
|
|
13
|
+
|
|
14
|
+
// Record metrics for datadog
|
|
15
|
+
const recordDatadog = (metric, tags) => {
|
|
16
|
+
datadog__default["default"].dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const time = () => performance.now();
|
|
20
|
+
|
|
21
|
+
function createTelemetryMiddleware$1(options) {
|
|
22
|
+
// trace
|
|
23
|
+
function trace() {
|
|
24
|
+
// validate apm and tracer
|
|
25
|
+
if (!(options?.apm && typeof options.apm == 'function')) {
|
|
26
|
+
options.apm = () => {};
|
|
27
|
+
}
|
|
28
|
+
if (!(options?.tracer && typeof options.tracer == 'function')) {
|
|
29
|
+
options.tracer = () => {};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
trace(); // expose tracing modules
|
|
33
|
+
|
|
34
|
+
return next => async request => {
|
|
35
|
+
// get start (high resolution milliseconds) timestamp
|
|
36
|
+
const start = time();
|
|
37
|
+
const nextRequest = {
|
|
38
|
+
...request,
|
|
39
|
+
...options
|
|
40
|
+
};
|
|
41
|
+
const response = await next(nextRequest);
|
|
42
|
+
const response_time = time() - start;
|
|
43
|
+
|
|
44
|
+
// send `response_time` to APM platforms
|
|
45
|
+
if (options?.customMetrics) {
|
|
46
|
+
if (options.customMetrics.datadog) {
|
|
47
|
+
recordDatadog(response_time, {
|
|
48
|
+
env: "production"
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (options.customMetrics.newrelic) {
|
|
52
|
+
// Lazy load New Relic only if necessary otherwise it will require to have set the env variable NEW_RELIC_APP_NAME
|
|
53
|
+
const {
|
|
54
|
+
recordNewRelic
|
|
55
|
+
} = await Promise.resolve().then(function () { return require('./newRelicHelper-2ce5bdaf.cjs.prod.js'); });
|
|
56
|
+
recordNewRelic(response_time);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return response;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
5
63
|
/**
|
|
6
64
|
* default newrelic APM and
|
|
7
65
|
* opentelemetry tracer modules
|
|
@@ -16,6 +74,12 @@ const defaultOptions = {
|
|
|
16
74
|
apm: () => {},
|
|
17
75
|
tracer: () => require('../opentelemetry')
|
|
18
76
|
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated use new `createTelemetryMiddleware`
|
|
80
|
+
* @param options
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
19
83
|
function createTelemetryMiddleware(options) {
|
|
20
84
|
// trace
|
|
21
85
|
function trace() {
|
|
@@ -39,4 +103,5 @@ function createTelemetryMiddleware(options) {
|
|
|
39
103
|
};
|
|
40
104
|
}
|
|
41
105
|
|
|
42
|
-
exports.createTelemetryMiddleware = createTelemetryMiddleware;
|
|
106
|
+
exports.createTelemetryMiddleware = createTelemetryMiddleware$1;
|
|
107
|
+
exports.createTelemetryMiddlewareLegacy = createTelemetryMiddleware;
|
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
import datadog from 'dd-trace';
|
|
2
|
+
|
|
3
|
+
// Initialize datadog once
|
|
4
|
+
datadog.init();
|
|
5
|
+
|
|
6
|
+
// Record metrics for datadog
|
|
7
|
+
const recordDatadog = (metric, tags) => {
|
|
8
|
+
datadog.dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const time = () => performance.now();
|
|
12
|
+
|
|
13
|
+
function createTelemetryMiddleware$1(options) {
|
|
14
|
+
// trace
|
|
15
|
+
function trace() {
|
|
16
|
+
// validate apm and tracer
|
|
17
|
+
if (!(options?.apm && typeof options.apm == 'function')) {
|
|
18
|
+
options.apm = () => {};
|
|
19
|
+
}
|
|
20
|
+
if (!(options?.tracer && typeof options.tracer == 'function')) {
|
|
21
|
+
options.tracer = () => {};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
trace(); // expose tracing modules
|
|
25
|
+
|
|
26
|
+
return next => async request => {
|
|
27
|
+
// get start (high resolution milliseconds) timestamp
|
|
28
|
+
const start = time();
|
|
29
|
+
const nextRequest = {
|
|
30
|
+
...request,
|
|
31
|
+
...options
|
|
32
|
+
};
|
|
33
|
+
const response = await next(nextRequest);
|
|
34
|
+
const response_time = time() - start;
|
|
35
|
+
|
|
36
|
+
// send `response_time` to APM platforms
|
|
37
|
+
if (options?.customMetrics) {
|
|
38
|
+
if (options.customMetrics.datadog) {
|
|
39
|
+
recordDatadog(response_time, {
|
|
40
|
+
env: process.env.NODE_ENV || 'dev'
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (options.customMetrics.newrelic) {
|
|
44
|
+
// Lazy load New Relic only if necessary otherwise it will require to have set the env variable NEW_RELIC_APP_NAME
|
|
45
|
+
const {
|
|
46
|
+
recordNewRelic
|
|
47
|
+
} = await import('./newRelicHelper-b7df4fbe.esm.js');
|
|
48
|
+
recordNewRelic(response_time);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return response;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
1
55
|
/**
|
|
2
56
|
* default newrelic APM and
|
|
3
57
|
* opentelemetry tracer modules
|
|
@@ -12,6 +66,12 @@ const defaultOptions = {
|
|
|
12
66
|
apm: () => {},
|
|
13
67
|
tracer: () => require('../opentelemetry')
|
|
14
68
|
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @deprecated use new `createTelemetryMiddleware`
|
|
72
|
+
* @param options
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
15
75
|
function createTelemetryMiddleware(options) {
|
|
16
76
|
// trace
|
|
17
77
|
function trace() {
|
|
@@ -35,4 +95,4 @@ function createTelemetryMiddleware(options) {
|
|
|
35
95
|
};
|
|
36
96
|
}
|
|
37
97
|
|
|
38
|
-
export { createTelemetryMiddleware };
|
|
98
|
+
export { createTelemetryMiddleware$1 as createTelemetryMiddleware, createTelemetryMiddleware as createTelemetryMiddlewareLegacy };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MiddlewareLegacy, OTelemetryMiddlewareOptions } from "../types/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated use new `createTelemetryMiddleware`
|
|
4
|
+
* @param options
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export default function createTelemetryMiddleware(options: OTelemetryMiddlewareOptions): MiddlewareLegacy;
|
|
8
|
+
//# sourceMappingURL=apm-legacy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apm-legacy.d.ts","sourceRoot":"../../../src","sources":["apm-legacy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAIhB,2BAA2B,EAC5B,0BAAsB;AAiBvB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,OAAO,EAAE,2BAA2B,GACnC,gBAAgB,CA0BlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apm.d.ts","sourceRoot":"../../../src","sources":["apm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAIV,2BAA2B,EAC5B,0BAAsB;
|
|
1
|
+
{"version":3,"file":"apm.d.ts","sourceRoot":"../../../src","sources":["apm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAIV,2BAA2B,EAC5B,0BAAsB;AAIvB,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,OAAO,EAAE,2BAA2B,GACnC,UAAU,CA0CZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AAAA,kCAAgC;AAChC,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,iBAAa"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AAAA,kCAAgC;AAChC,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,iBAAa;AAC5D,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,wBAAoB"}
|
|
@@ -1,48 +1,57 @@
|
|
|
1
1
|
export type JsonObject<T = unknown> = { [key: string]: T }
|
|
2
2
|
export type MiddlewareRequest = ClientRequest
|
|
3
|
-
export type Middleware = (next: Dispatch) => Dispatch
|
|
4
3
|
|
|
5
|
-
export type
|
|
6
|
-
request: MiddlewareRequest,
|
|
7
|
-
response: MiddlewareResponse
|
|
8
|
-
) => unknown
|
|
4
|
+
export type Middleware = (next: Next) => (request: MiddlewareRequest) => Promise<MiddlewareResponse>
|
|
9
5
|
|
|
10
|
-
export type
|
|
11
|
-
|
|
12
|
-
response: MiddlewareResponse
|
|
13
|
-
) => unknown
|
|
6
|
+
// export type Dispatch = (next: Next) => (request: MiddlewareRequest) => Promise<MiddlewareResponse>
|
|
7
|
+
export type Next = (request: MiddlewareRequest) => Promise<MiddlewareResponse>
|
|
14
8
|
|
|
15
|
-
export type MiddlewareResponse = {
|
|
16
|
-
resolve
|
|
17
|
-
reject
|
|
18
|
-
body
|
|
19
|
-
error?: HttpErrorType
|
|
20
|
-
statusCode: number
|
|
21
|
-
headers?:
|
|
22
|
-
|
|
9
|
+
export type MiddlewareResponse<T = unknown> = {
|
|
10
|
+
resolve: Function;
|
|
11
|
+
reject: Function;
|
|
12
|
+
body: T;
|
|
13
|
+
error?: HttpErrorType;
|
|
14
|
+
statusCode: number;
|
|
15
|
+
headers?: Record<string, any>
|
|
16
|
+
originalRequest?: MiddlewareRequest;
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
export interface ClientRequest {
|
|
26
20
|
baseUri?: string
|
|
27
21
|
uri?: string
|
|
28
|
-
headers?:
|
|
22
|
+
headers?: Record<string, any>
|
|
29
23
|
method: MethodType
|
|
30
24
|
uriTemplate?: string
|
|
31
25
|
pathVariables?: VariableMap
|
|
32
26
|
queryParams?: VariableMap
|
|
33
|
-
body?: any
|
|
27
|
+
body?: Record<string, any> | string | Uint8Array;
|
|
28
|
+
response?: ClientResponse
|
|
29
|
+
resolve?: Function;
|
|
30
|
+
reject?: Function;
|
|
31
|
+
[key: string]: any
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type ClientResponse<T = any> = {
|
|
35
|
+
body: T
|
|
36
|
+
code?: number
|
|
37
|
+
statusCode?: number
|
|
38
|
+
headers?: Record<string, any>
|
|
39
|
+
error?: HttpErrorType
|
|
40
|
+
retryCount?: number
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
export type HttpErrorType = {
|
|
37
|
-
name
|
|
44
|
+
name?: string
|
|
38
45
|
message: string
|
|
39
|
-
code
|
|
40
|
-
status
|
|
46
|
+
code?: number
|
|
47
|
+
status?: number
|
|
48
|
+
method: MethodType
|
|
41
49
|
statusCode: number
|
|
42
|
-
originalRequest
|
|
43
|
-
body
|
|
50
|
+
originalRequest?: ClientRequest
|
|
51
|
+
body: JsonObject
|
|
44
52
|
retryCount?: number
|
|
45
|
-
headers?:
|
|
53
|
+
headers?: Record<string, any>
|
|
54
|
+
[key: string]: any
|
|
46
55
|
}
|
|
47
56
|
|
|
48
57
|
export type VariableMap = {
|
|
@@ -58,47 +67,75 @@ export type QueryParam =
|
|
|
58
67
|
| boolean[]
|
|
59
68
|
| undefined
|
|
60
69
|
|
|
61
|
-
export type MethodType =
|
|
62
|
-
| 'ACL'
|
|
63
|
-
| 'BIND'
|
|
64
|
-
| 'CHECKOUT'
|
|
65
|
-
| 'CONNECT'
|
|
66
|
-
| 'COPY'
|
|
67
|
-
| 'DELETE'
|
|
70
|
+
export type MethodType =
|
|
68
71
|
| 'GET'
|
|
69
72
|
| 'HEAD'
|
|
70
|
-
| 'LINK'
|
|
71
|
-
| 'LOCK'
|
|
72
|
-
| 'M-SEARCH'
|
|
73
|
-
| 'MERGE'
|
|
74
|
-
| 'MKACTIVITY'
|
|
75
|
-
| 'MKCALENDAR'
|
|
76
|
-
| 'MKCOL'
|
|
77
|
-
| 'MOVE'
|
|
78
|
-
| 'NOTIFY'
|
|
79
|
-
| 'OPTIONS'
|
|
80
|
-
| 'PATCH'
|
|
81
73
|
| 'POST'
|
|
82
|
-
| 'PROPFIND'
|
|
83
|
-
| 'PROPPATCH'
|
|
84
|
-
| 'PURGE'
|
|
85
74
|
| 'PUT'
|
|
86
|
-
| '
|
|
87
|
-
| '
|
|
88
|
-
| '
|
|
89
|
-
| '
|
|
90
|
-
| 'SUBSCRIBE'
|
|
75
|
+
| 'PATCH'
|
|
76
|
+
| 'DELETE'
|
|
77
|
+
| 'CONNECT'
|
|
78
|
+
| 'OPTIONS'
|
|
91
79
|
| 'TRACE'
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
|
|
81
|
+
export type CustomMetric = {
|
|
82
|
+
newrelic?: boolean;
|
|
83
|
+
datadog?: boolean;
|
|
84
|
+
}
|
|
96
85
|
|
|
97
86
|
export type TelemetryMiddlewareOptions = {
|
|
98
87
|
apm?: Function;
|
|
99
88
|
tracer?: Function;
|
|
100
89
|
userAgent?: string;
|
|
90
|
+
customMetrics?: CustomMetric;
|
|
101
91
|
createTelemetryMiddleware: (options?: OTelemetryMiddlewareOptions) => Middleware
|
|
102
92
|
}
|
|
103
93
|
|
|
104
94
|
export type OTelemetryMiddlewareOptions = Omit<TelemetryMiddlewareOptions, 'createTelemetryMiddleware'>
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
// LEGACY TYPES
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated
|
|
100
|
+
*/
|
|
101
|
+
export type NextLegacy = (
|
|
102
|
+
request: MiddlewareRequestLegacy,
|
|
103
|
+
response: MiddlewareResponseLegacy
|
|
104
|
+
) => unknown
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated
|
|
108
|
+
*/
|
|
109
|
+
export type MiddlewareResponseLegacy = {
|
|
110
|
+
resolve(response: JsonObject): void
|
|
111
|
+
reject(error: JsonObject): void
|
|
112
|
+
body?: JsonObject
|
|
113
|
+
error?: HttpErrorType
|
|
114
|
+
statusCode: number
|
|
115
|
+
headers?: JsonObject<string>
|
|
116
|
+
request?: JsonObject
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @deprecated
|
|
121
|
+
*/
|
|
122
|
+
export interface ClientRequestLegacy {
|
|
123
|
+
baseUri?: string
|
|
124
|
+
uri?: string
|
|
125
|
+
headers?: VariableMap
|
|
126
|
+
method: MethodType
|
|
127
|
+
uriTemplate?: string
|
|
128
|
+
pathVariables?: VariableMap
|
|
129
|
+
queryParams?: VariableMap
|
|
130
|
+
body?: any,
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated
|
|
135
|
+
*/
|
|
136
|
+
export type MiddlewareLegacy = (next: NextLegacy) => NextLegacy
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @deprecated
|
|
140
|
+
*/
|
|
141
|
+
export type MiddlewareRequestLegacy = ClientRequestLegacy
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var newrelic = require('newrelic');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
var newrelic__default = /*#__PURE__*/_interopDefault(newrelic);
|
|
8
|
+
|
|
9
|
+
// record for newrelic
|
|
10
|
+
const recordNewRelic = metric => {
|
|
11
|
+
newrelic__default["default"].recordMetric(`Commercetools/Client/Response/Total`, metric);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.recordNewRelic = recordNewRelic;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var newrelic = require('newrelic');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
var newrelic__default = /*#__PURE__*/_interopDefault(newrelic);
|
|
8
|
+
|
|
9
|
+
// record for newrelic
|
|
10
|
+
const recordNewRelic = metric => {
|
|
11
|
+
newrelic__default["default"].recordMetric(`Commercetools/Client/Response/Total`, metric);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.recordNewRelic = recordNewRelic;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var newrelic = require('newrelic');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
var newrelic__default = /*#__PURE__*/_interopDefault(newrelic);
|
|
8
|
+
|
|
9
|
+
// record for newrelic
|
|
10
|
+
const recordNewRelic = metric => {
|
|
11
|
+
newrelic__default["default"].recordMetric(`Commercetools/Client/Response/Total`, metric);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.recordNewRelic = recordNewRelic;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools/ts-sdk-apm",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "commercetools typescript SDK application performance monitoring.",
|
|
5
5
|
"main": "dist/commercetools-ts-sdk-apm.cjs.js",
|
|
6
6
|
"module": "dist/commercetools-ts-sdk-apm.esm.js",
|
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
"private": false,
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@opentelemetry/api": "^1.4.1",
|
|
12
|
-
"@opentelemetry/auto-instrumentations-node": "^0.
|
|
13
|
-
"@opentelemetry/exporter-metrics-otlp-http": "^0.
|
|
14
|
-
"@opentelemetry/sdk-node": "^0.
|
|
15
|
-
"
|
|
12
|
+
"@opentelemetry/auto-instrumentations-node": "^0.56.0",
|
|
13
|
+
"@opentelemetry/exporter-metrics-otlp-http": "^0.57.0",
|
|
14
|
+
"@opentelemetry/sdk-node": "^0.57.0",
|
|
15
|
+
"dd-trace": "^5.31.0",
|
|
16
|
+
"newrelic": "^12.10.0",
|
|
17
|
+
"uuid": "11.0.5"
|
|
16
18
|
},
|
|
17
19
|
"publishConfig": {
|
|
18
20
|
"access": "public"
|
|
@@ -51,5 +53,8 @@
|
|
|
51
53
|
"organize_imports": "find src -type f -name '*.ts' | xargs organize-imports-cli",
|
|
52
54
|
"postbuild": "yarn organize_imports",
|
|
53
55
|
"post_process_generate": "yarn organize_imports"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/newrelic": "9.14.7"
|
|
54
59
|
}
|
|
55
60
|
}
|