@commercetools/ts-sdk-apm 3.1.0 → 3.3.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @commercetools/ts-sdk-apm
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#936](https://github.com/commercetools/commercetools-sdk-typescript/pull/936) [`f702837`](https://github.com/commercetools/commercetools-sdk-typescript/commit/f702837c3ec7fde11641c94abb5ed4dab138acf9) Thanks [@barbara79](https://github.com/barbara79)! - updated documentation with client v3
8
+
9
+ ## 3.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#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
14
+
3
15
  ## 3.1.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -26,7 +26,7 @@ Import the package and add it to the SDK client using `withTelemetryMiddleware()
26
26
 
27
27
  ```typescript
28
28
  // import the @commercetools/ts-sdk-apm package
29
- import { ClientBuilder } from '@commercetools/sdk-client-v2'
29
+ import { ClientBuilder } from '@commercetools/ts-client'
30
30
  import { createTelemetryMiddleware } from '@commercetools/ts-sdk-apm'
31
31
 
32
32
  // newrelic options
@@ -47,13 +47,19 @@ const client = new ClientBuilder()
47
47
 
48
48
  ## Using a custom (user-defined options)
49
49
 
50
- All the monitoring and tracing functionality has been implemented by default however, the `telemetryOptions` accepts three function parameters `createTelemetryMiddleware`, `apm` and `tracer`, the `createTelemetryMiddleware` and `tracer` can be custom implemented.
50
+ All monitoring and tracing functionality are implemented by default.
51
+ The `telemetryOptions` accepts four configuration options: `createTelemetryMiddleware`, `apm`, `tracer` and `customMetrics`. The `createTelemetryMiddleware` and `tracer` parameters can be custom-implemented.
52
+ Additionally, `customMetrics` can be included to record custom metrics based on available APM. For example, if we want to record and send custom metrics to Newrelic, we can set the `newrelic` field to `true` in the customMetrics configuration option same goes for datadog. For collecting custom metrics only Newrelic and Datadog are currently supported.
51
53
 
52
54
  ```typescript
53
55
  type telemetryOptions = {
54
- createTelemetryMiddleware: (options: Omit<telemetryOptions, 'createTelemetryMiddleware'>) => Middleware;
55
- apm?: () => typeof require('newrelic');
56
- tracer?: () => typeof require('/absolute-path-to-a-tracer(opentelemetry)-module')
56
+ createTelemetryMiddleware: (options: Omit<telemetryOptions, 'createTelemetryMiddleware'>) => Middleware,
57
+ apm?: () => typeof require('newrelic'),
58
+ tracer?: () => typeof require('/absolute-path-to-a-tracer(opentelemetry)-module'),
59
+ customMetrics?: {
60
+ newrelic?: true;
61
+ datadog?: false; // it can be omitted
62
+ }
57
63
  }
58
64
  ```
59
65
 
@@ -66,6 +72,9 @@ const telemetryOptions = {
66
72
  require(
67
73
  require('path').join(__dirname, '..', '..', 'custom-telemetry-module.js')
68
74
  ), // make sure the require takes in an absolute path to the custom tracer module.
75
+ customMetrics: {
76
+ datadog: true,
77
+ },
69
78
  }
70
79
  ```
71
80
 
@@ -3,52 +3,34 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var datadog = require('dd-trace');
6
- var newrelic = require('newrelic');
7
6
 
8
7
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
9
8
 
10
9
  var datadog__default = /*#__PURE__*/_interopDefault(datadog);
11
- var newrelic__default = /*#__PURE__*/_interopDefault(newrelic);
12
10
 
13
- const time = () => performance.now();
11
+ // Initialize datadog once
12
+ datadog__default["default"].init();
14
13
 
15
- // record for datadog
14
+ // Record metrics for datadog
16
15
  const recordDatadog = (metric, tags) => {
17
- datadog__default["default"].init().dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
16
+ datadog__default["default"].dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
18
17
  };
19
18
 
20
- // record for newrelic
21
- const recordNewrelic = metric => {
22
- newrelic__default["default"].recordMetric(`Commercetools/Client/Response/Total`, metric);
23
- };
19
+ const time = () => performance.now();
24
20
 
25
- /**
26
- * default newrelic APM and
27
- * opentelemetry tracer modules
28
- */
29
- const defaultOptions$1 = {
30
- /**
31
- * if this is to be used with newrelic, then
32
- * pass this (apm) as an option in the `createTelemetryMiddleware`
33
- * function e.g createTelemetryMiddleware({ apm: () => require('newrelic'), ... })
34
- */
35
- apm: () => require('newrelic'),
36
- tracer: () => require('../opentelemetry')
37
- };
38
21
  function createTelemetryMiddleware$1(options) {
39
22
  // trace
40
23
  function trace() {
41
24
  // validate apm and tracer
42
25
  if (!(options?.apm && typeof options.apm == 'function')) {
43
- options.apm = defaultOptions$1.apm;
26
+ options.apm = () => {};
44
27
  }
45
28
  if (!(options?.tracer && typeof options.tracer == 'function')) {
46
- options.tracer = defaultOptions$1.tracer;
29
+ options.tracer = () => {};
47
30
  }
48
- options.apm();
49
- options.tracer();
50
31
  }
51
32
  trace(); // expose tracing modules
33
+
52
34
  return next => async request => {
53
35
  // get start (high resolution milliseconds) timestamp
54
36
  const start = time();
@@ -61,10 +43,18 @@ function createTelemetryMiddleware$1(options) {
61
43
 
62
44
  // send `response_time` to APM platforms
63
45
  if (options?.customMetrics) {
64
- options.customMetrics.newrelic && recordNewrelic(response_time);
65
- options.customMetrics.datadog && recordDatadog(response_time, {
66
- env: 'dev'
67
- });
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
+ }
68
58
  }
69
59
  return response;
70
60
  };
@@ -113,13 +103,5 @@ function createTelemetryMiddleware(options) {
113
103
  };
114
104
  }
115
105
 
116
- Object.defineProperty(exports, 'datadog', {
117
- enumerable: true,
118
- get: function () { return datadog__default["default"]; }
119
- });
120
- Object.defineProperty(exports, 'newrelic', {
121
- enumerable: true,
122
- get: function () { return newrelic__default["default"]; }
123
- });
124
106
  exports.createTelemetryMiddleware = createTelemetryMiddleware$1;
125
107
  exports.createTelemetryMiddlewareLegacy = createTelemetryMiddleware;
@@ -1,47 +1,28 @@
1
1
  import datadog from 'dd-trace';
2
- export { default as datadog } from 'dd-trace';
3
- import newrelic from 'newrelic';
4
- export { default as newrelic } from 'newrelic';
5
2
 
6
- const time = () => performance.now();
3
+ // Initialize datadog once
4
+ datadog.init();
7
5
 
8
- // record for datadog
6
+ // Record metrics for datadog
9
7
  const recordDatadog = (metric, tags) => {
10
- datadog.init().dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
8
+ datadog.dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
11
9
  };
12
10
 
13
- // record for newrelic
14
- const recordNewrelic = metric => {
15
- newrelic.recordMetric(`Commercetools/Client/Response/Total`, metric);
16
- };
11
+ const time = () => performance.now();
17
12
 
18
- /**
19
- * default newrelic APM and
20
- * opentelemetry tracer modules
21
- */
22
- const defaultOptions$1 = {
23
- /**
24
- * if this is to be used with newrelic, then
25
- * pass this (apm) as an option in the `createTelemetryMiddleware`
26
- * function e.g createTelemetryMiddleware({ apm: () => require('newrelic'), ... })
27
- */
28
- apm: () => require('newrelic'),
29
- tracer: () => require('../opentelemetry')
30
- };
31
13
  function createTelemetryMiddleware$1(options) {
32
14
  // trace
33
15
  function trace() {
34
16
  // validate apm and tracer
35
17
  if (!(options?.apm && typeof options.apm == 'function')) {
36
- options.apm = defaultOptions$1.apm;
18
+ options.apm = () => {};
37
19
  }
38
20
  if (!(options?.tracer && typeof options.tracer == 'function')) {
39
- options.tracer = defaultOptions$1.tracer;
21
+ options.tracer = () => {};
40
22
  }
41
- options.apm();
42
- options.tracer();
43
23
  }
44
24
  trace(); // expose tracing modules
25
+
45
26
  return next => async request => {
46
27
  // get start (high resolution milliseconds) timestamp
47
28
  const start = time();
@@ -54,10 +35,18 @@ function createTelemetryMiddleware$1(options) {
54
35
 
55
36
  // send `response_time` to APM platforms
56
37
  if (options?.customMetrics) {
57
- options.customMetrics.newrelic && recordNewrelic(response_time);
58
- options.customMetrics.datadog && recordDatadog(response_time, {
59
- env: 'dev'
60
- });
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
+ }
61
50
  }
62
51
  return response;
63
52
  };
@@ -3,52 +3,34 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var datadog = require('dd-trace');
6
- var newrelic = require('newrelic');
7
6
 
8
7
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
9
8
 
10
9
  var datadog__default = /*#__PURE__*/_interopDefault(datadog);
11
- var newrelic__default = /*#__PURE__*/_interopDefault(newrelic);
12
10
 
13
- const time = () => performance.now();
11
+ // Initialize datadog once
12
+ datadog__default["default"].init();
14
13
 
15
- // record for datadog
14
+ // Record metrics for datadog
16
15
  const recordDatadog = (metric, tags) => {
17
- datadog__default["default"].init().dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
16
+ datadog__default["default"].dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
18
17
  };
19
18
 
20
- // record for newrelic
21
- const recordNewrelic = metric => {
22
- newrelic__default["default"].recordMetric(`Commercetools/Client/Response/Total`, metric);
23
- };
19
+ const time = () => performance.now();
24
20
 
25
- /**
26
- * default newrelic APM and
27
- * opentelemetry tracer modules
28
- */
29
- const defaultOptions$1 = {
30
- /**
31
- * if this is to be used with newrelic, then
32
- * pass this (apm) as an option in the `createTelemetryMiddleware`
33
- * function e.g createTelemetryMiddleware({ apm: () => require('newrelic'), ... })
34
- */
35
- apm: () => require('newrelic'),
36
- tracer: () => require('../opentelemetry')
37
- };
38
21
  function createTelemetryMiddleware$1(options) {
39
22
  // trace
40
23
  function trace() {
41
24
  // validate apm and tracer
42
25
  if (!(options?.apm && typeof options.apm == 'function')) {
43
- options.apm = defaultOptions$1.apm;
26
+ options.apm = () => {};
44
27
  }
45
28
  if (!(options?.tracer && typeof options.tracer == 'function')) {
46
- options.tracer = defaultOptions$1.tracer;
29
+ options.tracer = () => {};
47
30
  }
48
- options.apm();
49
- options.tracer();
50
31
  }
51
32
  trace(); // expose tracing modules
33
+
52
34
  return next => async request => {
53
35
  // get start (high resolution milliseconds) timestamp
54
36
  const start = time();
@@ -61,10 +43,18 @@ function createTelemetryMiddleware$1(options) {
61
43
 
62
44
  // send `response_time` to APM platforms
63
45
  if (options?.customMetrics) {
64
- options.customMetrics.newrelic && recordNewrelic(response_time);
65
- options.customMetrics.datadog && recordDatadog(response_time, {
66
- env: 'dev'
67
- });
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
+ }
68
58
  }
69
59
  return response;
70
60
  };
@@ -113,13 +103,5 @@ function createTelemetryMiddleware(options) {
113
103
  };
114
104
  }
115
105
 
116
- Object.defineProperty(exports, 'datadog', {
117
- enumerable: true,
118
- get: function () { return datadog__default["default"]; }
119
- });
120
- Object.defineProperty(exports, 'newrelic', {
121
- enumerable: true,
122
- get: function () { return newrelic__default["default"]; }
123
- });
124
106
  exports.createTelemetryMiddleware = createTelemetryMiddleware$1;
125
107
  exports.createTelemetryMiddlewareLegacy = createTelemetryMiddleware;
@@ -3,52 +3,34 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var datadog = require('dd-trace');
6
- var newrelic = require('newrelic');
7
6
 
8
7
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
9
8
 
10
9
  var datadog__default = /*#__PURE__*/_interopDefault(datadog);
11
- var newrelic__default = /*#__PURE__*/_interopDefault(newrelic);
12
10
 
13
- const time = () => performance.now();
11
+ // Initialize datadog once
12
+ datadog__default["default"].init();
14
13
 
15
- // record for datadog
14
+ // Record metrics for datadog
16
15
  const recordDatadog = (metric, tags) => {
17
- datadog__default["default"].init().dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
16
+ datadog__default["default"].dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
18
17
  };
19
18
 
20
- // record for newrelic
21
- const recordNewrelic = metric => {
22
- newrelic__default["default"].recordMetric(`Commercetools/Client/Response/Total`, metric);
23
- };
19
+ const time = () => performance.now();
24
20
 
25
- /**
26
- * default newrelic APM and
27
- * opentelemetry tracer modules
28
- */
29
- const defaultOptions$1 = {
30
- /**
31
- * if this is to be used with newrelic, then
32
- * pass this (apm) as an option in the `createTelemetryMiddleware`
33
- * function e.g createTelemetryMiddleware({ apm: () => require('newrelic'), ... })
34
- */
35
- apm: () => require('newrelic'),
36
- tracer: () => require('../opentelemetry')
37
- };
38
21
  function createTelemetryMiddleware$1(options) {
39
22
  // trace
40
23
  function trace() {
41
24
  // validate apm and tracer
42
25
  if (!(options?.apm && typeof options.apm == 'function')) {
43
- options.apm = defaultOptions$1.apm;
26
+ options.apm = () => {};
44
27
  }
45
28
  if (!(options?.tracer && typeof options.tracer == 'function')) {
46
- options.tracer = defaultOptions$1.tracer;
29
+ options.tracer = () => {};
47
30
  }
48
- options.apm();
49
- options.tracer();
50
31
  }
51
32
  trace(); // expose tracing modules
33
+
52
34
  return next => async request => {
53
35
  // get start (high resolution milliseconds) timestamp
54
36
  const start = time();
@@ -61,10 +43,18 @@ function createTelemetryMiddleware$1(options) {
61
43
 
62
44
  // send `response_time` to APM platforms
63
45
  if (options?.customMetrics) {
64
- options.customMetrics.newrelic && recordNewrelic(response_time);
65
- options.customMetrics.datadog && recordDatadog(response_time, {
66
- env: 'dev'
67
- });
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
+ }
68
58
  }
69
59
  return response;
70
60
  };
@@ -113,13 +103,5 @@ function createTelemetryMiddleware(options) {
113
103
  };
114
104
  }
115
105
 
116
- Object.defineProperty(exports, 'datadog', {
117
- enumerable: true,
118
- get: function () { return datadog__default["default"]; }
119
- });
120
- Object.defineProperty(exports, 'newrelic', {
121
- enumerable: true,
122
- get: function () { return newrelic__default["default"]; }
123
- });
124
106
  exports.createTelemetryMiddleware = createTelemetryMiddleware$1;
125
107
  exports.createTelemetryMiddlewareLegacy = createTelemetryMiddleware;
@@ -1,47 +1,28 @@
1
1
  import datadog from 'dd-trace';
2
- export { default as datadog } from 'dd-trace';
3
- import newrelic from 'newrelic';
4
- export { default as newrelic } from 'newrelic';
5
2
 
6
- const time = () => performance.now();
3
+ // Initialize datadog once
4
+ datadog.init();
7
5
 
8
- // record for datadog
6
+ // Record metrics for datadog
9
7
  const recordDatadog = (metric, tags) => {
10
- datadog.init().dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
8
+ datadog.dogstatsd.gauge(`Commercetools_Client_Response_Total`, metric, tags);
11
9
  };
12
10
 
13
- // record for newrelic
14
- const recordNewrelic = metric => {
15
- newrelic.recordMetric(`Commercetools/Client/Response/Total`, metric);
16
- };
11
+ const time = () => performance.now();
17
12
 
18
- /**
19
- * default newrelic APM and
20
- * opentelemetry tracer modules
21
- */
22
- const defaultOptions$1 = {
23
- /**
24
- * if this is to be used with newrelic, then
25
- * pass this (apm) as an option in the `createTelemetryMiddleware`
26
- * function e.g createTelemetryMiddleware({ apm: () => require('newrelic'), ... })
27
- */
28
- apm: () => require('newrelic'),
29
- tracer: () => require('../opentelemetry')
30
- };
31
13
  function createTelemetryMiddleware$1(options) {
32
14
  // trace
33
15
  function trace() {
34
16
  // validate apm and tracer
35
17
  if (!(options?.apm && typeof options.apm == 'function')) {
36
- options.apm = defaultOptions$1.apm;
18
+ options.apm = () => {};
37
19
  }
38
20
  if (!(options?.tracer && typeof options.tracer == 'function')) {
39
- options.tracer = defaultOptions$1.tracer;
21
+ options.tracer = () => {};
40
22
  }
41
- options.apm();
42
- options.tracer();
43
23
  }
44
24
  trace(); // expose tracing modules
25
+
45
26
  return next => async request => {
46
27
  // get start (high resolution milliseconds) timestamp
47
28
  const start = time();
@@ -54,10 +35,18 @@ function createTelemetryMiddleware$1(options) {
54
35
 
55
36
  // send `response_time` to APM platforms
56
37
  if (options?.customMetrics) {
57
- options.customMetrics.newrelic && recordNewrelic(response_time);
58
- options.customMetrics.datadog && recordDatadog(response_time, {
59
- env: 'dev'
60
- });
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
+ }
61
50
  }
62
51
  return response;
63
52
  };
@@ -1 +1 @@
1
- {"version":3,"file":"apm-legacy.d.ts","sourceRoot":"../../../src","sources":["apm-legacy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAKhB,2BAA2B,EAC5B,0BAAsB;AAiBvB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,OAAO,EAAE,2BAA2B,GACnC,gBAAgB,CA0BlB"}
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;AAiBvB,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,OAAO,EAAE,2BAA2B,GACnC,UAAU,CAuCZ"}
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,5 +1,4 @@
1
1
  export * from "../types/types.js";
2
2
  export { default as createTelemetryMiddleware } from "./apm.js";
3
3
  export { default as createTelemetryMiddlewareLegacy } from "./apm-legacy.js";
4
- export * from "./lib/agents.js";
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -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;AAC5D,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,wBAAoB;AACzE,gCAA6B"}
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"}
@@ -3,7 +3,6 @@ export type MiddlewareRequest = ClientRequest
3
3
 
4
4
  export type Middleware = (next: Next) => (request: MiddlewareRequest) => Promise<MiddlewareResponse>
5
5
 
6
- // export type Dispatch = (next: Next) => (request: MiddlewareRequest) => Promise<MiddlewareResponse>
7
6
  export type Next = (request: MiddlewareRequest) => Promise<MiddlewareResponse>
8
7
 
9
8
  export type MiddlewareResponse<T = unknown> = {
@@ -33,7 +32,7 @@ export interface ClientRequest {
33
32
 
34
33
  export type ClientResponse<T = any> = {
35
34
  body: T
36
- code?: number
35
+ code?: string
37
36
  statusCode?: number
38
37
  headers?: Record<string, any>
39
38
  error?: HttpErrorType
@@ -43,7 +42,7 @@ export type ClientResponse<T = any> = {
43
42
  export type HttpErrorType = {
44
43
  name?: string
45
44
  message: string
46
- code?: number
45
+ code?: string
47
46
  status?: number
48
47
  method: MethodType
49
48
  statusCode: number
@@ -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;
@@ -0,0 +1,8 @@
1
+ import newrelic from 'newrelic';
2
+
3
+ // record for newrelic
4
+ const recordNewRelic = metric => {
5
+ newrelic.recordMetric(`Commercetools/Client/Response/Total`, metric);
6
+ };
7
+
8
+ export { recordNewRelic };
@@ -0,0 +1,8 @@
1
+ import newrelic from 'newrelic';
2
+
3
+ // record for newrelic
4
+ const recordNewRelic = metric => {
5
+ newrelic.recordMetric(`Commercetools/Client/Response/Total`, metric);
6
+ };
7
+
8
+ export { recordNewRelic };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools/ts-sdk-apm",
3
- "version": "3.1.0",
3
+ "version": "3.3.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,12 +9,12 @@
9
9
  "private": false,
10
10
  "dependencies": {
11
11
  "@opentelemetry/api": "^1.4.1",
12
- "@opentelemetry/auto-instrumentations-node": "^0.55.0",
12
+ "@opentelemetry/auto-instrumentations-node": "^0.56.0",
13
13
  "@opentelemetry/exporter-metrics-otlp-http": "^0.57.0",
14
14
  "@opentelemetry/sdk-node": "^0.57.0",
15
15
  "dd-trace": "^5.31.0",
16
16
  "newrelic": "^12.10.0",
17
- "uuid": "11.0.4"
17
+ "uuid": "11.1.0"
18
18
  },
19
19
  "publishConfig": {
20
20
  "access": "public"
@@ -55,6 +55,6 @@
55
55
  "post_process_generate": "yarn organize_imports"
56
56
  },
57
57
  "devDependencies": {
58
- "@types/newrelic": "^9.14.6"
58
+ "@types/newrelic": "9.14.8"
59
59
  }
60
60
  }
@@ -1,4 +0,0 @@
1
- import datadog from 'dd-trace';
2
- import newrelic from 'newrelic';
3
- export { datadog, newrelic };
4
- //# sourceMappingURL=agents.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agents.d.ts","sourceRoot":"../../../../src/lib","sources":["agents.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,QAAQ,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAA"}