@grafana/faro-web-sdk 1.0.1 → 1.0.4
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/dist/bundle/faro-web-sdk.iife.js +1 -1
- package/dist/cjs/config/types.js.map +1 -1
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/metas/browser/meta.js +11 -0
- package/dist/cjs/metas/browser/meta.js.map +1 -1
- package/dist/esm/config/types.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/metas/browser/meta.js +11 -0
- package/dist/esm/metas/browser/meta.js.map +1 -1
- package/dist/types/config/types.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/instrumentations/console/instrumentation.d.ts +1 -1
- package/dist/types/instrumentations/errors/instrumentation.d.ts +1 -1
- package/dist/types/instrumentations/session/instrumentation.d.ts +1 -1
- package/dist/types/instrumentations/view/instrumentation.d.ts +1 -1
- package/dist/types/instrumentations/webVitals/instrumentation.d.ts +1 -1
- package/dist/types/transports/console/transport.d.ts +1 -1
- package/dist/types/transports/fetch/transport.d.ts +1 -1
- package/package.json +3 -3
- package/dist/cjs/transports/otlp/otlpPayloadLogger.js +0 -6
- package/dist/cjs/transports/otlp/otlpPayloadLogger.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/OtelPayload.js +0 -56
- package/dist/cjs/transports/otlp/payload/OtelPayload.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/attribute/attributeUtils.js +0 -53
- package/dist/cjs/transports/otlp/payload/attribute/attributeUtils.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/attribute/index.js +0 -8
- package/dist/cjs/transports/otlp/payload/attribute/index.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/index.js +0 -6
- package/dist/cjs/transports/otlp/payload/index.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/transform/index.js +0 -7
- package/dist/cjs/transports/otlp/payload/transform/index.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/transform/transform.js +0 -169
- package/dist/cjs/transports/otlp/payload/transform/transform.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/transform/types.js +0 -3
- package/dist/cjs/transports/otlp/payload/transform/types.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/types.js +0 -3
- package/dist/cjs/transports/otlp/payload/types.js.map +0 -1
- package/dist/esm/transports/otlp/otlpPayloadLogger.js +0 -3
- package/dist/esm/transports/otlp/otlpPayloadLogger.js.map +0 -1
- package/dist/esm/transports/otlp/payload/OtelPayload.js +0 -45
- package/dist/esm/transports/otlp/payload/OtelPayload.js.map +0 -1
- package/dist/esm/transports/otlp/payload/attribute/attributeUtils.js +0 -44
- package/dist/esm/transports/otlp/payload/attribute/attributeUtils.js.map +0 -1
- package/dist/esm/transports/otlp/payload/attribute/index.js +0 -2
- package/dist/esm/transports/otlp/payload/attribute/index.js.map +0 -1
- package/dist/esm/transports/otlp/payload/index.js +0 -2
- package/dist/esm/transports/otlp/payload/index.js.map +0 -1
- package/dist/esm/transports/otlp/payload/transform/index.js +0 -2
- package/dist/esm/transports/otlp/payload/transform/index.js.map +0 -1
- package/dist/esm/transports/otlp/payload/transform/transform.js +0 -158
- package/dist/esm/transports/otlp/payload/transform/transform.js.map +0 -1
- package/dist/esm/transports/otlp/payload/transform/types.js +0 -2
- package/dist/esm/transports/otlp/payload/transform/types.js.map +0 -1
- package/dist/esm/transports/otlp/payload/types.js +0 -2
- package/dist/esm/transports/otlp/payload/types.js.map +0 -1
- package/dist/types/transports/otlp/otlpPayloadLogger.d.ts +0 -1
- package/dist/types/transports/otlp/payload/OtelPayload.d.ts +0 -8
- package/dist/types/transports/otlp/payload/attribute/attributeUtils.d.ts +0 -4
- package/dist/types/transports/otlp/payload/attribute/index.d.ts +0 -1
- package/dist/types/transports/otlp/payload/index.d.ts +0 -2
- package/dist/types/transports/otlp/payload/transform/index.d.ts +0 -2
- package/dist/types/transports/otlp/payload/transform/transform.d.ts +0 -6
- package/dist/types/transports/otlp/payload/transform/types.d.ts +0 -28
- package/dist/types/transports/otlp/payload/types.d.ts +0 -6
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OtelPayload = void 0;
|
|
4
|
-
var faro_core_1 = require("@grafana/faro-core");
|
|
5
|
-
var otlpPayloadLogger_1 = require("../otlpPayloadLogger");
|
|
6
|
-
var transform_1 = require("./transform");
|
|
7
|
-
var OtelPayload = /** @class */ (function () {
|
|
8
|
-
function OtelPayload(transportItem) {
|
|
9
|
-
this.resourceLogsWithMetas = [];
|
|
10
|
-
if (transportItem) {
|
|
11
|
-
this.addResourceItem(transportItem);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
OtelPayload.prototype.getPayload = function () {
|
|
15
|
-
return {
|
|
16
|
-
resourceLogs: this.resourceLogsWithMetas.map(function (_a) {
|
|
17
|
-
var resourceLog = _a.resourceLog;
|
|
18
|
-
return resourceLog;
|
|
19
|
-
}),
|
|
20
|
-
resourceSpans: [],
|
|
21
|
-
resourceMetrics: [],
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
OtelPayload.prototype.addResourceItem = function (transportItem) {
|
|
25
|
-
var type = transportItem.type, meta = transportItem.meta;
|
|
26
|
-
switch (type) {
|
|
27
|
-
case faro_core_1.TransportItemType.LOG:
|
|
28
|
-
case faro_core_1.TransportItemType.EXCEPTION:
|
|
29
|
-
case faro_core_1.TransportItemType.EVENT:
|
|
30
|
-
case faro_core_1.TransportItemType.MEASUREMENT:
|
|
31
|
-
var resourceLogWithMeta = this.resourceLogsWithMetas.find(function (_a) {
|
|
32
|
-
var meta = _a.meta;
|
|
33
|
-
return (0, faro_core_1.deepEqual)(transportItem.meta, meta);
|
|
34
|
-
});
|
|
35
|
-
if (resourceLogWithMeta) {
|
|
36
|
-
var resourceLog = resourceLogWithMeta.resourceLog;
|
|
37
|
-
resourceLog.scopeLogs.push((0, transform_1.toScopeLog)(transportItem));
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
this.resourceLogsWithMetas.push({
|
|
41
|
-
resourceLog: (0, transform_1.toResourceLog)(transportItem),
|
|
42
|
-
meta: meta,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
break;
|
|
46
|
-
case faro_core_1.TransportItemType.TRACE:
|
|
47
|
-
break;
|
|
48
|
-
default:
|
|
49
|
-
otlpPayloadLogger_1.internalLogger.error("Unknown TransportItemType: ".concat(type));
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
return OtelPayload;
|
|
54
|
-
}());
|
|
55
|
-
exports.OtelPayload = OtelPayload;
|
|
56
|
-
//# sourceMappingURL=OtelPayload.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OtelPayload.js","sourceRoot":"","sources":["../../../../../src/transports/otlp/payload/OtelPayload.ts"],"names":[],"mappings":";;;AAAA,gDAAuF;AAEvF,0DAAsD;AAEtD,yCAAwD;AASxD;IAGE,qBAAY,aAA6B;QAFjC,0BAAqB,GAAG,EAA2B,CAAC;QAG1D,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;SACrC;IACH,CAAC;IAED,gCAAU,GAAV;QACE,OAAO;YACL,YAAY,EAAE,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,UAAC,EAAe;oBAAb,WAAW,iBAAA;gBAAO,OAAA,WAAW;YAAX,CAAW,CAAC;YAC9E,aAAa,EAAE,EAAE;YACjB,eAAe,EAAE,EAAE;SACX,CAAC;IACb,CAAC;IAED,qCAAe,GAAf,UAAgB,aAA4B;QAClC,IAAA,IAAI,GAAW,aAAa,KAAxB,EAAE,IAAI,GAAK,aAAa,KAAlB,CAAmB;QAErC,QAAQ,IAAI,EAAE;YACZ,KAAK,6BAAiB,CAAC,GAAG,CAAC;YAC3B,KAAK,6BAAiB,CAAC,SAAS,CAAC;YACjC,KAAK,6BAAiB,CAAC,KAAK,CAAC;YAC7B,KAAK,6BAAiB,CAAC,WAAW;gBAChC,IAAM,mBAAmB,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,UAAC,EAAQ;wBAAN,IAAI,UAAA;oBAAO,OAAA,IAAA,qBAAS,EAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC;gBAAnC,CAAmC,CAAC,CAAC;gBAE/G,IAAI,mBAAmB,EAAE;oBACf,IAAA,WAAW,GAAK,mBAAmB,YAAxB,CAAyB;oBAC5C,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,IAAA,sBAAU,EAAC,aAAa,CAAC,CAAC,CAAC;iBACvD;qBAAM;oBACL,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC;wBAC9B,WAAW,EAAE,IAAA,yBAAa,EAAC,aAAa,CAAC;wBACzC,IAAI,MAAA;qBACL,CAAC,CAAC;iBACJ;gBAED,MAAM;YACR,KAAK,6BAAiB,CAAC,KAAK;gBAC1B,MAAM;YACR;gBACE,kCAAc,CAAC,KAAK,CAAC,qCAA8B,IAAI,CAAE,CAAC,CAAC;gBAC3D,MAAM;SACT;IACH,CAAC;IACH,kBAAC;AAAD,CAAC,AA7CD,IA6CC;AA7CY,kCAAW","sourcesContent":["import { deepEqual, Meta, TransportItem, TransportItemType } from '@grafana/faro-core';\n\nimport { internalLogger } from '../otlpPayloadLogger';\n\nimport { toResourceLog, toScopeLog } from './transform';\nimport type { ResourceLog } from './transform';\nimport type { OtelTransportPayload } from './types';\n\ninterface ResourceLogsMetaMap {\n resourceLog: ResourceLog;\n meta: Meta;\n}\n\nexport class OtelPayload {\n private resourceLogsWithMetas = [] as ResourceLogsMetaMap[];\n\n constructor(transportItem?: TransportItem) {\n if (transportItem) {\n this.addResourceItem(transportItem);\n }\n }\n\n getPayload(): OtelTransportPayload {\n return {\n resourceLogs: this.resourceLogsWithMetas.map(({ resourceLog }) => resourceLog),\n resourceSpans: [],\n resourceMetrics: [],\n } as const;\n }\n\n addResourceItem(transportItem: TransportItem): void {\n const { type, meta } = transportItem;\n\n switch (type) {\n case TransportItemType.LOG:\n case TransportItemType.EXCEPTION:\n case TransportItemType.EVENT:\n case TransportItemType.MEASUREMENT:\n const resourceLogWithMeta = this.resourceLogsWithMetas.find(({ meta }) => deepEqual(transportItem.meta, meta));\n\n if (resourceLogWithMeta) {\n const { resourceLog } = resourceLogWithMeta;\n resourceLog.scopeLogs.push(toScopeLog(transportItem));\n } else {\n this.resourceLogsWithMetas.push({\n resourceLog: toResourceLog(transportItem),\n meta,\n });\n }\n\n break;\n case TransportItemType.TRACE:\n break;\n default:\n internalLogger.error(`Unknown TransportItemType: ${type}`);\n break;\n }\n }\n}\n"]}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isAttribute = exports.toAttribute = exports.toAttributeValue = void 0;
|
|
4
|
-
var faro_core_1 = require("@grafana/faro-core");
|
|
5
|
-
function toAttributeValue(value) {
|
|
6
|
-
if ((0, faro_core_1.isString)(value)) {
|
|
7
|
-
return { stringValue: value };
|
|
8
|
-
}
|
|
9
|
-
if ((0, faro_core_1.isInt)(value)) {
|
|
10
|
-
return { intValue: value };
|
|
11
|
-
}
|
|
12
|
-
if ((0, faro_core_1.isNumber)(value)) {
|
|
13
|
-
return { doubleValue: value };
|
|
14
|
-
}
|
|
15
|
-
if ((0, faro_core_1.isBoolean)(value)) {
|
|
16
|
-
return { boolValue: value };
|
|
17
|
-
}
|
|
18
|
-
if ((0, faro_core_1.isArray)(value)) {
|
|
19
|
-
return { arrayValue: { values: value.map(toAttributeValue) } };
|
|
20
|
-
}
|
|
21
|
-
if (value instanceof Uint8Array) {
|
|
22
|
-
return { bytesValue: value };
|
|
23
|
-
}
|
|
24
|
-
if ((0, faro_core_1.isObject)(value)) {
|
|
25
|
-
return {
|
|
26
|
-
kvlistValue: {
|
|
27
|
-
values: Object.entries(value)
|
|
28
|
-
.map(function (_a) {
|
|
29
|
-
var attributeName = _a[0], attributeValue = _a[1];
|
|
30
|
-
return toAttribute(attributeName, attributeValue);
|
|
31
|
-
})
|
|
32
|
-
.filter(isAttribute),
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return {};
|
|
37
|
-
}
|
|
38
|
-
exports.toAttributeValue = toAttributeValue;
|
|
39
|
-
function toAttribute(attributeName, attributeValue) {
|
|
40
|
-
if (attributeValue == null || attributeValue === '') {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
key: attributeName,
|
|
45
|
-
value: toAttributeValue(attributeValue),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
exports.toAttribute = toAttribute;
|
|
49
|
-
function isAttribute(item) {
|
|
50
|
-
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';
|
|
51
|
-
}
|
|
52
|
-
exports.isAttribute = isAttribute;
|
|
53
|
-
//# sourceMappingURL=attributeUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attributeUtils.js","sourceRoot":"","sources":["../../../../../../src/transports/otlp/payload/attribute/attributeUtils.ts"],"names":[],"mappings":";;;AAEA,gDAA6F;AAE7F,SAAgB,gBAAgB,CAAC,KAAc;IAC7C,IAAI,IAAA,oBAAQ,EAAC,KAAK,CAAC,EAAE;QACnB,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;KAC/B;IAED,IAAI,IAAA,iBAAK,EAAC,KAAK,CAAC,EAAE;QAChB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;KAC5B;IAED,IAAI,IAAA,oBAAQ,EAAC,KAAK,CAAC,EAAE;QACnB,OAAO,EAAE,WAAW,EAAE,KAAe,EAAE,CAA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CAAC;AAFD,kCAEC","sourcesContent":["import type { IAnyValue, IKeyValue } from '@opentelemetry/otlp-transformer';\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,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/transports/otlp/payload/attribute/index.ts"],"names":[],"mappings":";;;AAAA,mDAA8E;AAArE,6GAAA,WAAW,OAAA;AAAE,kHAAA,gBAAgB,OAAA;AAAE,6GAAA,WAAW,OAAA","sourcesContent":["export { toAttribute, toAttributeValue, isAttribute } from './attributeUtils';\n"]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/transports/otlp/payload/index.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAAnC,0GAAA,WAAW,OAAA","sourcesContent":["export type { OtelTransportPayload } from './types';\nexport { OtelPayload } from './OtelPayload';\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toResourceLog = exports.toScopeLog = void 0;
|
|
4
|
-
var transform_1 = require("./transform");
|
|
5
|
-
Object.defineProperty(exports, "toScopeLog", { enumerable: true, get: function () { return transform_1.toScopeLog; } });
|
|
6
|
-
Object.defineProperty(exports, "toResourceLog", { enumerable: true, get: function () { return transform_1.toResourceLog; } });
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/transports/otlp/payload/transform/index.ts"],"names":[],"mappings":";;;AAEA,yCAAwD;AAA/C,uGAAA,UAAU,OAAA;AAAE,0GAAA,aAAa,OAAA","sourcesContent":["export type { LogRecord, LogTransportItem, ResourceLog, Resource, ScopeLog } from './types';\n\nexport { toScopeLog, toResourceLog } from './transform';\n"]}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.toScopeLog = exports.toResourceLog = void 0;
|
|
13
|
-
var semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
14
|
-
var faro_core_1 = require("@grafana/faro-core");
|
|
15
|
-
var otlpPayloadLogger_1 = require("../../otlpPayloadLogger");
|
|
16
|
-
var attribute_1 = require("../attribute");
|
|
17
|
-
/**
|
|
18
|
-
* Seems currently to be missing in the semantic-conventions npm package.
|
|
19
|
-
* See: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#todos
|
|
20
|
-
*
|
|
21
|
-
* Attributes are as defined by the Otel docs
|
|
22
|
-
*/
|
|
23
|
-
var SemanticBrowserAttributes = {
|
|
24
|
-
BROWSER_BRANDS: 'browser.brands',
|
|
25
|
-
BROWSER_PLATFORM: 'browser.platform',
|
|
26
|
-
BROWSER_MOBILE: 'browser.mobile',
|
|
27
|
-
BROWSER_USER_AGENT: 'browser.user_agent',
|
|
28
|
-
BROWSER_LANGUAGE: 'browser.language',
|
|
29
|
-
};
|
|
30
|
-
function toResourceLog(transportItem) {
|
|
31
|
-
var resource = toResource(transportItem);
|
|
32
|
-
return {
|
|
33
|
-
resource: resource,
|
|
34
|
-
scopeLogs: [toScopeLog(transportItem)],
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
exports.toResourceLog = toResourceLog;
|
|
38
|
-
function toResource(transportItem) {
|
|
39
|
-
var _a = transportItem.meta, browser = _a.browser, sdk = _a.sdk, app = _a.app;
|
|
40
|
-
return {
|
|
41
|
-
attributes: [
|
|
42
|
-
(0, attribute_1.toAttribute)(SemanticBrowserAttributes.BROWSER_MOBILE, browser === null || browser === void 0 ? void 0 : browser.mobile),
|
|
43
|
-
(0, attribute_1.toAttribute)(SemanticBrowserAttributes.BROWSER_USER_AGENT, browser === null || browser === void 0 ? void 0 : browser.userAgent),
|
|
44
|
-
(0, attribute_1.toAttribute)(SemanticBrowserAttributes.BROWSER_LANGUAGE, browser === null || browser === void 0 ? void 0 : browser.language),
|
|
45
|
-
(0, attribute_1.toAttribute)('browser.os', browser === null || browser === void 0 ? void 0 : browser.os),
|
|
46
|
-
// toAttribute(SemanticBrowserAttributes.BROWSER_BRANDS, browser?.brands),
|
|
47
|
-
(0, attribute_1.toAttribute)('browser.name', browser === null || browser === void 0 ? void 0 : browser.name),
|
|
48
|
-
(0, attribute_1.toAttribute)('browser.version', browser === null || browser === void 0 ? void 0 : browser.version),
|
|
49
|
-
(0, attribute_1.toAttribute)(semantic_conventions_1.SemanticResourceAttributes.TELEMETRY_SDK_NAME, sdk === null || sdk === void 0 ? void 0 : sdk.name),
|
|
50
|
-
(0, attribute_1.toAttribute)(semantic_conventions_1.SemanticResourceAttributes.TELEMETRY_SDK_VERSION, sdk === null || sdk === void 0 ? void 0 : sdk.version),
|
|
51
|
-
Boolean(sdk)
|
|
52
|
-
? (0, attribute_1.toAttribute)(semantic_conventions_1.SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE, semantic_conventions_1.TelemetrySdkLanguageValues.WEBJS)
|
|
53
|
-
: undefined,
|
|
54
|
-
(0, attribute_1.toAttribute)(semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME, app === null || app === void 0 ? void 0 : app.name),
|
|
55
|
-
(0, attribute_1.toAttribute)(semantic_conventions_1.SemanticResourceAttributes.SERVICE_VERSION, app === null || app === void 0 ? void 0 : app.version),
|
|
56
|
-
(0, attribute_1.toAttribute)(semantic_conventions_1.SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT, app === null || app === void 0 ? void 0 : app.environment),
|
|
57
|
-
].filter(attribute_1.isAttribute),
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function toScopeLog(transportItem) {
|
|
61
|
-
return {
|
|
62
|
-
scope: {
|
|
63
|
-
name: '@grafana/faro-web-sdk',
|
|
64
|
-
version: faro_core_1.VERSION,
|
|
65
|
-
},
|
|
66
|
-
logRecords: [toLogRecord(transportItem)],
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
exports.toScopeLog = toScopeLog;
|
|
70
|
-
function toLogRecord(transportItem) {
|
|
71
|
-
var type = transportItem.type;
|
|
72
|
-
switch (type) {
|
|
73
|
-
case faro_core_1.TransportItemType.LOG:
|
|
74
|
-
return toLogLogRecord(transportItem);
|
|
75
|
-
case faro_core_1.TransportItemType.EXCEPTION:
|
|
76
|
-
return toErrorLogRecord(transportItem);
|
|
77
|
-
case faro_core_1.TransportItemType.EVENT:
|
|
78
|
-
return toEventLogRecord(transportItem);
|
|
79
|
-
case faro_core_1.TransportItemType.MEASUREMENT:
|
|
80
|
-
return toMeasurementLogRecord(transportItem);
|
|
81
|
-
default:
|
|
82
|
-
var error = "Unknown TransportItemType: ".concat(type);
|
|
83
|
-
otlpPayloadLogger_1.internalLogger.error(error);
|
|
84
|
-
throw new Error(error);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function toLogLogRecord(transportItem) {
|
|
88
|
-
var _a, _b;
|
|
89
|
-
var meta = transportItem.meta, payload = transportItem.payload;
|
|
90
|
-
var timeUnixNano = toTimeUnixNano(payload.timestamp);
|
|
91
|
-
var body = (0, attribute_1.toAttributeValue)(payload.message);
|
|
92
|
-
return {
|
|
93
|
-
timeUnixNano: timeUnixNano,
|
|
94
|
-
severityNumber: 10,
|
|
95
|
-
severityText: 'INFO2',
|
|
96
|
-
body: body,
|
|
97
|
-
attributes: getCommonLogAttributes(meta),
|
|
98
|
-
traceId: (_a = payload.trace) === null || _a === void 0 ? void 0 : _a.trace_id,
|
|
99
|
-
spanId: (_b = payload.trace) === null || _b === void 0 ? void 0 : _b.trace_id,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function toEventLogRecord(transportItem) {
|
|
103
|
-
var _a, _b;
|
|
104
|
-
var meta = transportItem.meta, payload = transportItem.payload;
|
|
105
|
-
var timeUnixNano = toTimeUnixNano(payload.timestamp);
|
|
106
|
-
var body = (0, attribute_1.toAttributeValue)(payload.name);
|
|
107
|
-
return {
|
|
108
|
-
timeUnixNano: timeUnixNano,
|
|
109
|
-
body: body,
|
|
110
|
-
attributes: __spreadArray(__spreadArray([], getCommonLogAttributes(meta), true), [
|
|
111
|
-
(0, attribute_1.toAttribute)('event.name', payload.name),
|
|
112
|
-
(0, attribute_1.toAttribute)('event.domain', payload.domain),
|
|
113
|
-
(0, attribute_1.toAttribute)('event.attributes', payload.attributes),
|
|
114
|
-
], false).filter(attribute_1.isAttribute),
|
|
115
|
-
traceId: (_a = payload.trace) === null || _a === void 0 ? void 0 : _a.trace_id,
|
|
116
|
-
spanId: (_b = payload.trace) === null || _b === void 0 ? void 0 : _b.trace_id,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
function toErrorLogRecord(transportItem) {
|
|
120
|
-
var _a, _b;
|
|
121
|
-
var meta = transportItem.meta, payload = transportItem.payload;
|
|
122
|
-
var timeUnixNano = toTimeUnixNano(payload.timestamp);
|
|
123
|
-
return {
|
|
124
|
-
timeUnixNano: timeUnixNano,
|
|
125
|
-
attributes: __spreadArray(__spreadArray([], getCommonLogAttributes(meta), true), [
|
|
126
|
-
(0, attribute_1.toAttribute)(semantic_conventions_1.SemanticAttributes.EXCEPTION_TYPE, payload.type),
|
|
127
|
-
(0, attribute_1.toAttribute)(semantic_conventions_1.SemanticAttributes.EXCEPTION_MESSAGE, payload.value),
|
|
128
|
-
// toAttribute(SemanticAttributes.EXCEPTION_STACKTRACE, undefined),
|
|
129
|
-
(0, attribute_1.toAttribute)('faro.error.stacktrace', payload.stacktrace),
|
|
130
|
-
], false).filter(attribute_1.isAttribute),
|
|
131
|
-
traceId: (_a = payload.trace) === null || _a === void 0 ? void 0 : _a.trace_id,
|
|
132
|
-
spanId: (_b = payload.trace) === null || _b === void 0 ? void 0 : _b.trace_id,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function toMeasurementLogRecord(transportItem) {
|
|
136
|
-
var _a, _b;
|
|
137
|
-
var meta = transportItem.meta, payload = transportItem.payload;
|
|
138
|
-
var timeUnixNano = toTimeUnixNano(payload.timestamp);
|
|
139
|
-
var _c = Object.entries(payload.values).flat(), measurementName = _c[0], measurementValue = _c[1];
|
|
140
|
-
return {
|
|
141
|
-
timeUnixNano: timeUnixNano,
|
|
142
|
-
attributes: __spreadArray(__spreadArray([], getCommonLogAttributes(meta), true), [
|
|
143
|
-
(0, attribute_1.toAttribute)('measurement.type', payload.type),
|
|
144
|
-
(0, attribute_1.toAttribute)('measurement.name', measurementName),
|
|
145
|
-
(0, attribute_1.toAttribute)('measurement.value', measurementValue),
|
|
146
|
-
], false).filter(attribute_1.isAttribute),
|
|
147
|
-
traceId: (_a = payload.trace) === null || _a === void 0 ? void 0 : _a.trace_id,
|
|
148
|
-
spanId: (_b = payload.trace) === null || _b === void 0 ? void 0 : _b.trace_id,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
function getCommonLogAttributes(meta) {
|
|
152
|
-
var view = meta.view, page = meta.page, session = meta.session, user = meta.user;
|
|
153
|
-
return [
|
|
154
|
-
(0, attribute_1.toAttribute)('view.name', view === null || view === void 0 ? void 0 : view.name),
|
|
155
|
-
(0, attribute_1.toAttribute)(semantic_conventions_1.SemanticAttributes.HTTP_URL, page === null || page === void 0 ? void 0 : page.url),
|
|
156
|
-
(0, attribute_1.toAttribute)('page.id', page === null || page === void 0 ? void 0 : page.id),
|
|
157
|
-
(0, attribute_1.toAttribute)('page.attributes', page === null || page === void 0 ? void 0 : page.attributes),
|
|
158
|
-
(0, attribute_1.toAttribute)('session.id', session === null || session === void 0 ? void 0 : session.id),
|
|
159
|
-
(0, attribute_1.toAttribute)('session.attributes', session === null || session === void 0 ? void 0 : session.attributes),
|
|
160
|
-
(0, attribute_1.toAttribute)(semantic_conventions_1.SemanticAttributes.ENDUSER_ID, user === null || user === void 0 ? void 0 : user.id),
|
|
161
|
-
(0, attribute_1.toAttribute)('enduser.name', user === null || user === void 0 ? void 0 : user.username),
|
|
162
|
-
(0, attribute_1.toAttribute)('enduser.email', user === null || user === void 0 ? void 0 : user.email),
|
|
163
|
-
(0, attribute_1.toAttribute)('enduser.attributes', user === null || user === void 0 ? void 0 : user.attributes),
|
|
164
|
-
].filter(attribute_1.isAttribute);
|
|
165
|
-
}
|
|
166
|
-
function toTimeUnixNano(timestamp) {
|
|
167
|
-
return Date.parse(timestamp) * 1e6;
|
|
168
|
-
}
|
|
169
|
-
//# sourceMappingURL=transform.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../../../../src/transports/otlp/payload/transform/transform.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,4EAI6C;AAE7C,gDAS4B;AAE5B,6DAAyD;AACzD,0CAA0E;AAI1E;;;;;GAKG;AACH,IAAM,yBAAyB,GAAG;IAChC,cAAc,EAAE,gBAAgB;IAChC,gBAAgB,EAAE,kBAAkB;IACpC,cAAc,EAAE,gBAAgB;IAChC,kBAAkB,EAAE,oBAAoB;IACxC,gBAAgB,EAAE,kBAAkB;CAC5B,CAAC;AAEX,SAAgB,aAAa,CAAC,aAA+B;IAC3D,IAAM,QAAQ,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAE3C,OAAO;QACL,QAAQ,UAAA;QACR,SAAS,EAAE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ACvC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC;AACrC,CAAC","sourcesContent":["import type { IKeyValue } from '@opentelemetry/otlp-transformer';\nimport {\n SemanticAttributes,\n SemanticResourceAttributes,\n TelemetrySdkLanguageValues,\n} from '@opentelemetry/semantic-conventions';\n\nimport {\n EventEvent,\n ExceptionEvent,\n LogEvent,\n MeasurementEvent,\n Meta,\n TransportItem,\n TransportItemType,\n VERSION,\n} from '@grafana/faro-core';\n\nimport { internalLogger } from '../../otlpPayloadLogger';\nimport { isAttribute, toAttribute, toAttributeValue } from '../attribute';\n\nimport type { LogRecord, LogTransportItem, Resource, ScopeLog } from './types';\n\n/**\n * Seems currently to be missing in the semantic-conventions npm package.\n * See: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#todos\n *\n * Attributes are as defined by the Otel docs\n */\nconst SemanticBrowserAttributes = {\n BROWSER_BRANDS: 'browser.brands',\n BROWSER_PLATFORM: 'browser.platform',\n BROWSER_MOBILE: 'browser.mobile',\n BROWSER_USER_AGENT: 'browser.user_agent',\n BROWSER_LANGUAGE: 'browser.language',\n} as const;\n\nexport function toResourceLog(transportItem: LogTransportItem) {\n const resource = toResource(transportItem);\n\n return {\n resource,\n scopeLogs: [toScopeLog(transportItem)],\n };\n}\n\nfunction toResource(transportItem: LogTransportItem): Readonly<Resource> {\n const { browser, sdk, app } = transportItem.meta;\n\n return {\n attributes: [\n toAttribute(SemanticBrowserAttributes.BROWSER_MOBILE, browser?.mobile),\n toAttribute(SemanticBrowserAttributes.BROWSER_USER_AGENT, browser?.userAgent),\n toAttribute(SemanticBrowserAttributes.BROWSER_LANGUAGE, browser?.language),\n toAttribute('browser.os', browser?.os),\n // toAttribute(SemanticBrowserAttributes.BROWSER_BRANDS, browser?.brands),\n toAttribute('browser.name', browser?.name),\n toAttribute('browser.version', browser?.version),\n\n toAttribute(SemanticResourceAttributes.TELEMETRY_SDK_NAME, sdk?.name),\n toAttribute(SemanticResourceAttributes.TELEMETRY_SDK_VERSION, sdk?.version),\n Boolean(sdk)\n ? toAttribute(SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE, TelemetrySdkLanguageValues.WEBJS)\n : undefined,\n\n toAttribute(SemanticResourceAttributes.SERVICE_NAME, app?.name),\n toAttribute(SemanticResourceAttributes.SERVICE_VERSION, app?.version),\n toAttribute(SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT, app?.environment),\n ].filter(isAttribute),\n };\n}\n\nexport function toScopeLog(transportItem: LogTransportItem): ScopeLog {\n return {\n scope: {\n name: '@grafana/faro-web-sdk',\n version: VERSION,\n },\n logRecords: [toLogRecord(transportItem)],\n };\n}\n\nfunction toLogRecord(transportItem: LogTransportItem): LogRecord {\n const { type } = transportItem;\n\n switch (type) {\n case TransportItemType.LOG:\n return toLogLogRecord(transportItem as TransportItem<LogEvent>);\n case TransportItemType.EXCEPTION:\n return toErrorLogRecord(transportItem as TransportItem<ExceptionEvent>);\n case TransportItemType.EVENT:\n return toEventLogRecord(transportItem as TransportItem<EventEvent>);\n case TransportItemType.MEASUREMENT:\n return toMeasurementLogRecord(transportItem as TransportItem<MeasurementEvent>);\n default:\n const error = `Unknown TransportItemType: ${type}`;\n internalLogger.error(error);\n throw new Error(error);\n }\n}\n\nfunction toLogLogRecord(transportItem: TransportItem<LogEvent>): LogRecord {\n const { meta, payload } = transportItem;\n const timeUnixNano = toTimeUnixNano(payload.timestamp);\n const body = toAttributeValue(payload.message) as { stringValue: string; key: string };\n\n return {\n timeUnixNano,\n severityNumber: 10,\n severityText: 'INFO2',\n body,\n attributes: getCommonLogAttributes(meta),\n traceId: payload.trace?.trace_id,\n spanId: payload.trace?.trace_id,\n } as const;\n}\n\nfunction toEventLogRecord(transportItem: TransportItem<EventEvent>): LogRecord {\n const { meta, payload } = transportItem;\n const timeUnixNano = toTimeUnixNano(payload.timestamp);\n const body = toAttributeValue(payload.name) as { stringValue: string; key: string };\n\n return {\n timeUnixNano,\n body,\n attributes: [\n ...getCommonLogAttributes(meta),\n toAttribute('event.name', payload.name), // No prefix because this is a semantic attribute. But event.name constant is currently missing in sematic-conventions npm package\n toAttribute('event.domain', payload.domain), // No prefix because this is a semantic attribute. But event.domain constant is currently missing in sematic-conventions npm package\n toAttribute('event.attributes', payload.attributes),\n ].filter(isAttribute),\n traceId: payload.trace?.trace_id,\n spanId: payload.trace?.trace_id,\n } as const;\n}\n\nfunction toErrorLogRecord(transportItem: TransportItem<ExceptionEvent>): LogRecord {\n const { meta, payload } = transportItem;\n const timeUnixNano = toTimeUnixNano(payload.timestamp);\n\n return {\n timeUnixNano,\n attributes: [\n ...getCommonLogAttributes(meta),\n toAttribute(SemanticAttributes.EXCEPTION_TYPE, payload.type),\n toAttribute(SemanticAttributes.EXCEPTION_MESSAGE, payload.value),\n // toAttribute(SemanticAttributes.EXCEPTION_STACKTRACE, undefined),\n toAttribute('faro.error.stacktrace', payload.stacktrace),\n ].filter(isAttribute),\n traceId: payload.trace?.trace_id,\n spanId: payload.trace?.trace_id,\n } as const;\n}\n\nfunction toMeasurementLogRecord(transportItem: TransportItem<MeasurementEvent>): LogRecord {\n const { meta, payload } = transportItem;\n const timeUnixNano = toTimeUnixNano(payload.timestamp);\n const [measurementName, measurementValue] = Object.entries(payload.values).flat();\n\n return {\n timeUnixNano,\n attributes: [\n ...getCommonLogAttributes(meta),\n toAttribute('measurement.type', payload.type),\n toAttribute('measurement.name', measurementName),\n toAttribute('measurement.value', measurementValue),\n ].filter(isAttribute),\n traceId: payload.trace?.trace_id,\n spanId: payload.trace?.trace_id,\n } as const;\n}\n\nfunction getCommonLogAttributes(meta: Meta): IKeyValue[] {\n const { view, page, session, user } = meta;\n\n return [\n toAttribute('view.name', view?.name),\n toAttribute(SemanticAttributes.HTTP_URL, page?.url),\n toAttribute('page.id', page?.id),\n toAttribute('page.attributes', page?.attributes),\n toAttribute('session.id', session?.id),\n toAttribute('session.attributes', session?.attributes),\n toAttribute(SemanticAttributes.ENDUSER_ID, user?.id),\n toAttribute('enduser.name', user?.username),\n toAttribute('enduser.email', user?.email),\n toAttribute('enduser.attributes', user?.attributes),\n ].filter(isAttribute);\n}\n\nfunction toTimeUnixNano(timestamp: string): number {\n return Date.parse(timestamp) * 1e6;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/transports/otlp/payload/transform/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IKeyValue } from '@opentelemetry/otlp-transformer';\n\nimport type { APIEvent, TransportItem } from '@grafana/faro-core';\n\nexport interface Resource {\n attributes: IKeyValue[];\n}\n\nexport interface ScopeLog {\n scope: { name: string; version: string };\n logRecords: LogRecord[];\n}\n\nexport interface LogRecord {\n timeUnixNano?: number;\n severityNumber?: number;\n severityText?: string;\n body?: { stringValue: string };\n attributes?: IKeyValue[];\n traceId?: string;\n spanId?: string;\n}\n\nexport interface ResourceLog {\n resource: Resource;\n scopeLogs: ScopeLog[];\n}\n\nexport type LogTransportItem = TransportItem<Exclude<APIEvent, 'TraceEvent'>>;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/transports/otlp/payload/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ResourceLog } from './transform';\n\nexport interface OtelTransportPayload {\n readonly resourceLogs: Readonly<ResourceLog[]>;\n readonly resourceSpans: Readonly<unknown[]>;\n readonly resourceMetrics: Readonly<unknown[]>;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"otlpPayloadLogger.js","sourceRoot":"","sources":["../../../../src/transports/otlp/otlpPayloadLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,EAAE,CAAC","sourcesContent":["import { createInternalLogger } from '@grafana/faro-core';\n\nexport const internalLogger = createInternalLogger();\n"]}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { deepEqual, TransportItemType } from '@grafana/faro-core';
|
|
2
|
-
import { internalLogger } from '../otlpPayloadLogger';
|
|
3
|
-
import { toResourceLog, toScopeLog } from './transform';
|
|
4
|
-
export class OtelPayload {
|
|
5
|
-
constructor(transportItem) {
|
|
6
|
-
this.resourceLogsWithMetas = [];
|
|
7
|
-
if (transportItem) {
|
|
8
|
-
this.addResourceItem(transportItem);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
getPayload() {
|
|
12
|
-
return {
|
|
13
|
-
resourceLogs: this.resourceLogsWithMetas.map(({ resourceLog }) => resourceLog),
|
|
14
|
-
resourceSpans: [],
|
|
15
|
-
resourceMetrics: [],
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
addResourceItem(transportItem) {
|
|
19
|
-
const { type, meta } = transportItem;
|
|
20
|
-
switch (type) {
|
|
21
|
-
case TransportItemType.LOG:
|
|
22
|
-
case TransportItemType.EXCEPTION:
|
|
23
|
-
case TransportItemType.EVENT:
|
|
24
|
-
case TransportItemType.MEASUREMENT:
|
|
25
|
-
const resourceLogWithMeta = this.resourceLogsWithMetas.find(({ meta }) => deepEqual(transportItem.meta, meta));
|
|
26
|
-
if (resourceLogWithMeta) {
|
|
27
|
-
const { resourceLog } = resourceLogWithMeta;
|
|
28
|
-
resourceLog.scopeLogs.push(toScopeLog(transportItem));
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
this.resourceLogsWithMetas.push({
|
|
32
|
-
resourceLog: toResourceLog(transportItem),
|
|
33
|
-
meta,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
break;
|
|
37
|
-
case TransportItemType.TRACE:
|
|
38
|
-
break;
|
|
39
|
-
default:
|
|
40
|
-
internalLogger.error(`Unknown TransportItemType: ${type}`);
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=OtelPayload.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OtelPayload.js","sourceRoot":"","sources":["../../../../../src/transports/otlp/payload/OtelPayload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuB,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AASxD,MAAM,OAAO,WAAW;IAGtB,YAAY,aAA6B;QAFjC,0BAAqB,GAAG,EAA2B,CAAC;QAG1D,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;SACrC;IACH,CAAC;IAED,UAAU;QACR,OAAO;YACL,YAAY,EAAE,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC;YAC9E,aAAa,EAAE,EAAE;YACjB,eAAe,EAAE,EAAE;SACX,CAAC;IACb,CAAC;IAED,eAAe,CAAC,aAA4B;QAC1C,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC;QAErC,QAAQ,IAAI,EAAE;YACZ,KAAK,iBAAiB,CAAC,GAAG,CAAC;YAC3B,KAAK,iBAAiB,CAAC,SAAS,CAAC;YACjC,KAAK,iBAAiB,CAAC,KAAK,CAAC;YAC7B,KAAK,iBAAiB,CAAC,WAAW;gBAChC,MAAM,mBAAmB,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;gBAE/G,IAAI,mBAAmB,EAAE;oBACvB,MAAM,EAAE,WAAW,EAAE,GAAG,mBAAmB,CAAC;oBAC5C,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;iBACvD;qBAAM;oBACL,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC;wBAC9B,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC;wBACzC,IAAI;qBACL,CAAC,CAAC;iBACJ;gBAED,MAAM;YACR,KAAK,iBAAiB,CAAC,KAAK;gBAC1B,MAAM;YACR;gBACE,cAAc,CAAC,KAAK,CAAC,8BAA8B,IAAI,EAAE,CAAC,CAAC;gBAC3D,MAAM;SACT;IACH,CAAC;CACF","sourcesContent":["import { deepEqual, Meta, TransportItem, TransportItemType } from '@grafana/faro-core';\n\nimport { internalLogger } from '../otlpPayloadLogger';\n\nimport { toResourceLog, toScopeLog } from './transform';\nimport type { ResourceLog } from './transform';\nimport type { OtelTransportPayload } from './types';\n\ninterface ResourceLogsMetaMap {\n resourceLog: ResourceLog;\n meta: Meta;\n}\n\nexport class OtelPayload {\n private resourceLogsWithMetas = [] as ResourceLogsMetaMap[];\n\n constructor(transportItem?: TransportItem) {\n if (transportItem) {\n this.addResourceItem(transportItem);\n }\n }\n\n getPayload(): OtelTransportPayload {\n return {\n resourceLogs: this.resourceLogsWithMetas.map(({ resourceLog }) => resourceLog),\n resourceSpans: [],\n resourceMetrics: [],\n } as const;\n }\n\n addResourceItem(transportItem: TransportItem): void {\n const { type, meta } = transportItem;\n\n switch (type) {\n case TransportItemType.LOG:\n case TransportItemType.EXCEPTION:\n case TransportItemType.EVENT:\n case TransportItemType.MEASUREMENT:\n const resourceLogWithMeta = this.resourceLogsWithMetas.find(({ meta }) => deepEqual(transportItem.meta, meta));\n\n if (resourceLogWithMeta) {\n const { resourceLog } = resourceLogWithMeta;\n resourceLog.scopeLogs.push(toScopeLog(transportItem));\n } else {\n this.resourceLogsWithMetas.push({\n resourceLog: toResourceLog(transportItem),\n meta,\n });\n }\n\n break;\n case TransportItemType.TRACE:\n break;\n default:\n internalLogger.error(`Unknown TransportItemType: ${type}`);\n break;\n }\n }\n}\n"]}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { isArray, isBoolean, isInt, isNumber, isObject, isString } from '@grafana/faro-core';
|
|
2
|
-
export function toAttributeValue(value) {
|
|
3
|
-
if (isString(value)) {
|
|
4
|
-
return { stringValue: value };
|
|
5
|
-
}
|
|
6
|
-
if (isInt(value)) {
|
|
7
|
-
return { intValue: value };
|
|
8
|
-
}
|
|
9
|
-
if (isNumber(value)) {
|
|
10
|
-
return { doubleValue: value };
|
|
11
|
-
}
|
|
12
|
-
if (isBoolean(value)) {
|
|
13
|
-
return { boolValue: value };
|
|
14
|
-
}
|
|
15
|
-
if (isArray(value)) {
|
|
16
|
-
return { arrayValue: { values: value.map(toAttributeValue) } };
|
|
17
|
-
}
|
|
18
|
-
if (value instanceof Uint8Array) {
|
|
19
|
-
return { bytesValue: value };
|
|
20
|
-
}
|
|
21
|
-
if (isObject(value)) {
|
|
22
|
-
return {
|
|
23
|
-
kvlistValue: {
|
|
24
|
-
values: Object.entries(value)
|
|
25
|
-
.map(([attributeName, attributeValue]) => toAttribute(attributeName, attributeValue))
|
|
26
|
-
.filter(isAttribute),
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
return {};
|
|
31
|
-
}
|
|
32
|
-
export function toAttribute(attributeName, attributeValue) {
|
|
33
|
-
if (attributeValue == null || attributeValue === '') {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
key: attributeName,
|
|
38
|
-
value: toAttributeValue(attributeValue),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export function isAttribute(item) {
|
|
42
|
-
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';
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=attributeUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attributeUtils.js","sourceRoot":"","sources":["../../../../../../src/transports/otlp/payload/attribute/attributeUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE7F,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;KAC/B;IAED,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;QAChB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;KAC5B;IAED,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,EAAE,WAAW,EAAE,KAAe,EAAE,CAAC;KACzC;IAED,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE;QACpB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;KAC7B;IAED,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;QAClB,OAAO,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC;KAChE;IAED,IAAI,KAAK,YAAY,UAAU,EAAE;QAC/B,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;KAC9B;IAED,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO;YACL,WAAW,EAAE;gBACX,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;qBAC1B,GAAG,CAAC,CAAC,CAAC,aAAa,EAAE,cAAc,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;qBACpF,MAAM,CAAC,WAAW,CAAC;aACvB;SACF,CAAC;KACH;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,aAAqB,EAAE,cAAmB;IACpE,IAAI,cAAc,IAAI,IAAI,IAAI,cAAc,KAAK,EAAE,EAAE;QACnD,OAAO,SAAS,CAAC;KAClB;IAED,OAAO;QACL,GAAG,EAAE,aAAa;QAClB,KAAK,EAAE,gBAAgB,CAAC,cAAc,CAAC;KACxC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,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';\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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/transports/otlp/payload/attribute/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["export { toAttribute, toAttributeValue, isAttribute } from './attributeUtils';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/transports/otlp/payload/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC","sourcesContent":["export type { OtelTransportPayload } from './types';\nexport { OtelPayload } from './OtelPayload';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/transports/otlp/payload/transform/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export type { LogRecord, LogTransportItem, ResourceLog, Resource, ScopeLog } from './types';\n\nexport { toScopeLog, toResourceLog } from './transform';\n"]}
|