@commercetools/ts-sdk-apm 3.3.2 → 4.4.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 +41 -1
- package/dist/commercetools-ts-sdk-apm.browser.cjs.js +9 -51
- package/dist/commercetools-ts-sdk-apm.browser.esm.js +9 -50
- package/dist/commercetools-ts-sdk-apm.cjs.dev.js +9 -51
- package/dist/commercetools-ts-sdk-apm.cjs.prod.js +9 -51
- package/dist/commercetools-ts-sdk-apm.esm.js +9 -50
- package/dist/declarations/src/index.d.ts +0 -1
- package/dist/declarations/src/index.d.ts.map +1 -1
- package/dist/declarations/types/types.d.ts +0 -47
- package/dist/newRelicHelper-0e64cc35.browser.esm.js +8 -0
- package/dist/newRelicHelper-86b0a261.esm.js +8 -0
- package/dist/newRelicHelper-a1299333.cjs.prod.js +14 -0
- package/dist/newRelicHelper-da9e4a44.cjs.dev.js +14 -0
- package/dist/newRelicHelper-f0d942b0.browser.cjs.js +14 -0
- package/dist/opentelemetry-8a97600d.esm.js +86 -0
- package/dist/opentelemetry-a1ac8980.browser.cjs.js +88 -0
- package/dist/opentelemetry-a32b3e9d.cjs.prod.js +79 -0
- package/dist/opentelemetry-b1e59a80.browser.esm.js +86 -0
- package/dist/opentelemetry-f4763b74.cjs.dev.js +88 -0
- package/package.json +8 -8
- package/dist/declarations/src/apm-legacy.d.ts +0 -8
- package/dist/declarations/src/apm-legacy.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @commercetools/ts-sdk-apm
|
|
2
2
|
|
|
3
|
+
## 4.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1209](https://github.com/commercetools/commercetools-sdk-typescript/pull/1209) [`77c6132`](https://github.com/commercetools/commercetools-sdk-typescript/commit/77c61328d222dbbbde3e79c63c2bb76df3f012a6) Thanks [@ajimae](https://github.com/ajimae)! - release all packages
|
|
8
|
+
|
|
9
|
+
## 4.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#1205](https://github.com/commercetools/commercetools-sdk-typescript/pull/1205) [`1ceb53b`](https://github.com/commercetools/commercetools-sdk-typescript/commit/1ceb53bf00457494ad061d7fe77a8d1b5a010d04) Thanks [@ajimae](https://github.com/ajimae)! - release packages
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#1205](https://github.com/commercetools/commercetools-sdk-typescript/pull/1205) [`1ceb53b`](https://github.com/commercetools/commercetools-sdk-typescript/commit/1ceb53bf00457494ad061d7fe77a8d1b5a010d04) Thanks [@ajimae](https://github.com/ajimae)! - release packages
|
|
18
|
+
|
|
19
|
+
- [#1205](https://github.com/commercetools/commercetools-sdk-typescript/pull/1205) [`1ceb53b`](https://github.com/commercetools/commercetools-sdk-typescript/commit/1ceb53bf00457494ad061d7fe77a8d1b5a010d04) Thanks [@ajimae](https://github.com/ajimae)! - release changeset
|
|
20
|
+
|
|
21
|
+
## 4.2.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- [#1203](https://github.com/commercetools/commercetools-sdk-typescript/pull/1203) [`e0b0fcc`](https://github.com/commercetools/commercetools-sdk-typescript/commit/e0b0fccaed4812c0ac47b0c8c4724e81174b0255) Thanks [@ajimae](https://github.com/ajimae)! - release packages
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- [#1203](https://github.com/commercetools/commercetools-sdk-typescript/pull/1203) [`e0b0fcc`](https://github.com/commercetools/commercetools-sdk-typescript/commit/e0b0fccaed4812c0ac47b0c8c4724e81174b0255) Thanks [@ajimae](https://github.com/ajimae)! - release changeset
|
|
30
|
+
|
|
31
|
+
## 4.1.0
|
|
32
|
+
|
|
33
|
+
### Minor Changes
|
|
34
|
+
|
|
35
|
+
- [#1201](https://github.com/commercetools/commercetools-sdk-typescript/pull/1201) [`f7c3101`](https://github.com/commercetools/commercetools-sdk-typescript/commit/f7c31015ae0e18111c31fcdb3baee8e964bad99b) Thanks [@ajimae](https://github.com/ajimae)! - release packages
|
|
36
|
+
|
|
37
|
+
## 4.0.0
|
|
38
|
+
|
|
39
|
+
### Major Changes
|
|
40
|
+
|
|
41
|
+
- [#1044](https://github.com/commercetools/commercetools-sdk-typescript/pull/1044) [`29967a3`](https://github.com/commercetools/commercetools-sdk-typescript/commit/29967a3e5957bd2fc35d90ad95d8e8f2917565e4) Thanks [@ajimae](https://github.com/ajimae)! - - fix issue with missing module
|
|
42
|
+
- remove deprecated and legacy apm modules
|
|
43
|
+
|
|
3
44
|
## 3.3.2
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
|
@@ -49,7 +90,6 @@
|
|
|
49
90
|
### Patch Changes
|
|
50
91
|
|
|
51
92
|
- [#551](https://github.com/commercetools/commercetools-sdk-typescript/pull/551) [`9e7939a`](https://github.com/commercetools/commercetools-sdk-typescript/commit/9e7939a1df234fd1f4f77c60f4ff75b31d7fc3fd) Thanks [@github-actions](https://github.com/apps/github-actions)! - BREAKING CHANGE:
|
|
52
|
-
|
|
53
93
|
- fix URI parameters to be URI encoded
|
|
54
94
|
|
|
55
95
|
- [#545](https://github.com/commercetools/commercetools-sdk-typescript/pull/545) [`a6d0df2`](https://github.com/commercetools/commercetools-sdk-typescript/commit/a6d0df2034b72504db2aa2d13a8d3726d97cc881) Thanks [@ajimae](https://github.com/ajimae)! - - fix user-agent header
|
|
@@ -13,12 +13,12 @@ datadog__default["default"].init();
|
|
|
13
13
|
|
|
14
14
|
// Record metrics for datadog
|
|
15
15
|
const recordDatadog = (metric, tags) => {
|
|
16
|
-
datadog__default["default"].dogstatsd.gauge(`
|
|
16
|
+
datadog__default["default"].dogstatsd.gauge(`client_response_time`, metric, tags);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
const time = () => performance.now();
|
|
20
20
|
|
|
21
|
-
function createTelemetryMiddleware
|
|
21
|
+
function createTelemetryMiddleware(options) {
|
|
22
22
|
/**
|
|
23
23
|
* default newrelic APM and
|
|
24
24
|
* opentelemetry tracer modules
|
|
@@ -31,7 +31,7 @@ function createTelemetryMiddleware$1(options) {
|
|
|
31
31
|
* Note: don't forget to install newrelic agent in your project `yarn add newrelic`
|
|
32
32
|
*/
|
|
33
33
|
apm: () => {},
|
|
34
|
-
tracer: () => require('
|
|
34
|
+
tracer: () => Promise.resolve().then(function () { return require('./opentelemetry-a1ac8980.browser.cjs.js'); })
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
// trace
|
|
@@ -48,12 +48,13 @@ function createTelemetryMiddleware$1(options) {
|
|
|
48
48
|
}
|
|
49
49
|
trace(); // expose tracing modules
|
|
50
50
|
return next => async request => {
|
|
51
|
-
// get start (high resolution milliseconds) timestamp
|
|
52
|
-
const start = time();
|
|
53
51
|
const nextRequest = {
|
|
54
52
|
...request,
|
|
55
53
|
...options
|
|
56
54
|
};
|
|
55
|
+
|
|
56
|
+
// start (high resolution milliseconds) timestamp
|
|
57
|
+
const start = time();
|
|
57
58
|
const response = await next(nextRequest);
|
|
58
59
|
const response_time = time() - start;
|
|
59
60
|
|
|
@@ -64,57 +65,14 @@ function createTelemetryMiddleware$1(options) {
|
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
if (options?.customMetrics && options.customMetrics.newrelic) {
|
|
68
|
+
// @ts-ignore
|
|
67
69
|
const {
|
|
68
70
|
recordNewRelic
|
|
69
|
-
} = require('./
|
|
71
|
+
} = await Promise.resolve().then(function () { return require('./newRelicHelper-f0d942b0.browser.cjs.js'); });
|
|
70
72
|
recordNewRelic(response_time);
|
|
71
73
|
}
|
|
72
74
|
return response;
|
|
73
75
|
};
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
* default newrelic APM and
|
|
78
|
-
* opentelemetry tracer modules
|
|
79
|
-
*/
|
|
80
|
-
const defaultOptions = {
|
|
81
|
-
/**
|
|
82
|
-
* if this is to be used with newrelic, then
|
|
83
|
-
* pass this (apm) as an option in the `createTelemetryMiddleware`
|
|
84
|
-
* function e.g createTelemetryMiddleware({ apm: () => require('newrelic'), ... })
|
|
85
|
-
* Note: don't forget to install newrelic agent in your project `yarn add newrelic`
|
|
86
|
-
*/
|
|
87
|
-
apm: () => {},
|
|
88
|
-
tracer: () => require('../opentelemetry')
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @deprecated use new `createTelemetryMiddleware`
|
|
93
|
-
* @param options
|
|
94
|
-
* @returns
|
|
95
|
-
*/
|
|
96
|
-
function createTelemetryMiddleware(options) {
|
|
97
|
-
// trace
|
|
98
|
-
function trace() {
|
|
99
|
-
// validate apm and tracer
|
|
100
|
-
if (!(options?.apm && typeof options.apm == 'function')) {
|
|
101
|
-
options.apm = defaultOptions.apm;
|
|
102
|
-
}
|
|
103
|
-
if (!(options?.tracer && typeof options.tracer == 'function')) {
|
|
104
|
-
options.tracer = defaultOptions.tracer;
|
|
105
|
-
}
|
|
106
|
-
options.apm();
|
|
107
|
-
options.tracer();
|
|
108
|
-
}
|
|
109
|
-
trace(); // expose tracing modules
|
|
110
|
-
return next => (request, response) => {
|
|
111
|
-
const nextRequest = {
|
|
112
|
-
...request,
|
|
113
|
-
...options
|
|
114
|
-
};
|
|
115
|
-
next(nextRequest, response);
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
exports.createTelemetryMiddleware = createTelemetryMiddleware$1;
|
|
120
|
-
exports.createTelemetryMiddlewareLegacy = createTelemetryMiddleware;
|
|
78
|
+
exports.createTelemetryMiddleware = createTelemetryMiddleware;
|
|
@@ -5,12 +5,12 @@ datadog.init();
|
|
|
5
5
|
|
|
6
6
|
// Record metrics for datadog
|
|
7
7
|
const recordDatadog = (metric, tags) => {
|
|
8
|
-
datadog.dogstatsd.gauge(`
|
|
8
|
+
datadog.dogstatsd.gauge(`client_response_time`, metric, tags);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const time = () => performance.now();
|
|
12
12
|
|
|
13
|
-
function createTelemetryMiddleware
|
|
13
|
+
function createTelemetryMiddleware(options) {
|
|
14
14
|
/**
|
|
15
15
|
* default newrelic APM and
|
|
16
16
|
* opentelemetry tracer modules
|
|
@@ -23,7 +23,7 @@ function createTelemetryMiddleware$1(options) {
|
|
|
23
23
|
* Note: don't forget to install newrelic agent in your project `yarn add newrelic`
|
|
24
24
|
*/
|
|
25
25
|
apm: () => {},
|
|
26
|
-
tracer: () =>
|
|
26
|
+
tracer: () => import('./opentelemetry-b1e59a80.browser.esm.js')
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
// trace
|
|
@@ -40,12 +40,13 @@ function createTelemetryMiddleware$1(options) {
|
|
|
40
40
|
}
|
|
41
41
|
trace(); // expose tracing modules
|
|
42
42
|
return next => async request => {
|
|
43
|
-
// get start (high resolution milliseconds) timestamp
|
|
44
|
-
const start = time();
|
|
45
43
|
const nextRequest = {
|
|
46
44
|
...request,
|
|
47
45
|
...options
|
|
48
46
|
};
|
|
47
|
+
|
|
48
|
+
// start (high resolution milliseconds) timestamp
|
|
49
|
+
const start = time();
|
|
49
50
|
const response = await next(nextRequest);
|
|
50
51
|
const response_time = time() - start;
|
|
51
52
|
|
|
@@ -56,56 +57,14 @@ function createTelemetryMiddleware$1(options) {
|
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
59
|
if (options?.customMetrics && options.customMetrics.newrelic) {
|
|
60
|
+
// @ts-ignore
|
|
59
61
|
const {
|
|
60
62
|
recordNewRelic
|
|
61
|
-
} =
|
|
63
|
+
} = await import('./newRelicHelper-0e64cc35.browser.esm.js');
|
|
62
64
|
recordNewRelic(response_time);
|
|
63
65
|
}
|
|
64
66
|
return response;
|
|
65
67
|
};
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
* default newrelic APM and
|
|
70
|
-
* opentelemetry tracer modules
|
|
71
|
-
*/
|
|
72
|
-
const defaultOptions = {
|
|
73
|
-
/**
|
|
74
|
-
* if this is to be used with newrelic, then
|
|
75
|
-
* pass this (apm) as an option in the `createTelemetryMiddleware`
|
|
76
|
-
* function e.g createTelemetryMiddleware({ apm: () => require('newrelic'), ... })
|
|
77
|
-
* Note: don't forget to install newrelic agent in your project `yarn add newrelic`
|
|
78
|
-
*/
|
|
79
|
-
apm: () => {},
|
|
80
|
-
tracer: () => require('../opentelemetry')
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* @deprecated use new `createTelemetryMiddleware`
|
|
85
|
-
* @param options
|
|
86
|
-
* @returns
|
|
87
|
-
*/
|
|
88
|
-
function createTelemetryMiddleware(options) {
|
|
89
|
-
// trace
|
|
90
|
-
function trace() {
|
|
91
|
-
// validate apm and tracer
|
|
92
|
-
if (!(options?.apm && typeof options.apm == 'function')) {
|
|
93
|
-
options.apm = defaultOptions.apm;
|
|
94
|
-
}
|
|
95
|
-
if (!(options?.tracer && typeof options.tracer == 'function')) {
|
|
96
|
-
options.tracer = defaultOptions.tracer;
|
|
97
|
-
}
|
|
98
|
-
options.apm();
|
|
99
|
-
options.tracer();
|
|
100
|
-
}
|
|
101
|
-
trace(); // expose tracing modules
|
|
102
|
-
return next => (request, response) => {
|
|
103
|
-
const nextRequest = {
|
|
104
|
-
...request,
|
|
105
|
-
...options
|
|
106
|
-
};
|
|
107
|
-
next(nextRequest, response);
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export { createTelemetryMiddleware$1 as createTelemetryMiddleware, createTelemetryMiddleware as createTelemetryMiddlewareLegacy };
|
|
70
|
+
export { createTelemetryMiddleware };
|
|
@@ -13,12 +13,12 @@ datadog__default["default"].init();
|
|
|
13
13
|
|
|
14
14
|
// Record metrics for datadog
|
|
15
15
|
const recordDatadog = (metric, tags) => {
|
|
16
|
-
datadog__default["default"].dogstatsd.gauge(`
|
|
16
|
+
datadog__default["default"].dogstatsd.gauge(`client_response_time`, metric, tags);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
const time = () => performance.now();
|
|
20
20
|
|
|
21
|
-
function createTelemetryMiddleware
|
|
21
|
+
function createTelemetryMiddleware(options) {
|
|
22
22
|
/**
|
|
23
23
|
* default newrelic APM and
|
|
24
24
|
* opentelemetry tracer modules
|
|
@@ -31,7 +31,7 @@ function createTelemetryMiddleware$1(options) {
|
|
|
31
31
|
* Note: don't forget to install newrelic agent in your project `yarn add newrelic`
|
|
32
32
|
*/
|
|
33
33
|
apm: () => {},
|
|
34
|
-
tracer: () => require('
|
|
34
|
+
tracer: () => Promise.resolve().then(function () { return require('./opentelemetry-f4763b74.cjs.dev.js'); })
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
// trace
|
|
@@ -48,12 +48,13 @@ function createTelemetryMiddleware$1(options) {
|
|
|
48
48
|
}
|
|
49
49
|
trace(); // expose tracing modules
|
|
50
50
|
return next => async request => {
|
|
51
|
-
// get start (high resolution milliseconds) timestamp
|
|
52
|
-
const start = time();
|
|
53
51
|
const nextRequest = {
|
|
54
52
|
...request,
|
|
55
53
|
...options
|
|
56
54
|
};
|
|
55
|
+
|
|
56
|
+
// start (high resolution milliseconds) timestamp
|
|
57
|
+
const start = time();
|
|
57
58
|
const response = await next(nextRequest);
|
|
58
59
|
const response_time = time() - start;
|
|
59
60
|
|
|
@@ -64,57 +65,14 @@ function createTelemetryMiddleware$1(options) {
|
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
if (options?.customMetrics && options.customMetrics.newrelic) {
|
|
68
|
+
// @ts-ignore
|
|
67
69
|
const {
|
|
68
70
|
recordNewRelic
|
|
69
|
-
} = require('./
|
|
71
|
+
} = await Promise.resolve().then(function () { return require('./newRelicHelper-da9e4a44.cjs.dev.js'); });
|
|
70
72
|
recordNewRelic(response_time);
|
|
71
73
|
}
|
|
72
74
|
return response;
|
|
73
75
|
};
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
* default newrelic APM and
|
|
78
|
-
* opentelemetry tracer modules
|
|
79
|
-
*/
|
|
80
|
-
const defaultOptions = {
|
|
81
|
-
/**
|
|
82
|
-
* if this is to be used with newrelic, then
|
|
83
|
-
* pass this (apm) as an option in the `createTelemetryMiddleware`
|
|
84
|
-
* function e.g createTelemetryMiddleware({ apm: () => require('newrelic'), ... })
|
|
85
|
-
* Note: don't forget to install newrelic agent in your project `yarn add newrelic`
|
|
86
|
-
*/
|
|
87
|
-
apm: () => {},
|
|
88
|
-
tracer: () => require('../opentelemetry')
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @deprecated use new `createTelemetryMiddleware`
|
|
93
|
-
* @param options
|
|
94
|
-
* @returns
|
|
95
|
-
*/
|
|
96
|
-
function createTelemetryMiddleware(options) {
|
|
97
|
-
// trace
|
|
98
|
-
function trace() {
|
|
99
|
-
// validate apm and tracer
|
|
100
|
-
if (!(options?.apm && typeof options.apm == 'function')) {
|
|
101
|
-
options.apm = defaultOptions.apm;
|
|
102
|
-
}
|
|
103
|
-
if (!(options?.tracer && typeof options.tracer == 'function')) {
|
|
104
|
-
options.tracer = defaultOptions.tracer;
|
|
105
|
-
}
|
|
106
|
-
options.apm();
|
|
107
|
-
options.tracer();
|
|
108
|
-
}
|
|
109
|
-
trace(); // expose tracing modules
|
|
110
|
-
return next => (request, response) => {
|
|
111
|
-
const nextRequest = {
|
|
112
|
-
...request,
|
|
113
|
-
...options
|
|
114
|
-
};
|
|
115
|
-
next(nextRequest, response);
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
exports.createTelemetryMiddleware = createTelemetryMiddleware$1;
|
|
120
|
-
exports.createTelemetryMiddlewareLegacy = createTelemetryMiddleware;
|
|
78
|
+
exports.createTelemetryMiddleware = createTelemetryMiddleware;
|
|
@@ -13,12 +13,12 @@ datadog__default["default"].init();
|
|
|
13
13
|
|
|
14
14
|
// Record metrics for datadog
|
|
15
15
|
const recordDatadog = (metric, tags) => {
|
|
16
|
-
datadog__default["default"].dogstatsd.gauge(`
|
|
16
|
+
datadog__default["default"].dogstatsd.gauge(`client_response_time`, metric, tags);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
const time = () => performance.now();
|
|
20
20
|
|
|
21
|
-
function createTelemetryMiddleware
|
|
21
|
+
function createTelemetryMiddleware(options) {
|
|
22
22
|
/**
|
|
23
23
|
* default newrelic APM and
|
|
24
24
|
* opentelemetry tracer modules
|
|
@@ -31,7 +31,7 @@ function createTelemetryMiddleware$1(options) {
|
|
|
31
31
|
* Note: don't forget to install newrelic agent in your project `yarn add newrelic`
|
|
32
32
|
*/
|
|
33
33
|
apm: () => {},
|
|
34
|
-
tracer: () => require('
|
|
34
|
+
tracer: () => Promise.resolve().then(function () { return require('./opentelemetry-a32b3e9d.cjs.prod.js'); })
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
// trace
|
|
@@ -48,12 +48,13 @@ function createTelemetryMiddleware$1(options) {
|
|
|
48
48
|
}
|
|
49
49
|
trace(); // expose tracing modules
|
|
50
50
|
return next => async request => {
|
|
51
|
-
// get start (high resolution milliseconds) timestamp
|
|
52
|
-
const start = time();
|
|
53
51
|
const nextRequest = {
|
|
54
52
|
...request,
|
|
55
53
|
...options
|
|
56
54
|
};
|
|
55
|
+
|
|
56
|
+
// start (high resolution milliseconds) timestamp
|
|
57
|
+
const start = time();
|
|
57
58
|
const response = await next(nextRequest);
|
|
58
59
|
const response_time = time() - start;
|
|
59
60
|
|
|
@@ -64,57 +65,14 @@ function createTelemetryMiddleware$1(options) {
|
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
if (options?.customMetrics && options.customMetrics.newrelic) {
|
|
68
|
+
// @ts-ignore
|
|
67
69
|
const {
|
|
68
70
|
recordNewRelic
|
|
69
|
-
} = require('./
|
|
71
|
+
} = await Promise.resolve().then(function () { return require('./newRelicHelper-a1299333.cjs.prod.js'); });
|
|
70
72
|
recordNewRelic(response_time);
|
|
71
73
|
}
|
|
72
74
|
return response;
|
|
73
75
|
};
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
* default newrelic APM and
|
|
78
|
-
* opentelemetry tracer modules
|
|
79
|
-
*/
|
|
80
|
-
const defaultOptions = {
|
|
81
|
-
/**
|
|
82
|
-
* if this is to be used with newrelic, then
|
|
83
|
-
* pass this (apm) as an option in the `createTelemetryMiddleware`
|
|
84
|
-
* function e.g createTelemetryMiddleware({ apm: () => require('newrelic'), ... })
|
|
85
|
-
* Note: don't forget to install newrelic agent in your project `yarn add newrelic`
|
|
86
|
-
*/
|
|
87
|
-
apm: () => {},
|
|
88
|
-
tracer: () => require('../opentelemetry')
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @deprecated use new `createTelemetryMiddleware`
|
|
93
|
-
* @param options
|
|
94
|
-
* @returns
|
|
95
|
-
*/
|
|
96
|
-
function createTelemetryMiddleware(options) {
|
|
97
|
-
// trace
|
|
98
|
-
function trace() {
|
|
99
|
-
// validate apm and tracer
|
|
100
|
-
if (!(options?.apm && typeof options.apm == 'function')) {
|
|
101
|
-
options.apm = defaultOptions.apm;
|
|
102
|
-
}
|
|
103
|
-
if (!(options?.tracer && typeof options.tracer == 'function')) {
|
|
104
|
-
options.tracer = defaultOptions.tracer;
|
|
105
|
-
}
|
|
106
|
-
options.apm();
|
|
107
|
-
options.tracer();
|
|
108
|
-
}
|
|
109
|
-
trace(); // expose tracing modules
|
|
110
|
-
return next => (request, response) => {
|
|
111
|
-
const nextRequest = {
|
|
112
|
-
...request,
|
|
113
|
-
...options
|
|
114
|
-
};
|
|
115
|
-
next(nextRequest, response);
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
exports.createTelemetryMiddleware = createTelemetryMiddleware$1;
|
|
120
|
-
exports.createTelemetryMiddlewareLegacy = createTelemetryMiddleware;
|
|
78
|
+
exports.createTelemetryMiddleware = createTelemetryMiddleware;
|
|
@@ -5,12 +5,12 @@ datadog.init();
|
|
|
5
5
|
|
|
6
6
|
// Record metrics for datadog
|
|
7
7
|
const recordDatadog = (metric, tags) => {
|
|
8
|
-
datadog.dogstatsd.gauge(`
|
|
8
|
+
datadog.dogstatsd.gauge(`client_response_time`, metric, tags);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const time = () => performance.now();
|
|
12
12
|
|
|
13
|
-
function createTelemetryMiddleware
|
|
13
|
+
function createTelemetryMiddleware(options) {
|
|
14
14
|
/**
|
|
15
15
|
* default newrelic APM and
|
|
16
16
|
* opentelemetry tracer modules
|
|
@@ -23,7 +23,7 @@ function createTelemetryMiddleware$1(options) {
|
|
|
23
23
|
* Note: don't forget to install newrelic agent in your project `yarn add newrelic`
|
|
24
24
|
*/
|
|
25
25
|
apm: () => {},
|
|
26
|
-
tracer: () =>
|
|
26
|
+
tracer: () => import('./opentelemetry-8a97600d.esm.js')
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
// trace
|
|
@@ -40,12 +40,13 @@ function createTelemetryMiddleware$1(options) {
|
|
|
40
40
|
}
|
|
41
41
|
trace(); // expose tracing modules
|
|
42
42
|
return next => async request => {
|
|
43
|
-
// get start (high resolution milliseconds) timestamp
|
|
44
|
-
const start = time();
|
|
45
43
|
const nextRequest = {
|
|
46
44
|
...request,
|
|
47
45
|
...options
|
|
48
46
|
};
|
|
47
|
+
|
|
48
|
+
// start (high resolution milliseconds) timestamp
|
|
49
|
+
const start = time();
|
|
49
50
|
const response = await next(nextRequest);
|
|
50
51
|
const response_time = time() - start;
|
|
51
52
|
|
|
@@ -56,56 +57,14 @@ function createTelemetryMiddleware$1(options) {
|
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
59
|
if (options?.customMetrics && options.customMetrics.newrelic) {
|
|
60
|
+
// @ts-ignore
|
|
59
61
|
const {
|
|
60
62
|
recordNewRelic
|
|
61
|
-
} =
|
|
63
|
+
} = await import('./newRelicHelper-86b0a261.esm.js');
|
|
62
64
|
recordNewRelic(response_time);
|
|
63
65
|
}
|
|
64
66
|
return response;
|
|
65
67
|
};
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
* default newrelic APM and
|
|
70
|
-
* opentelemetry tracer modules
|
|
71
|
-
*/
|
|
72
|
-
const defaultOptions = {
|
|
73
|
-
/**
|
|
74
|
-
* if this is to be used with newrelic, then
|
|
75
|
-
* pass this (apm) as an option in the `createTelemetryMiddleware`
|
|
76
|
-
* function e.g createTelemetryMiddleware({ apm: () => require('newrelic'), ... })
|
|
77
|
-
* Note: don't forget to install newrelic agent in your project `yarn add newrelic`
|
|
78
|
-
*/
|
|
79
|
-
apm: () => {},
|
|
80
|
-
tracer: () => require('../opentelemetry')
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* @deprecated use new `createTelemetryMiddleware`
|
|
85
|
-
* @param options
|
|
86
|
-
* @returns
|
|
87
|
-
*/
|
|
88
|
-
function createTelemetryMiddleware(options) {
|
|
89
|
-
// trace
|
|
90
|
-
function trace() {
|
|
91
|
-
// validate apm and tracer
|
|
92
|
-
if (!(options?.apm && typeof options.apm == 'function')) {
|
|
93
|
-
options.apm = defaultOptions.apm;
|
|
94
|
-
}
|
|
95
|
-
if (!(options?.tracer && typeof options.tracer == 'function')) {
|
|
96
|
-
options.tracer = defaultOptions.tracer;
|
|
97
|
-
}
|
|
98
|
-
options.apm();
|
|
99
|
-
options.tracer();
|
|
100
|
-
}
|
|
101
|
-
trace(); // expose tracing modules
|
|
102
|
-
return next => (request, response) => {
|
|
103
|
-
const nextRequest = {
|
|
104
|
-
...request,
|
|
105
|
-
...options
|
|
106
|
-
};
|
|
107
|
-
next(nextRequest, response);
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export { createTelemetryMiddleware$1 as createTelemetryMiddleware, createTelemetryMiddleware as createTelemetryMiddlewareLegacy };
|
|
70
|
+
export { createTelemetryMiddleware };
|
|
@@ -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"}
|
|
@@ -91,50 +91,3 @@ export type TelemetryMiddlewareOptions = {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
export type OTelemetryMiddlewareOptions = Omit<TelemetryMiddlewareOptions, 'createTelemetryMiddleware'>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
// LEGACY TYPES
|
|
97
|
-
/**
|
|
98
|
-
* @deprecated
|
|
99
|
-
*/
|
|
100
|
-
export type NextLegacy = (
|
|
101
|
-
request: MiddlewareRequestLegacy,
|
|
102
|
-
response: MiddlewareResponseLegacy
|
|
103
|
-
) => unknown
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* @deprecated
|
|
107
|
-
*/
|
|
108
|
-
export type MiddlewareResponseLegacy = {
|
|
109
|
-
resolve(response: JsonObject): void
|
|
110
|
-
reject(error: JsonObject): void
|
|
111
|
-
body?: JsonObject
|
|
112
|
-
error?: HttpErrorType
|
|
113
|
-
statusCode: number
|
|
114
|
-
headers?: JsonObject<string>
|
|
115
|
-
request?: JsonObject
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @deprecated
|
|
120
|
-
*/
|
|
121
|
-
export interface ClientRequestLegacy {
|
|
122
|
-
baseUri?: string
|
|
123
|
-
uri?: string
|
|
124
|
-
headers?: VariableMap
|
|
125
|
-
method: MethodType
|
|
126
|
-
uriTemplate?: string
|
|
127
|
-
pathVariables?: VariableMap
|
|
128
|
-
queryParams?: VariableMap
|
|
129
|
-
body?: any,
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @deprecated
|
|
134
|
-
*/
|
|
135
|
-
export type MiddlewareLegacy = (next: NextLegacy) => NextLegacy
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* @deprecated
|
|
139
|
-
*/
|
|
140
|
-
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(`Client/Response/Time`, 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(`Client/Response/Time`, 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(`Client/Response/Time`, metric);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.recordNewRelic = recordNewRelic;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require('dotenv').config();
|
|
2
|
+
const process = require('process');
|
|
3
|
+
const {
|
|
4
|
+
v4: uuidv4
|
|
5
|
+
} = require('uuid');
|
|
6
|
+
const opentelemetry = require('@opentelemetry/sdk-node');
|
|
7
|
+
const {
|
|
8
|
+
getNodeAutoInstrumentations
|
|
9
|
+
} = require('@opentelemetry/auto-instrumentations-node');
|
|
10
|
+
const {
|
|
11
|
+
Resource
|
|
12
|
+
} = require('@opentelemetry/resources');
|
|
13
|
+
const {
|
|
14
|
+
SemanticResourceAttributes
|
|
15
|
+
} = require('@opentelemetry/semantic-conventions');
|
|
16
|
+
const {
|
|
17
|
+
OTLPTraceExporter
|
|
18
|
+
} = require('@opentelemetry/exporter-trace-otlp-http');
|
|
19
|
+
const {
|
|
20
|
+
OTLPMetricExporter
|
|
21
|
+
} = require('@opentelemetry/exporter-metrics-otlp-http');
|
|
22
|
+
const {
|
|
23
|
+
AggregationTemporality,
|
|
24
|
+
PeriodicExportingMetricReader
|
|
25
|
+
} = require('@opentelemetry/sdk-metrics');
|
|
26
|
+
const api = require('@opentelemetry/api');
|
|
27
|
+
|
|
28
|
+
// enable logging ONLY for developement
|
|
29
|
+
// this is useful for debugging instrumentation issues
|
|
30
|
+
// remove from production after issues (if any) are resolved
|
|
31
|
+
// view more logging levels here: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/src/diag/types.ts#L67
|
|
32
|
+
|
|
33
|
+
if (process.env.NODE_ENV == 'development') {
|
|
34
|
+
api.diag.setLogger(new api.DiagConsoleLogger(), api.DiagLogLevel.INFO, api.DiagLogLevel.ERROR);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Declare the resource to be used.
|
|
38
|
+
// A resource represents a collection of attributes describing the
|
|
39
|
+
// service. This collection of attributes will be associated with all
|
|
40
|
+
// telemetry generated from this service (traces, metrics, logs).
|
|
41
|
+
const resource = new Resource({
|
|
42
|
+
[SemanticResourceAttributes.SERVICE_INSTANCE_ID]: uuidv4(),
|
|
43
|
+
[SemanticResourceAttributes.SERVICE_NAME]: process.env['NEW_RELIC_APP_NAME']
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Enable auto-instrumentation from the meta package.
|
|
47
|
+
const instrumentations = [getNodeAutoInstrumentations()];
|
|
48
|
+
|
|
49
|
+
// Configure the OTLP/HTTP exporters.
|
|
50
|
+
// The following assumes you've set the OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OLTP_HEADERS
|
|
51
|
+
// environment variables.
|
|
52
|
+
const traceExporter = new OTLPTraceExporter();
|
|
53
|
+
const metricExporter = new OTLPMetricExporter({
|
|
54
|
+
temporalityPreference: AggregationTemporality.DELTA
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// If you haven't set the OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OLTP_HEADERS
|
|
58
|
+
// environment variables, you can configure the OTLP exporter programmatically by
|
|
59
|
+
// uncommenting the following code:
|
|
60
|
+
|
|
61
|
+
// this endpoint contains a path since this exporter is signal specific (traces)
|
|
62
|
+
// see more details here: https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-quick-start/#note-endpoints
|
|
63
|
+
// const url = "https://otlp.nr-data.net:4317/v1/traces";
|
|
64
|
+
|
|
65
|
+
// Configure PeriodicMetricReader
|
|
66
|
+
const metricReader = new PeriodicExportingMetricReader({
|
|
67
|
+
exporter: metricExporter,
|
|
68
|
+
exportIntervalMillis: 5000
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Configure the OpenTelemetry NodeSDK
|
|
72
|
+
const sdk = new opentelemetry.NodeSDK({
|
|
73
|
+
resource,
|
|
74
|
+
traceExporter,
|
|
75
|
+
metricReader,
|
|
76
|
+
instrumentations
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Initialize the SDK and register with the OpenTelemetry API:
|
|
80
|
+
// this enables the API to record telemetry
|
|
81
|
+
sdk.start();
|
|
82
|
+
|
|
83
|
+
// Gracefully shut down the SDK on process exit
|
|
84
|
+
process.on('SIGTERM', () => {
|
|
85
|
+
sdk.shutdown().then(() => console.log('OpenTelemetry terminated')).catch(error => console.log('Error terminating OpenTelemetry', error)).finally(() => process.exit(0));
|
|
86
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('dotenv').config();
|
|
4
|
+
const process = require('process');
|
|
5
|
+
const {
|
|
6
|
+
v4: uuidv4
|
|
7
|
+
} = require('uuid');
|
|
8
|
+
const opentelemetry = require('@opentelemetry/sdk-node');
|
|
9
|
+
const {
|
|
10
|
+
getNodeAutoInstrumentations
|
|
11
|
+
} = require('@opentelemetry/auto-instrumentations-node');
|
|
12
|
+
const {
|
|
13
|
+
Resource
|
|
14
|
+
} = require('@opentelemetry/resources');
|
|
15
|
+
const {
|
|
16
|
+
SemanticResourceAttributes
|
|
17
|
+
} = require('@opentelemetry/semantic-conventions');
|
|
18
|
+
const {
|
|
19
|
+
OTLPTraceExporter
|
|
20
|
+
} = require('@opentelemetry/exporter-trace-otlp-http');
|
|
21
|
+
const {
|
|
22
|
+
OTLPMetricExporter
|
|
23
|
+
} = require('@opentelemetry/exporter-metrics-otlp-http');
|
|
24
|
+
const {
|
|
25
|
+
AggregationTemporality,
|
|
26
|
+
PeriodicExportingMetricReader
|
|
27
|
+
} = require('@opentelemetry/sdk-metrics');
|
|
28
|
+
const api = require('@opentelemetry/api');
|
|
29
|
+
|
|
30
|
+
// enable logging ONLY for developement
|
|
31
|
+
// this is useful for debugging instrumentation issues
|
|
32
|
+
// remove from production after issues (if any) are resolved
|
|
33
|
+
// view more logging levels here: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/src/diag/types.ts#L67
|
|
34
|
+
|
|
35
|
+
if (process.env.NODE_ENV == 'development') {
|
|
36
|
+
api.diag.setLogger(new api.DiagConsoleLogger(), api.DiagLogLevel.INFO, api.DiagLogLevel.ERROR);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Declare the resource to be used.
|
|
40
|
+
// A resource represents a collection of attributes describing the
|
|
41
|
+
// service. This collection of attributes will be associated with all
|
|
42
|
+
// telemetry generated from this service (traces, metrics, logs).
|
|
43
|
+
const resource = new Resource({
|
|
44
|
+
[SemanticResourceAttributes.SERVICE_INSTANCE_ID]: uuidv4(),
|
|
45
|
+
[SemanticResourceAttributes.SERVICE_NAME]: process.env['NEW_RELIC_APP_NAME']
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Enable auto-instrumentation from the meta package.
|
|
49
|
+
const instrumentations = [getNodeAutoInstrumentations()];
|
|
50
|
+
|
|
51
|
+
// Configure the OTLP/HTTP exporters.
|
|
52
|
+
// The following assumes you've set the OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OLTP_HEADERS
|
|
53
|
+
// environment variables.
|
|
54
|
+
const traceExporter = new OTLPTraceExporter();
|
|
55
|
+
const metricExporter = new OTLPMetricExporter({
|
|
56
|
+
temporalityPreference: AggregationTemporality.DELTA
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// If you haven't set the OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OLTP_HEADERS
|
|
60
|
+
// environment variables, you can configure the OTLP exporter programmatically by
|
|
61
|
+
// uncommenting the following code:
|
|
62
|
+
|
|
63
|
+
// this endpoint contains a path since this exporter is signal specific (traces)
|
|
64
|
+
// see more details here: https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-quick-start/#note-endpoints
|
|
65
|
+
// const url = "https://otlp.nr-data.net:4317/v1/traces";
|
|
66
|
+
|
|
67
|
+
// Configure PeriodicMetricReader
|
|
68
|
+
const metricReader = new PeriodicExportingMetricReader({
|
|
69
|
+
exporter: metricExporter,
|
|
70
|
+
exportIntervalMillis: 5000
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Configure the OpenTelemetry NodeSDK
|
|
74
|
+
const sdk = new opentelemetry.NodeSDK({
|
|
75
|
+
resource,
|
|
76
|
+
traceExporter,
|
|
77
|
+
metricReader,
|
|
78
|
+
instrumentations
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Initialize the SDK and register with the OpenTelemetry API:
|
|
82
|
+
// this enables the API to record telemetry
|
|
83
|
+
sdk.start();
|
|
84
|
+
|
|
85
|
+
// Gracefully shut down the SDK on process exit
|
|
86
|
+
process.on('SIGTERM', () => {
|
|
87
|
+
sdk.shutdown().then(() => console.log('OpenTelemetry terminated')).catch(error => console.log('Error terminating OpenTelemetry', error)).finally(() => process.exit(0));
|
|
88
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('dotenv').config();
|
|
4
|
+
const process = require('process');
|
|
5
|
+
const {
|
|
6
|
+
v4: uuidv4
|
|
7
|
+
} = require('uuid');
|
|
8
|
+
const opentelemetry = require('@opentelemetry/sdk-node');
|
|
9
|
+
const {
|
|
10
|
+
getNodeAutoInstrumentations
|
|
11
|
+
} = require('@opentelemetry/auto-instrumentations-node');
|
|
12
|
+
const {
|
|
13
|
+
Resource
|
|
14
|
+
} = require('@opentelemetry/resources');
|
|
15
|
+
const {
|
|
16
|
+
SemanticResourceAttributes
|
|
17
|
+
} = require('@opentelemetry/semantic-conventions');
|
|
18
|
+
const {
|
|
19
|
+
OTLPTraceExporter
|
|
20
|
+
} = require('@opentelemetry/exporter-trace-otlp-http');
|
|
21
|
+
const {
|
|
22
|
+
OTLPMetricExporter
|
|
23
|
+
} = require('@opentelemetry/exporter-metrics-otlp-http');
|
|
24
|
+
const {
|
|
25
|
+
AggregationTemporality,
|
|
26
|
+
PeriodicExportingMetricReader
|
|
27
|
+
} = require('@opentelemetry/sdk-metrics');
|
|
28
|
+
require('@opentelemetry/api');
|
|
29
|
+
|
|
30
|
+
// Declare the resource to be used.
|
|
31
|
+
// A resource represents a collection of attributes describing the
|
|
32
|
+
// service. This collection of attributes will be associated with all
|
|
33
|
+
// telemetry generated from this service (traces, metrics, logs).
|
|
34
|
+
const resource = new Resource({
|
|
35
|
+
[SemanticResourceAttributes.SERVICE_INSTANCE_ID]: uuidv4(),
|
|
36
|
+
[SemanticResourceAttributes.SERVICE_NAME]: process.env['NEW_RELIC_APP_NAME']
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Enable auto-instrumentation from the meta package.
|
|
40
|
+
const instrumentations = [getNodeAutoInstrumentations()];
|
|
41
|
+
|
|
42
|
+
// Configure the OTLP/HTTP exporters.
|
|
43
|
+
// The following assumes you've set the OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OLTP_HEADERS
|
|
44
|
+
// environment variables.
|
|
45
|
+
const traceExporter = new OTLPTraceExporter();
|
|
46
|
+
const metricExporter = new OTLPMetricExporter({
|
|
47
|
+
temporalityPreference: AggregationTemporality.DELTA
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// If you haven't set the OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OLTP_HEADERS
|
|
51
|
+
// environment variables, you can configure the OTLP exporter programmatically by
|
|
52
|
+
// uncommenting the following code:
|
|
53
|
+
|
|
54
|
+
// this endpoint contains a path since this exporter is signal specific (traces)
|
|
55
|
+
// see more details here: https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-quick-start/#note-endpoints
|
|
56
|
+
// const url = "https://otlp.nr-data.net:4317/v1/traces";
|
|
57
|
+
|
|
58
|
+
// Configure PeriodicMetricReader
|
|
59
|
+
const metricReader = new PeriodicExportingMetricReader({
|
|
60
|
+
exporter: metricExporter,
|
|
61
|
+
exportIntervalMillis: 5000
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Configure the OpenTelemetry NodeSDK
|
|
65
|
+
const sdk = new opentelemetry.NodeSDK({
|
|
66
|
+
resource,
|
|
67
|
+
traceExporter,
|
|
68
|
+
metricReader,
|
|
69
|
+
instrumentations
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Initialize the SDK and register with the OpenTelemetry API:
|
|
73
|
+
// this enables the API to record telemetry
|
|
74
|
+
sdk.start();
|
|
75
|
+
|
|
76
|
+
// Gracefully shut down the SDK on process exit
|
|
77
|
+
process.on('SIGTERM', () => {
|
|
78
|
+
sdk.shutdown().then(() => console.log('OpenTelemetry terminated')).catch(error => console.log('Error terminating OpenTelemetry', error)).finally(() => process.exit(0));
|
|
79
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require('dotenv').config();
|
|
2
|
+
const process = require('process');
|
|
3
|
+
const {
|
|
4
|
+
v4: uuidv4
|
|
5
|
+
} = require('uuid');
|
|
6
|
+
const opentelemetry = require('@opentelemetry/sdk-node');
|
|
7
|
+
const {
|
|
8
|
+
getNodeAutoInstrumentations
|
|
9
|
+
} = require('@opentelemetry/auto-instrumentations-node');
|
|
10
|
+
const {
|
|
11
|
+
Resource
|
|
12
|
+
} = require('@opentelemetry/resources');
|
|
13
|
+
const {
|
|
14
|
+
SemanticResourceAttributes
|
|
15
|
+
} = require('@opentelemetry/semantic-conventions');
|
|
16
|
+
const {
|
|
17
|
+
OTLPTraceExporter
|
|
18
|
+
} = require('@opentelemetry/exporter-trace-otlp-http');
|
|
19
|
+
const {
|
|
20
|
+
OTLPMetricExporter
|
|
21
|
+
} = require('@opentelemetry/exporter-metrics-otlp-http');
|
|
22
|
+
const {
|
|
23
|
+
AggregationTemporality,
|
|
24
|
+
PeriodicExportingMetricReader
|
|
25
|
+
} = require('@opentelemetry/sdk-metrics');
|
|
26
|
+
const api = require('@opentelemetry/api');
|
|
27
|
+
|
|
28
|
+
// enable logging ONLY for developement
|
|
29
|
+
// this is useful for debugging instrumentation issues
|
|
30
|
+
// remove from production after issues (if any) are resolved
|
|
31
|
+
// view more logging levels here: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/src/diag/types.ts#L67
|
|
32
|
+
|
|
33
|
+
if (process.env.NODE_ENV == 'development') {
|
|
34
|
+
api.diag.setLogger(new api.DiagConsoleLogger(), api.DiagLogLevel.INFO, api.DiagLogLevel.ERROR);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Declare the resource to be used.
|
|
38
|
+
// A resource represents a collection of attributes describing the
|
|
39
|
+
// service. This collection of attributes will be associated with all
|
|
40
|
+
// telemetry generated from this service (traces, metrics, logs).
|
|
41
|
+
const resource = new Resource({
|
|
42
|
+
[SemanticResourceAttributes.SERVICE_INSTANCE_ID]: uuidv4(),
|
|
43
|
+
[SemanticResourceAttributes.SERVICE_NAME]: process.env['NEW_RELIC_APP_NAME']
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Enable auto-instrumentation from the meta package.
|
|
47
|
+
const instrumentations = [getNodeAutoInstrumentations()];
|
|
48
|
+
|
|
49
|
+
// Configure the OTLP/HTTP exporters.
|
|
50
|
+
// The following assumes you've set the OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OLTP_HEADERS
|
|
51
|
+
// environment variables.
|
|
52
|
+
const traceExporter = new OTLPTraceExporter();
|
|
53
|
+
const metricExporter = new OTLPMetricExporter({
|
|
54
|
+
temporalityPreference: AggregationTemporality.DELTA
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// If you haven't set the OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OLTP_HEADERS
|
|
58
|
+
// environment variables, you can configure the OTLP exporter programmatically by
|
|
59
|
+
// uncommenting the following code:
|
|
60
|
+
|
|
61
|
+
// this endpoint contains a path since this exporter is signal specific (traces)
|
|
62
|
+
// see more details here: https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-quick-start/#note-endpoints
|
|
63
|
+
// const url = "https://otlp.nr-data.net:4317/v1/traces";
|
|
64
|
+
|
|
65
|
+
// Configure PeriodicMetricReader
|
|
66
|
+
const metricReader = new PeriodicExportingMetricReader({
|
|
67
|
+
exporter: metricExporter,
|
|
68
|
+
exportIntervalMillis: 5000
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Configure the OpenTelemetry NodeSDK
|
|
72
|
+
const sdk = new opentelemetry.NodeSDK({
|
|
73
|
+
resource,
|
|
74
|
+
traceExporter,
|
|
75
|
+
metricReader,
|
|
76
|
+
instrumentations
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Initialize the SDK and register with the OpenTelemetry API:
|
|
80
|
+
// this enables the API to record telemetry
|
|
81
|
+
sdk.start();
|
|
82
|
+
|
|
83
|
+
// Gracefully shut down the SDK on process exit
|
|
84
|
+
process.on('SIGTERM', () => {
|
|
85
|
+
sdk.shutdown().then(() => console.log('OpenTelemetry terminated')).catch(error => console.log('Error terminating OpenTelemetry', error)).finally(() => process.exit(0));
|
|
86
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('dotenv').config();
|
|
4
|
+
const process = require('process');
|
|
5
|
+
const {
|
|
6
|
+
v4: uuidv4
|
|
7
|
+
} = require('uuid');
|
|
8
|
+
const opentelemetry = require('@opentelemetry/sdk-node');
|
|
9
|
+
const {
|
|
10
|
+
getNodeAutoInstrumentations
|
|
11
|
+
} = require('@opentelemetry/auto-instrumentations-node');
|
|
12
|
+
const {
|
|
13
|
+
Resource
|
|
14
|
+
} = require('@opentelemetry/resources');
|
|
15
|
+
const {
|
|
16
|
+
SemanticResourceAttributes
|
|
17
|
+
} = require('@opentelemetry/semantic-conventions');
|
|
18
|
+
const {
|
|
19
|
+
OTLPTraceExporter
|
|
20
|
+
} = require('@opentelemetry/exporter-trace-otlp-http');
|
|
21
|
+
const {
|
|
22
|
+
OTLPMetricExporter
|
|
23
|
+
} = require('@opentelemetry/exporter-metrics-otlp-http');
|
|
24
|
+
const {
|
|
25
|
+
AggregationTemporality,
|
|
26
|
+
PeriodicExportingMetricReader
|
|
27
|
+
} = require('@opentelemetry/sdk-metrics');
|
|
28
|
+
const api = require('@opentelemetry/api');
|
|
29
|
+
|
|
30
|
+
// enable logging ONLY for developement
|
|
31
|
+
// this is useful for debugging instrumentation issues
|
|
32
|
+
// remove from production after issues (if any) are resolved
|
|
33
|
+
// view more logging levels here: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/src/diag/types.ts#L67
|
|
34
|
+
|
|
35
|
+
if (process.env.NODE_ENV == 'development') {
|
|
36
|
+
api.diag.setLogger(new api.DiagConsoleLogger(), api.DiagLogLevel.INFO, api.DiagLogLevel.ERROR);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Declare the resource to be used.
|
|
40
|
+
// A resource represents a collection of attributes describing the
|
|
41
|
+
// service. This collection of attributes will be associated with all
|
|
42
|
+
// telemetry generated from this service (traces, metrics, logs).
|
|
43
|
+
const resource = new Resource({
|
|
44
|
+
[SemanticResourceAttributes.SERVICE_INSTANCE_ID]: uuidv4(),
|
|
45
|
+
[SemanticResourceAttributes.SERVICE_NAME]: process.env['NEW_RELIC_APP_NAME']
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Enable auto-instrumentation from the meta package.
|
|
49
|
+
const instrumentations = [getNodeAutoInstrumentations()];
|
|
50
|
+
|
|
51
|
+
// Configure the OTLP/HTTP exporters.
|
|
52
|
+
// The following assumes you've set the OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OLTP_HEADERS
|
|
53
|
+
// environment variables.
|
|
54
|
+
const traceExporter = new OTLPTraceExporter();
|
|
55
|
+
const metricExporter = new OTLPMetricExporter({
|
|
56
|
+
temporalityPreference: AggregationTemporality.DELTA
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// If you haven't set the OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OLTP_HEADERS
|
|
60
|
+
// environment variables, you can configure the OTLP exporter programmatically by
|
|
61
|
+
// uncommenting the following code:
|
|
62
|
+
|
|
63
|
+
// this endpoint contains a path since this exporter is signal specific (traces)
|
|
64
|
+
// see more details here: https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-quick-start/#note-endpoints
|
|
65
|
+
// const url = "https://otlp.nr-data.net:4317/v1/traces";
|
|
66
|
+
|
|
67
|
+
// Configure PeriodicMetricReader
|
|
68
|
+
const metricReader = new PeriodicExportingMetricReader({
|
|
69
|
+
exporter: metricExporter,
|
|
70
|
+
exportIntervalMillis: 5000
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Configure the OpenTelemetry NodeSDK
|
|
74
|
+
const sdk = new opentelemetry.NodeSDK({
|
|
75
|
+
resource,
|
|
76
|
+
traceExporter,
|
|
77
|
+
metricReader,
|
|
78
|
+
instrumentations
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Initialize the SDK and register with the OpenTelemetry API:
|
|
82
|
+
// this enables the API to record telemetry
|
|
83
|
+
sdk.start();
|
|
84
|
+
|
|
85
|
+
// Gracefully shut down the SDK on process exit
|
|
86
|
+
process.on('SIGTERM', () => {
|
|
87
|
+
sdk.shutdown().then(() => console.log('OpenTelemetry terminated')).catch(error => console.log('Error terminating OpenTelemetry', error)).finally(() => process.exit(0));
|
|
88
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools/ts-sdk-apm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.4.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,11 +9,11 @@
|
|
|
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.
|
|
12
|
+
"@opentelemetry/auto-instrumentations-node": "^0.64.0",
|
|
13
|
+
"@opentelemetry/exporter-metrics-otlp-http": "^0.205.0",
|
|
14
|
+
"@opentelemetry/sdk-node": "^0.205.0",
|
|
15
15
|
"dd-trace": "^5.31.0",
|
|
16
|
-
"newrelic": "^
|
|
16
|
+
"newrelic": "^13.0.0",
|
|
17
17
|
"uuid": "11.1.0"
|
|
18
18
|
},
|
|
19
19
|
"publishConfig": {
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"opentelemetry",
|
|
33
33
|
"tracing"
|
|
34
34
|
],
|
|
35
|
-
"homepage": "https://github.com/commercetools/commercetools-typescript
|
|
36
|
-
"bugs": "https://github.com/commercetools/commercetools-typescript
|
|
35
|
+
"homepage": "https://github.com/commercetools/commercetools-sdk-typescript",
|
|
36
|
+
"bugs": "https://github.com/commercetools/commercetools-sdk-typescript/issues",
|
|
37
37
|
"repository": {
|
|
38
38
|
"type": "git",
|
|
39
|
-
"url": "https://github.com/commercetools/commercetools-typescript
|
|
39
|
+
"url": "https://github.com/commercetools/commercetools-sdk-typescript"
|
|
40
40
|
},
|
|
41
41
|
"files": [
|
|
42
42
|
"dist",
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|