@foam-ai/node-cliengo 0.1.0-alpha.19 → 0.1.0-alpha.20
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.
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* because the raw function takes a tracer argument — use foam.createFastifyPlugin()
|
|
16
16
|
* instead.
|
|
17
17
|
*/
|
|
18
|
-
export { init, getFoam } from './init';
|
|
18
|
+
export { init, getFoam, createFastifyLoggerConfig } from './init';
|
|
19
19
|
export { buildTraceparent, extractParentContext, getTraceContext } from './trace-bridge';
|
|
20
20
|
export { injectSnsAttributes } from './sns';
|
|
21
21
|
export { injectJobData, wrapJobConsumer } from './job';
|
|
@@ -17,10 +17,11 @@
|
|
|
17
17
|
* instead.
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.FOAM_OTEL_ENDPOINT = exports.loadNewRelic = exports.createPinoMixin = exports.createWinstonFormat = exports.getFastifyRequestTraceContext = exports.createPinoHttpOptions = exports.getRequestTraceContext = exports.createExpressErrorHandler = exports.createExpressMiddleware = exports.wrapSqsConsumer = exports.wrapJobConsumer = exports.injectJobData = exports.injectSnsAttributes = exports.getTraceContext = exports.extractParentContext = exports.buildTraceparent = exports.getFoam = exports.init = void 0;
|
|
20
|
+
exports.FOAM_OTEL_ENDPOINT = exports.loadNewRelic = exports.createPinoMixin = exports.createWinstonFormat = exports.getFastifyRequestTraceContext = exports.createPinoHttpOptions = exports.getRequestTraceContext = exports.createExpressErrorHandler = exports.createExpressMiddleware = exports.wrapSqsConsumer = exports.wrapJobConsumer = exports.injectJobData = exports.injectSnsAttributes = exports.getTraceContext = exports.extractParentContext = exports.buildTraceparent = exports.createFastifyLoggerConfig = exports.getFoam = exports.init = void 0;
|
|
21
21
|
var init_1 = require("./init");
|
|
22
22
|
Object.defineProperty(exports, "init", { enumerable: true, get: function () { return init_1.init; } });
|
|
23
23
|
Object.defineProperty(exports, "getFoam", { enumerable: true, get: function () { return init_1.getFoam; } });
|
|
24
|
+
Object.defineProperty(exports, "createFastifyLoggerConfig", { enumerable: true, get: function () { return init_1.createFastifyLoggerConfig; } });
|
|
24
25
|
var trace_bridge_1 = require("./trace-bridge");
|
|
25
26
|
Object.defineProperty(exports, "buildTraceparent", { enumerable: true, get: function () { return trace_bridge_1.buildTraceparent; } });
|
|
26
27
|
Object.defineProperty(exports, "extractParentContext", { enumerable: true, get: function () { return trace_bridge_1.extractParentContext; } });
|
|
@@ -56,3 +56,19 @@ export declare function init(serviceName: string, options?: InitOptions): FoamIn
|
|
|
56
56
|
* no circular dependency, no holder pattern needed.
|
|
57
57
|
*/
|
|
58
58
|
export declare function getFoam(serviceName?: string): FoamInstance | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Standalone Fastify logger config that handles the getFoam() lookup internally.
|
|
61
|
+
* If Foam is initialized, returns { mixin, stream (multistream with OTLP), ...opts }.
|
|
62
|
+
* If Foam is not initialized (disabled, not yet called), returns opts as-is —
|
|
63
|
+
* Fastify gets a plain Pino logger with no OTLP destination.
|
|
64
|
+
*
|
|
65
|
+
* // No getFoam() check or ternary needed:
|
|
66
|
+
* Fastify({ logger: createFastifyLoggerConfig({ level: 'info' }) })
|
|
67
|
+
*
|
|
68
|
+
* // Dev with pino-pretty:
|
|
69
|
+
* Fastify({ logger: createFastifyLoggerConfig({
|
|
70
|
+
* level: 'debug',
|
|
71
|
+
* streams: [{ stream: pinoPretty() }],
|
|
72
|
+
* })})
|
|
73
|
+
*/
|
|
74
|
+
export declare function createFastifyLoggerConfig(opts?: Record<string, any>): Record<string, any>;
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.init = init;
|
|
54
54
|
exports.getFoam = getFoam;
|
|
55
|
+
exports.createFastifyLoggerConfig = createFastifyLoggerConfig;
|
|
55
56
|
const api_1 = require("@opentelemetry/api");
|
|
56
57
|
const exporter_logs_otlp_http_1 = require("@opentelemetry/exporter-logs-otlp-http");
|
|
57
58
|
const exporter_metrics_otlp_http_1 = require("@opentelemetry/exporter-metrics-otlp-http");
|
|
@@ -420,3 +421,26 @@ function getFoam(serviceName) {
|
|
|
420
421
|
}
|
|
421
422
|
return undefined;
|
|
422
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* Standalone Fastify logger config that handles the getFoam() lookup internally.
|
|
426
|
+
* If Foam is initialized, returns { mixin, stream (multistream with OTLP), ...opts }.
|
|
427
|
+
* If Foam is not initialized (disabled, not yet called), returns opts as-is —
|
|
428
|
+
* Fastify gets a plain Pino logger with no OTLP destination.
|
|
429
|
+
*
|
|
430
|
+
* // No getFoam() check or ternary needed:
|
|
431
|
+
* Fastify({ logger: createFastifyLoggerConfig({ level: 'info' }) })
|
|
432
|
+
*
|
|
433
|
+
* // Dev with pino-pretty:
|
|
434
|
+
* Fastify({ logger: createFastifyLoggerConfig({
|
|
435
|
+
* level: 'debug',
|
|
436
|
+
* streams: [{ stream: pinoPretty() }],
|
|
437
|
+
* })})
|
|
438
|
+
*/
|
|
439
|
+
function createFastifyLoggerConfig(opts = {}) {
|
|
440
|
+
const foam = getFoam();
|
|
441
|
+
if (foam) {
|
|
442
|
+
return foam.createFastifyLoggerConfig(opts);
|
|
443
|
+
}
|
|
444
|
+
const { streams: _streams, ...pinoOpts } = opts;
|
|
445
|
+
return { ...pinoOpts };
|
|
446
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foam-ai/node-cliengo",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.20",
|
|
4
4
|
"description": "Unified observability (traces, logs, metrics) for Cliengo Node.js services, connecting New Relic APM with Foam's OTel collector.",
|
|
5
5
|
"main": "dist/node-cliengo/src/index.js",
|
|
6
6
|
"types": "dist/node-cliengo/src/index.d.ts",
|