@grafana/faro-transport-otlp-http 2.9.0 → 2.10.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.
Files changed (91) hide show
  1. package/dist/bundle/faro-transport-otlp-http.iife.js +3 -1
  2. package/dist/bundle/faro-transport-otlp-http.iife.js.map +1 -0
  3. package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/asyncToGenerator.js +28 -0
  4. package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/defineProperty.js +13 -0
  5. package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectSpread2.js +26 -0
  6. package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectWithoutProperties.js +14 -0
  7. package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectWithoutPropertiesLoose.js +13 -0
  8. package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPrimitive.js +15 -0
  9. package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPropertyKey.js +10 -0
  10. package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/typeof.js +17 -0
  11. package/dist/cjs/index.js +2 -4
  12. package/dist/cjs/payload/OtelPayload.js +52 -61
  13. package/dist/cjs/payload/OtelPayload.js.map +1 -1
  14. package/dist/cjs/payload/attribute/attributeUtils.js +21 -40
  15. package/dist/cjs/payload/attribute/attributeUtils.js.map +1 -1
  16. package/dist/cjs/payload/attribute/index.js +4 -6
  17. package/dist/cjs/payload/index.js +2 -4
  18. package/dist/cjs/payload/transform/index.js +3 -5
  19. package/dist/cjs/payload/transform/transform.js +185 -169
  20. package/dist/cjs/payload/transform/transform.js.map +1 -1
  21. package/dist/cjs/payload/transform/types.js +0 -1
  22. package/dist/cjs/payload/types.js +0 -1
  23. package/dist/cjs/semconv.js +39 -23
  24. package/dist/cjs/semconv.js.map +1 -1
  25. package/dist/cjs/transport.js +117 -138
  26. package/dist/cjs/transport.js.map +1 -1
  27. package/dist/cjs/types.js +0 -1
  28. package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/asyncToGenerator.js +27 -0
  29. package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/defineProperty.js +12 -0
  30. package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectSpread2.js +25 -0
  31. package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectWithoutProperties.js +13 -0
  32. package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
  33. package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPrimitive.js +14 -0
  34. package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPropertyKey.js +9 -0
  35. package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/typeof.js +11 -0
  36. package/dist/esm/index.js +2 -2
  37. package/dist/esm/payload/OtelPayload.js +53 -60
  38. package/dist/esm/payload/OtelPayload.js.map +1 -1
  39. package/dist/esm/payload/attribute/attributeUtils.js +22 -40
  40. package/dist/esm/payload/attribute/attributeUtils.js.map +1 -1
  41. package/dist/esm/payload/attribute/index.js +2 -2
  42. package/dist/esm/payload/index.js +2 -2
  43. package/dist/esm/payload/transform/index.js +2 -2
  44. package/dist/esm/payload/transform/transform.js +186 -169
  45. package/dist/esm/payload/transform/transform.js.map +1 -1
  46. package/dist/esm/payload/transform/types.js +0 -2
  47. package/dist/esm/payload/types.js +0 -2
  48. package/dist/esm/semconv.js +25 -21
  49. package/dist/esm/semconv.js.map +1 -1
  50. package/dist/esm/transport.js +118 -137
  51. package/dist/esm/transport.js.map +1 -1
  52. package/dist/esm/types.js +0 -2
  53. package/dist/types/index.d.ts +3 -2
  54. package/dist/types/payload/OtelPayload.d.ts +18 -16
  55. package/dist/types/payload/attribute/attributeUtils.d.ts +7 -4
  56. package/dist/types/payload/attribute/index.d.ts +2 -1
  57. package/dist/types/payload/index.d.ts +5 -3
  58. package/dist/types/payload/transform/index.d.ts +3 -2
  59. package/dist/types/payload/transform/transform.d.ts +8 -5
  60. package/dist/types/payload/transform/types.d.ts +45 -42
  61. package/dist/types/payload/types.d.ts +10 -6
  62. package/dist/types/semconv.d.ts +24 -21
  63. package/dist/types/transport.d.ts +19 -17
  64. package/dist/types/types.d.ts +25 -22
  65. package/package.json +8 -16
  66. package/dist/bundle/types/index.d.ts +0 -2
  67. package/dist/bundle/types/payload/OtelPayload.d.ts +0 -19
  68. package/dist/bundle/types/payload/attribute/attributeUtils.d.ts +0 -4
  69. package/dist/bundle/types/payload/attribute/index.d.ts +0 -1
  70. package/dist/bundle/types/payload/index.d.ts +0 -3
  71. package/dist/bundle/types/payload/transform/index.d.ts +0 -2
  72. package/dist/bundle/types/payload/transform/transform.d.ts +0 -5
  73. package/dist/bundle/types/payload/transform/types.d.ts +0 -52
  74. package/dist/bundle/types/payload/types.d.ts +0 -7
  75. package/dist/bundle/types/semconv.d.ts +0 -22
  76. package/dist/bundle/types/transport.d.ts +0 -18
  77. package/dist/bundle/types/types.d.ts +0 -24
  78. package/dist/cjs/index.js.map +0 -1
  79. package/dist/cjs/payload/attribute/index.js.map +0 -1
  80. package/dist/cjs/payload/index.js.map +0 -1
  81. package/dist/cjs/payload/transform/index.js.map +0 -1
  82. package/dist/cjs/payload/transform/types.js.map +0 -1
  83. package/dist/cjs/payload/types.js.map +0 -1
  84. package/dist/cjs/types.js.map +0 -1
  85. package/dist/esm/index.js.map +0 -1
  86. package/dist/esm/payload/attribute/index.js.map +0 -1
  87. package/dist/esm/payload/index.js.map +0 -1
  88. package/dist/esm/payload/transform/index.js.map +0 -1
  89. package/dist/esm/payload/transform/types.js.map +0 -1
  90. package/dist/esm/payload/types.js.map +0 -1
  91. package/dist/esm/types.js.map +0 -1
@@ -1,65 +1,56 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OtelPayload = void 0;
4
- const faro_core_1 = require("@grafana/faro-core");
5
- const transform_1 = require("./transform");
6
- class OtelPayload {
7
- constructor({ internalLogger, customOtlpTransform, transportItem }) {
8
- this.resourceSpans = [];
9
- this.internalLogger = internalLogger;
10
- this.resourceLogs = [];
11
- this.getLogTransforms = (0, transform_1.getLogTransforms)(this.internalLogger, customOtlpTransform);
12
- this.getTraceTransforms = (0, transform_1.getTraceTransforms)(this.internalLogger);
13
- if (transportItem) {
14
- this.addResourceItem(transportItem);
15
- }
16
- }
17
- getPayload() {
18
- return {
19
- resourceLogs: this.resourceLogs,
20
- resourceSpans: this.resourceSpans,
21
- };
22
- }
23
- addResourceItem(transportItem) {
24
- var _a, _b, _c, _d;
25
- const { type } = transportItem;
26
- try {
27
- switch (type) {
28
- case faro_core_1.TransportItemType.LOG:
29
- case faro_core_1.TransportItemType.EXCEPTION:
30
- case faro_core_1.TransportItemType.EVENT:
31
- case faro_core_1.TransportItemType.MEASUREMENT: {
32
- const { toLogRecord, toResourceLog } = this.getLogTransforms;
33
- // Currently the scope is fixed to '@grafana/faro-web-sdk'.
34
- // Once we are able to drive the scope by instrumentation this will change and we need to align this function
35
- if (this.resourceLogs.length === 0) {
36
- this.resourceLogs = [toResourceLog(transportItem)];
37
- }
38
- else {
39
- // Faro takes care of the grouping with different metadata (or OTel attributes), so we can safely
40
- // use the just the first element of the resource.
41
- (_b = (_a = this.resourceLogs[0]) === null || _a === void 0 ? void 0 : _a.scopeLogs[0]) === null || _b === void 0 ? void 0 : _b.logRecords.push(toLogRecord(transportItem));
42
- }
43
- break;
44
- }
45
- case faro_core_1.TransportItemType.TRACE: {
46
- const { toResourceSpan } = this.getTraceTransforms;
47
- // We use the Otel Model as it is to avoid unnecessary resource consumption.
48
- // This is because we don't need the same logic to add items as it is for logs.
49
- // Also the Otel library already applies the respective protocol transforms so there is no need for additional transforms.
50
- // We only transform the resource object to ensure that we are compliant with the respective Faro Metas which add a few more items to the resource object.
51
- this.resourceSpans.push(toResourceSpan(transportItem));
52
- break;
53
- }
54
- default:
55
- (_c = this.internalLogger) === null || _c === void 0 ? void 0 : _c.error(`Unknown TransportItemType: ${type}`);
56
- break;
57
- }
58
- }
59
- catch (error) {
60
- (_d = this.internalLogger) === null || _d === void 0 ? void 0 : _d.error(error);
61
- }
62
- }
63
- }
3
+ const require_payload_transform_transform = require("./transform/transform.js");
4
+ require("./transform/index.js");
5
+ let _grafana_faro_core = require("@grafana/faro-core");
6
+ //#region src/payload/OtelPayload.ts
7
+ var OtelPayload = class {
8
+ constructor({ internalLogger, customOtlpTransform, transportItem }) {
9
+ this.resourceSpans = [];
10
+ this.internalLogger = internalLogger;
11
+ this.resourceLogs = [];
12
+ this.getLogTransforms = require_payload_transform_transform.getLogTransforms(this.internalLogger, customOtlpTransform);
13
+ this.getTraceTransforms = require_payload_transform_transform.getTraceTransforms(this.internalLogger);
14
+ if (transportItem) this.addResourceItem(transportItem);
15
+ }
16
+ getPayload() {
17
+ return {
18
+ resourceLogs: this.resourceLogs,
19
+ resourceSpans: this.resourceSpans
20
+ };
21
+ }
22
+ addResourceItem(transportItem) {
23
+ const { type } = transportItem;
24
+ try {
25
+ switch (type) {
26
+ case _grafana_faro_core.TransportItemType.LOG:
27
+ case _grafana_faro_core.TransportItemType.EXCEPTION:
28
+ case _grafana_faro_core.TransportItemType.EVENT:
29
+ case _grafana_faro_core.TransportItemType.MEASUREMENT: {
30
+ const { toLogRecord, toResourceLog } = this.getLogTransforms;
31
+ if (this.resourceLogs.length === 0) this.resourceLogs = [toResourceLog(transportItem)];
32
+ else {
33
+ var _this$resourceLogs$;
34
+ (_this$resourceLogs$ = this.resourceLogs[0]) === null || _this$resourceLogs$ === void 0 || (_this$resourceLogs$ = _this$resourceLogs$.scopeLogs[0]) === null || _this$resourceLogs$ === void 0 || _this$resourceLogs$.logRecords.push(toLogRecord(transportItem));
35
+ }
36
+ break;
37
+ }
38
+ case _grafana_faro_core.TransportItemType.TRACE: {
39
+ const { toResourceSpan } = this.getTraceTransforms;
40
+ this.resourceSpans.push(toResourceSpan(transportItem));
41
+ break;
42
+ }
43
+ default:
44
+ var _this$internalLogger;
45
+ (_this$internalLogger = this.internalLogger) === null || _this$internalLogger === void 0 || _this$internalLogger.error(`Unknown TransportItemType: ${type}`);
46
+ }
47
+ } catch (error) {
48
+ var _this$internalLogger2;
49
+ (_this$internalLogger2 = this.internalLogger) === null || _this$internalLogger2 === void 0 || _this$internalLogger2.error(error);
50
+ }
51
+ }
52
+ };
53
+ //#endregion
64
54
  exports.OtelPayload = OtelPayload;
55
+
65
56
  //# sourceMappingURL=OtelPayload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OtelPayload.js","sourceRoot":"","sources":["../../../src/payload/OtelPayload.ts"],"names":[],"mappings":";;;AAAA,kDAAuD;AAKvD,2CAAmE;AAWnE,MAAa,WAAW;IAStB,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,aAAa,EAAqB;QAP7E,kBAAa,GAAG,EAAmB,CAAC;QAQ1C,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QAEvB,IAAI,CAAC,gBAAgB,GAAG,IAAA,4BAAgB,EAAC,IAAI,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;QACnF,IAAI,CAAC,kBAAkB,GAAG,IAAA,8BAAkB,EAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAElE,IAAI,aAAa,EAAE,CAAC;YAClB,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,UAAU;QACR,OAAO;YACL,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,aAAa,EAAE,IAAI,CAAC,aAAa;SACzB,CAAC;IACb,CAAC;IAED,eAAe,CAAC,aAA4B;;QAC1C,MAAM,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC;QAE/B,IAAI,C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,CAAC;CACF;AArED,kCAqEC","sourcesContent":["import { TransportItemType } from '@grafana/faro-core';\nimport type { InternalLogger, TraceEvent, TransportItem } from '@grafana/faro-core';\n\nimport type { OtlpHttpTransportOptions } from '../types';\n\nimport { getLogTransforms, getTraceTransforms } from './transform';\nimport type { LogsTransform, TraceTransform } from './transform';\nimport type { ResourceLogs, ResourceSpans } from './transform/types';\nimport type { OtelTransportPayload } from './types';\n\ntype OtelPayloadParams = {\n internalLogger: InternalLogger;\n transportItem?: TransportItem;\n customOtlpTransform?: OtlpHttpTransportOptions['otlpTransform'];\n};\n\nexport class OtelPayload {\n private resourceLogs: ResourceLogs;\n private resourceSpans = [] as ResourceSpans;\n\n private getLogTransforms: LogsTransform;\n private getTraceTransforms: TraceTransform;\n\n private internalLogger: InternalLogger;\n\n constructor({ internalLogger, customOtlpTransform, transportItem }: OtelPayloadParams) {\n this.internalLogger = internalLogger;\n this.resourceLogs = [];\n\n this.getLogTransforms = getLogTransforms(this.internalLogger, customOtlpTransform);\n this.getTraceTransforms = getTraceTransforms(this.internalLogger);\n\n if (transportItem) {\n this.addResourceItem(transportItem);\n }\n }\n\n getPayload(): OtelTransportPayload {\n return {\n resourceLogs: this.resourceLogs,\n resourceSpans: this.resourceSpans,\n } as const;\n }\n\n addResourceItem(transportItem: TransportItem): void {\n const { type } = transportItem;\n\n try {\n switch (type) {\n case TransportItemType.LOG:\n case TransportItemType.EXCEPTION:\n case TransportItemType.EVENT:\n case TransportItemType.MEASUREMENT: {\n const { toLogRecord, toResourceLog } = this.getLogTransforms;\n\n // Currently the scope is fixed to '@grafana/faro-web-sdk'.\n // Once we are able to drive the scope by instrumentation this will change and we need to align this function\n if (this.resourceLogs.length === 0) {\n this.resourceLogs = [toResourceLog(transportItem)];\n } else {\n // Faro takes care of the grouping with different metadata (or OTel attributes), so we can safely\n // use the just the first element of the resource.\n this.resourceLogs[0]?.scopeLogs[0]?.logRecords.push(toLogRecord(transportItem));\n }\n break;\n }\n case TransportItemType.TRACE: {\n const { toResourceSpan } = this.getTraceTransforms;\n\n // We use the Otel Model as it is to avoid unnecessary resource consumption.\n // This is because we don't need the same logic to add items as it is for logs.\n // Also the Otel library already applies the respective protocol transforms so there is no need for additional transforms.\n // We only transform the resource object to ensure that we are compliant with the respective Faro Metas which add a few more items to the resource object.\n this.resourceSpans.push(toResourceSpan(transportItem as TransportItem<TraceEvent>));\n\n break;\n }\n default:\n this.internalLogger?.error(`Unknown TransportItemType: ${type}`);\n break;\n }\n } catch (error) {\n this.internalLogger?.error(error);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"OtelPayload.js","names":["getLogTransforms","getTraceTransforms","TransportItemType"],"sources":["../../../src/payload/OtelPayload.ts"],"sourcesContent":["import { TransportItemType } from '@grafana/faro-core';\nimport type { InternalLogger, TraceEvent, TransportItem } from '@grafana/faro-core';\n\nimport type { OtlpHttpTransportOptions } from '../types';\n\nimport { getLogTransforms, getTraceTransforms } from './transform';\nimport type { LogsTransform, TraceTransform } from './transform';\nimport type { ResourceLogs, ResourceSpans } from './transform/types';\nimport type { OtelTransportPayload } from './types';\n\ntype OtelPayloadParams = {\n internalLogger: InternalLogger;\n transportItem?: TransportItem;\n customOtlpTransform?: OtlpHttpTransportOptions['otlpTransform'];\n};\n\nexport class OtelPayload {\n private resourceLogs: ResourceLogs;\n private resourceSpans = [] as ResourceSpans;\n\n private getLogTransforms: LogsTransform;\n private getTraceTransforms: TraceTransform;\n\n private internalLogger: InternalLogger;\n\n constructor({ internalLogger, customOtlpTransform, transportItem }: OtelPayloadParams) {\n this.internalLogger = internalLogger;\n this.resourceLogs = [];\n\n this.getLogTransforms = getLogTransforms(this.internalLogger, customOtlpTransform);\n this.getTraceTransforms = getTraceTransforms(this.internalLogger);\n\n if (transportItem) {\n this.addResourceItem(transportItem);\n }\n }\n\n getPayload(): OtelTransportPayload {\n return {\n resourceLogs: this.resourceLogs,\n resourceSpans: this.resourceSpans,\n } as const;\n }\n\n addResourceItem(transportItem: TransportItem): void {\n const { type } = transportItem;\n\n try {\n switch (type) {\n case TransportItemType.LOG:\n case TransportItemType.EXCEPTION:\n case TransportItemType.EVENT:\n case TransportItemType.MEASUREMENT: {\n const { toLogRecord, toResourceLog } = this.getLogTransforms;\n\n // Currently the scope is fixed to '@grafana/faro-web-sdk'.\n // Once we are able to drive the scope by instrumentation this will change and we need to align this function\n if (this.resourceLogs.length === 0) {\n this.resourceLogs = [toResourceLog(transportItem)];\n } else {\n // Faro takes care of the grouping with different metadata (or OTel attributes), so we can safely\n // use the just the first element of the resource.\n this.resourceLogs[0]?.scopeLogs[0]?.logRecords.push(toLogRecord(transportItem));\n }\n break;\n }\n case TransportItemType.TRACE: {\n const { toResourceSpan } = this.getTraceTransforms;\n\n // We use the Otel Model as it is to avoid unnecessary resource consumption.\n // This is because we don't need the same logic to add items as it is for logs.\n // Also the Otel library already applies the respective protocol transforms so there is no need for additional transforms.\n // We only transform the resource object to ensure that we are compliant with the respective Faro Metas which add a few more items to the resource object.\n this.resourceSpans.push(toResourceSpan(transportItem as TransportItem<TraceEvent>));\n\n break;\n }\n default:\n this.internalLogger?.error(`Unknown TransportItemType: ${type}`);\n break;\n }\n } catch (error) {\n this.internalLogger?.error(error);\n }\n }\n}\n"],"mappings":";;;;;;AAgBA,IAAa,cAAb,MAAyB;CASvB,YAAY,EAAE,gBAAgB,qBAAqB,iBAAoC;EAPvF,KAAQ,gBAAgB,CAAC;EAQvB,KAAK,iBAAiB;EACtB,KAAK,eAAe,CAAC;EAErB,KAAK,mBAAmBA,oCAAAA,iBAAiB,KAAK,gBAAgB,mBAAmB;EACjF,KAAK,qBAAqBC,oCAAAA,mBAAmB,KAAK,cAAc;EAEhE,IAAI,eACF,KAAK,gBAAgB,aAAa;CAEtC;CAEA,aAAmC;EACjC,OAAO;GACL,cAAc,KAAK;GACnB,eAAe,KAAK;EACtB;CACF;CAEA,gBAAgB,eAAoC;EAClD,MAAM,EAAE,SAAS;EAEjB,IAAI;GACF,QAAQ,MAAR;IACE,KAAKC,mBAAAA,kBAAkB;IACvB,KAAKA,mBAAAA,kBAAkB;IACvB,KAAKA,mBAAAA,kBAAkB;IACvB,KAAKA,mBAAAA,kBAAkB,aAAa;KAClC,MAAM,EAAE,aAAa,kBAAkB,KAAK;KAI5C,IAAI,KAAK,aAAa,WAAW,GAC/B,KAAK,eAAe,CAAC,cAAc,aAAa,CAAC;UAC5C;;MAGL,CAAA,sBAAA,KAAK,aAAa,QAAA,QAAA,wBAAA,KAAA,MAAA,sBAAA,oBAAI,UAAU,QAAA,QAAA,wBAAA,KAAA,KAAA,oBAAI,WAAW,KAAK,YAAY,aAAa,CAAC;KAChF;KACA;IACF;IACA,KAAKA,mBAAAA,kBAAkB,OAAO;KAC5B,MAAM,EAAE,mBAAmB,KAAK;KAMhC,KAAK,cAAc,KAAK,eAAe,aAA0C,CAAC;KAElF;IACF;IACA;;KACE,CAAA,uBAAA,KAAK,oBAAA,QAAA,yBAAA,KAAA,KAAA,qBAAgB,MAAM,8BAA8B,MAAM;GAEnE;EACF,SAAS,OAAO;;GACd,CAAA,wBAAA,KAAK,oBAAA,QAAA,0BAAA,KAAA,KAAA,sBAAgB,MAAM,KAAK;EAClC;CACF;AACF"}
@@ -1,49 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toAttributeValue = toAttributeValue;
4
- exports.toAttribute = toAttribute;
5
- exports.isAttribute = isAttribute;
6
- const faro_core_1 = require("@grafana/faro-core");
3
+ let _grafana_faro_core = require("@grafana/faro-core");
4
+ //#region src/payload/attribute/attributeUtils.ts
7
5
  function toAttributeValue(value) {
8
- if ((0, faro_core_1.isString)(value)) {
9
- return { stringValue: value };
10
- }
11
- if ((0, faro_core_1.isInt)(value)) {
12
- return { intValue: value };
13
- }
14
- if ((0, faro_core_1.isNumber)(value)) {
15
- return { doubleValue: value };
16
- }
17
- if ((0, faro_core_1.isBoolean)(value)) {
18
- return { boolValue: value };
19
- }
20
- if ((0, faro_core_1.isArray)(value)) {
21
- return { arrayValue: { values: value.map(toAttributeValue) } };
22
- }
23
- if (value instanceof Uint8Array) {
24
- return { bytesValue: value };
25
- }
26
- if ((0, faro_core_1.isObject)(value)) {
27
- return {
28
- kvlistValue: {
29
- values: Object.entries(value)
30
- .map(([attributeName, attributeValue]) => toAttribute(attributeName, attributeValue))
31
- .filter(isAttribute),
32
- },
33
- };
34
- }
35
- return {};
6
+ if ((0, _grafana_faro_core.isString)(value)) return { stringValue: value };
7
+ if ((0, _grafana_faro_core.isInt)(value)) return { intValue: value };
8
+ if ((0, _grafana_faro_core.isNumber)(value)) return { doubleValue: value };
9
+ if ((0, _grafana_faro_core.isBoolean)(value)) return { boolValue: value };
10
+ if ((0, _grafana_faro_core.isArray)(value)) return { arrayValue: { values: value.map(toAttributeValue) } };
11
+ if (value instanceof Uint8Array) return { bytesValue: value };
12
+ if ((0, _grafana_faro_core.isObject)(value)) return { kvlistValue: { values: Object.entries(value).map(([attributeName, attributeValue]) => toAttribute(attributeName, attributeValue)).filter(isAttribute) } };
13
+ return {};
36
14
  }
37
15
  function toAttribute(attributeName, attributeValue) {
38
- if (attributeValue == null || attributeValue === '') {
39
- return undefined;
40
- }
41
- return {
42
- key: attributeName,
43
- value: toAttributeValue(attributeValue),
44
- };
16
+ if (attributeValue == null || attributeValue === "") return;
17
+ return {
18
+ key: attributeName,
19
+ value: toAttributeValue(attributeValue)
20
+ };
45
21
  }
46
22
  function isAttribute(item) {
47
- return Boolean(item) && typeof (item === null || item === void 0 ? void 0 : item.key) === 'string' && typeof (item === null || item === void 0 ? void 0 : item.value) !== 'undefined';
23
+ return Boolean(item) && typeof (item === null || item === void 0 ? void 0 : item.key) === "string" && typeof (item === null || item === void 0 ? void 0 : item.value) !== "undefined";
48
24
  }
25
+ //#endregion
26
+ exports.isAttribute = isAttribute;
27
+ exports.toAttribute = toAttribute;
28
+ exports.toAttributeValue = toAttributeValue;
29
+
49
30
  //# sourceMappingURL=attributeUtils.js.map
@@ -1 +1 @@
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OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAgB,WAAW,CAAC,aAAqB,EAAE,cAAmB;IACpE,IAAI,cAAc,IAAI,IAAI,IAAI,cAAc,KAAK,EAAE,EAAE,CAAC;QACpD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,GAAG,EAAE,aAAa;QAClB,KAAK,EAAE,gBAAgB,CAAC,cAAc,CAAC;KACxC,CAAC;AACJ,CAAC;AAED,SAAgB,WAAW,CAAC,IAAS;IACnC,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAA,KAAK,QAAQ,IAAI,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAA,KAAK,WAAW,CAAC;AAC9F,CAAC","sourcesContent":["import type { IAnyValue, IKeyValue } from '@opentelemetry/otlp-transformer/build/src/common/internal-types';\n\nimport { isArray, isBoolean, isInt, isNumber, isObject, isString } from '@grafana/faro-core';\n\nexport function toAttributeValue(value: unknown): IAnyValue {\n if (isString(value)) {\n return { stringValue: value };\n }\n\n if (isInt(value)) {\n return { intValue: value };\n }\n\n if (isNumber(value)) {\n return { doubleValue: value as number };\n }\n\n if (isBoolean(value)) {\n return { boolValue: value };\n }\n\n if (isArray(value)) {\n return { arrayValue: { values: value.map(toAttributeValue) } };\n }\n\n if (value instanceof Uint8Array) {\n return { bytesValue: value };\n }\n\n if (isObject(value)) {\n return {\n kvlistValue: {\n values: Object.entries(value)\n .map(([attributeName, attributeValue]) => toAttribute(attributeName, attributeValue))\n .filter(isAttribute),\n },\n };\n }\n\n return {};\n}\n\nexport function toAttribute(attributeName: string, attributeValue: any): IKeyValue | undefined {\n if (attributeValue == null || attributeValue === '') {\n return undefined;\n }\n\n return {\n key: attributeName,\n value: toAttributeValue(attributeValue),\n };\n}\n\nexport function isAttribute(item: any): item is IKeyValue {\n return Boolean(item) && typeof item?.key === 'string' && typeof item?.value !== 'undefined';\n}\n"]}
1
+ {"version":3,"file":"attributeUtils.js","names":["isString","isInt","isNumber","isBoolean","isArray","isObject"],"sources":["../../../../src/payload/attribute/attributeUtils.ts"],"sourcesContent":["import type { IAnyValue, IKeyValue } from '@opentelemetry/otlp-transformer/build/src/common/internal-types';\n\nimport { isArray, isBoolean, isInt, isNumber, isObject, isString } from '@grafana/faro-core';\n\nexport function toAttributeValue(value: unknown): IAnyValue {\n if (isString(value)) {\n return { stringValue: value };\n }\n\n if (isInt(value)) {\n return { intValue: value };\n }\n\n if (isNumber(value)) {\n return { doubleValue: value as number };\n }\n\n if (isBoolean(value)) {\n return { boolValue: value };\n }\n\n if (isArray(value)) {\n return { arrayValue: { values: value.map(toAttributeValue) } };\n }\n\n if (value instanceof Uint8Array) {\n return { bytesValue: value };\n }\n\n if (isObject(value)) {\n return {\n kvlistValue: {\n values: Object.entries(value)\n .map(([attributeName, attributeValue]) => toAttribute(attributeName, attributeValue))\n .filter(isAttribute),\n },\n };\n }\n\n return {};\n}\n\nexport function toAttribute(attributeName: string, attributeValue: any): IKeyValue | undefined {\n if (attributeValue == null || attributeValue === '') {\n return undefined;\n }\n\n return {\n key: attributeName,\n value: toAttributeValue(attributeValue),\n };\n}\n\nexport function isAttribute(item: any): item is IKeyValue {\n return Boolean(item) && typeof item?.key === 'string' && typeof item?.value !== 'undefined';\n}\n"],"mappings":";;;;AAIA,SAAgB,iBAAiB,OAA2B;CAC1D,KAAA,GAAIA,mBAAAA,SAAAA,CAAS,KAAK,GAChB,OAAO,EAAE,aAAa,MAAM;CAG9B,KAAA,GAAIC,mBAAAA,MAAAA,CAAM,KAAK,GACb,OAAO,EAAE,UAAU,MAAM;CAG3B,KAAA,GAAIC,mBAAAA,SAAAA,CAAS,KAAK,GAChB,OAAO,EAAE,aAAa,MAAgB;CAGxC,KAAA,GAAIC,mBAAAA,UAAAA,CAAU,KAAK,GACjB,OAAO,EAAE,WAAW,MAAM;CAG5B,KAAA,GAAIC,mBAAAA,QAAAA,CAAQ,KAAK,GACf,OAAO,EAAE,YAAY,EAAE,QAAQ,MAAM,IAAI,gBAAgB,EAAE,EAAE;CAG/D,IAAI,iBAAiB,YACnB,OAAO,EAAE,YAAY,MAAM;CAG7B,KAAA,GAAIC,mBAAAA,SAAAA,CAAS,KAAK,GAChB,OAAO,EACL,aAAa,EACX,QAAQ,OAAO,QAAQ,KAAK,CAAC,CAC1B,KAAK,CAAC,eAAe,oBAAoB,YAAY,eAAe,cAAc,CAAC,CAAC,CACpF,OAAO,WAAW,EACvB,EACF;CAGF,OAAO,CAAC;AACV;AAEA,SAAgB,YAAY,eAAuB,gBAA4C;CAC7F,IAAI,kBAAkB,QAAQ,mBAAmB,IAC/C;CAGF,OAAO;EACL,KAAK;EACL,OAAO,iBAAiB,cAAc;CACxC;AACF;AAEA,SAAgB,YAAY,MAA8B;CACxD,OAAO,QAAQ,IAAI,KAAK,QAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAO,KAAM,SAAQ,YAAY,QAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAO,KAAM,WAAU;AAClF"}
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAttribute = exports.toAttributeValue = exports.toAttribute = void 0;
4
- var attributeUtils_1 = require("./attributeUtils");
5
- Object.defineProperty(exports, "toAttribute", { enumerable: true, get: function () { return attributeUtils_1.toAttribute; } });
6
- Object.defineProperty(exports, "toAttributeValue", { enumerable: true, get: function () { return attributeUtils_1.toAttributeValue; } });
7
- Object.defineProperty(exports, "isAttribute", { enumerable: true, get: function () { return attributeUtils_1.isAttribute; } });
8
- //# sourceMappingURL=index.js.map
3
+ const require_payload_attribute_attributeUtils = require("./attributeUtils.js");
4
+ exports.isAttribute = require_payload_attribute_attributeUtils.isAttribute;
5
+ exports.toAttribute = require_payload_attribute_attributeUtils.toAttribute;
6
+ exports.toAttributeValue = require_payload_attribute_attributeUtils.toAttributeValue;
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OtelPayload = void 0;
4
- var OtelPayload_1 = require("./OtelPayload");
5
- Object.defineProperty(exports, "OtelPayload", { enumerable: true, get: function () { return OtelPayload_1.OtelPayload; } });
6
- //# sourceMappingURL=index.js.map
3
+ const require_payload_OtelPayload = require("./OtelPayload.js");
4
+ exports.OtelPayload = require_payload_OtelPayload.OtelPayload;
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTraceTransforms = exports.getLogTransforms = void 0;
4
- var transform_1 = require("./transform");
5
- Object.defineProperty(exports, "getLogTransforms", { enumerable: true, get: function () { return transform_1.getLogTransforms; } });
6
- Object.defineProperty(exports, "getTraceTransforms", { enumerable: true, get: function () { return transform_1.getTraceTransforms; } });
7
- //# sourceMappingURL=index.js.map
3
+ const require_payload_transform_transform = require("./transform.js");
4
+ exports.getLogTransforms = require_payload_transform_transform.getLogTransforms;
5
+ exports.getTraceTransforms = require_payload_transform_transform.getTraceTransforms;