Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/exporter/ConsoleMetricExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ class ConsoleMetricExporter extends StandardConsoleMetricExporter {
for (const dp of metric.dataPoints) {
const t = dp.attributes['sap.tenancy.tenant_id']
collector[t] ??= {}
collector[t][name] = collector !== other ? dp.value : dp
if (collector === other) {
collector[t][name] ??= []
collector[t][name].push(dp)
Comment thread
schiwekM marked this conversation as resolved.
} else {
collector[t][name] = dp.value
}
}
}

Expand Down Expand Up @@ -114,7 +119,7 @@ class ConsoleMetricExporter extends StandardConsoleMetricExporter {
// export other metrics
for (const tenant of Object.keys(other)) {
for (const [k, v] of Object.entries(other[tenant])) {
LOG.info(`${k}${tenant !== 'undefined' ? ` of tenant "${tenant}"` : ''}: ${inspect(v)}`)
LOG.info(`${k}${tenant !== 'undefined' ? ` of tenant "${tenant}"` : ''}: ${inspect(v.length === 1 ? v[0] : v)}`)
Comment thread
schiwekM marked this conversation as resolved.
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/metrics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,16 @@ describe('metrics', () => {
expect(log.output).to.match(/process/i)
expect(log.output).not.to.match(/network/i)
})

test('other metrics with multiple datapoints are logged as array', async () => {
const { status } = await GET('/odata/v4/admin/Books', admin)
expect(status).to.equal(200)

await wait(200)

// nodejs.eventloop.time has multiple datapoints (active + idle) → logged as array
expect(log.output).to.match(/nodejs\.eventloop\.time: \[/)
// nodejs.eventloop.utilization has single datapoint → logged unwrapped (not as array)
expect(log.output).to.match(/nodejs\.eventloop\.utilization: \{/)
})
})
Loading