Skip to content

Commit

Permalink
add metric prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
anik3tra0 committed Jan 29, 2024
1 parent e8e56e4 commit d6d0e00
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const {
} = require('@opentelemetry/semantic-conventions');
const os = require('os');
const {v4: uuidv4} = require('uuid');

const metricPrefix = process.env.METRIC_PREFIX
const workflowIDCount = parseInt(process.env.WORKFLOW_ID_COUNT);
const customerIDCount = parseInt(process.env.CUSTOMER_ID_COUNT);
const otlpEndpoint = process.env.OTLP_ENDPOINT;
Expand Down Expand Up @@ -49,19 +49,19 @@ meterProvider.addMetricReader(new PeriodicExportingMetricReader({
const meter = meterProvider.getMeter(otelMeterName);

// Create Observable Gauges
const memoryUsageGauge = meter.createObservableGauge('memory_usage', {
const memoryUsageGauge = meter.createObservableGauge(`${metricPrefix}_memory_usage`, {
description: 'Tracks the memory usage of the application', valueType: ValueType.DOUBLE
});

const concurrencyGauge = meter.createObservableGauge('concurrency', {
const concurrencyGauge = meter.createObservableGauge(`${metricPrefix}_concurrency`, {
description: 'Current concurrency level', valueType: ValueType.INT
});

const cpuUsageGauge = meter.createObservableGauge('cpu_usage', {
const cpuUsageGauge = meter.createObservableGauge(`${metricPrefix}_cpu_usage`, {
description: 'CPU usage percentage', valueType: ValueType.DOUBLE
});

const runInTimeGauge = meter.createObservableGauge('run_in_time', {
const runInTimeGauge = meter.createObservableGauge(`${metricPrefix}_run_time`, {
description: 'Run time in seconds', valueType: ValueType.INT
});

Expand Down Expand Up @@ -94,8 +94,8 @@ cpuUsageGauge.addCallback((observableResult) => {
runInTimeGauge.addCallback((observableResult) => {
workflowIDs.forEach(workflow_id => {
customerIDs.forEach(customer_id => {
let run_in_time = Math.floor(Math.random() * 60);
observableResult.observe(run_in_time, {
let run_time = Math.floor(Math.random() * 60);
observableResult.observe(run_time, {
...attributes, 'workflow_id': workflow_id, 'customer_id': customer_id
});
});
Expand Down

0 comments on commit d6d0e00

Please sign in to comment.