UNPKG

@grafana/faro-transport-otlp-http

Version:

Faro transport which converts the Faro data model to the Otlp data model.

52 lines 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toAttributeValue = toAttributeValue; exports.toAttribute = toAttribute; exports.isAttribute = isAttribute; var faro_core_1 = require("@grafana/faro-core"); function toAttributeValue(value) { if ((0, faro_core_1.isString)(value)) { return { stringValue: value }; } if ((0, faro_core_1.isInt)(value)) { return { intValue: value }; } if ((0, faro_core_1.isNumber)(value)) { return { doubleValue: value }; } if ((0, faro_core_1.isBoolean)(value)) { return { boolValue: value }; } if ((0, faro_core_1.isArray)(value)) { return { arrayValue: { values: value.map(toAttributeValue) } }; } if (value instanceof Uint8Array) { return { bytesValue: value }; } if ((0, faro_core_1.isObject)(value)) { return { kvlistValue: { values: Object.entries(value) .map(function (_a) { var attributeName = _a[0], attributeValue = _a[1]; return toAttribute(attributeName, attributeValue); }) .filter(isAttribute), }, }; } return {}; } function toAttribute(attributeName, attributeValue) { if (attributeValue == null || attributeValue === '') { return undefined; } return { key: attributeName, value: toAttributeValue(attributeValue), }; } function isAttribute(item) { 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'; } //# sourceMappingURL=attributeUtils.js.map