@conduit-client/service-instrument-command 3.19.6 → 3.20.3

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.
@@ -1,6 +1,2 @@
1
- /*!
2
- * Copyright (c) 2022, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
1
+
6
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/v1/index.js CHANGED
@@ -1,8 +1,3 @@
1
- /*!
2
- * Copyright (c) 2022, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
1
  function buildInstrumentCommand(services) {
7
2
  const meter = services.instrumentation.metrics.getMeter("onestore");
8
3
  return function instrumentCommand(commandClass, commandName) {
@@ -22,7 +17,7 @@ function buildInstrumentCommand(services) {
22
17
  try {
23
18
  result = super.execute(...args);
24
19
  } catch (e) {
25
- if ((e == null ? void 0 : e.name) === "AbortError") {
20
+ if (e?.name === "AbortError") {
26
21
  abortCounter.add(1);
27
22
  } else {
28
23
  errorCounter.add(1);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/v1/build-instrument-command.ts","../../src/v1/index.ts"],"sourcesContent":["import type { NamedInstrumentationService } from '@conduit-client/service-instrumentation/v1';\nimport type { Command } from '@conduit-client/command-base/v1';\n\nexport type ParamsOf<C extends Command<any, any>> =\n C extends Command<any, infer Params> ? Params : never;\nexport type ResultOf<C extends Command<any, any>> =\n C extends Command<infer Result, any> ? Result : never;\n\nexport type CommandConstructor<Result, Params extends any[] = []> = new (\n ...args: any[]\n) => Command<Result, Params>;\n\nexport function buildInstrumentCommand(services: NamedInstrumentationService) {\n const meter = services.instrumentation.metrics.getMeter('onestore');\n\n return function instrumentCommand<C extends CommandConstructor<any, any>>(\n commandClass: C,\n commandName: string\n ): C {\n const invocationCounter = meter.createCounter(`${commandName}.command.invocation.count`);\n const errorCounter = meter.createCounter(`${commandName}.command.error.count`);\n const abortCounter = meter.createCounter(`${commandName}.command.abort.count`);\n const durationHistogram = meter.createHistogram(`${commandName}.command.duration`);\n return class extends commandClass {\n execute(...args: ParamsOf<InstanceType<C>>): ResultOf<InstanceType<C>> {\n invocationCounter.add(1);\n\n let result;\n\n const start = services.instrumentation.currentTimeMs();\n function recordDuration() {\n const end = services.instrumentation.currentTimeMs();\n durationHistogram.record(end - start);\n }\n\n try {\n result = super.execute(...(args as any[]));\n } catch (e) {\n // Note: not checking for DOMException because in Node.js it's AbortError,\n // and vice versa for AbortError in the browser.\n if ((e as Error)?.name === 'AbortError') {\n abortCounter.add(1);\n } else {\n errorCounter.add(1);\n }\n throw e;\n }\n\n if (typeof result === 'object' && result !== null && 'then' in result) {\n (result as Promise<unknown>).then(recordDuration, () => {\n errorCounter.add(1);\n });\n } else {\n recordDuration();\n }\n\n return result;\n }\n };\n };\n}\n","import { buildInstrumentCommand } from './build-instrument-command';\nimport type { InstrumentationService } from '@conduit-client/service-instrumentation/v1';\nimport type { NamedService, ServiceDescriptor } from '@conduit-client/utils';\n\nexport { type CommandConstructor } from './build-instrument-command';\n\nexport type IInstrumentCommand = ReturnType<typeof buildInstrumentCommand>;\n\nexport function buildServiceDescriptor(\n instrumentation: InstrumentationService\n): InstrumentCommandServiceDescriptor {\n return {\n type: 'instrumentCommand',\n version: '1.0',\n service: buildInstrumentCommand({ instrumentation }),\n };\n}\n\nexport type InstrumentCommandServiceDescriptor = ServiceDescriptor<\n IInstrumentCommand,\n 'instrumentCommand',\n '1.0'\n>;\nexport type NamedInstrumentCommandService<Name extends string = 'instrumentCommand'> = NamedService<\n Name,\n IInstrumentCommand\n>;\n"],"names":[],"mappings":";;;;;AAYO,SAAS,uBAAuB,UAAuC;AAC1E,QAAM,QAAQ,SAAS,gBAAgB,QAAQ,SAAS,UAAU;AAElE,SAAO,SAAS,kBACZ,cACA,aACC;AACD,UAAM,oBAAoB,MAAM,cAAc,GAAG,WAAW,2BAA2B;AACvF,UAAM,eAAe,MAAM,cAAc,GAAG,WAAW,sBAAsB;AAC7E,UAAM,eAAe,MAAM,cAAc,GAAG,WAAW,sBAAsB;AAC7E,UAAM,oBAAoB,MAAM,gBAAgB,GAAG,WAAW,mBAAmB;AACjF,WAAO,cAAc,aAAa;AAAA,MAC9B,WAAW,MAA4D;AACnE,0BAAkB,IAAI,CAAC;AAEvB,YAAI;AAEJ,cAAM,QAAQ,SAAS,gBAAgB,cAAA;AACvC,iBAAS,iBAAiB;AACtB,gBAAM,MAAM,SAAS,gBAAgB,cAAA;AACrC,4BAAkB,OAAO,MAAM,KAAK;AAAA,QACxC;AAEA,YAAI;AACA,mBAAS,MAAM,QAAQ,GAAI,IAAc;AAAA,QAC7C,SAAS,GAAG;AAGR,eAAK,uBAAa,UAAS,cAAc;AACrC,yBAAa,IAAI,CAAC;AAAA,UACtB,OAAO;AACH,yBAAa,IAAI,CAAC;AAAA,UACtB;AACA,gBAAM;AAAA,QACV;AAEA,YAAI,OAAO,WAAW,YAAY,WAAW,QAAQ,UAAU,QAAQ;AAClE,iBAA4B,KAAK,gBAAgB,MAAM;AACpD,yBAAa,IAAI,CAAC;AAAA,UACtB,CAAC;AAAA,QACL,OAAO;AACH,yBAAA;AAAA,QACJ;AAEA,eAAO;AAAA,MACX;AAAA,IAAA;AAAA,EAER;AACJ;ACpDO,SAAS,uBACZ,iBACkC;AAClC,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS,uBAAuB,EAAE,gBAAA,CAAiB;AAAA,EAAA;AAE3D;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/v1/build-instrument-command.ts","../../src/v1/index.ts"],"sourcesContent":["import type { NamedInstrumentationService } from '@conduit-client/service-instrumentation/v1';\nimport type { Command } from '@conduit-client/command-base/v1';\n\nexport type ParamsOf<C extends Command<any, any>> =\n C extends Command<any, infer Params> ? Params : never;\nexport type ResultOf<C extends Command<any, any>> =\n C extends Command<infer Result, any> ? Result : never;\n\nexport type CommandConstructor<Result, Params extends any[] = []> = new (\n ...args: any[]\n) => Command<Result, Params>;\n\nexport function buildInstrumentCommand(services: NamedInstrumentationService) {\n const meter = services.instrumentation.metrics.getMeter('onestore');\n\n return function instrumentCommand<C extends CommandConstructor<any, any>>(\n commandClass: C,\n commandName: string\n ): C {\n const invocationCounter = meter.createCounter(`${commandName}.command.invocation.count`);\n const errorCounter = meter.createCounter(`${commandName}.command.error.count`);\n const abortCounter = meter.createCounter(`${commandName}.command.abort.count`);\n const durationHistogram = meter.createHistogram(`${commandName}.command.duration`);\n return class extends commandClass {\n execute(...args: ParamsOf<InstanceType<C>>): ResultOf<InstanceType<C>> {\n invocationCounter.add(1);\n\n let result;\n\n const start = services.instrumentation.currentTimeMs();\n function recordDuration() {\n const end = services.instrumentation.currentTimeMs();\n durationHistogram.record(end - start);\n }\n\n try {\n result = super.execute(...(args as any[]));\n } catch (e) {\n // Note: not checking for DOMException because in Node.js it's AbortError,\n // and vice versa for AbortError in the browser.\n if ((e as Error)?.name === 'AbortError') {\n abortCounter.add(1);\n } else {\n errorCounter.add(1);\n }\n throw e;\n }\n\n if (typeof result === 'object' && result !== null && 'then' in result) {\n (result as Promise<unknown>).then(recordDuration, () => {\n errorCounter.add(1);\n });\n } else {\n recordDuration();\n }\n\n return result;\n }\n };\n };\n}\n","import { buildInstrumentCommand } from './build-instrument-command';\nimport type { InstrumentationService } from '@conduit-client/service-instrumentation/v1';\nimport type { NamedService, ServiceDescriptor } from '@conduit-client/utils';\n\nexport { type CommandConstructor } from './build-instrument-command';\n\nexport type IInstrumentCommand = ReturnType<typeof buildInstrumentCommand>;\n\nexport function buildServiceDescriptor(\n instrumentation: InstrumentationService\n): InstrumentCommandServiceDescriptor {\n return {\n type: 'instrumentCommand',\n version: '1.0',\n service: buildInstrumentCommand({ instrumentation }),\n };\n}\n\nexport type InstrumentCommandServiceDescriptor = ServiceDescriptor<\n IInstrumentCommand,\n 'instrumentCommand',\n '1.0'\n>;\nexport type NamedInstrumentCommandService<Name extends string = 'instrumentCommand'> = NamedService<\n Name,\n IInstrumentCommand\n>;\n"],"names":[],"mappings":"AAYO,SAAS,uBAAuB,UAAuC;AAC1E,QAAM,QAAQ,SAAS,gBAAgB,QAAQ,SAAS,UAAU;AAElE,SAAO,SAAS,kBACZ,cACA,aACC;AACD,UAAM,oBAAoB,MAAM,cAAc,GAAG,WAAW,2BAA2B;AACvF,UAAM,eAAe,MAAM,cAAc,GAAG,WAAW,sBAAsB;AAC7E,UAAM,eAAe,MAAM,cAAc,GAAG,WAAW,sBAAsB;AAC7E,UAAM,oBAAoB,MAAM,gBAAgB,GAAG,WAAW,mBAAmB;AACjF,WAAO,cAAc,aAAa;AAAA,MAC9B,WAAW,MAA4D;AACnE,0BAAkB,IAAI,CAAC;AAEvB,YAAI;AAEJ,cAAM,QAAQ,SAAS,gBAAgB,cAAA;AACvC,iBAAS,iBAAiB;AACtB,gBAAM,MAAM,SAAS,gBAAgB,cAAA;AACrC,4BAAkB,OAAO,MAAM,KAAK;AAAA,QACxC;AAEA,YAAI;AACA,mBAAS,MAAM,QAAQ,GAAI,IAAc;AAAA,QAC7C,SAAS,GAAG;AAGR,cAAK,GAAa,SAAS,cAAc;AACrC,yBAAa,IAAI,CAAC;AAAA,UACtB,OAAO;AACH,yBAAa,IAAI,CAAC;AAAA,UACtB;AACA,gBAAM;AAAA,QACV;AAEA,YAAI,OAAO,WAAW,YAAY,WAAW,QAAQ,UAAU,QAAQ;AAClE,iBAA4B,KAAK,gBAAgB,MAAM;AACpD,yBAAa,IAAI,CAAC;AAAA,UACtB,CAAC;AAAA,QACL,OAAO;AACH,yBAAA;AAAA,QACJ;AAEA,eAAO;AAAA,MACX;AAAA,IAAA;AAAA,EAER;AACJ;ACpDO,SAAS,uBACZ,iBACkC;AAClC,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS,uBAAuB,EAAE,gBAAA,CAAiB;AAAA,EAAA;AAE3D;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conduit-client/service-instrument-command",
3
- "version": "3.19.6",
3
+ "version": "3.20.3",
4
4
  "private": false,
5
5
  "description": "Luvio Instrument Command service definition",
6
6
  "type": "module",
@@ -31,8 +31,8 @@
31
31
  "watch": "npm run build --watch"
32
32
  },
33
33
  "dependencies": {
34
- "@conduit-client/service-instrumentation": "3.19.6",
35
- "@conduit-client/utils": "3.19.6"
34
+ "@conduit-client/service-instrumentation": "3.20.3",
35
+ "@conduit-client/utils": "3.20.3"
36
36
  },
37
37
  "volta": {
38
38
  "extends": "../../../../package.json"