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.
package/dist/cli.js CHANGED
@@ -438,6 +438,7 @@ var DevtoolsServer = class {
438
438
  }
439
439
  addTrace(trace) {
440
440
  const existing = this.traces.find((t) => t.traceId === trace.traceId);
441
+ const merged = existing ?? trace;
441
442
  if (existing) {
442
443
  const existingSpanIds = new Set(existing.spans.map((s) => s.spanId));
443
444
  for (const span of trace.spans) {
@@ -449,6 +450,14 @@ var DevtoolsServer = class {
449
450
  existing.endTime = Math.max(existing.endTime, trace.endTime);
450
451
  existing.duration = existing.endTime - existing.startTime;
451
452
  if (trace.status === "ERROR") existing.status = "ERROR";
453
+ const root = existing.spans.find((s) => !s.parentSpanId);
454
+ if (root) {
455
+ existing.rootSpan = root;
456
+ const rootService = root.attributes?.["service.name"];
457
+ if (typeof rootService === "string" && rootService.length > 0) {
458
+ existing.service = rootService;
459
+ }
460
+ }
452
461
  } else {
453
462
  this.traces = appendWithLimit(
454
463
  this.traces,
@@ -457,7 +466,7 @@ var DevtoolsServer = class {
457
466
  );
458
467
  }
459
468
  this.errorAggregator.addErrorsFromTrace(trace);
460
- this.broadcast({ traces: [trace], metrics: [], logs: [], errors: this.errorAggregator.getErrorGroups() });
469
+ this.broadcast({ traces: [merged], metrics: [], logs: [], errors: this.errorAggregator.getErrorGroups() });
461
470
  }
462
471
  addTraces(traces) {
463
472
  for (const trace of traces) this.addTrace(trace);
@@ -1009,7 +1018,8 @@ function findPackageRoot() {
1009
1018
  }
1010
1019
  return dir;
1011
1020
  }
1012
- 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>`;
1021
+ 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>';
1022
+ 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>`;
1013
1023
  var cachedVersion = null;
1014
1024
  function getVersion() {
1015
1025
  if (cachedVersion !== null) return cachedVersion;
@@ -1046,6 +1056,7 @@ function getWidgetJs() {
1046
1056
  function attachDevtoolsRoutes(httpServer, devtools, options = {}) {
1047
1057
  const loopbackOnly = options.loopbackOnly ?? true;
1048
1058
  httpServer.on("request", async (req, res) => {
1059
+ if (req.headers.upgrade?.toLowerCase() === "websocket") return;
1049
1060
  res.setHeader("Access-Control-Allow-Origin", "*");
1050
1061
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
1051
1062
  res.setHeader("Access-Control-Allow-Headers", "Content-Type");
@@ -1068,6 +1079,15 @@ function attachDevtoolsRoutes(httpServer, devtools, options = {}) {
1068
1079
  res.end(js);
1069
1080
  return;
1070
1081
  }
1082
+ if (req.method === "GET" && (url === "/favicon.svg" || url === "/favicon.ico")) {
1083
+ res.writeHead(200, {
1084
+ "Content-Type": "image/svg+xml; charset=utf-8",
1085
+ "Cache-Control": "public, max-age=86400",
1086
+ "Content-Length": Buffer.byteLength(DEVTOOLS_FAVICON_SVG)
1087
+ });
1088
+ res.end(DEVTOOLS_FAVICON_SVG);
1089
+ return;
1090
+ }
1071
1091
  if (req.method === "GET" && url === "/healthz") {
1072
1092
  sendJson(res, 200, {
1073
1093
  ok: true,