You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, so we are trying to use prometheus-api-metrics following as mentioned in official doc. But getting circular structure to json error.
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Socket'
| property 'parser' -> object with constructor 'HTTPParser'
--- property 'socket' closes the circle
at JSON.stringify (<anonymous>)
at /Users/ahsannaseem/coding/project-repo/node_modules/prometheus-api-metrics/src/metrics-middleware.js:14:61
code in application.ts
require("dotenv-extended").load();
process.env.NODE_ENV !== "development" ? require("newrelic") : null;
import * as loggerConfig from "./config/logger-config";
loggerConfig.initialize();
import * as bodyParser from "body-parser";
import { registerConfigsAndLoad, container, createDatabasePools } from "./config/inversify.config";
import { loadAndSetScheduleForPeriodicData } from "./services/periodic-loaded-config";
import { Server } from "net";
//declare prometheus-api-metrics
import * as apiMetrics from "prometheus-api-metrics";
let isGlobalsInitilizingStarted: boolean = false;
let isGlobalsInitilized: boolean = false;
export async function initGlobals() {
if (isGlobalsInitilizingStarted)
throw new Error("Initilizing is already started.");
isGlobalsInitilizingStarted = true;
console.log("Initilized global variables.");
await require("./config/container-config").configure();
await registerConfigsAndLoad();
createDatabasePools();
// some init can be done in parallel
await Promise.all([
require("./config/redis-config").configure(),
loadAndSetScheduleForPeriodicData()
]);
isGlobalsInitilized = true;
}
export async function startSqsEventListener() {
if (!isGlobalsInitilized) {
throw new Error("Globals are noit initilized. Run initGlobals() first.");
}
await require("./config/sqs-config").listen();
}
export async function startWebServer(): Promise<Server> {
if (!isGlobalsInitilized) {
throw new Error("Globals are noit initilized. Run initGlobals() first.");
}
// start http server
const app = require("express")();
app.use(bodyParser.json());
// consume api-metrics
app.use(apiMetrics);
const routeConfig = require("./config/route-config");
routeConfig.configure(app);
const port = process.env.PORT || 3000;
return app.listen(port, function () {
console.log("service listening on port", port);
});
}
The text was updated successfully, but these errors were encountered:
Hi, so we are trying to use
prometheus-api-metrics
following as mentioned in official doc. But getting circular structure to json error.code in application.ts
The text was updated successfully, but these errors were encountered: