@vtex/api
Version:
VTEX I/O API client
32 lines (31 loc) • 1.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HostMetricsInstrumentation = void 0;
const instrumentation_1 = require("@opentelemetry/instrumentation");
const host_metrics_1 = require("@opentelemetry/host-metrics");
class HostMetricsInstrumentation extends instrumentation_1.InstrumentationBase {
constructor(config = {}) {
const instrumentation_name = config.name || 'host-metrics-instrumentation';
const instrumentation_version = '1.0.0';
super(instrumentation_name, instrumentation_version, config);
}
init() { }
enable() {
if (!this._config.meterProvider) {
throw new Error('MeterProvider is required for HostMetricsInstrumentation');
}
this.hostMetrics = new host_metrics_1.HostMetrics({
meterProvider: this._config.meterProvider,
name: this._config.name || 'host-metrics',
});
this.hostMetrics.start();
console.debug('HostMetricsInstrumentation enabled');
}
disable() {
if (this.hostMetrics) {
this.hostMetrics = undefined;
console.debug('HostMetricsInstrumentation disabled');
}
}
}
exports.HostMetricsInstrumentation = HostMetricsInstrumentation;