mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 22:11:09 +03:00
Lazyloaded OpenTelemetry packages to avoid boot time regression
- we don't want to load the Otel packages unless the instrumentation is enabled, because they dramatically increase the boot time (2x locally!)
This commit is contained in:
parent
bec000567d
commit
12cbb22b85
@ -1,7 +1,3 @@
|
||||
const {NodeSDK} = require('@opentelemetry/sdk-node');
|
||||
const {OTLPTraceExporter} = require('@opentelemetry/exporter-trace-otlp-http');
|
||||
const {getNodeAutoInstrumentations} = require('@opentelemetry/auto-instrumentations-node');
|
||||
|
||||
async function initOpenTelemetry({config}) {
|
||||
// Always enable in development environment
|
||||
// In production, only enable if explicitly enabled via config `opentelemetry:enabled`
|
||||
@ -16,6 +12,12 @@ async function initOpenTelemetry({config}) {
|
||||
headers: {},
|
||||
concurrencyLimit: 10
|
||||
};
|
||||
|
||||
// Lazyloaded to avoid boot time overhead when not enabled
|
||||
const {NodeSDK} = require('@opentelemetry/sdk-node');
|
||||
const {OTLPTraceExporter} = require('@opentelemetry/exporter-trace-otlp-http');
|
||||
const {getNodeAutoInstrumentations} = require('@opentelemetry/auto-instrumentations-node');
|
||||
|
||||
const sdk = new NodeSDK({
|
||||
serviceName: 'ghost',
|
||||
traceExporter: new OTLPTraceExporter(collectorOptions),
|
||||
@ -28,4 +30,4 @@ async function initOpenTelemetry({config}) {
|
||||
|
||||
module.exports = {
|
||||
initOpenTelemetry
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user