autotel-devtools 5.0.0 → 5.0.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/README.md +14 -4
- package/dist/cli.cjs +270 -7
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +250 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +270 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +250 -7
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs +274 -7
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +14 -1
- package/dist/server/index.d.ts +14 -1
- package/dist/server/index.js +251 -8
- package/dist/server/index.js.map +1 -1
- package/dist/widget.global.js +2 -2
- package/package.json +22 -20
- package/skills/autotel-devtools/SKILL.md +9 -5
package/dist/server/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { ExportResultCode } from '@opentelemetry/core';
|
|
|
4
4
|
import { readFileSync, existsSync } from 'fs';
|
|
5
5
|
import { resolve, dirname } from 'path';
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
7
|
+
import * as protobuf from 'protobufjs';
|
|
7
8
|
|
|
8
9
|
// src/server/server.ts
|
|
9
10
|
|
|
@@ -984,7 +985,7 @@ var SPAN_KIND_MAP = {
|
|
|
984
985
|
function normalizeHexId(id) {
|
|
985
986
|
if (!id) return "";
|
|
986
987
|
const isBase64Like = /^[A-Za-z0-9+/=]+$/.test(id) && !/^[0-9a-f]+$/i.test(id);
|
|
987
|
-
const isLikelyBase64Id = isBase64Like && (id.length === 24 || id.length === 28 || id.length === 44 || id.length === 48);
|
|
988
|
+
const isLikelyBase64Id = isBase64Like && (id.length === 12 || id.length === 24 || id.length === 28 || id.length === 44 || id.length === 48);
|
|
988
989
|
if (isLikelyBase64Id) {
|
|
989
990
|
try {
|
|
990
991
|
const bytes = Buffer.from(id, "base64");
|
|
@@ -1116,13 +1117,255 @@ async function readJsonBody(req) {
|
|
|
1116
1117
|
req.on("error", reject);
|
|
1117
1118
|
});
|
|
1118
1119
|
}
|
|
1120
|
+
async function readRawBody(req) {
|
|
1121
|
+
return new Promise((resolve2, reject) => {
|
|
1122
|
+
const chunks = [];
|
|
1123
|
+
req.on("data", (chunk) => chunks.push(chunk));
|
|
1124
|
+
req.on("end", () => resolve2(Buffer.concat(chunks)));
|
|
1125
|
+
req.on("error", reject);
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
function isProtobufContentType(contentType) {
|
|
1129
|
+
if (!contentType) return false;
|
|
1130
|
+
const value = contentType.toLowerCase();
|
|
1131
|
+
return value.includes("application/x-protobuf") || value.includes("application/protobuf");
|
|
1132
|
+
}
|
|
1119
1133
|
function sendJson(res, status, data) {
|
|
1120
1134
|
const body = JSON.stringify(data);
|
|
1121
1135
|
res.writeHead(status, { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(body) });
|
|
1122
1136
|
res.end(body);
|
|
1123
1137
|
}
|
|
1138
|
+
var COMMON_PROTO = `
|
|
1139
|
+
syntax = "proto3";
|
|
1140
|
+
package opentelemetry.proto.common.v1;
|
|
1141
|
+
|
|
1142
|
+
message AnyValue {
|
|
1143
|
+
oneof value {
|
|
1144
|
+
string string_value = 1;
|
|
1145
|
+
bool bool_value = 2;
|
|
1146
|
+
int64 int_value = 3;
|
|
1147
|
+
double double_value = 4;
|
|
1148
|
+
ArrayValue array_value = 5;
|
|
1149
|
+
KeyValueList kvlist_value = 6;
|
|
1150
|
+
bytes bytes_value = 7;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
message ArrayValue { repeated AnyValue values = 1; }
|
|
1154
|
+
message KeyValueList { repeated KeyValue values = 1; }
|
|
1155
|
+
message KeyValue {
|
|
1156
|
+
string key = 1;
|
|
1157
|
+
AnyValue value = 2;
|
|
1158
|
+
}
|
|
1159
|
+
message InstrumentationScope {
|
|
1160
|
+
string name = 1;
|
|
1161
|
+
string version = 2;
|
|
1162
|
+
repeated KeyValue attributes = 3;
|
|
1163
|
+
uint32 dropped_attributes_count = 4;
|
|
1164
|
+
}
|
|
1165
|
+
`;
|
|
1166
|
+
var RESOURCE_PROTO = `
|
|
1167
|
+
syntax = "proto3";
|
|
1168
|
+
package opentelemetry.proto.resource.v1;
|
|
1169
|
+
|
|
1170
|
+
message Resource {
|
|
1171
|
+
repeated opentelemetry.proto.common.v1.KeyValue attributes = 1;
|
|
1172
|
+
uint32 dropped_attributes_count = 2;
|
|
1173
|
+
}
|
|
1174
|
+
`;
|
|
1175
|
+
var TRACE_PROTO = `
|
|
1176
|
+
syntax = "proto3";
|
|
1177
|
+
package opentelemetry.proto.trace.v1;
|
|
1178
|
+
|
|
1179
|
+
message ResourceSpans {
|
|
1180
|
+
opentelemetry.proto.resource.v1.Resource resource = 1;
|
|
1181
|
+
repeated ScopeSpans scope_spans = 2;
|
|
1182
|
+
string schema_url = 3;
|
|
1183
|
+
}
|
|
1184
|
+
message ScopeSpans {
|
|
1185
|
+
opentelemetry.proto.common.v1.InstrumentationScope scope = 1;
|
|
1186
|
+
repeated Span spans = 2;
|
|
1187
|
+
string schema_url = 3;
|
|
1188
|
+
}
|
|
1189
|
+
message Span {
|
|
1190
|
+
bytes trace_id = 1;
|
|
1191
|
+
bytes span_id = 2;
|
|
1192
|
+
string trace_state = 3;
|
|
1193
|
+
bytes parent_span_id = 4;
|
|
1194
|
+
fixed32 flags = 16;
|
|
1195
|
+
string name = 5;
|
|
1196
|
+
SpanKind kind = 6;
|
|
1197
|
+
fixed64 start_time_unix_nano = 7;
|
|
1198
|
+
fixed64 end_time_unix_nano = 8;
|
|
1199
|
+
repeated opentelemetry.proto.common.v1.KeyValue attributes = 9;
|
|
1200
|
+
uint32 dropped_attributes_count = 10;
|
|
1201
|
+
repeated Event events = 11;
|
|
1202
|
+
uint32 dropped_events_count = 12;
|
|
1203
|
+
repeated Link links = 13;
|
|
1204
|
+
uint32 dropped_links_count = 14;
|
|
1205
|
+
Status status = 15;
|
|
1206
|
+
|
|
1207
|
+
enum SpanKind {
|
|
1208
|
+
SPAN_KIND_UNSPECIFIED = 0;
|
|
1209
|
+
SPAN_KIND_INTERNAL = 1;
|
|
1210
|
+
SPAN_KIND_SERVER = 2;
|
|
1211
|
+
SPAN_KIND_CLIENT = 3;
|
|
1212
|
+
SPAN_KIND_PRODUCER = 4;
|
|
1213
|
+
SPAN_KIND_CONSUMER = 5;
|
|
1214
|
+
}
|
|
1215
|
+
message Event {
|
|
1216
|
+
fixed64 time_unix_nano = 1;
|
|
1217
|
+
string name = 2;
|
|
1218
|
+
repeated opentelemetry.proto.common.v1.KeyValue attributes = 3;
|
|
1219
|
+
uint32 dropped_attributes_count = 4;
|
|
1220
|
+
}
|
|
1221
|
+
message Link {
|
|
1222
|
+
bytes trace_id = 1;
|
|
1223
|
+
bytes span_id = 2;
|
|
1224
|
+
string trace_state = 3;
|
|
1225
|
+
repeated opentelemetry.proto.common.v1.KeyValue attributes = 4;
|
|
1226
|
+
uint32 dropped_attributes_count = 5;
|
|
1227
|
+
fixed32 flags = 6;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
message Status {
|
|
1231
|
+
reserved 1;
|
|
1232
|
+
string message = 2;
|
|
1233
|
+
StatusCode code = 3;
|
|
1234
|
+
|
|
1235
|
+
enum StatusCode {
|
|
1236
|
+
STATUS_CODE_UNSET = 0;
|
|
1237
|
+
STATUS_CODE_OK = 1;
|
|
1238
|
+
STATUS_CODE_ERROR = 2;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
message ExportTraceServiceRequest {
|
|
1242
|
+
repeated ResourceSpans resource_spans = 1;
|
|
1243
|
+
}
|
|
1244
|
+
`;
|
|
1245
|
+
var LOGS_PROTO = `
|
|
1246
|
+
syntax = "proto3";
|
|
1247
|
+
package opentelemetry.proto.logs.v1;
|
|
1248
|
+
|
|
1249
|
+
enum SeverityNumber {
|
|
1250
|
+
SEVERITY_NUMBER_UNSPECIFIED = 0;
|
|
1251
|
+
SEVERITY_NUMBER_TRACE = 1;
|
|
1252
|
+
SEVERITY_NUMBER_TRACE2 = 2;
|
|
1253
|
+
SEVERITY_NUMBER_TRACE3 = 3;
|
|
1254
|
+
SEVERITY_NUMBER_TRACE4 = 4;
|
|
1255
|
+
SEVERITY_NUMBER_DEBUG = 5;
|
|
1256
|
+
SEVERITY_NUMBER_DEBUG2 = 6;
|
|
1257
|
+
SEVERITY_NUMBER_DEBUG3 = 7;
|
|
1258
|
+
SEVERITY_NUMBER_DEBUG4 = 8;
|
|
1259
|
+
SEVERITY_NUMBER_INFO = 9;
|
|
1260
|
+
SEVERITY_NUMBER_INFO2 = 10;
|
|
1261
|
+
SEVERITY_NUMBER_INFO3 = 11;
|
|
1262
|
+
SEVERITY_NUMBER_INFO4 = 12;
|
|
1263
|
+
SEVERITY_NUMBER_WARN = 13;
|
|
1264
|
+
SEVERITY_NUMBER_WARN2 = 14;
|
|
1265
|
+
SEVERITY_NUMBER_WARN3 = 15;
|
|
1266
|
+
SEVERITY_NUMBER_WARN4 = 16;
|
|
1267
|
+
SEVERITY_NUMBER_ERROR = 17;
|
|
1268
|
+
SEVERITY_NUMBER_ERROR2 = 18;
|
|
1269
|
+
SEVERITY_NUMBER_ERROR3 = 19;
|
|
1270
|
+
SEVERITY_NUMBER_ERROR4 = 20;
|
|
1271
|
+
SEVERITY_NUMBER_FATAL = 21;
|
|
1272
|
+
SEVERITY_NUMBER_FATAL2 = 22;
|
|
1273
|
+
SEVERITY_NUMBER_FATAL3 = 23;
|
|
1274
|
+
SEVERITY_NUMBER_FATAL4 = 24;
|
|
1275
|
+
}
|
|
1276
|
+
message ResourceLogs {
|
|
1277
|
+
opentelemetry.proto.resource.v1.Resource resource = 1;
|
|
1278
|
+
repeated ScopeLogs scope_logs = 2;
|
|
1279
|
+
string schema_url = 3;
|
|
1280
|
+
}
|
|
1281
|
+
message ScopeLogs {
|
|
1282
|
+
opentelemetry.proto.common.v1.InstrumentationScope scope = 1;
|
|
1283
|
+
repeated LogRecord log_records = 2;
|
|
1284
|
+
string schema_url = 3;
|
|
1285
|
+
}
|
|
1286
|
+
message LogRecord {
|
|
1287
|
+
reserved 4;
|
|
1288
|
+
fixed64 time_unix_nano = 1;
|
|
1289
|
+
fixed64 observed_time_unix_nano = 11;
|
|
1290
|
+
SeverityNumber severity_number = 2;
|
|
1291
|
+
string severity_text = 3;
|
|
1292
|
+
opentelemetry.proto.common.v1.AnyValue body = 5;
|
|
1293
|
+
repeated opentelemetry.proto.common.v1.KeyValue attributes = 6;
|
|
1294
|
+
uint32 dropped_attributes_count = 7;
|
|
1295
|
+
fixed32 flags = 8;
|
|
1296
|
+
bytes trace_id = 9;
|
|
1297
|
+
bytes span_id = 10;
|
|
1298
|
+
}
|
|
1299
|
+
message ExportLogsServiceRequest {
|
|
1300
|
+
repeated ResourceLogs resource_logs = 1;
|
|
1301
|
+
}
|
|
1302
|
+
`;
|
|
1303
|
+
var METRICS_PROTO = `
|
|
1304
|
+
syntax = "proto3";
|
|
1305
|
+
package opentelemetry.proto.metrics.v1;
|
|
1306
|
+
|
|
1307
|
+
message ResourceMetrics {
|
|
1308
|
+
opentelemetry.proto.resource.v1.Resource resource = 1;
|
|
1309
|
+
repeated ScopeMetrics scope_metrics = 2;
|
|
1310
|
+
string schema_url = 3;
|
|
1311
|
+
}
|
|
1312
|
+
message ScopeMetrics {
|
|
1313
|
+
opentelemetry.proto.common.v1.InstrumentationScope scope = 1;
|
|
1314
|
+
repeated Metric metrics = 2;
|
|
1315
|
+
string schema_url = 3;
|
|
1316
|
+
}
|
|
1317
|
+
message Metric {
|
|
1318
|
+
string name = 1;
|
|
1319
|
+
string description = 2;
|
|
1320
|
+
string unit = 3;
|
|
1321
|
+
}
|
|
1322
|
+
message ExportMetricsServiceRequest {
|
|
1323
|
+
repeated ResourceMetrics resource_metrics = 1;
|
|
1324
|
+
}
|
|
1325
|
+
`;
|
|
1326
|
+
var TO_OBJECT_OPTIONS = {
|
|
1327
|
+
longs: String,
|
|
1328
|
+
bytes: String,
|
|
1329
|
+
defaults: false
|
|
1330
|
+
};
|
|
1331
|
+
var cachedRoot = null;
|
|
1332
|
+
function getRoot() {
|
|
1333
|
+
if (cachedRoot) return cachedRoot;
|
|
1334
|
+
const root = new protobuf.Root();
|
|
1335
|
+
for (const source of [COMMON_PROTO, RESOURCE_PROTO, TRACE_PROTO, LOGS_PROTO, METRICS_PROTO]) {
|
|
1336
|
+
protobuf.parse(source, root, { keepCase: false });
|
|
1337
|
+
}
|
|
1338
|
+
root.resolveAll();
|
|
1339
|
+
cachedRoot = root;
|
|
1340
|
+
return root;
|
|
1341
|
+
}
|
|
1342
|
+
function decodeRequest(typeName, body) {
|
|
1343
|
+
const messageType = getRoot().lookupType(typeName);
|
|
1344
|
+
const message = messageType.decode(body);
|
|
1345
|
+
return messageType.toObject(message, TO_OBJECT_OPTIONS);
|
|
1346
|
+
}
|
|
1347
|
+
function decodeOtlpTraceRequest(body) {
|
|
1348
|
+
return decodeRequest("opentelemetry.proto.trace.v1.ExportTraceServiceRequest", body);
|
|
1349
|
+
}
|
|
1350
|
+
function decodeOtlpLogsRequest(body) {
|
|
1351
|
+
return decodeRequest("opentelemetry.proto.logs.v1.ExportLogsServiceRequest", body);
|
|
1352
|
+
}
|
|
1353
|
+
function decodeOtlpMetricsRequest(body) {
|
|
1354
|
+
return decodeRequest("opentelemetry.proto.metrics.v1.ExportMetricsServiceRequest", body);
|
|
1355
|
+
}
|
|
1124
1356
|
|
|
1125
1357
|
// src/server/http.ts
|
|
1358
|
+
var PROTOBUF_DECODERS = {
|
|
1359
|
+
traces: decodeOtlpTraceRequest,
|
|
1360
|
+
logs: decodeOtlpLogsRequest,
|
|
1361
|
+
metrics: decodeOtlpMetricsRequest
|
|
1362
|
+
};
|
|
1363
|
+
async function readOtlpPayload(req, signal) {
|
|
1364
|
+
if (isProtobufContentType(req.headers["content-type"])) {
|
|
1365
|
+
return PROTOBUF_DECODERS[signal](await readRawBody(req));
|
|
1366
|
+
}
|
|
1367
|
+
return readJsonBody(req);
|
|
1368
|
+
}
|
|
1126
1369
|
function findPackageRoot() {
|
|
1127
1370
|
let dir = dirname(fileURLToPath(import.meta.url));
|
|
1128
1371
|
for (let i = 0; i < 5; i++) {
|
|
@@ -1191,33 +1434,33 @@ function attachDevtoolsRoutes(httpServer, devtools) {
|
|
|
1191
1434
|
}
|
|
1192
1435
|
if (req.method === "POST" && url === "/v1/traces") {
|
|
1193
1436
|
try {
|
|
1194
|
-
const payload = await
|
|
1437
|
+
const payload = await readOtlpPayload(req, "traces");
|
|
1195
1438
|
const traces = parseOtlpTraces(payload);
|
|
1196
1439
|
devtools.addTraces(traces);
|
|
1197
1440
|
sendJson(res, 200, { acceptedTraces: traces.length });
|
|
1198
1441
|
} catch (e) {
|
|
1199
|
-
sendJson(res, 400, { error: "Invalid OTLP
|
|
1442
|
+
sendJson(res, 400, { error: "Invalid OTLP payload", message: e instanceof Error ? e.message : String(e) });
|
|
1200
1443
|
}
|
|
1201
1444
|
return;
|
|
1202
1445
|
}
|
|
1203
1446
|
if (req.method === "POST" && url === "/v1/logs") {
|
|
1204
1447
|
try {
|
|
1205
|
-
const payload = await
|
|
1448
|
+
const payload = await readOtlpPayload(req, "logs");
|
|
1206
1449
|
const logs = parseOtlpLogs(payload);
|
|
1207
1450
|
devtools.addLogs(logs);
|
|
1208
1451
|
sendJson(res, 200, { acceptedLogs: logs.length });
|
|
1209
1452
|
} catch (e) {
|
|
1210
|
-
sendJson(res, 400, { error: "Invalid OTLP
|
|
1453
|
+
sendJson(res, 400, { error: "Invalid OTLP payload", message: e instanceof Error ? e.message : String(e) });
|
|
1211
1454
|
}
|
|
1212
1455
|
return;
|
|
1213
1456
|
}
|
|
1214
1457
|
if (req.method === "POST" && url === "/v1/metrics") {
|
|
1215
1458
|
try {
|
|
1216
|
-
const payload = await
|
|
1459
|
+
const payload = await readOtlpPayload(req, "metrics");
|
|
1217
1460
|
const count = countOtlpMetrics(payload);
|
|
1218
1461
|
sendJson(res, 200, { acceptedMetrics: count });
|
|
1219
1462
|
} catch (e) {
|
|
1220
|
-
sendJson(res, 400, { error: "Invalid OTLP
|
|
1463
|
+
sendJson(res, 400, { error: "Invalid OTLP payload", message: e instanceof Error ? e.message : String(e) });
|
|
1221
1464
|
}
|
|
1222
1465
|
return;
|
|
1223
1466
|
}
|
|
@@ -1230,6 +1473,6 @@ function createDevtoolsHttpServer(devtools, _options = {}) {
|
|
|
1230
1473
|
return server;
|
|
1231
1474
|
}
|
|
1232
1475
|
|
|
1233
|
-
export { DevtoolsLogExporter, DevtoolsRemoteExporter, DevtoolsServer, DevtoolsSpanExporter, ErrorAggregator, appendManyWithLimit, appendWithLimit, applyTelemetryLimits, attachDevtoolsRoutes, createDevtoolsHttpServer, parseOtlpLogs, parseOtlpTraces, resolveTelemetryLimits };
|
|
1476
|
+
export { DevtoolsLogExporter, DevtoolsRemoteExporter, DevtoolsServer, DevtoolsSpanExporter, ErrorAggregator, appendManyWithLimit, appendWithLimit, applyTelemetryLimits, attachDevtoolsRoutes, createDevtoolsHttpServer, decodeOtlpLogsRequest, decodeOtlpMetricsRequest, decodeOtlpTraceRequest, isProtobufContentType, parseOtlpLogs, parseOtlpTraces, resolveTelemetryLimits };
|
|
1234
1477
|
//# sourceMappingURL=index.js.map
|
|
1235
1478
|
//# sourceMappingURL=index.js.map
|