@neat.is/core 0.3.6 → 0.3.7
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/{chunk-4ASCXBZF.js → chunk-75IBA4UL.js} +34 -5
- package/dist/chunk-75IBA4UL.js.map +1 -0
- package/dist/{chunk-G3PDTGOW.js → chunk-CY67YKNO.js} +2 -2
- package/dist/{chunk-YHQYHFI3.js → chunk-EDHOCFOG.js} +86 -14
- package/dist/chunk-EDHOCFOG.js.map +1 -0
- package/dist/cli.cjs +93 -5
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +62 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +117 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +3 -3
- package/dist/neatd.cjs +117 -16
- package/dist/neatd.cjs.map +1 -1
- package/dist/neatd.js +2 -2
- package/dist/{otel-grpc-J4O2SIBZ.js → otel-grpc-PM4SWPZE.js} +3 -3
- package/dist/server.cjs +33 -4
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-4ASCXBZF.js.map +0 -1
- package/dist/chunk-YHQYHFI3.js.map +0 -1
- /package/dist/{chunk-G3PDTGOW.js.map → chunk-CY67YKNO.js.map} +0 -0
- /package/dist/{otel-grpc-J4O2SIBZ.js.map → otel-grpc-PM4SWPZE.js.map} +0 -0
package/dist/neatd.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
startDaemon
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EDHOCFOG.js";
|
|
5
5
|
import {
|
|
6
6
|
listProjects,
|
|
7
7
|
registryPath
|
|
8
8
|
} from "./chunk-ZU2RQRCN.js";
|
|
9
9
|
import {
|
|
10
10
|
__require
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-75IBA4UL.js";
|
|
12
12
|
|
|
13
13
|
// src/neatd.ts
|
|
14
14
|
import { promises as fs } from "fs";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
reshapeGrpcRequest,
|
|
3
3
|
startOtelGrpcReceiver
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-CY67YKNO.js";
|
|
5
|
+
import "./chunk-75IBA4UL.js";
|
|
6
6
|
export {
|
|
7
7
|
reshapeGrpcRequest,
|
|
8
8
|
startOtelGrpcReceiver
|
|
9
9
|
};
|
|
10
|
-
//# sourceMappingURL=otel-grpc-
|
|
10
|
+
//# sourceMappingURL=otel-grpc-PM4SWPZE.js.map
|
package/dist/server.cjs
CHANGED
|
@@ -256,8 +256,7 @@ function parseOtlpRequest(body) {
|
|
|
256
256
|
}
|
|
257
257
|
return out;
|
|
258
258
|
}
|
|
259
|
-
function
|
|
260
|
-
if (exportTraceServiceRequestType) return exportTraceServiceRequestType;
|
|
259
|
+
function loadProtoRoot() {
|
|
261
260
|
const here = import_node_path35.default.dirname((0, import_node_url2.fileURLToPath)(importMetaUrl));
|
|
262
261
|
const protoRoot = import_node_path35.default.resolve(here, "..", "proto");
|
|
263
262
|
const root = new import_protobufjs.default.Root();
|
|
@@ -266,11 +265,32 @@ function loadProtobufDecoder() {
|
|
|
266
265
|
"opentelemetry/proto/collector/trace/v1/trace_service.proto",
|
|
267
266
|
{ keepCase: true }
|
|
268
267
|
);
|
|
268
|
+
return root;
|
|
269
|
+
}
|
|
270
|
+
function loadProtobufDecoder() {
|
|
271
|
+
if (exportTraceServiceRequestType) return exportTraceServiceRequestType;
|
|
272
|
+
const root = loadProtoRoot();
|
|
269
273
|
exportTraceServiceRequestType = root.lookupType(
|
|
270
274
|
"opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest"
|
|
271
275
|
);
|
|
272
276
|
return exportTraceServiceRequestType;
|
|
273
277
|
}
|
|
278
|
+
function loadProtobufResponseEncoder() {
|
|
279
|
+
if (exportTraceServiceResponseType) return exportTraceServiceResponseType;
|
|
280
|
+
const root = loadProtoRoot();
|
|
281
|
+
exportTraceServiceResponseType = root.lookupType(
|
|
282
|
+
"opentelemetry.proto.collector.trace.v1.ExportTraceServiceResponse"
|
|
283
|
+
);
|
|
284
|
+
return exportTraceServiceResponseType;
|
|
285
|
+
}
|
|
286
|
+
function encodeProtobufResponseBody() {
|
|
287
|
+
if (cachedProtobufResponseBody) return cachedProtobufResponseBody;
|
|
288
|
+
const Type = loadProtobufResponseEncoder();
|
|
289
|
+
const msg = Type.create({});
|
|
290
|
+
const encoded = Type.encode(msg).finish();
|
|
291
|
+
cachedProtobufResponseBody = Buffer.from(encoded);
|
|
292
|
+
return cachedProtobufResponseBody;
|
|
293
|
+
}
|
|
274
294
|
async function decodeProtobufBody(buf) {
|
|
275
295
|
const Type = loadProtobufDecoder();
|
|
276
296
|
const decoded = Type.decode(buf).toJSON();
|
|
@@ -317,7 +337,9 @@ async function buildOtelReceiver(opts) {
|
|
|
317
337
|
app.post("/v1/traces", async (req, reply) => {
|
|
318
338
|
const ct = (req.headers["content-type"] ?? "").toString().split(";")[0].trim().toLowerCase();
|
|
319
339
|
let body;
|
|
340
|
+
let responseFlavor;
|
|
320
341
|
if (ct === "application/x-protobuf") {
|
|
342
|
+
responseFlavor = "protobuf";
|
|
321
343
|
try {
|
|
322
344
|
body = await decodeProtobufBody(req.body);
|
|
323
345
|
} catch (err) {
|
|
@@ -326,6 +348,7 @@ async function buildOtelReceiver(opts) {
|
|
|
326
348
|
});
|
|
327
349
|
}
|
|
328
350
|
} else if (!ct || ct === "application/json") {
|
|
351
|
+
responseFlavor = "json";
|
|
329
352
|
body = req.body ?? {};
|
|
330
353
|
} else {
|
|
331
354
|
return reply.code(415).send({ error: `unsupported content-type: ${ct}` });
|
|
@@ -343,7 +366,11 @@ async function buildOtelReceiver(opts) {
|
|
|
343
366
|
}
|
|
344
367
|
}
|
|
345
368
|
enqueue(spans);
|
|
346
|
-
|
|
369
|
+
if (responseFlavor === "protobuf") {
|
|
370
|
+
const buf = encodeProtobufResponseBody();
|
|
371
|
+
return reply.code(200).header("content-type", "application/x-protobuf").send(buf);
|
|
372
|
+
}
|
|
373
|
+
return reply.code(200).header("content-type", "application/json").send({ partialSuccess: {} });
|
|
347
374
|
});
|
|
348
375
|
const decorated = app;
|
|
349
376
|
decorated.flushPending = async () => {
|
|
@@ -353,7 +380,7 @@ async function buildOtelReceiver(opts) {
|
|
|
353
380
|
};
|
|
354
381
|
return decorated;
|
|
355
382
|
}
|
|
356
|
-
var import_node_path35, import_node_url2, import_fastify2, import_protobufjs, exportTraceServiceRequestType;
|
|
383
|
+
var import_node_path35, import_node_url2, import_fastify2, import_protobufjs, exportTraceServiceRequestType, exportTraceServiceResponseType, cachedProtobufResponseBody;
|
|
357
384
|
var init_otel = __esm({
|
|
358
385
|
"src/otel.ts"() {
|
|
359
386
|
"use strict";
|
|
@@ -363,6 +390,8 @@ var init_otel = __esm({
|
|
|
363
390
|
import_fastify2 = __toESM(require("fastify"), 1);
|
|
364
391
|
import_protobufjs = __toESM(require("protobufjs"), 1);
|
|
365
392
|
exportTraceServiceRequestType = null;
|
|
393
|
+
exportTraceServiceResponseType = null;
|
|
394
|
+
cachedProtobufResponseBody = null;
|
|
366
395
|
}
|
|
367
396
|
});
|
|
368
397
|
|