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/README.md
CHANGED
|
@@ -16,9 +16,9 @@ Standalone OTLP receiver with web UI for local development. Think TanStack Devto
|
|
|
16
16
|
│ npx autotel-devtools │
|
|
17
17
|
│ ┌───────────────────────────────────────┐ │
|
|
18
18
|
│ │ HTTP Server (port 4318) │ │
|
|
19
|
-
│ │ ├── POST /v1/traces ← OTLP JSON
|
|
20
|
-
│ │ ├── POST /v1/logs ← OTLP JSON
|
|
21
|
-
│ │ ├── POST /v1/metrics ← OTLP JSON
|
|
19
|
+
│ │ ├── POST /v1/traces ← OTLP JSON/PB │ │
|
|
20
|
+
│ │ ├── POST /v1/logs ← OTLP JSON/PB │ │
|
|
21
|
+
│ │ ├── POST /v1/metrics ← OTLP JSON/PB │ │
|
|
22
22
|
│ │ ├── GET / → Full page UI │ │
|
|
23
23
|
│ │ ├── GET /widget.js → Widget bundle │ │
|
|
24
24
|
│ │ ├── GET /healthz → Health check │ │
|
|
@@ -41,6 +41,16 @@ OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \
|
|
|
41
41
|
node app.js
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
The endpoints accept **both OTLP/JSON and OTLP/protobuf** (`application/x-protobuf`),
|
|
45
|
+
selected automatically from the request `Content-Type`. That means SDKs that default
|
|
46
|
+
to protobuf over OTLP HTTP — including the Python, Java, and Go OpenTelemetry SDKs —
|
|
47
|
+
work without any extra configuration:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Python / Java / Go SDKs default to http/protobuf — just point them at the receiver
|
|
51
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 python app.py
|
|
52
|
+
```
|
|
53
|
+
|
|
44
54
|
Open http://localhost:4318 to see traces, logs, and metrics.
|
|
45
55
|
|
|
46
56
|
### Embedded Widget
|
|
@@ -100,7 +110,7 @@ const myFunction = trace((ctx) => async () => {
|
|
|
100
110
|
### Server (Node.js)
|
|
101
111
|
|
|
102
112
|
- **DevtoolsServer** - WebSocket server + in-memory data store
|
|
103
|
-
- **HTTP Routes** - OTLP receivers for traces/logs/metrics
|
|
113
|
+
- **HTTP Routes** - OTLP receivers for traces/logs/metrics (JSON + protobuf)
|
|
104
114
|
- **Exporters** - OpenTelemetry span/log exporters
|
|
105
115
|
|
|
106
116
|
### Widget (Preact)
|
package/dist/cli.cjs
CHANGED
|
@@ -6,8 +6,29 @@ var fs = require('fs');
|
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var url = require('url');
|
|
8
8
|
var ws = require('ws');
|
|
9
|
+
var protobuf = require('protobufjs');
|
|
9
10
|
|
|
10
11
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n.default = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var protobuf__namespace = /*#__PURE__*/_interopNamespace(protobuf);
|
|
31
|
+
|
|
11
32
|
// src/server/error-aggregator.ts
|
|
12
33
|
var ErrorAggregator = class {
|
|
13
34
|
errorGroups = /* @__PURE__ */ new Map();
|
|
@@ -528,7 +549,7 @@ var SPAN_KIND_MAP = {
|
|
|
528
549
|
function normalizeHexId(id) {
|
|
529
550
|
if (!id) return "";
|
|
530
551
|
const isBase64Like = /^[A-Za-z0-9+/=]+$/.test(id) && !/^[0-9a-f]+$/i.test(id);
|
|
531
|
-
const isLikelyBase64Id = isBase64Like && (id.length === 24 || id.length === 28 || id.length === 44 || id.length === 48);
|
|
552
|
+
const isLikelyBase64Id = isBase64Like && (id.length === 12 || id.length === 24 || id.length === 28 || id.length === 44 || id.length === 48);
|
|
532
553
|
if (isLikelyBase64Id) {
|
|
533
554
|
try {
|
|
534
555
|
const bytes = Buffer.from(id, "base64");
|
|
@@ -660,13 +681,255 @@ async function readJsonBody(req) {
|
|
|
660
681
|
req.on("error", reject);
|
|
661
682
|
});
|
|
662
683
|
}
|
|
684
|
+
async function readRawBody(req) {
|
|
685
|
+
return new Promise((resolve3, reject) => {
|
|
686
|
+
const chunks = [];
|
|
687
|
+
req.on("data", (chunk) => chunks.push(chunk));
|
|
688
|
+
req.on("end", () => resolve3(Buffer.concat(chunks)));
|
|
689
|
+
req.on("error", reject);
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
function isProtobufContentType(contentType) {
|
|
693
|
+
if (!contentType) return false;
|
|
694
|
+
const value = contentType.toLowerCase();
|
|
695
|
+
return value.includes("application/x-protobuf") || value.includes("application/protobuf");
|
|
696
|
+
}
|
|
663
697
|
function sendJson(res, status, data) {
|
|
664
698
|
const body = JSON.stringify(data);
|
|
665
699
|
res.writeHead(status, { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(body) });
|
|
666
700
|
res.end(body);
|
|
667
701
|
}
|
|
702
|
+
var COMMON_PROTO = `
|
|
703
|
+
syntax = "proto3";
|
|
704
|
+
package opentelemetry.proto.common.v1;
|
|
705
|
+
|
|
706
|
+
message AnyValue {
|
|
707
|
+
oneof value {
|
|
708
|
+
string string_value = 1;
|
|
709
|
+
bool bool_value = 2;
|
|
710
|
+
int64 int_value = 3;
|
|
711
|
+
double double_value = 4;
|
|
712
|
+
ArrayValue array_value = 5;
|
|
713
|
+
KeyValueList kvlist_value = 6;
|
|
714
|
+
bytes bytes_value = 7;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
message ArrayValue { repeated AnyValue values = 1; }
|
|
718
|
+
message KeyValueList { repeated KeyValue values = 1; }
|
|
719
|
+
message KeyValue {
|
|
720
|
+
string key = 1;
|
|
721
|
+
AnyValue value = 2;
|
|
722
|
+
}
|
|
723
|
+
message InstrumentationScope {
|
|
724
|
+
string name = 1;
|
|
725
|
+
string version = 2;
|
|
726
|
+
repeated KeyValue attributes = 3;
|
|
727
|
+
uint32 dropped_attributes_count = 4;
|
|
728
|
+
}
|
|
729
|
+
`;
|
|
730
|
+
var RESOURCE_PROTO = `
|
|
731
|
+
syntax = "proto3";
|
|
732
|
+
package opentelemetry.proto.resource.v1;
|
|
733
|
+
|
|
734
|
+
message Resource {
|
|
735
|
+
repeated opentelemetry.proto.common.v1.KeyValue attributes = 1;
|
|
736
|
+
uint32 dropped_attributes_count = 2;
|
|
737
|
+
}
|
|
738
|
+
`;
|
|
739
|
+
var TRACE_PROTO = `
|
|
740
|
+
syntax = "proto3";
|
|
741
|
+
package opentelemetry.proto.trace.v1;
|
|
742
|
+
|
|
743
|
+
message ResourceSpans {
|
|
744
|
+
opentelemetry.proto.resource.v1.Resource resource = 1;
|
|
745
|
+
repeated ScopeSpans scope_spans = 2;
|
|
746
|
+
string schema_url = 3;
|
|
747
|
+
}
|
|
748
|
+
message ScopeSpans {
|
|
749
|
+
opentelemetry.proto.common.v1.InstrumentationScope scope = 1;
|
|
750
|
+
repeated Span spans = 2;
|
|
751
|
+
string schema_url = 3;
|
|
752
|
+
}
|
|
753
|
+
message Span {
|
|
754
|
+
bytes trace_id = 1;
|
|
755
|
+
bytes span_id = 2;
|
|
756
|
+
string trace_state = 3;
|
|
757
|
+
bytes parent_span_id = 4;
|
|
758
|
+
fixed32 flags = 16;
|
|
759
|
+
string name = 5;
|
|
760
|
+
SpanKind kind = 6;
|
|
761
|
+
fixed64 start_time_unix_nano = 7;
|
|
762
|
+
fixed64 end_time_unix_nano = 8;
|
|
763
|
+
repeated opentelemetry.proto.common.v1.KeyValue attributes = 9;
|
|
764
|
+
uint32 dropped_attributes_count = 10;
|
|
765
|
+
repeated Event events = 11;
|
|
766
|
+
uint32 dropped_events_count = 12;
|
|
767
|
+
repeated Link links = 13;
|
|
768
|
+
uint32 dropped_links_count = 14;
|
|
769
|
+
Status status = 15;
|
|
770
|
+
|
|
771
|
+
enum SpanKind {
|
|
772
|
+
SPAN_KIND_UNSPECIFIED = 0;
|
|
773
|
+
SPAN_KIND_INTERNAL = 1;
|
|
774
|
+
SPAN_KIND_SERVER = 2;
|
|
775
|
+
SPAN_KIND_CLIENT = 3;
|
|
776
|
+
SPAN_KIND_PRODUCER = 4;
|
|
777
|
+
SPAN_KIND_CONSUMER = 5;
|
|
778
|
+
}
|
|
779
|
+
message Event {
|
|
780
|
+
fixed64 time_unix_nano = 1;
|
|
781
|
+
string name = 2;
|
|
782
|
+
repeated opentelemetry.proto.common.v1.KeyValue attributes = 3;
|
|
783
|
+
uint32 dropped_attributes_count = 4;
|
|
784
|
+
}
|
|
785
|
+
message Link {
|
|
786
|
+
bytes trace_id = 1;
|
|
787
|
+
bytes span_id = 2;
|
|
788
|
+
string trace_state = 3;
|
|
789
|
+
repeated opentelemetry.proto.common.v1.KeyValue attributes = 4;
|
|
790
|
+
uint32 dropped_attributes_count = 5;
|
|
791
|
+
fixed32 flags = 6;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
message Status {
|
|
795
|
+
reserved 1;
|
|
796
|
+
string message = 2;
|
|
797
|
+
StatusCode code = 3;
|
|
798
|
+
|
|
799
|
+
enum StatusCode {
|
|
800
|
+
STATUS_CODE_UNSET = 0;
|
|
801
|
+
STATUS_CODE_OK = 1;
|
|
802
|
+
STATUS_CODE_ERROR = 2;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
message ExportTraceServiceRequest {
|
|
806
|
+
repeated ResourceSpans resource_spans = 1;
|
|
807
|
+
}
|
|
808
|
+
`;
|
|
809
|
+
var LOGS_PROTO = `
|
|
810
|
+
syntax = "proto3";
|
|
811
|
+
package opentelemetry.proto.logs.v1;
|
|
812
|
+
|
|
813
|
+
enum SeverityNumber {
|
|
814
|
+
SEVERITY_NUMBER_UNSPECIFIED = 0;
|
|
815
|
+
SEVERITY_NUMBER_TRACE = 1;
|
|
816
|
+
SEVERITY_NUMBER_TRACE2 = 2;
|
|
817
|
+
SEVERITY_NUMBER_TRACE3 = 3;
|
|
818
|
+
SEVERITY_NUMBER_TRACE4 = 4;
|
|
819
|
+
SEVERITY_NUMBER_DEBUG = 5;
|
|
820
|
+
SEVERITY_NUMBER_DEBUG2 = 6;
|
|
821
|
+
SEVERITY_NUMBER_DEBUG3 = 7;
|
|
822
|
+
SEVERITY_NUMBER_DEBUG4 = 8;
|
|
823
|
+
SEVERITY_NUMBER_INFO = 9;
|
|
824
|
+
SEVERITY_NUMBER_INFO2 = 10;
|
|
825
|
+
SEVERITY_NUMBER_INFO3 = 11;
|
|
826
|
+
SEVERITY_NUMBER_INFO4 = 12;
|
|
827
|
+
SEVERITY_NUMBER_WARN = 13;
|
|
828
|
+
SEVERITY_NUMBER_WARN2 = 14;
|
|
829
|
+
SEVERITY_NUMBER_WARN3 = 15;
|
|
830
|
+
SEVERITY_NUMBER_WARN4 = 16;
|
|
831
|
+
SEVERITY_NUMBER_ERROR = 17;
|
|
832
|
+
SEVERITY_NUMBER_ERROR2 = 18;
|
|
833
|
+
SEVERITY_NUMBER_ERROR3 = 19;
|
|
834
|
+
SEVERITY_NUMBER_ERROR4 = 20;
|
|
835
|
+
SEVERITY_NUMBER_FATAL = 21;
|
|
836
|
+
SEVERITY_NUMBER_FATAL2 = 22;
|
|
837
|
+
SEVERITY_NUMBER_FATAL3 = 23;
|
|
838
|
+
SEVERITY_NUMBER_FATAL4 = 24;
|
|
839
|
+
}
|
|
840
|
+
message ResourceLogs {
|
|
841
|
+
opentelemetry.proto.resource.v1.Resource resource = 1;
|
|
842
|
+
repeated ScopeLogs scope_logs = 2;
|
|
843
|
+
string schema_url = 3;
|
|
844
|
+
}
|
|
845
|
+
message ScopeLogs {
|
|
846
|
+
opentelemetry.proto.common.v1.InstrumentationScope scope = 1;
|
|
847
|
+
repeated LogRecord log_records = 2;
|
|
848
|
+
string schema_url = 3;
|
|
849
|
+
}
|
|
850
|
+
message LogRecord {
|
|
851
|
+
reserved 4;
|
|
852
|
+
fixed64 time_unix_nano = 1;
|
|
853
|
+
fixed64 observed_time_unix_nano = 11;
|
|
854
|
+
SeverityNumber severity_number = 2;
|
|
855
|
+
string severity_text = 3;
|
|
856
|
+
opentelemetry.proto.common.v1.AnyValue body = 5;
|
|
857
|
+
repeated opentelemetry.proto.common.v1.KeyValue attributes = 6;
|
|
858
|
+
uint32 dropped_attributes_count = 7;
|
|
859
|
+
fixed32 flags = 8;
|
|
860
|
+
bytes trace_id = 9;
|
|
861
|
+
bytes span_id = 10;
|
|
862
|
+
}
|
|
863
|
+
message ExportLogsServiceRequest {
|
|
864
|
+
repeated ResourceLogs resource_logs = 1;
|
|
865
|
+
}
|
|
866
|
+
`;
|
|
867
|
+
var METRICS_PROTO = `
|
|
868
|
+
syntax = "proto3";
|
|
869
|
+
package opentelemetry.proto.metrics.v1;
|
|
870
|
+
|
|
871
|
+
message ResourceMetrics {
|
|
872
|
+
opentelemetry.proto.resource.v1.Resource resource = 1;
|
|
873
|
+
repeated ScopeMetrics scope_metrics = 2;
|
|
874
|
+
string schema_url = 3;
|
|
875
|
+
}
|
|
876
|
+
message ScopeMetrics {
|
|
877
|
+
opentelemetry.proto.common.v1.InstrumentationScope scope = 1;
|
|
878
|
+
repeated Metric metrics = 2;
|
|
879
|
+
string schema_url = 3;
|
|
880
|
+
}
|
|
881
|
+
message Metric {
|
|
882
|
+
string name = 1;
|
|
883
|
+
string description = 2;
|
|
884
|
+
string unit = 3;
|
|
885
|
+
}
|
|
886
|
+
message ExportMetricsServiceRequest {
|
|
887
|
+
repeated ResourceMetrics resource_metrics = 1;
|
|
888
|
+
}
|
|
889
|
+
`;
|
|
890
|
+
var TO_OBJECT_OPTIONS = {
|
|
891
|
+
longs: String,
|
|
892
|
+
bytes: String,
|
|
893
|
+
defaults: false
|
|
894
|
+
};
|
|
895
|
+
var cachedRoot = null;
|
|
896
|
+
function getRoot() {
|
|
897
|
+
if (cachedRoot) return cachedRoot;
|
|
898
|
+
const root = new protobuf__namespace.Root();
|
|
899
|
+
for (const source of [COMMON_PROTO, RESOURCE_PROTO, TRACE_PROTO, LOGS_PROTO, METRICS_PROTO]) {
|
|
900
|
+
protobuf__namespace.parse(source, root, { keepCase: false });
|
|
901
|
+
}
|
|
902
|
+
root.resolveAll();
|
|
903
|
+
cachedRoot = root;
|
|
904
|
+
return root;
|
|
905
|
+
}
|
|
906
|
+
function decodeRequest(typeName, body) {
|
|
907
|
+
const messageType = getRoot().lookupType(typeName);
|
|
908
|
+
const message = messageType.decode(body);
|
|
909
|
+
return messageType.toObject(message, TO_OBJECT_OPTIONS);
|
|
910
|
+
}
|
|
911
|
+
function decodeOtlpTraceRequest(body) {
|
|
912
|
+
return decodeRequest("opentelemetry.proto.trace.v1.ExportTraceServiceRequest", body);
|
|
913
|
+
}
|
|
914
|
+
function decodeOtlpLogsRequest(body) {
|
|
915
|
+
return decodeRequest("opentelemetry.proto.logs.v1.ExportLogsServiceRequest", body);
|
|
916
|
+
}
|
|
917
|
+
function decodeOtlpMetricsRequest(body) {
|
|
918
|
+
return decodeRequest("opentelemetry.proto.metrics.v1.ExportMetricsServiceRequest", body);
|
|
919
|
+
}
|
|
668
920
|
|
|
669
921
|
// src/server/http.ts
|
|
922
|
+
var PROTOBUF_DECODERS = {
|
|
923
|
+
traces: decodeOtlpTraceRequest,
|
|
924
|
+
logs: decodeOtlpLogsRequest,
|
|
925
|
+
metrics: decodeOtlpMetricsRequest
|
|
926
|
+
};
|
|
927
|
+
async function readOtlpPayload(req, signal) {
|
|
928
|
+
if (isProtobufContentType(req.headers["content-type"])) {
|
|
929
|
+
return PROTOBUF_DECODERS[signal](await readRawBody(req));
|
|
930
|
+
}
|
|
931
|
+
return readJsonBody(req);
|
|
932
|
+
}
|
|
670
933
|
function findPackageRoot() {
|
|
671
934
|
let dir = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))));
|
|
672
935
|
for (let i = 0; i < 5; i++) {
|
|
@@ -735,33 +998,33 @@ function attachDevtoolsRoutes(httpServer, devtools) {
|
|
|
735
998
|
}
|
|
736
999
|
if (req.method === "POST" && url === "/v1/traces") {
|
|
737
1000
|
try {
|
|
738
|
-
const payload = await
|
|
1001
|
+
const payload = await readOtlpPayload(req, "traces");
|
|
739
1002
|
const traces = parseOtlpTraces(payload);
|
|
740
1003
|
devtools.addTraces(traces);
|
|
741
1004
|
sendJson(res, 200, { acceptedTraces: traces.length });
|
|
742
1005
|
} catch (e) {
|
|
743
|
-
sendJson(res, 400, { error: "Invalid OTLP
|
|
1006
|
+
sendJson(res, 400, { error: "Invalid OTLP payload", message: e instanceof Error ? e.message : String(e) });
|
|
744
1007
|
}
|
|
745
1008
|
return;
|
|
746
1009
|
}
|
|
747
1010
|
if (req.method === "POST" && url === "/v1/logs") {
|
|
748
1011
|
try {
|
|
749
|
-
const payload = await
|
|
1012
|
+
const payload = await readOtlpPayload(req, "logs");
|
|
750
1013
|
const logs = parseOtlpLogs(payload);
|
|
751
1014
|
devtools.addLogs(logs);
|
|
752
1015
|
sendJson(res, 200, { acceptedLogs: logs.length });
|
|
753
1016
|
} catch (e) {
|
|
754
|
-
sendJson(res, 400, { error: "Invalid OTLP
|
|
1017
|
+
sendJson(res, 400, { error: "Invalid OTLP payload", message: e instanceof Error ? e.message : String(e) });
|
|
755
1018
|
}
|
|
756
1019
|
return;
|
|
757
1020
|
}
|
|
758
1021
|
if (req.method === "POST" && url === "/v1/metrics") {
|
|
759
1022
|
try {
|
|
760
|
-
const payload = await
|
|
1023
|
+
const payload = await readOtlpPayload(req, "metrics");
|
|
761
1024
|
const count = countOtlpMetrics(payload);
|
|
762
1025
|
sendJson(res, 200, { acceptedMetrics: count });
|
|
763
1026
|
} catch (e) {
|
|
764
|
-
sendJson(res, 400, { error: "Invalid OTLP
|
|
1027
|
+
sendJson(res, 400, { error: "Invalid OTLP payload", message: e instanceof Error ? e.message : String(e) });
|
|
765
1028
|
}
|
|
766
1029
|
return;
|
|
767
1030
|
}
|