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/index.js
CHANGED
|
@@ -918,7 +918,17 @@ function decodeOtlpMetricsRequest(body) {
|
|
|
918
918
|
return decodeRequest("opentelemetry.proto.metrics.v1.ExportMetricsServiceRequest", body);
|
|
919
919
|
}
|
|
920
920
|
|
|
921
|
+
// src/server/identity.ts
|
|
922
|
+
var DEVTOOLS_IDENTITY = "autotel-devtools";
|
|
923
|
+
|
|
921
924
|
// src/server/http.ts
|
|
925
|
+
function sendOtlpError(res, req, e) {
|
|
926
|
+
sendJson(res, 400, {
|
|
927
|
+
error: "Invalid OTLP payload",
|
|
928
|
+
message: e instanceof Error ? e.message : String(e),
|
|
929
|
+
contentType: req.headers["content-type"] ?? null
|
|
930
|
+
});
|
|
931
|
+
}
|
|
922
932
|
var PROTOBUF_DECODERS = {
|
|
923
933
|
traces: decodeOtlpTraceRequest,
|
|
924
934
|
logs: decodeOtlpLogsRequest,
|
|
@@ -939,6 +949,18 @@ function findPackageRoot() {
|
|
|
939
949
|
return dir;
|
|
940
950
|
}
|
|
941
951
|
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>`;
|
|
952
|
+
var cachedVersion = null;
|
|
953
|
+
function getVersion() {
|
|
954
|
+
if (cachedVersion !== null) return cachedVersion;
|
|
955
|
+
let version = "unknown";
|
|
956
|
+
try {
|
|
957
|
+
const pkg = JSON.parse(readFileSync(resolve(findPackageRoot(), "package.json"), "utf8"));
|
|
958
|
+
if (typeof pkg.version === "string") version = pkg.version;
|
|
959
|
+
} catch {
|
|
960
|
+
}
|
|
961
|
+
cachedVersion = version;
|
|
962
|
+
return version;
|
|
963
|
+
}
|
|
942
964
|
var cachedWidgetJs = null;
|
|
943
965
|
function getWidgetJs() {
|
|
944
966
|
if (!cachedWidgetJs) {
|
|
@@ -965,6 +987,8 @@ function attachDevtoolsRoutes(httpServer, devtools) {
|
|
|
965
987
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
966
988
|
res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
|
|
967
989
|
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
|
|
990
|
+
res.setHeader("x-autotel-devtools", getVersion());
|
|
991
|
+
res.setHeader("Access-Control-Expose-Headers", "x-autotel-devtools");
|
|
968
992
|
if (req.method === "OPTIONS") {
|
|
969
993
|
res.writeHead(204);
|
|
970
994
|
res.end();
|
|
@@ -983,7 +1007,12 @@ function attachDevtoolsRoutes(httpServer, devtools) {
|
|
|
983
1007
|
return;
|
|
984
1008
|
}
|
|
985
1009
|
if (req.method === "GET" && url === "/healthz") {
|
|
986
|
-
sendJson(res, 200, {
|
|
1010
|
+
sendJson(res, 200, {
|
|
1011
|
+
ok: true,
|
|
1012
|
+
service: DEVTOOLS_IDENTITY,
|
|
1013
|
+
version: getVersion(),
|
|
1014
|
+
clients: devtools.clientCount
|
|
1015
|
+
});
|
|
987
1016
|
return;
|
|
988
1017
|
}
|
|
989
1018
|
if (req.method === "GET" && url === "/v1/traces") {
|
|
@@ -1003,7 +1032,7 @@ function attachDevtoolsRoutes(httpServer, devtools) {
|
|
|
1003
1032
|
devtools.addTraces(traces);
|
|
1004
1033
|
sendJson(res, 200, { acceptedTraces: traces.length });
|
|
1005
1034
|
} catch (e) {
|
|
1006
|
-
|
|
1035
|
+
sendOtlpError(res, req, e);
|
|
1007
1036
|
}
|
|
1008
1037
|
return;
|
|
1009
1038
|
}
|
|
@@ -1014,7 +1043,7 @@ function attachDevtoolsRoutes(httpServer, devtools) {
|
|
|
1014
1043
|
devtools.addLogs(logs);
|
|
1015
1044
|
sendJson(res, 200, { acceptedLogs: logs.length });
|
|
1016
1045
|
} catch (e) {
|
|
1017
|
-
|
|
1046
|
+
sendOtlpError(res, req, e);
|
|
1018
1047
|
}
|
|
1019
1048
|
return;
|
|
1020
1049
|
}
|
|
@@ -1024,7 +1053,7 @@ function attachDevtoolsRoutes(httpServer, devtools) {
|
|
|
1024
1053
|
const count = countOtlpMetrics(payload);
|
|
1025
1054
|
sendJson(res, 200, { acceptedMetrics: count });
|
|
1026
1055
|
} catch (e) {
|
|
1027
|
-
|
|
1056
|
+
sendOtlpError(res, req, e);
|
|
1028
1057
|
}
|
|
1029
1058
|
return;
|
|
1030
1059
|
}
|