Skip to content

Commit

Permalink
wrapper metrics in flag
Browse files Browse the repository at this point in the history
  • Loading branch information
anhnd350309 committed Feb 21, 2025
1 parent 2518823 commit f1d80eb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions examples/grid/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DRPNode } from "@ts-drp/node";
import { enableTracing, OpentelemetryMetrics } from "@ts-drp/tracer";
import { enableTracing, IMetrics, OpentelemetryMetrics } from "@ts-drp/tracer";

import { Grid } from "./objects/grid";
import { render, enableUIControls, renderInfo } from "./render";
Expand Down Expand Up @@ -75,10 +75,9 @@ async function createConnectHandlers() {
});
}

async function run() {
async function run(metrics?: IMetrics) {
enableUIControls();
renderInfo();
const metrics = new OpentelemetryMetrics("grid-service-2");

const button_create = <HTMLButtonElement>document.getElementById("createGrid");
button_create.addEventListener("click", async () => {
Expand Down Expand Up @@ -133,16 +132,18 @@ async function run() {
}

async function main() {
let metrics: IMetrics | undefined = undefined;
if (import.meta.env.VITE_ENABLE_TRACING) {
enableTracing();
metrics = new OpentelemetryMetrics("grid-service-2");
}

const networkConfig = getNetworkConfigFromEnv();
gridState.node = new DRPNode(networkConfig ? { network_config: networkConfig } : undefined);
await gridState.node.start();
await gridState.node.networkNode.isDialable(async () => {
console.log("Started node", import.meta.env);
await run();
await run(metrics);
});

setInterval(renderInfo, import.meta.env.VITE_RENDER_INFO_INTERVAL);
Expand Down

0 comments on commit f1d80eb

Please sign in to comment.