@forklaunch/core 0.7.1 → 0.7.3
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/lib/{openTelemetryCollector-CmZ3T_2T.d.mts → openTelemetryCollector-DQC2FfOu.d.mts} +1 -0
- package/lib/{openTelemetryCollector-CmZ3T_2T.d.ts → openTelemetryCollector-DQC2FfOu.d.ts} +1 -0
- package/lib/src/cache/index.d.mts +1 -1
- package/lib/src/cache/index.d.ts +1 -1
- package/lib/src/cache/index.js +12 -7
- package/lib/src/cache/index.js.map +1 -1
- package/lib/src/cache/index.mjs +13 -8
- package/lib/src/cache/index.mjs.map +1 -1
- package/lib/src/http/index.d.mts +4 -2
- package/lib/src/http/index.d.ts +4 -2
- package/lib/src/http/index.js +12 -3
- package/lib/src/http/index.js.map +1 -1
- package/lib/src/http/index.mjs +13 -4
- package/lib/src/http/index.mjs.map +1 -1
- package/lib/src/services/index.d.mts +0 -1
- package/lib/src/services/index.d.ts +0 -1
- package/lib/src/services/index.js +9 -16
- package/lib/src/services/index.js.map +1 -1
- package/lib/src/services/index.mjs +9 -14
- package/lib/src/services/index.mjs.map +1 -1
- package/package.json +3 -3
package/lib/src/http/index.mjs
CHANGED
@@ -241,6 +241,7 @@ import {
|
|
241
241
|
ATTR_SERVICE_NAME as ATTR_SERVICE_NAME2
|
242
242
|
} from "@opentelemetry/semantic-conventions";
|
243
243
|
import dotenv from "dotenv";
|
244
|
+
import { v4 as v42 } from "uuid";
|
244
245
|
|
245
246
|
// src/http/guards/isForklaunchRequest.ts
|
246
247
|
function isForklaunchRequest(request) {
|
@@ -248,10 +249,11 @@ function isForklaunchRequest(request) {
|
|
248
249
|
}
|
249
250
|
|
250
251
|
// src/http/telemetry/pinoLogger.ts
|
251
|
-
import { isNever } from "@forklaunch/common";
|
252
|
+
import { isNever, safeStringify } from "@forklaunch/common";
|
252
253
|
import { trace as trace2 } from "@opentelemetry/api";
|
253
254
|
import { logs } from "@opentelemetry/api-logs";
|
254
255
|
import pino from "pino";
|
256
|
+
import PinoPretty from "pino-pretty";
|
255
257
|
|
256
258
|
// src/http/guards/isLoggerMeta.ts
|
257
259
|
function isLoggerMeta(arg) {
|
@@ -259,7 +261,6 @@ function isLoggerMeta(arg) {
|
|
259
261
|
}
|
260
262
|
|
261
263
|
// src/http/telemetry/pinoLogger.ts
|
262
|
-
import PinoPretty from "pino-pretty";
|
263
264
|
function meta(meta2) {
|
264
265
|
return meta2;
|
265
266
|
}
|
@@ -314,7 +315,7 @@ var PinoLogger = class _PinoLogger {
|
|
314
315
|
return false;
|
315
316
|
}
|
316
317
|
return true;
|
317
|
-
});
|
318
|
+
}).map(safeStringify);
|
318
319
|
const activeSpan = trace2.getActiveSpan();
|
319
320
|
if (activeSpan) {
|
320
321
|
const activeSpanContext = activeSpan.spanContext();
|
@@ -390,8 +391,12 @@ var OpenTelemetryCollector = class {
|
|
390
391
|
break;
|
391
392
|
}
|
392
393
|
}
|
393
|
-
this.log(
|
394
|
+
this.log(
|
395
|
+
"info",
|
396
|
+
"OpenTelemetry Collector (Traces + Logs + Metrics) started"
|
397
|
+
);
|
394
398
|
}
|
399
|
+
uuid = v42();
|
395
400
|
logger;
|
396
401
|
metrics;
|
397
402
|
log(level, ...args) {
|
@@ -2289,6 +2294,9 @@ import {
|
|
2289
2294
|
|
2290
2295
|
// src/http/telemetry/recordMetric.ts
|
2291
2296
|
function recordMetric(req, res) {
|
2297
|
+
if (res.metricRecorded) {
|
2298
|
+
return;
|
2299
|
+
}
|
2292
2300
|
httpRequestsTotalCounter.add(1, {
|
2293
2301
|
[ATTR_SERVICE_NAME3]: getEnvVar("OTEL_SERVICE_NAME"),
|
2294
2302
|
[ATTR_API_NAME]: req.contractDetails?.name,
|
@@ -2297,6 +2305,7 @@ function recordMetric(req, res) {
|
|
2297
2305
|
[ATTR_HTTP_ROUTE3]: req.originalPath,
|
2298
2306
|
[ATTR_HTTP_RESPONSE_STATUS_CODE3]: res.statusCode || 0
|
2299
2307
|
});
|
2308
|
+
res.metricRecorded = true;
|
2300
2309
|
}
|
2301
2310
|
|
2302
2311
|
// src/http/middleware/response/enrichExpressLikeSend.middleware.ts
|