@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.
- package/dist/bundle/faro-transport-otlp-http.iife.js +3 -1
- package/dist/bundle/faro-transport-otlp-http.iife.js.map +1 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/asyncToGenerator.js +28 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/defineProperty.js +13 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectSpread2.js +26 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectWithoutProperties.js +14 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectWithoutPropertiesLoose.js +13 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPrimitive.js +15 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPropertyKey.js +10 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/typeof.js +17 -0
- package/dist/cjs/index.js +2 -4
- package/dist/cjs/payload/OtelPayload.js +52 -61
- package/dist/cjs/payload/OtelPayload.js.map +1 -1
- package/dist/cjs/payload/attribute/attributeUtils.js +21 -40
- package/dist/cjs/payload/attribute/attributeUtils.js.map +1 -1
- package/dist/cjs/payload/attribute/index.js +4 -6
- package/dist/cjs/payload/index.js +2 -4
- package/dist/cjs/payload/transform/index.js +3 -5
- package/dist/cjs/payload/transform/transform.js +185 -169
- package/dist/cjs/payload/transform/transform.js.map +1 -1
- package/dist/cjs/payload/transform/types.js +0 -1
- package/dist/cjs/payload/types.js +0 -1
- package/dist/cjs/semconv.js +39 -23
- package/dist/cjs/semconv.js.map +1 -1
- package/dist/cjs/transport.js +117 -138
- package/dist/cjs/transport.js.map +1 -1
- package/dist/cjs/types.js +0 -1
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/asyncToGenerator.js +27 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/defineProperty.js +12 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectSpread2.js +25 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectWithoutProperties.js +13 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPrimitive.js +14 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPropertyKey.js +9 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/typeof.js +11 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/payload/OtelPayload.js +53 -60
- package/dist/esm/payload/OtelPayload.js.map +1 -1
- package/dist/esm/payload/attribute/attributeUtils.js +22 -40
- package/dist/esm/payload/attribute/attributeUtils.js.map +1 -1
- package/dist/esm/payload/attribute/index.js +2 -2
- package/dist/esm/payload/index.js +2 -2
- package/dist/esm/payload/transform/index.js +2 -2
- package/dist/esm/payload/transform/transform.js +186 -169
- package/dist/esm/payload/transform/transform.js.map +1 -1
- package/dist/esm/payload/transform/types.js +0 -2
- package/dist/esm/payload/types.js +0 -2
- package/dist/esm/semconv.js +25 -21
- package/dist/esm/semconv.js.map +1 -1
- package/dist/esm/transport.js +118 -137
- package/dist/esm/transport.js.map +1 -1
- package/dist/esm/types.js +0 -2
- package/dist/types/index.d.ts +3 -2
- package/dist/types/payload/OtelPayload.d.ts +18 -16
- package/dist/types/payload/attribute/attributeUtils.d.ts +7 -4
- package/dist/types/payload/attribute/index.d.ts +2 -1
- package/dist/types/payload/index.d.ts +5 -3
- package/dist/types/payload/transform/index.d.ts +3 -2
- package/dist/types/payload/transform/transform.d.ts +8 -5
- package/dist/types/payload/transform/types.d.ts +45 -42
- package/dist/types/payload/types.d.ts +10 -6
- package/dist/types/semconv.d.ts +24 -21
- package/dist/types/transport.d.ts +19 -17
- package/dist/types/types.d.ts +25 -22
- package/package.json +8 -16
- package/dist/bundle/types/index.d.ts +0 -2
- package/dist/bundle/types/payload/OtelPayload.d.ts +0 -19
- package/dist/bundle/types/payload/attribute/attributeUtils.d.ts +0 -4
- package/dist/bundle/types/payload/attribute/index.d.ts +0 -1
- package/dist/bundle/types/payload/index.d.ts +0 -3
- package/dist/bundle/types/payload/transform/index.d.ts +0 -2
- package/dist/bundle/types/payload/transform/transform.d.ts +0 -5
- package/dist/bundle/types/payload/transform/types.d.ts +0 -52
- package/dist/bundle/types/payload/types.d.ts +0 -7
- package/dist/bundle/types/semconv.d.ts +0 -22
- package/dist/bundle/types/transport.d.ts +0 -18
- package/dist/bundle/types/types.d.ts +0 -24
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/payload/attribute/index.js.map +0 -1
- package/dist/cjs/payload/index.js.map +0 -1
- package/dist/cjs/payload/transform/index.js.map +0 -1
- package/dist/cjs/payload/transform/types.js.map +0 -1
- package/dist/cjs/payload/types.js.map +0 -1
- package/dist/cjs/types.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/payload/attribute/index.js.map +0 -1
- package/dist/esm/payload/index.js.map +0 -1
- package/dist/esm/payload/transform/index.js.map +0 -1
- package/dist/esm/payload/transform/types.js.map +0 -1
- package/dist/esm/payload/types.js.map +0 -1
- package/dist/esm/types.js.map +0 -1
package/dist/cjs/transport.js
CHANGED
|
@@ -1,144 +1,123 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
3
|
+
const require_objectSpread2 = require("./_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectSpread2.js");
|
|
4
|
+
const require_payload_OtelPayload = require("./payload/OtelPayload.js");
|
|
5
|
+
require("./payload/index.js");
|
|
6
|
+
const require_asyncToGenerator = require("./_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/asyncToGenerator.js");
|
|
7
|
+
const require_objectWithoutProperties = require("./_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectWithoutProperties.js");
|
|
8
|
+
let _grafana_faro_core = require("@grafana/faro-core");
|
|
9
|
+
//#region src/transport.ts
|
|
10
|
+
const _excluded = ["headers"];
|
|
26
11
|
const DEFAULT_BUFFER_SIZE = 30;
|
|
27
|
-
const DEFAULT_CONCURRENCY = 5;
|
|
28
|
-
const DEFAULT_RATE_LIMIT_BACKOFF_MS =
|
|
29
|
-
const BEACON_BODY_SIZE_LIMIT =
|
|
12
|
+
const DEFAULT_CONCURRENCY = 5;
|
|
13
|
+
const DEFAULT_RATE_LIMIT_BACKOFF_MS = 5e3;
|
|
14
|
+
const BEACON_BODY_SIZE_LIMIT = 6e4;
|
|
30
15
|
const TOO_MANY_REQUESTS = 429;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (!isNaN(date)) {
|
|
137
|
-
return new Date(date);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return new Date(now + this.rateLimitBackoffMs);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
16
|
+
var OtlpHttpTransport = class extends _grafana_faro_core.BaseTransport {
|
|
17
|
+
constructor(options) {
|
|
18
|
+
var _options$defaultRateL, _options$bufferSize, _options$concurrency;
|
|
19
|
+
super();
|
|
20
|
+
this.options = options;
|
|
21
|
+
this.name = "@grafana/faro-web-sdk:transport-otlp-http";
|
|
22
|
+
this.version = _grafana_faro_core.VERSION;
|
|
23
|
+
this.sendingTracesDisabledUntil = /* @__PURE__ */ new Date();
|
|
24
|
+
this.sendingLogsDisabledUntil = /* @__PURE__ */ new Date();
|
|
25
|
+
this.rateLimitBackoffMs = (_options$defaultRateL = options.defaultRateLimitBackoffMs) !== null && _options$defaultRateL !== void 0 ? _options$defaultRateL : DEFAULT_RATE_LIMIT_BACKOFF_MS;
|
|
26
|
+
this.promiseBuffer = (0, _grafana_faro_core.createPromiseBuffer)({
|
|
27
|
+
size: (_options$bufferSize = options === null || options === void 0 ? void 0 : options.bufferSize) !== null && _options$bufferSize !== void 0 ? _options$bufferSize : DEFAULT_BUFFER_SIZE,
|
|
28
|
+
concurrency: (_options$concurrency = options === null || options === void 0 ? void 0 : options.concurrency) !== null && _options$concurrency !== void 0 ? _options$concurrency : DEFAULT_CONCURRENCY
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
getIgnoreUrls() {
|
|
32
|
+
var _this$config$ignoreUr;
|
|
33
|
+
const { tracesURL = "", logsURL = "" } = this.options;
|
|
34
|
+
return [tracesURL, logsURL].filter(Boolean).concat((_this$config$ignoreUr = this.config.ignoreUrls) !== null && _this$config$ignoreUr !== void 0 ? _this$config$ignoreUr : []);
|
|
35
|
+
}
|
|
36
|
+
isBatched() {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
send(items) {
|
|
40
|
+
var _this = this;
|
|
41
|
+
return require_asyncToGenerator.default(function* () {
|
|
42
|
+
const otelPayload = new require_payload_OtelPayload.OtelPayload({
|
|
43
|
+
internalLogger: _this.internalLogger,
|
|
44
|
+
customOtlpTransform: _this.options.otlpTransform
|
|
45
|
+
});
|
|
46
|
+
items.forEach((item) => otelPayload.addResourceItem(item));
|
|
47
|
+
yield _this.sendPayload(otelPayload.getPayload());
|
|
48
|
+
})();
|
|
49
|
+
}
|
|
50
|
+
sendPayload(payload) {
|
|
51
|
+
var _this2 = this;
|
|
52
|
+
return require_asyncToGenerator.default(function* () {
|
|
53
|
+
try {
|
|
54
|
+
const { tracesURL = "", logsURL = "" } = _this2.options;
|
|
55
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
56
|
+
if (!((0, _grafana_faro_core.isArray)(value) && value.length > 0)) continue;
|
|
57
|
+
let disabledUntil;
|
|
58
|
+
let updateDisabledUntil = (_) => {};
|
|
59
|
+
let url = "";
|
|
60
|
+
switch (key) {
|
|
61
|
+
case "resourceSpans":
|
|
62
|
+
url = tracesURL;
|
|
63
|
+
disabledUntil = _this2.sendingTracesDisabledUntil;
|
|
64
|
+
updateDisabledUntil = (retryAfterDate) => {
|
|
65
|
+
_this2.sendingTracesDisabledUntil = retryAfterDate;
|
|
66
|
+
};
|
|
67
|
+
break;
|
|
68
|
+
case "resourceLogs":
|
|
69
|
+
url = logsURL;
|
|
70
|
+
disabledUntil = _this2.sendingLogsDisabledUntil;
|
|
71
|
+
updateDisabledUntil = (retryAfterDate) => {
|
|
72
|
+
_this2.sendingLogsDisabledUntil = retryAfterDate;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (disabledUntil && disabledUntil > new Date(Date.now())) {
|
|
76
|
+
_this2.logWarn(`Dropping transport item due to too many requests. Backoff until ${disabledUntil}`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const body = JSON.stringify({ [key]: value });
|
|
80
|
+
const { requestOptions, apiKey } = _this2.options;
|
|
81
|
+
const _ref = requestOptions !== null && requestOptions !== void 0 ? requestOptions : {}, { headers = {} } = _ref, restOfRequestOptions = require_objectWithoutProperties.default(_ref, _excluded);
|
|
82
|
+
if (!url) continue;
|
|
83
|
+
yield _this2.promiseBuffer.add(require_asyncToGenerator.default(function* () {
|
|
84
|
+
const resolvedHeaders = {};
|
|
85
|
+
for (const [key, value] of Object.entries(headers)) resolvedHeaders[key] = typeof value === "function" ? yield Promise.resolve(value()) : value;
|
|
86
|
+
return fetch(url, require_objectSpread2.default({
|
|
87
|
+
method: "POST",
|
|
88
|
+
headers: require_objectSpread2.default(require_objectSpread2.default({ "Content-Type": "application/json" }, resolvedHeaders), apiKey ? { "x-api-key": apiKey } : {}),
|
|
89
|
+
body,
|
|
90
|
+
keepalive: body.length <= BEACON_BODY_SIZE_LIMIT
|
|
91
|
+
}, restOfRequestOptions !== null && restOfRequestOptions !== void 0 ? restOfRequestOptions : {})).then((response) => {
|
|
92
|
+
if (response.status === TOO_MANY_REQUESTS) {
|
|
93
|
+
updateDisabledUntil(_this2.getRetryAfterDate(response));
|
|
94
|
+
_this2.logWarn(`Too many requests, backing off until ${disabledUntil}`);
|
|
95
|
+
}
|
|
96
|
+
response.text().catch(_grafana_faro_core.noop);
|
|
97
|
+
return response;
|
|
98
|
+
}).catch((error) => {
|
|
99
|
+
_this2.logError("Failed sending payload to the receiver\n", JSON.parse(body), error);
|
|
100
|
+
});
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
} catch (error) {
|
|
104
|
+
_this2.logError(error);
|
|
105
|
+
}
|
|
106
|
+
})();
|
|
107
|
+
}
|
|
108
|
+
getRetryAfterDate(response) {
|
|
109
|
+
const now = Date.now();
|
|
110
|
+
const retryAfterHeader = response.headers.get("Retry-After");
|
|
111
|
+
if (retryAfterHeader) {
|
|
112
|
+
const delay = Number(retryAfterHeader);
|
|
113
|
+
if (!isNaN(delay)) return new Date(delay * 1e3 + now);
|
|
114
|
+
const date = Date.parse(retryAfterHeader);
|
|
115
|
+
if (!isNaN(date)) return new Date(date);
|
|
116
|
+
}
|
|
117
|
+
return new Date(now + this.rateLimitBackoffMs);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
//#endregion
|
|
143
121
|
exports.OtlpHttpTransport = OtlpHttpTransport;
|
|
122
|
+
|
|
144
123
|
//# sourceMappingURL=transport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","
|
|
1
|
+
{"version":3,"file":"transport.js","names":["BaseTransport","VERSION","createPromiseBuffer","OtelPayload","this","isArray","noop"],"sources":["../../src/transport.ts"],"sourcesContent":["import { BaseTransport, createPromiseBuffer, isArray, noop, VERSION } from '@grafana/faro-core';\nimport type { Patterns, PromiseBuffer, TransportItem } from '@grafana/faro-core';\n\nimport { OtelPayload } from './payload';\nimport type { OtelTransportPayload } from './payload';\nimport type { OtlpHttpTransportOptions } from './types';\n\nconst DEFAULT_BUFFER_SIZE = 30;\nconst DEFAULT_CONCURRENCY = 5; // chrome supports 10 total, firefox 17\nconst DEFAULT_RATE_LIMIT_BACKOFF_MS = 5000;\n\nconst BEACON_BODY_SIZE_LIMIT = 60000;\nconst TOO_MANY_REQUESTS = 429;\n\nexport class OtlpHttpTransport extends BaseTransport {\n readonly name = '@grafana/faro-web-sdk:transport-otlp-http';\n readonly version: string = VERSION;\n\n private readonly promiseBuffer: PromiseBuffer<Response | void>;\n private readonly rateLimitBackoffMs: number;\n\n private sendingTracesDisabledUntil: Date = new Date();\n private sendingLogsDisabledUntil: Date = new Date();\n\n constructor(private options: OtlpHttpTransportOptions) {\n super();\n this.rateLimitBackoffMs = options.defaultRateLimitBackoffMs ?? DEFAULT_RATE_LIMIT_BACKOFF_MS;\n\n this.promiseBuffer = createPromiseBuffer({\n size: options?.bufferSize ?? DEFAULT_BUFFER_SIZE,\n concurrency: options?.concurrency ?? DEFAULT_CONCURRENCY,\n });\n }\n\n override getIgnoreUrls(): Patterns {\n const { tracesURL = '', logsURL = '' } = this.options;\n return ([tracesURL, logsURL].filter(Boolean) as Patterns).concat(this.config.ignoreUrls ?? []);\n }\n\n override isBatched(): boolean {\n return true;\n }\n\n async send(items: TransportItem[]): Promise<void> {\n const otelPayload = new OtelPayload({\n internalLogger: this.internalLogger,\n customOtlpTransform: this.options.otlpTransform,\n });\n\n items.forEach((item) => otelPayload.addResourceItem(item));\n await this.sendPayload(otelPayload.getPayload());\n }\n\n private async sendPayload(payload: OtelTransportPayload): Promise<void> {\n try {\n const { tracesURL = '', logsURL = '' } = this.options;\n\n for (const [key, value] of Object.entries(payload)) {\n if (!(isArray(value) && value.length > 0)) {\n continue;\n }\n\n let disabledUntil: Date | undefined;\n let updateDisabledUntil = (_: Date) => {};\n let url = '';\n\n switch (key) {\n case 'resourceSpans':\n url = tracesURL;\n disabledUntil = this.sendingTracesDisabledUntil;\n updateDisabledUntil = (retryAfterDate: Date) => {\n this.sendingTracesDisabledUntil = retryAfterDate;\n };\n break;\n case 'resourceLogs':\n url = logsURL;\n disabledUntil = this.sendingLogsDisabledUntil;\n updateDisabledUntil = (retryAfterDate: Date) => {\n this.sendingLogsDisabledUntil = retryAfterDate;\n };\n break;\n }\n\n if (disabledUntil && disabledUntil > new Date(Date.now())) {\n this.logWarn(`Dropping transport item due to too many requests. Backoff until ${disabledUntil}`);\n return undefined;\n }\n\n const body = JSON.stringify({ [key]: value });\n\n const { requestOptions, apiKey } = this.options;\n const { headers = {}, ...restOfRequestOptions } = requestOptions ?? {};\n\n if (!url) {\n continue;\n }\n\n await this.promiseBuffer.add(async () => {\n const resolvedHeaders: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n resolvedHeaders[key] = typeof value === 'function' ? await Promise.resolve(value()) : value;\n }\n\n return fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...resolvedHeaders,\n ...(apiKey ? { 'x-api-key': apiKey } : {}),\n },\n body,\n keepalive: body.length <= BEACON_BODY_SIZE_LIMIT,\n ...(restOfRequestOptions ?? {}),\n })\n .then((response) => {\n if (response.status === TOO_MANY_REQUESTS) {\n updateDisabledUntil(this.getRetryAfterDate(response));\n this.logWarn(`Too many requests, backing off until ${disabledUntil}`);\n }\n\n // read the body so the connection can be closed\n response.text().catch(noop);\n return response;\n })\n .catch((error) => {\n this.logError('Failed sending payload to the receiver\\n', JSON.parse(body), error);\n });\n });\n }\n } catch (error) {\n this.logError(error);\n }\n }\n\n private getRetryAfterDate(response: Response): Date {\n const now = Date.now();\n const retryAfterHeader = response.headers.get('Retry-After');\n\n if (retryAfterHeader) {\n const delay = Number(retryAfterHeader);\n\n if (!isNaN(delay)) {\n return new Date(delay * 1000 + now);\n }\n\n const date = Date.parse(retryAfterHeader);\n\n if (!isNaN(date)) {\n return new Date(date);\n }\n }\n\n return new Date(now + this.rateLimitBackoffMs);\n }\n}\n"],"mappings":"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"}
|
package/dist/cjs/types.js
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/asyncToGenerator.js
|
|
2
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
3
|
+
try {
|
|
4
|
+
var i = n[a](c), u = i.value;
|
|
5
|
+
} catch (n) {
|
|
6
|
+
e(n);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
10
|
+
}
|
|
11
|
+
function _asyncToGenerator(n) {
|
|
12
|
+
return function() {
|
|
13
|
+
var t = this, e = arguments;
|
|
14
|
+
return new Promise(function(r, o) {
|
|
15
|
+
var a = n.apply(t, e);
|
|
16
|
+
function _next(n) {
|
|
17
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
18
|
+
}
|
|
19
|
+
function _throw(n) {
|
|
20
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
21
|
+
}
|
|
22
|
+
_next(void 0);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { _asyncToGenerator as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import toPropertyKey from "./toPropertyKey.js";
|
|
2
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/defineProperty.js
|
|
3
|
+
function _defineProperty(e, r, t) {
|
|
4
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
5
|
+
value: t,
|
|
6
|
+
enumerable: !0,
|
|
7
|
+
configurable: !0,
|
|
8
|
+
writable: !0
|
|
9
|
+
}) : e[r] = t, e;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { _defineProperty as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import _defineProperty from "./defineProperty.js";
|
|
2
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/objectSpread2.js
|
|
3
|
+
function ownKeys(e, r) {
|
|
4
|
+
var t = Object.keys(e);
|
|
5
|
+
if (Object.getOwnPropertySymbols) {
|
|
6
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
7
|
+
r && (o = o.filter(function(r) {
|
|
8
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
9
|
+
})), t.push.apply(t, o);
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
}
|
|
13
|
+
function _objectSpread2(e) {
|
|
14
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
15
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
16
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
17
|
+
_defineProperty(e, r, t[r]);
|
|
18
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
19
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return e;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { _objectSpread2 as default };
|
package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectWithoutProperties.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "./objectWithoutPropertiesLoose.js";
|
|
2
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/objectWithoutProperties.js
|
|
3
|
+
function _objectWithoutProperties(e, t) {
|
|
4
|
+
if (null == e) return {};
|
|
5
|
+
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
6
|
+
if (Object.getOwnPropertySymbols) {
|
|
7
|
+
var s = Object.getOwnPropertySymbols(e);
|
|
8
|
+
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
9
|
+
}
|
|
10
|
+
return i;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { _objectWithoutProperties as default };
|
package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectWithoutPropertiesLoose.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/objectWithoutPropertiesLoose.js
|
|
2
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
3
|
+
if (null == r) return {};
|
|
4
|
+
var t = {};
|
|
5
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
6
|
+
if (e.includes(n)) continue;
|
|
7
|
+
t[n] = r[n];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { _objectWithoutPropertiesLoose as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import _typeof from "./typeof.js";
|
|
2
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/toPrimitive.js
|
|
3
|
+
function toPrimitive(t, r) {
|
|
4
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
5
|
+
var e = t[Symbol.toPrimitive];
|
|
6
|
+
if (void 0 !== e) {
|
|
7
|
+
var i = e.call(t, r || "default");
|
|
8
|
+
if ("object" != _typeof(i)) return i;
|
|
9
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
10
|
+
}
|
|
11
|
+
return ("string" === r ? String : Number)(t);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { toPrimitive as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import _typeof from "./typeof.js";
|
|
2
|
+
import toPrimitive from "./toPrimitive.js";
|
|
3
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/toPropertyKey.js
|
|
4
|
+
function toPropertyKey(t) {
|
|
5
|
+
var i = toPrimitive(t, "string");
|
|
6
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { toPropertyKey as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
5
|
+
return typeof o;
|
|
6
|
+
} : function(o) {
|
|
7
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { _typeof as default };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { OtlpHttpTransport } from "./transport.js";
|
|
2
|
+
export { OtlpHttpTransport };
|
|
@@ -1,61 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
(_d = this.internalLogger) === null || _d === void 0 ? void 0 : _d.error(error);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
import { getLogTransforms, getTraceTransforms } from "./transform/transform.js";
|
|
2
|
+
import "./transform/index.js";
|
|
3
|
+
import { TransportItemType } from "@grafana/faro-core";
|
|
4
|
+
//#region src/payload/OtelPayload.ts
|
|
5
|
+
var OtelPayload = class {
|
|
6
|
+
constructor({ internalLogger, customOtlpTransform, transportItem }) {
|
|
7
|
+
this.resourceSpans = [];
|
|
8
|
+
this.internalLogger = internalLogger;
|
|
9
|
+
this.resourceLogs = [];
|
|
10
|
+
this.getLogTransforms = getLogTransforms(this.internalLogger, customOtlpTransform);
|
|
11
|
+
this.getTraceTransforms = getTraceTransforms(this.internalLogger);
|
|
12
|
+
if (transportItem) this.addResourceItem(transportItem);
|
|
13
|
+
}
|
|
14
|
+
getPayload() {
|
|
15
|
+
return {
|
|
16
|
+
resourceLogs: this.resourceLogs,
|
|
17
|
+
resourceSpans: this.resourceSpans
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
addResourceItem(transportItem) {
|
|
21
|
+
const { type } = transportItem;
|
|
22
|
+
try {
|
|
23
|
+
switch (type) {
|
|
24
|
+
case TransportItemType.LOG:
|
|
25
|
+
case TransportItemType.EXCEPTION:
|
|
26
|
+
case TransportItemType.EVENT:
|
|
27
|
+
case TransportItemType.MEASUREMENT: {
|
|
28
|
+
const { toLogRecord, toResourceLog } = this.getLogTransforms;
|
|
29
|
+
if (this.resourceLogs.length === 0) this.resourceLogs = [toResourceLog(transportItem)];
|
|
30
|
+
else {
|
|
31
|
+
var _this$resourceLogs$;
|
|
32
|
+
(_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));
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
case TransportItemType.TRACE: {
|
|
37
|
+
const { toResourceSpan } = this.getTraceTransforms;
|
|
38
|
+
this.resourceSpans.push(toResourceSpan(transportItem));
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
default:
|
|
42
|
+
var _this$internalLogger;
|
|
43
|
+
(_this$internalLogger = this.internalLogger) === null || _this$internalLogger === void 0 || _this$internalLogger.error(`Unknown TransportItemType: ${type}`);
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
var _this$internalLogger2;
|
|
47
|
+
(_this$internalLogger2 = this.internalLogger) === null || _this$internalLogger2 === void 0 || _this$internalLogger2.error(error);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
export { OtelPayload };
|
|
53
|
+
|
|
61
54
|
//# sourceMappingURL=OtelPayload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OtelPayload.js","
|
|
1
|
+
{"version":3,"file":"OtelPayload.js","names":[],"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,mBAAmB,iBAAiB,KAAK,gBAAgB,mBAAmB;EACjF,KAAK,qBAAqB,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,KAAK,kBAAkB;IACvB,KAAK,kBAAkB;IACvB,KAAK,kBAAkB;IACvB,KAAK,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,KAAK,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"}
|