Ghost/ghost/core/test/unit/shared/instrumentation.test.js
Chris Raible 5f9c0d21c5
Added eventLoopUtilization instrumentation behind config (#20819)
ref
https://linear.app/tryghost/issue/ENG-1505/start-monitoring-event-loop-utilization-in-production-with

- The two main constraints we've observed in Ghost are the database connection pool and the CPU usage. However, there is a third constraint that we may be hitting, but can't currently observe: the event loop.
- This commit re-enabled OpenTelemetry (behind a config flag), removes the problematic tracing instrumentation which was breaking the frontend, and adds a Prometheus endpoint to export the eventLoopUtilization metric.
- This should give us visibility into whether we are hitting constraints in the event loop and address the root cause if we are.
2024-08-22 19:16:53 -07:00

23 lines
855 B
JavaScript

const assert = require('assert/strict');
const sinon = require('sinon');
describe('UNIT: instrumentation', function () {
it('should initialize OpenTelemetry if configured', async function () {
const config = {
get: sinon.stub().returns(true)
};
const instrumentation = require('../../../core/shared/instrumentation');
const result = await instrumentation.initOpenTelemetry({config});
assert.equal(result, true);
});
it('should not initialize OpenTelemetry if not configured', async function () {
const config = {
get: sinon.stub().returns(false)
};
const instrumentation = require('../../../core/shared/instrumentation');
const result = await instrumentation.initOpenTelemetry({config});
assert.equal(result, false);
});
});