Skip to content

Commit

Permalink
Add todos
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
  • Loading branch information
pavolloffay committed Oct 26, 2023
1 parent 36b03b1 commit 10fd25c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
19 changes: 9 additions & 10 deletions app/frontend/index.js
Expand Up @@ -17,12 +17,12 @@ const backend2url =
process.env.BACKEND2_URL || "http://localhost:5000/rolldice";

const myMeter = metrics.getMeter("app-meter");
const gameCounter = myMeter.createUpDownCounter('app_games_total', {
description: "A counter of how often the game has been played",
const requestCounter = myMeter.createCounter('request_total', {
description: "Counter of requests",
valueType: ValueType.INT
})
const requestCounter = myMeter.createUpDownCounter('request_total', {
description: "Counter of requests",
const gameCounter = myMeter.createUpDownCounter('app_games_total', {
description: "A counter of how often the game has been played",
valueType: ValueType.INT
})
const winCounter = myMeter.createUpDownCounter('app_wins_total', {
Expand All @@ -42,7 +42,7 @@ app.get("/", (req, res) => {
span = trace.getSpan(context.active())
if(span) {
span.setAttribute('app.player1', player1)
// TODO: Add an attribute for player2
// TODO(tracing): Add an attribute for player2
}

const p1 = new Promise((resolve, reject) => {
Expand Down Expand Up @@ -99,15 +99,14 @@ app.get("/", (req, res) => {
winner = player2
winnerRolled = roll2
}
// TODO: Add the winner as a span attribute
// TODO(tracing): Add the winner as a span attribute

// Count the total number of games
gameCounter.add(1);


// TODO (metrics): count how often ach player wins
// use app.winner tag
// Count how often each player wins
winCounter.add(1, {
"app.winner": winner,
});

// Add counters for numbers rolled and/or for players who played

Expand Down
4 changes: 2 additions & 2 deletions app/frontend/instrument.js
Expand Up @@ -17,8 +17,8 @@ const { PeriodicExportingMetricReader, MeterProvider, ConsoleMetricExporter } =
const sdk = new opentelemetry.NodeSDK({
traceExporter: new OTLPTraceExporter(),
metricReader: new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter(),
// exporter: new ConsoleMetricExporter()
// exporter: new OTLPMetricExporter(),
exporter: new ConsoleMetricExporter()
}),
instrumentations: [getNodeAutoInstrumentations()]
});
Expand Down

0 comments on commit 10fd25c

Please sign in to comment.