autotel-devtools 6.0.1 → 6.1.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/README.md +19 -0
- package/dist/cli.cjs +66 -4
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +66 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +33 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -4
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs +56 -4
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +17 -1
- package/dist/server/index.d.ts +17 -1
- package/dist/server/index.js +55 -5
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -1393,7 +1393,38 @@ function decodeOtlpMetricsRequest(body) {
|
|
|
1393
1393
|
return decodeRequest("opentelemetry.proto.metrics.v1.ExportMetricsServiceRequest", body);
|
|
1394
1394
|
}
|
|
1395
1395
|
|
|
1396
|
+
// src/server/identity.ts
|
|
1397
|
+
var DEVTOOLS_IDENTITY = "autotel-devtools";
|
|
1398
|
+
async function probePortHolder(host, port, timeoutMs = 500) {
|
|
1399
|
+
const authority = host.includes(":") ? `[${host}]` : host;
|
|
1400
|
+
const controller = new AbortController();
|
|
1401
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
1402
|
+
try {
|
|
1403
|
+
const res = await fetch(`http://${authority}:${port}/healthz`, {
|
|
1404
|
+
signal: controller.signal
|
|
1405
|
+
});
|
|
1406
|
+
if (res.headers.get("x-autotel-devtools")) return "autotel-devtools";
|
|
1407
|
+
try {
|
|
1408
|
+
const body = await res.json();
|
|
1409
|
+
if (body && body.service === DEVTOOLS_IDENTITY) return "autotel-devtools";
|
|
1410
|
+
} catch {
|
|
1411
|
+
}
|
|
1412
|
+
return "foreign";
|
|
1413
|
+
} catch {
|
|
1414
|
+
return "none";
|
|
1415
|
+
} finally {
|
|
1416
|
+
clearTimeout(timer);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1396
1420
|
// src/server/http.ts
|
|
1421
|
+
function sendOtlpError(res, req, e) {
|
|
1422
|
+
sendJson(res, 400, {
|
|
1423
|
+
error: "Invalid OTLP payload",
|
|
1424
|
+
message: e instanceof Error ? e.message : String(e),
|
|
1425
|
+
contentType: req.headers["content-type"] ?? null
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1397
1428
|
var PROTOBUF_DECODERS = {
|
|
1398
1429
|
traces: decodeOtlpTraceRequest,
|
|
1399
1430
|
logs: decodeOtlpLogsRequest,
|
|
@@ -1414,6 +1445,18 @@ function findPackageRoot() {
|
|
|
1414
1445
|
return dir;
|
|
1415
1446
|
}
|
|
1416
1447
|
var FULLPAGE_HTML = `<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>autotel-devtools</title><style>*{margin:0;padding:0;box-sizing:border-box}html,body{height:100%;width:100%;overflow:hidden}</style></head><body><script src="/widget.js?mode=fullpage"></script></body></html>`;
|
|
1448
|
+
var cachedVersion = null;
|
|
1449
|
+
function getVersion() {
|
|
1450
|
+
if (cachedVersion !== null) return cachedVersion;
|
|
1451
|
+
let version = "unknown";
|
|
1452
|
+
try {
|
|
1453
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve(findPackageRoot(), "package.json"), "utf8"));
|
|
1454
|
+
if (typeof pkg.version === "string") version = pkg.version;
|
|
1455
|
+
} catch {
|
|
1456
|
+
}
|
|
1457
|
+
cachedVersion = version;
|
|
1458
|
+
return version;
|
|
1459
|
+
}
|
|
1417
1460
|
var cachedWidgetJs = null;
|
|
1418
1461
|
function getWidgetJs() {
|
|
1419
1462
|
if (!cachedWidgetJs) {
|
|
@@ -1440,6 +1483,8 @@ function attachDevtoolsRoutes(httpServer, devtools) {
|
|
|
1440
1483
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
1441
1484
|
res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
|
|
1442
1485
|
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
|
|
1486
|
+
res.setHeader("x-autotel-devtools", getVersion());
|
|
1487
|
+
res.setHeader("Access-Control-Expose-Headers", "x-autotel-devtools");
|
|
1443
1488
|
if (req.method === "OPTIONS") {
|
|
1444
1489
|
res.writeHead(204);
|
|
1445
1490
|
res.end();
|
|
@@ -1458,7 +1503,12 @@ function attachDevtoolsRoutes(httpServer, devtools) {
|
|
|
1458
1503
|
return;
|
|
1459
1504
|
}
|
|
1460
1505
|
if (req.method === "GET" && url === "/healthz") {
|
|
1461
|
-
sendJson(res, 200, {
|
|
1506
|
+
sendJson(res, 200, {
|
|
1507
|
+
ok: true,
|
|
1508
|
+
service: DEVTOOLS_IDENTITY,
|
|
1509
|
+
version: getVersion(),
|
|
1510
|
+
clients: devtools.clientCount
|
|
1511
|
+
});
|
|
1462
1512
|
return;
|
|
1463
1513
|
}
|
|
1464
1514
|
if (req.method === "GET" && url === "/v1/traces") {
|
|
@@ -1478,7 +1528,7 @@ function attachDevtoolsRoutes(httpServer, devtools) {
|
|
|
1478
1528
|
devtools.addTraces(traces);
|
|
1479
1529
|
sendJson(res, 200, { acceptedTraces: traces.length });
|
|
1480
1530
|
} catch (e) {
|
|
1481
|
-
|
|
1531
|
+
sendOtlpError(res, req, e);
|
|
1482
1532
|
}
|
|
1483
1533
|
return;
|
|
1484
1534
|
}
|
|
@@ -1489,7 +1539,7 @@ function attachDevtoolsRoutes(httpServer, devtools) {
|
|
|
1489
1539
|
devtools.addLogs(logs);
|
|
1490
1540
|
sendJson(res, 200, { acceptedLogs: logs.length });
|
|
1491
1541
|
} catch (e) {
|
|
1492
|
-
|
|
1542
|
+
sendOtlpError(res, req, e);
|
|
1493
1543
|
}
|
|
1494
1544
|
return;
|
|
1495
1545
|
}
|
|
@@ -1499,7 +1549,7 @@ function attachDevtoolsRoutes(httpServer, devtools) {
|
|
|
1499
1549
|
const count = countOtlpMetrics(payload);
|
|
1500
1550
|
sendJson(res, 200, { acceptedMetrics: count });
|
|
1501
1551
|
} catch (e) {
|
|
1502
|
-
|
|
1552
|
+
sendOtlpError(res, req, e);
|
|
1503
1553
|
}
|
|
1504
1554
|
return;
|
|
1505
1555
|
}
|
|
@@ -1512,6 +1562,7 @@ function createDevtoolsHttpServer(devtools, _options = {}) {
|
|
|
1512
1562
|
return server;
|
|
1513
1563
|
}
|
|
1514
1564
|
|
|
1565
|
+
exports.DEVTOOLS_IDENTITY = DEVTOOLS_IDENTITY;
|
|
1515
1566
|
exports.DevtoolsLogExporter = DevtoolsLogExporter;
|
|
1516
1567
|
exports.DevtoolsRemoteExporter = DevtoolsRemoteExporter;
|
|
1517
1568
|
exports.DevtoolsServer = DevtoolsServer;
|
|
@@ -1528,6 +1579,7 @@ exports.decodeOtlpTraceRequest = decodeOtlpTraceRequest;
|
|
|
1528
1579
|
exports.isProtobufContentType = isProtobufContentType;
|
|
1529
1580
|
exports.parseOtlpLogs = parseOtlpLogs;
|
|
1530
1581
|
exports.parseOtlpTraces = parseOtlpTraces;
|
|
1582
|
+
exports.probePortHolder = probePortHolder;
|
|
1531
1583
|
exports.resolveTelemetryLimits = resolveTelemetryLimits;
|
|
1532
1584
|
//# sourceMappingURL=index.cjs.map
|
|
1533
1585
|
//# sourceMappingURL=index.cjs.map
|