autotel-devtools 8.1.0 → 8.1.1

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.
@@ -455,6 +455,7 @@ var DevtoolsServer = class {
455
455
  }
456
456
  addTrace(trace) {
457
457
  const existing = this.traces.find((t) => t.traceId === trace.traceId);
458
+ const merged = existing ?? trace;
458
459
  if (existing) {
459
460
  const existingSpanIds = new Set(existing.spans.map((s) => s.spanId));
460
461
  for (const span of trace.spans) {
@@ -466,6 +467,14 @@ var DevtoolsServer = class {
466
467
  existing.endTime = Math.max(existing.endTime, trace.endTime);
467
468
  existing.duration = existing.endTime - existing.startTime;
468
469
  if (trace.status === "ERROR") existing.status = "ERROR";
470
+ const root = existing.spans.find((s) => !s.parentSpanId);
471
+ if (root) {
472
+ existing.rootSpan = root;
473
+ const rootService = root.attributes?.["service.name"];
474
+ if (typeof rootService === "string" && rootService.length > 0) {
475
+ existing.service = rootService;
476
+ }
477
+ }
469
478
  } else {
470
479
  this.traces = appendWithLimit(
471
480
  this.traces,
@@ -474,7 +483,7 @@ var DevtoolsServer = class {
474
483
  );
475
484
  }
476
485
  this.errorAggregator.addErrorsFromTrace(trace);
477
- this.broadcast({ traces: [trace], metrics: [], logs: [], errors: this.errorAggregator.getErrorGroups() });
486
+ this.broadcast({ traces: [merged], metrics: [], logs: [], errors: this.errorAggregator.getErrorGroups() });
478
487
  }
479
488
  addTraces(traces) {
480
489
  for (const trace of traces) this.addTrace(trace);
@@ -1486,7 +1495,8 @@ function findPackageRoot() {
1486
1495
  }
1487
1496
  return dir;
1488
1497
  }
1489
- 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>`;
1498
+ var DEVTOOLS_FAVICON_SVG = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="#0f172a"/><text x="32" y="41" text-anchor="middle" font-size="32">\u{1F6F0}\uFE0F</text></svg>';
1499
+ 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><link rel="icon" href="/favicon.svg" type="image/svg+xml"><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>`;
1490
1500
  var cachedVersion = null;
1491
1501
  function getVersion() {
1492
1502
  if (cachedVersion !== null) return cachedVersion;
@@ -1523,6 +1533,7 @@ function getWidgetJs() {
1523
1533
  function attachDevtoolsRoutes(httpServer, devtools, options = {}) {
1524
1534
  const loopbackOnly = options.loopbackOnly ?? true;
1525
1535
  httpServer.on("request", async (req, res) => {
1536
+ if (req.headers.upgrade?.toLowerCase() === "websocket") return;
1526
1537
  res.setHeader("Access-Control-Allow-Origin", "*");
1527
1538
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
1528
1539
  res.setHeader("Access-Control-Allow-Headers", "Content-Type");
@@ -1545,6 +1556,15 @@ function attachDevtoolsRoutes(httpServer, devtools, options = {}) {
1545
1556
  res.end(js);
1546
1557
  return;
1547
1558
  }
1559
+ if (req.method === "GET" && (url === "/favicon.svg" || url === "/favicon.ico")) {
1560
+ res.writeHead(200, {
1561
+ "Content-Type": "image/svg+xml; charset=utf-8",
1562
+ "Cache-Control": "public, max-age=86400",
1563
+ "Content-Length": Buffer.byteLength(DEVTOOLS_FAVICON_SVG)
1564
+ });
1565
+ res.end(DEVTOOLS_FAVICON_SVG);
1566
+ return;
1567
+ }
1548
1568
  if (req.method === "GET" && url === "/healthz") {
1549
1569
  sendJson(res, 200, {
1550
1570
  ok: true,