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/index.js CHANGED
@@ -440,6 +440,7 @@ var DevtoolsServer = class {
440
440
  }
441
441
  addTrace(trace) {
442
442
  const existing = this.traces.find((t) => t.traceId === trace.traceId);
443
+ const merged = existing ?? trace;
443
444
  if (existing) {
444
445
  const existingSpanIds = new Set(existing.spans.map((s) => s.spanId));
445
446
  for (const span of trace.spans) {
@@ -451,6 +452,14 @@ var DevtoolsServer = class {
451
452
  existing.endTime = Math.max(existing.endTime, trace.endTime);
452
453
  existing.duration = existing.endTime - existing.startTime;
453
454
  if (trace.status === "ERROR") existing.status = "ERROR";
455
+ const root = existing.spans.find((s) => !s.parentSpanId);
456
+ if (root) {
457
+ existing.rootSpan = root;
458
+ const rootService = root.attributes?.["service.name"];
459
+ if (typeof rootService === "string" && rootService.length > 0) {
460
+ existing.service = rootService;
461
+ }
462
+ }
454
463
  } else {
455
464
  this.traces = appendWithLimit(
456
465
  this.traces,
@@ -459,7 +468,7 @@ var DevtoolsServer = class {
459
468
  );
460
469
  }
461
470
  this.errorAggregator.addErrorsFromTrace(trace);
462
- this.broadcast({ traces: [trace], metrics: [], logs: [], errors: this.errorAggregator.getErrorGroups() });
471
+ this.broadcast({ traces: [merged], metrics: [], logs: [], errors: this.errorAggregator.getErrorGroups() });
463
472
  }
464
473
  addTraces(traces) {
465
474
  for (const trace of traces) this.addTrace(trace);
@@ -990,7 +999,8 @@ function findPackageRoot() {
990
999
  }
991
1000
  return dir;
992
1001
  }
993
- 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>`;
1002
+ 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>';
1003
+ 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>`;
994
1004
  var cachedVersion = null;
995
1005
  function getVersion() {
996
1006
  if (cachedVersion !== null) return cachedVersion;
@@ -1027,6 +1037,7 @@ function getWidgetJs() {
1027
1037
  function attachDevtoolsRoutes(httpServer, devtools, options = {}) {
1028
1038
  const loopbackOnly = options.loopbackOnly ?? true;
1029
1039
  httpServer.on("request", async (req, res) => {
1040
+ if (req.headers.upgrade?.toLowerCase() === "websocket") return;
1030
1041
  res.setHeader("Access-Control-Allow-Origin", "*");
1031
1042
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
1032
1043
  res.setHeader("Access-Control-Allow-Headers", "Content-Type");
@@ -1049,6 +1060,15 @@ function attachDevtoolsRoutes(httpServer, devtools, options = {}) {
1049
1060
  res.end(js);
1050
1061
  return;
1051
1062
  }
1063
+ if (req.method === "GET" && (url === "/favicon.svg" || url === "/favicon.ico")) {
1064
+ res.writeHead(200, {
1065
+ "Content-Type": "image/svg+xml; charset=utf-8",
1066
+ "Cache-Control": "public, max-age=86400",
1067
+ "Content-Length": Buffer.byteLength(DEVTOOLS_FAVICON_SVG)
1068
+ });
1069
+ res.end(DEVTOOLS_FAVICON_SVG);
1070
+ return;
1071
+ }
1052
1072
  if (req.method === "GET" && url === "/healthz") {
1053
1073
  sendJson(res, 200, {
1054
1074
  ok: true,