@monocle.sh/studio 0.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/LICENSE +15 -0
- package/dist/adonisrc.d.ts +6 -0
- package/dist/adonisrc.js +25 -0
- package/dist/config/app.d.ts +6 -0
- package/dist/config/app.js +5 -0
- package/dist/config/bodyparser.d.ts +4 -0
- package/dist/config/bodyparser.js +5 -0
- package/dist/config/encryption.d.ts +12 -0
- package/dist/config/encryption.js +11 -0
- package/dist/config/logger.d.ts +4 -0
- package/dist/config/logger.js +13 -0
- package/dist/config/static.d.ts +6 -0
- package/dist/config/static.js +11 -0
- package/dist/controllers/api_controller.d.ts +174 -0
- package/dist/controllers/api_controller.js +118 -0
- package/dist/controllers/mcp_controller.d.ts +20 -0
- package/dist/controllers/mcp_controller.js +29 -0
- package/dist/controllers/otlp_controller.d.ts +52 -0
- package/dist/controllers/otlp_controller.js +92 -0
- package/dist/controllers/sse_controller.d.ts +18 -0
- package/dist/controllers/sse_controller.js +36 -0
- package/dist/db/connection.d.ts +20 -0
- package/dist/db/connection.js +38 -0
- package/dist/db/schema.d.ts +10 -0
- package/dist/db/schema.js +45 -0
- package/dist/db/types.d.ts +40 -0
- package/dist/db/types.js +1 -0
- package/dist/mcp/define_tool.d.ts +10 -0
- package/dist/mcp/define_tool.js +9 -0
- package/dist/mcp/tools/clear_data.d.ts +9 -0
- package/dist/mcp/tools/clear_data.js +26 -0
- package/dist/mcp/tools/get_trace.d.ts +12 -0
- package/dist/mcp/tools/get_trace.js +25 -0
- package/dist/mcp/tools/index.d.ts +10 -0
- package/dist/mcp/tools/index.js +37 -0
- package/dist/mcp/tools/list_errors.d.ts +14 -0
- package/dist/mcp/tools/list_errors.js +25 -0
- package/dist/mcp/tools/list_logs.d.ts +16 -0
- package/dist/mcp/tools/list_logs.js +30 -0
- package/dist/mcp/tools/list_queries.d.ts +15 -0
- package/dist/mcp/tools/list_queries.js +27 -0
- package/dist/mcp/tools/list_traces.d.ts +14 -0
- package/dist/mcp/tools/list_traces.js +25 -0
- package/dist/mcp/types.d.ts +21 -0
- package/dist/mcp/types.js +1 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +2 -0
- package/dist/providers/api_provider.d.ts +14 -0
- package/dist/providers/api_provider.js +13 -0
- package/dist/repositories/log_repository.d.ts +43 -0
- package/dist/repositories/log_repository.js +58 -0
- package/dist/repositories/span_repository.d.ts +136 -0
- package/dist/repositories/span_repository.js +254 -0
- package/dist/semconv.d.ts +38 -0
- package/dist/semconv.js +40 -0
- package/dist/server.d.ts +16 -0
- package/dist/server.js +68 -0
- package/dist/services/event_bus.d.ts +24 -0
- package/dist/services/event_bus.js +24 -0
- package/dist/services/otlp_parser.d.ts +21 -0
- package/dist/services/otlp_parser.js +121 -0
- package/dist/start/kernel.d.ts +1 -0
- package/dist/start/kernel.js +5 -0
- package/dist/start/routes.d.ts +1 -0
- package/dist/start/routes.js +35 -0
- package/dist/transformers/command_transformer.d.ts +18 -0
- package/dist/transformers/command_transformer.js +20 -0
- package/dist/transformers/exception_transformer.d.ts +17 -0
- package/dist/transformers/exception_transformer.js +19 -0
- package/dist/transformers/job_transformer.d.ts +18 -0
- package/dist/transformers/job_transformer.js +20 -0
- package/dist/transformers/log_transformer.d.ts +18 -0
- package/dist/transformers/log_transformer.js +19 -0
- package/dist/transformers/query_transformer.d.ts +20 -0
- package/dist/transformers/query_transformer.js +27 -0
- package/dist/transformers/span_transformer.d.ts +22 -0
- package/dist/transformers/span_transformer.js +23 -0
- package/dist/transformers/trace_transformer.d.ts +22 -0
- package/dist/transformers/trace_transformer.js +33 -0
- package/dist/types/logs.d.ts +19 -0
- package/dist/types/logs.js +1 -0
- package/dist/types/otlp.d.ts +105 -0
- package/dist/types/otlp.js +1 -0
- package/dist/types/spans.d.ts +29 -0
- package/dist/types/spans.js +1 -0
- package/dist/validators.d.ts +103 -0
- package/dist/validators.js +41 -0
- package/package.json +60 -0
- package/ui/dist/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
- package/ui/dist/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
- package/ui/dist/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
- package/ui/dist/assets/index-Bfk6GRvP.css +1 -0
- package/ui/dist/assets/index-XOaGlb1r.js +115 -0
- package/ui/dist/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/ui/dist/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/ui/dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/ui/dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/ui/dist/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/ui/dist/assets/silkscreen-latin-400-normal-CtPo2yA5.woff2 +0 -0
- package/ui/dist/assets/silkscreen-latin-400-normal-D0DfPJut.woff +0 -0
- package/ui/dist/favicon.svg +4 -0
- package/ui/dist/index.html +14 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
//#region src/services/otlp_parser.ts
|
|
2
|
+
const SPAN_KIND_MAP = {
|
|
3
|
+
0: "UNSPECIFIED",
|
|
4
|
+
1: "INTERNAL",
|
|
5
|
+
2: "SERVER",
|
|
6
|
+
3: "CLIENT",
|
|
7
|
+
4: "PRODUCER",
|
|
8
|
+
5: "CONSUMER"
|
|
9
|
+
};
|
|
10
|
+
const STATUS_CODE_MAP = {
|
|
11
|
+
0: "UNSET",
|
|
12
|
+
1: "OK",
|
|
13
|
+
2: "ERROR"
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Recursively extracts a typed value from an OTLP AnyValue union.
|
|
17
|
+
*/
|
|
18
|
+
function extractValue(value) {
|
|
19
|
+
if (value.stringValue !== void 0) return value.stringValue;
|
|
20
|
+
if (value.intValue !== void 0) return Number(value.intValue);
|
|
21
|
+
if (value.doubleValue !== void 0) return value.doubleValue;
|
|
22
|
+
if (value.boolValue !== void 0) return value.boolValue;
|
|
23
|
+
if (value.arrayValue) return value.arrayValue.values.map(extractValue);
|
|
24
|
+
if (value.kvlistValue) return flattenAttributes(value.kvlistValue.values);
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Flattens an array of OTLP key-value attributes into a plain object.
|
|
29
|
+
*/
|
|
30
|
+
function flattenAttributes(attrs) {
|
|
31
|
+
if (!attrs?.length) return {};
|
|
32
|
+
const result = {};
|
|
33
|
+
for (const attr of attrs) result[attr.key] = extractValue(attr.value);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Extracts the service.name from a resource's attribute list.
|
|
38
|
+
*/
|
|
39
|
+
function findServiceName(attrs) {
|
|
40
|
+
if (!attrs) return null;
|
|
41
|
+
return attrs.find((a) => a.key === "service.name")?.value?.stringValue ?? null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Converts an OTLP trace export request into flat span models
|
|
45
|
+
* ready for DuckDB insertion.
|
|
46
|
+
*/
|
|
47
|
+
function parseTraceRequest(body) {
|
|
48
|
+
const spans = [];
|
|
49
|
+
for (const resourceSpan of body.resourceSpans ?? []) {
|
|
50
|
+
const resourceAttrs = flattenAttributes(resourceSpan.resource?.attributes);
|
|
51
|
+
const serviceName = findServiceName(resourceSpan.resource?.attributes);
|
|
52
|
+
for (const scopeSpan of resourceSpan.scopeSpans ?? []) {
|
|
53
|
+
const scopeName = scopeSpan.scope?.name ?? null;
|
|
54
|
+
const scopeVersion = scopeSpan.scope?.version ?? null;
|
|
55
|
+
for (const span of scopeSpan.spans ?? []) {
|
|
56
|
+
const startTimeUnix = BigInt(span.startTimeUnixNano);
|
|
57
|
+
const endTimeUnix = BigInt(span.endTimeUnixNano);
|
|
58
|
+
const events = span.events?.length ? span.events.map((e) => ({
|
|
59
|
+
name: e.name,
|
|
60
|
+
timeUnixNano: e.timeUnixNano ?? "0",
|
|
61
|
+
attributes: flattenAttributes(e.attributes)
|
|
62
|
+
})) : null;
|
|
63
|
+
spans.push({
|
|
64
|
+
traceId: span.traceId,
|
|
65
|
+
spanId: span.spanId,
|
|
66
|
+
parentSpanId: span.parentSpanId || null,
|
|
67
|
+
spanName: span.name,
|
|
68
|
+
spanKind: SPAN_KIND_MAP[span.kind ?? 0] ?? "UNSPECIFIED",
|
|
69
|
+
serviceName,
|
|
70
|
+
statusCode: STATUS_CODE_MAP[span.status?.code ?? 0] ?? "UNSET",
|
|
71
|
+
statusMessage: span.status?.message ?? null,
|
|
72
|
+
startTimeUnix,
|
|
73
|
+
endTimeUnix,
|
|
74
|
+
durationNs: endTimeUnix - startTimeUnix,
|
|
75
|
+
resourceAttributes: Object.keys(resourceAttrs).length ? resourceAttrs : null,
|
|
76
|
+
spanAttributes: span.attributes?.length ? flattenAttributes(span.attributes) : null,
|
|
77
|
+
scopeName,
|
|
78
|
+
scopeVersion,
|
|
79
|
+
events
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return spans;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Converts an OTLP log export request into flat log models
|
|
88
|
+
* ready for DuckDB insertion.
|
|
89
|
+
*/
|
|
90
|
+
function parseLogRequest(body) {
|
|
91
|
+
const logs = [];
|
|
92
|
+
for (const resourceLog of body.resourceLogs ?? []) {
|
|
93
|
+
const resourceAttrs = flattenAttributes(resourceLog.resource?.attributes);
|
|
94
|
+
const serviceName = findServiceName(resourceLog.resource?.attributes);
|
|
95
|
+
for (const scopeLog of resourceLog.scopeLogs ?? []) {
|
|
96
|
+
const scopeName = scopeLog.scope?.name ?? null;
|
|
97
|
+
const scopeVersion = scopeLog.scope?.version ?? null;
|
|
98
|
+
for (const logRecord of scopeLog.logRecords ?? []) {
|
|
99
|
+
const timestamp = logRecord.timeUnixNano ?? logRecord.observedTimeUnixNano ?? "0";
|
|
100
|
+
let body = null;
|
|
101
|
+
if (logRecord.body) body = logRecord.body.stringValue ?? JSON.stringify(extractValue(logRecord.body));
|
|
102
|
+
logs.push({
|
|
103
|
+
timestampUnix: BigInt(timestamp),
|
|
104
|
+
traceId: logRecord.traceId || null,
|
|
105
|
+
spanId: logRecord.spanId || null,
|
|
106
|
+
severityText: logRecord.severityText ?? null,
|
|
107
|
+
severityNumber: logRecord.severityNumber ?? null,
|
|
108
|
+
serviceName,
|
|
109
|
+
body,
|
|
110
|
+
resourceAttributes: Object.keys(resourceAttrs).length ? resourceAttrs : null,
|
|
111
|
+
logAttributes: logRecord.attributes?.length ? flattenAttributes(logRecord.attributes) : null,
|
|
112
|
+
scopeName,
|
|
113
|
+
scopeVersion
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return logs;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { flattenAttributes, parseLogRequest, parseTraceRequest };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createReadStream, existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import router from "@adonisjs/core/services/router";
|
|
5
|
+
//#region src/start/routes.ts
|
|
6
|
+
router.post("/v1/traces", [() => import("../controllers/otlp_controller.js"), "traces"]).as("otlp.traces");
|
|
7
|
+
router.post("/v1/logs", [() => import("../controllers/otlp_controller.js"), "logs"]).as("otlp.logs");
|
|
8
|
+
router.get("/api/services", [() => import("../controllers/api_controller.js"), "listServices"]).as("services.index");
|
|
9
|
+
router.get("/api/traces", [() => import("../controllers/api_controller.js"), "listTraces"]).as("traces.index");
|
|
10
|
+
router.get("/api/traces/:traceId", [() => import("../controllers/api_controller.js"), "getTrace"]).as("traces.show");
|
|
11
|
+
router.get("/api/queries", [() => import("../controllers/api_controller.js"), "listQueries"]).as("queries.index");
|
|
12
|
+
router.get("/api/exceptions", [() => import("../controllers/api_controller.js"), "listExceptions"]).as("exceptions.index");
|
|
13
|
+
router.get("/api/jobs", [() => import("../controllers/api_controller.js"), "listJobs"]).as("jobs.index");
|
|
14
|
+
router.get("/api/commands", [() => import("../controllers/api_controller.js"), "listCommands"]).as("commands.index");
|
|
15
|
+
router.get("/api/logs", [() => import("../controllers/api_controller.js"), "listLogs"]).as("logs.index");
|
|
16
|
+
router.delete("/api/data", [() => import("../controllers/api_controller.js"), "clearData"]).as("data.clear");
|
|
17
|
+
router.get("/api/events", [() => import("../controllers/sse_controller.js"), "stream"]).as("events.stream");
|
|
18
|
+
router.post("/mcp", [() => import("../controllers/mcp_controller.js"), "handle"]).as("mcp.handle");
|
|
19
|
+
router.get("/mcp", [() => import("../controllers/mcp_controller.js"), "handle"]).as("mcp.stream");
|
|
20
|
+
router.delete("/mcp", [() => import("../controllers/mcp_controller.js"), "handle"]).as("mcp.delete");
|
|
21
|
+
/**
|
|
22
|
+
* SPA fallback — serve index.html for all non-API routes.
|
|
23
|
+
* Static assets (js, css, etc.) are handled by @adonisjs/static middleware.
|
|
24
|
+
*/
|
|
25
|
+
const uiDistPath = join(fileURLToPath(import.meta.url), "..", "..", "..", "ui", "dist");
|
|
26
|
+
router.get("*", ({ request, response }) => {
|
|
27
|
+
const url = request.url();
|
|
28
|
+
if (url.startsWith("/v1/") || url.startsWith("/api/")) return response.notFound("Not found");
|
|
29
|
+
const indexPath = join(uiDistPath, "index.html");
|
|
30
|
+
if (!existsSync(indexPath)) return response.ok("<html><body style=\"background:#222;color:#fff;font-family:monospace;display:flex;align-items:center;justify-content:center;height:100vh\"><div style=\"text-align:center\"><h2>Monocle DevTools</h2><p>UI not built yet. Run: cd packages/devtools/ui && pnpm build</p></div></body></html>");
|
|
31
|
+
response.header("content-type", "text/html");
|
|
32
|
+
response.stream(createReadStream(indexPath));
|
|
33
|
+
});
|
|
34
|
+
//#endregion
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseTransformer } from "@adonisjs/core/transformers";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/command_transformer.d.ts
|
|
4
|
+
declare class CommandTransformer extends BaseTransformer<Record<string, any>> {
|
|
5
|
+
toObject(): {
|
|
6
|
+
traceId: string;
|
|
7
|
+
rootSpanName: string;
|
|
8
|
+
serviceName: string;
|
|
9
|
+
commandName: string;
|
|
10
|
+
commandDescription: string;
|
|
11
|
+
statusCode: string;
|
|
12
|
+
durationMs: number;
|
|
13
|
+
startTime: string;
|
|
14
|
+
spanCount: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { CommandTransformer as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseTransformer } from "@adonisjs/core/transformers";
|
|
2
|
+
//#region src/transformers/command_transformer.ts
|
|
3
|
+
var CommandTransformer = class extends BaseTransformer {
|
|
4
|
+
toObject() {
|
|
5
|
+
const attrs = this.resource.span_attributes ? JSON.parse(this.resource.span_attributes) : {};
|
|
6
|
+
return {
|
|
7
|
+
traceId: this.resource.trace_id,
|
|
8
|
+
rootSpanName: this.resource.span_name,
|
|
9
|
+
serviceName: this.resource.service_name ?? null,
|
|
10
|
+
commandName: attrs["cli.command.name"] ?? this.resource.span_name,
|
|
11
|
+
commandDescription: attrs["cli.command.description"] ?? null,
|
|
12
|
+
statusCode: this.resource.status_code,
|
|
13
|
+
durationMs: Number(this.resource.duration_ns) / 1e6,
|
|
14
|
+
startTime: (/* @__PURE__ */ new Date(Number(this.resource.start_time_unix) / 1e6)).toISOString(),
|
|
15
|
+
spanCount: Number(this.resource.span_count ?? 0)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { CommandTransformer as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseTransformer } from "@adonisjs/core/transformers";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/exception_transformer.d.ts
|
|
4
|
+
declare class ExceptionTransformer extends BaseTransformer<Record<string, any>> {
|
|
5
|
+
toObject(): {
|
|
6
|
+
traceId: string;
|
|
7
|
+
spanId: string;
|
|
8
|
+
spanName: string;
|
|
9
|
+
serviceName: string;
|
|
10
|
+
exceptionType: string;
|
|
11
|
+
exceptionMessage: string;
|
|
12
|
+
exceptionStacktrace: string;
|
|
13
|
+
timestamp: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ExceptionTransformer as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseTransformer } from "@adonisjs/core/transformers";
|
|
2
|
+
//#region src/transformers/exception_transformer.ts
|
|
3
|
+
var ExceptionTransformer = class extends BaseTransformer {
|
|
4
|
+
toObject() {
|
|
5
|
+
const attrs = (typeof this.resource.event_json === "string" ? JSON.parse(this.resource.event_json) : this.resource.event_json).attributes ?? {};
|
|
6
|
+
return {
|
|
7
|
+
traceId: this.resource.trace_id,
|
|
8
|
+
spanId: this.resource.span_id,
|
|
9
|
+
spanName: this.resource.span_name,
|
|
10
|
+
serviceName: this.resource.service_name ?? null,
|
|
11
|
+
exceptionType: attrs["exception.type"] ?? null,
|
|
12
|
+
exceptionMessage: attrs["exception.message"] ?? null,
|
|
13
|
+
exceptionStacktrace: attrs["exception.stacktrace"] ?? null,
|
|
14
|
+
timestamp: (/* @__PURE__ */ new Date(Number(this.resource.start_time_unix) / 1e6)).toISOString()
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { ExceptionTransformer as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseTransformer } from "@adonisjs/core/transformers";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/job_transformer.d.ts
|
|
4
|
+
declare class JobTransformer extends BaseTransformer<Record<string, any>> {
|
|
5
|
+
toObject(): {
|
|
6
|
+
traceId: string;
|
|
7
|
+
rootSpanName: string;
|
|
8
|
+
serviceName: string;
|
|
9
|
+
jobName: string;
|
|
10
|
+
queueName: string | null;
|
|
11
|
+
statusCode: string;
|
|
12
|
+
durationMs: number;
|
|
13
|
+
startTime: string;
|
|
14
|
+
spanCount: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { JobTransformer as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseTransformer } from "@adonisjs/core/transformers";
|
|
2
|
+
//#region src/transformers/job_transformer.ts
|
|
3
|
+
var JobTransformer = class extends BaseTransformer {
|
|
4
|
+
toObject() {
|
|
5
|
+
const attrs = this.resource.span_attributes ? JSON.parse(this.resource.span_attributes) : {};
|
|
6
|
+
return {
|
|
7
|
+
traceId: this.resource.trace_id,
|
|
8
|
+
rootSpanName: this.resource.span_name,
|
|
9
|
+
serviceName: this.resource.service_name ?? null,
|
|
10
|
+
jobName: attrs["messaging.job.name"] ?? this.resource.span_name,
|
|
11
|
+
queueName: attrs["messaging.destination.name"] ?? attrs["messaging.destination"] ?? null,
|
|
12
|
+
statusCode: this.resource.status_code,
|
|
13
|
+
durationMs: Number(this.resource.duration_ns) / 1e6,
|
|
14
|
+
startTime: (/* @__PURE__ */ new Date(Number(this.resource.start_time_unix) / 1e6)).toISOString(),
|
|
15
|
+
spanCount: Number(this.resource.span_count ?? 0)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { JobTransformer as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseTransformer } from "@adonisjs/core/transformers";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/log_transformer.d.ts
|
|
4
|
+
declare class LogTransformer extends BaseTransformer<Record<string, any>> {
|
|
5
|
+
toObject(): {
|
|
6
|
+
timestampUnix: string;
|
|
7
|
+
traceId: string | null;
|
|
8
|
+
spanId: string | null;
|
|
9
|
+
severityText: string;
|
|
10
|
+
severityNumber: number | null;
|
|
11
|
+
serviceName: string;
|
|
12
|
+
body: string;
|
|
13
|
+
attributes: any;
|
|
14
|
+
timestamp: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { LogTransformer as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseTransformer } from "@adonisjs/core/transformers";
|
|
2
|
+
//#region src/transformers/log_transformer.ts
|
|
3
|
+
var LogTransformer = class extends BaseTransformer {
|
|
4
|
+
toObject() {
|
|
5
|
+
return {
|
|
6
|
+
timestampUnix: String(this.resource.timestamp_unix),
|
|
7
|
+
traceId: this.resource.trace_id || null,
|
|
8
|
+
spanId: this.resource.span_id || null,
|
|
9
|
+
severityText: this.resource.severity_text ?? null,
|
|
10
|
+
severityNumber: this.resource.severity_number,
|
|
11
|
+
serviceName: this.resource.service_name ?? null,
|
|
12
|
+
body: this.resource.body ?? null,
|
|
13
|
+
attributes: this.resource.log_attributes ? JSON.parse(this.resource.log_attributes) : {},
|
|
14
|
+
timestamp: (/* @__PURE__ */ new Date(Number(this.resource.timestamp_unix) / 1e6)).toISOString()
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { LogTransformer as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseTransformer } from "@adonisjs/core/transformers";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/query_transformer.d.ts
|
|
4
|
+
declare class QueryTransformer extends BaseTransformer<Record<string, any>> {
|
|
5
|
+
#private;
|
|
6
|
+
toObject(): {
|
|
7
|
+
traceId: string;
|
|
8
|
+
spanId: string;
|
|
9
|
+
spanName: string;
|
|
10
|
+
serviceName: string;
|
|
11
|
+
statusCode: string;
|
|
12
|
+
dbSystem: string | null;
|
|
13
|
+
dbStatement: string | null;
|
|
14
|
+
dbOperation: string | null;
|
|
15
|
+
durationMs: number;
|
|
16
|
+
startTime: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { QueryTransformer as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Semconv } from "../semconv.js";
|
|
2
|
+
import { BaseTransformer } from "@adonisjs/core/transformers";
|
|
3
|
+
//#region src/transformers/query_transformer.ts
|
|
4
|
+
const S = Semconv.Stable;
|
|
5
|
+
const L = Semconv.Legacy;
|
|
6
|
+
var QueryTransformer = class extends BaseTransformer {
|
|
7
|
+
#attr(stable, legacy) {
|
|
8
|
+
const attrs = this.resource.span_attributes ? JSON.parse(this.resource.span_attributes) : {};
|
|
9
|
+
return attrs[stable] ?? attrs[legacy] ?? null;
|
|
10
|
+
}
|
|
11
|
+
toObject() {
|
|
12
|
+
return {
|
|
13
|
+
traceId: this.resource.trace_id,
|
|
14
|
+
spanId: this.resource.span_id,
|
|
15
|
+
spanName: this.resource.span_name,
|
|
16
|
+
serviceName: this.resource.service_name ?? null,
|
|
17
|
+
statusCode: this.resource.status_code,
|
|
18
|
+
dbSystem: this.#attr(S.DB_SYSTEM, L.DB_SYSTEM),
|
|
19
|
+
dbStatement: this.#attr(S.DB_STATEMENT, L.DB_STATEMENT),
|
|
20
|
+
dbOperation: this.#attr(S.DB_OPERATION, L.DB_OPERATION),
|
|
21
|
+
durationMs: Number(this.resource.duration_ns) / 1e6,
|
|
22
|
+
startTime: (/* @__PURE__ */ new Date(Number(this.resource.start_time_unix) / 1e6)).toISOString()
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { QueryTransformer as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseTransformer } from "@adonisjs/core/transformers";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/span_transformer.d.ts
|
|
4
|
+
declare class SpanTransformer extends BaseTransformer<Record<string, any>> {
|
|
5
|
+
toObject(): {
|
|
6
|
+
traceId: string;
|
|
7
|
+
spanId: string;
|
|
8
|
+
parentSpanId: string | null;
|
|
9
|
+
name: string;
|
|
10
|
+
kind: string;
|
|
11
|
+
serviceName: string;
|
|
12
|
+
statusCode: string;
|
|
13
|
+
statusMessage: string;
|
|
14
|
+
startTimeUnix: string;
|
|
15
|
+
endTimeUnix: string;
|
|
16
|
+
durationMs: number;
|
|
17
|
+
attributes: any;
|
|
18
|
+
events: any;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { SpanTransformer as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseTransformer } from "@adonisjs/core/transformers";
|
|
2
|
+
//#region src/transformers/span_transformer.ts
|
|
3
|
+
var SpanTransformer = class extends BaseTransformer {
|
|
4
|
+
toObject() {
|
|
5
|
+
return {
|
|
6
|
+
traceId: this.resource.trace_id,
|
|
7
|
+
spanId: this.resource.span_id,
|
|
8
|
+
parentSpanId: this.resource.parent_span_id || null,
|
|
9
|
+
name: this.resource.span_name,
|
|
10
|
+
kind: this.resource.span_kind ?? null,
|
|
11
|
+
serviceName: this.resource.service_name ?? null,
|
|
12
|
+
statusCode: this.resource.status_code,
|
|
13
|
+
statusMessage: this.resource.status_message ?? null,
|
|
14
|
+
startTimeUnix: String(this.resource.start_time_unix),
|
|
15
|
+
endTimeUnix: String(this.resource.end_time_unix),
|
|
16
|
+
durationMs: Number(this.resource.duration_ns) / 1e6,
|
|
17
|
+
attributes: this.resource.span_attributes ? JSON.parse(this.resource.span_attributes) : {},
|
|
18
|
+
events: this.resource.events ? JSON.parse(this.resource.events) : []
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SpanTransformer as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseTransformer } from "@adonisjs/core/transformers";
|
|
2
|
+
|
|
3
|
+
//#region src/transformers/trace_transformer.d.ts
|
|
4
|
+
declare class TraceTransformer extends BaseTransformer<Record<string, any>> {
|
|
5
|
+
#private;
|
|
6
|
+
toObject(): {
|
|
7
|
+
traceId: string;
|
|
8
|
+
rootSpanName: string;
|
|
9
|
+
serviceName: string;
|
|
10
|
+
method: string | null;
|
|
11
|
+
path: string | null;
|
|
12
|
+
route: string;
|
|
13
|
+
host: string | null;
|
|
14
|
+
statusCode: string;
|
|
15
|
+
httpStatus: number | null;
|
|
16
|
+
durationMs: number;
|
|
17
|
+
startTime: string;
|
|
18
|
+
spanCount: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { TraceTransformer as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Semconv } from "../semconv.js";
|
|
2
|
+
import { BaseTransformer } from "@adonisjs/core/transformers";
|
|
3
|
+
//#region src/transformers/trace_transformer.ts
|
|
4
|
+
const S = Semconv.Stable;
|
|
5
|
+
const L = Semconv.Legacy;
|
|
6
|
+
var TraceTransformer = class extends BaseTransformer {
|
|
7
|
+
#attr(stable, legacy) {
|
|
8
|
+
const attrs = this.#attrs();
|
|
9
|
+
return attrs[stable] ?? attrs[legacy] ?? null;
|
|
10
|
+
}
|
|
11
|
+
#attrs() {
|
|
12
|
+
return this.resource.span_attributes ? JSON.parse(this.resource.span_attributes) : {};
|
|
13
|
+
}
|
|
14
|
+
toObject() {
|
|
15
|
+
const attrs = this.#attrs();
|
|
16
|
+
return {
|
|
17
|
+
traceId: this.resource.trace_id,
|
|
18
|
+
rootSpanName: this.resource.span_name,
|
|
19
|
+
serviceName: this.resource.service_name ?? null,
|
|
20
|
+
method: this.#attr(S.HTTP_METHOD, L.HTTP_METHOD),
|
|
21
|
+
path: this.#attr(S.HTTP_TARGET, L.HTTP_TARGET),
|
|
22
|
+
route: attrs[S.HTTP_ROUTE] ?? null,
|
|
23
|
+
host: attrs["server.address"] ?? attrs["http.host"] ?? attrs["net.host.name"] ?? null,
|
|
24
|
+
statusCode: this.resource.status_code,
|
|
25
|
+
httpStatus: Number(this.#attr(S.HTTP_STATUS_CODE, L.HTTP_STATUS_CODE)) || null,
|
|
26
|
+
durationMs: Number(this.resource.duration_ns) / 1e6,
|
|
27
|
+
startTime: (/* @__PURE__ */ new Date(Number(this.resource.start_time_unix) / 1e6)).toISOString(),
|
|
28
|
+
spanCount: Number(this.resource.span_count ?? 0)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { TraceTransformer as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/types/logs.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Internal flat log type for DuckDB storage.
|
|
4
|
+
*/
|
|
5
|
+
interface FlatLog {
|
|
6
|
+
timestampUnix: bigint;
|
|
7
|
+
traceId: string | null;
|
|
8
|
+
spanId: string | null;
|
|
9
|
+
severityText: string | null;
|
|
10
|
+
severityNumber: number | null;
|
|
11
|
+
serviceName: string | null;
|
|
12
|
+
body: string | null;
|
|
13
|
+
resourceAttributes: Record<string, unknown> | null;
|
|
14
|
+
logAttributes: Record<string, unknown> | null;
|
|
15
|
+
scopeName: string | null;
|
|
16
|
+
scopeVersion: string | null;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { FlatLog };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
//#region src/types/otlp.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* OTLP JSON wire format types.
|
|
4
|
+
* Based on the OpenTelemetry Protocol specification.
|
|
5
|
+
*/
|
|
6
|
+
interface OtlpAnyValue {
|
|
7
|
+
stringValue?: string;
|
|
8
|
+
intValue?: string | number;
|
|
9
|
+
doubleValue?: number;
|
|
10
|
+
boolValue?: boolean;
|
|
11
|
+
arrayValue?: {
|
|
12
|
+
values: OtlpAnyValue[];
|
|
13
|
+
};
|
|
14
|
+
kvlistValue?: {
|
|
15
|
+
values: OtlpAttribute[];
|
|
16
|
+
};
|
|
17
|
+
bytesValue?: string;
|
|
18
|
+
}
|
|
19
|
+
interface OtlpAttribute {
|
|
20
|
+
key: string;
|
|
21
|
+
value: OtlpAnyValue;
|
|
22
|
+
}
|
|
23
|
+
interface OtlpResource {
|
|
24
|
+
attributes?: OtlpAttribute[];
|
|
25
|
+
droppedAttributesCount?: number;
|
|
26
|
+
}
|
|
27
|
+
interface OtlpInstrumentationScope {
|
|
28
|
+
name?: string;
|
|
29
|
+
version?: string;
|
|
30
|
+
attributes?: OtlpAttribute[];
|
|
31
|
+
}
|
|
32
|
+
interface OtlpSpanEvent {
|
|
33
|
+
timeUnixNano?: string;
|
|
34
|
+
name: string;
|
|
35
|
+
attributes?: OtlpAttribute[];
|
|
36
|
+
droppedAttributesCount?: number;
|
|
37
|
+
}
|
|
38
|
+
interface OtlpSpanLink {
|
|
39
|
+
traceId: string;
|
|
40
|
+
spanId: string;
|
|
41
|
+
traceState?: string;
|
|
42
|
+
attributes?: OtlpAttribute[];
|
|
43
|
+
droppedAttributesCount?: number;
|
|
44
|
+
}
|
|
45
|
+
interface OtlpSpanStatus {
|
|
46
|
+
code?: number;
|
|
47
|
+
message?: string;
|
|
48
|
+
}
|
|
49
|
+
interface OtlpSpan {
|
|
50
|
+
traceId: string;
|
|
51
|
+
spanId: string;
|
|
52
|
+
parentSpanId?: string;
|
|
53
|
+
traceState?: string;
|
|
54
|
+
name: string;
|
|
55
|
+
kind?: number;
|
|
56
|
+
startTimeUnixNano: string;
|
|
57
|
+
endTimeUnixNano: string;
|
|
58
|
+
attributes?: OtlpAttribute[];
|
|
59
|
+
droppedAttributesCount?: number;
|
|
60
|
+
events?: OtlpSpanEvent[];
|
|
61
|
+
droppedEventsCount?: number;
|
|
62
|
+
links?: OtlpSpanLink[];
|
|
63
|
+
droppedLinksCount?: number;
|
|
64
|
+
status?: OtlpSpanStatus;
|
|
65
|
+
}
|
|
66
|
+
interface OtlpScopeSpans {
|
|
67
|
+
scope?: OtlpInstrumentationScope;
|
|
68
|
+
spans: OtlpSpan[];
|
|
69
|
+
schemaUrl?: string;
|
|
70
|
+
}
|
|
71
|
+
interface OtlpResourceSpans {
|
|
72
|
+
resource?: OtlpResource;
|
|
73
|
+
scopeSpans: OtlpScopeSpans[];
|
|
74
|
+
schemaUrl?: string;
|
|
75
|
+
}
|
|
76
|
+
interface OtlpTraceRequest {
|
|
77
|
+
resourceSpans: OtlpResourceSpans[];
|
|
78
|
+
}
|
|
79
|
+
interface OtlpLogRecord {
|
|
80
|
+
timeUnixNano?: string;
|
|
81
|
+
observedTimeUnixNano?: string;
|
|
82
|
+
severityNumber?: number;
|
|
83
|
+
severityText?: string;
|
|
84
|
+
traceId?: string;
|
|
85
|
+
spanId?: string;
|
|
86
|
+
body?: OtlpAnyValue;
|
|
87
|
+
attributes?: OtlpAttribute[];
|
|
88
|
+
droppedAttributesCount?: number;
|
|
89
|
+
flags?: number;
|
|
90
|
+
}
|
|
91
|
+
interface OtlpScopeLogs {
|
|
92
|
+
scope?: OtlpInstrumentationScope;
|
|
93
|
+
logRecords: OtlpLogRecord[];
|
|
94
|
+
schemaUrl?: string;
|
|
95
|
+
}
|
|
96
|
+
interface OtlpResourceLogs {
|
|
97
|
+
resource?: OtlpResource;
|
|
98
|
+
scopeLogs: OtlpScopeLogs[];
|
|
99
|
+
schemaUrl?: string;
|
|
100
|
+
}
|
|
101
|
+
interface OtlpLogRequest {
|
|
102
|
+
resourceLogs: OtlpResourceLogs[];
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { OtlpAnyValue, OtlpAttribute, OtlpInstrumentationScope, OtlpLogRecord, OtlpLogRequest, OtlpResource, OtlpResourceLogs, OtlpResourceSpans, OtlpScopeLogs, OtlpScopeSpans, OtlpSpan, OtlpSpanEvent, OtlpSpanLink, OtlpSpanStatus, OtlpTraceRequest };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/types/spans.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Internal flat span type for DuckDB storage.
|
|
4
|
+
*/
|
|
5
|
+
interface FlatSpan {
|
|
6
|
+
traceId: string;
|
|
7
|
+
spanId: string;
|
|
8
|
+
parentSpanId: string | null;
|
|
9
|
+
spanName: string;
|
|
10
|
+
spanKind: string | null;
|
|
11
|
+
serviceName: string | null;
|
|
12
|
+
statusCode: string;
|
|
13
|
+
statusMessage: string | null;
|
|
14
|
+
startTimeUnix: bigint;
|
|
15
|
+
endTimeUnix: bigint;
|
|
16
|
+
durationNs: bigint;
|
|
17
|
+
resourceAttributes: Record<string, unknown> | null;
|
|
18
|
+
spanAttributes: Record<string, unknown> | null;
|
|
19
|
+
scopeName: string | null;
|
|
20
|
+
scopeVersion: string | null;
|
|
21
|
+
events: SpanEvent[] | null;
|
|
22
|
+
}
|
|
23
|
+
interface SpanEvent {
|
|
24
|
+
name: string;
|
|
25
|
+
timeUnixNano: string;
|
|
26
|
+
attributes: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { FlatSpan, SpanEvent };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|