import { MetricsGateway } from "./MetricsGateway.js";
import { NullMetricsGateway } from "./NullMetricsGateway.js";
import { assert } from "../../core/assert.js";

/**
 * Forwards metrics to another gateway
 */
export class ProxyMetricsGateway extends MetricsGateway {
    constructor() {
        super();

        /**
         *
         * @type {MetricsGateway}
         */
        this.target = NullMetricsGateway.INSTANCE;
    }

    /**
     *
     * @param {MetricsGateway} gateway
     */
    setTarget(gateway) {
        assert.defined(gateway, 'gateway');

        this.target = gateway;
    }

    record(type, event) {

        this.target.record(type, event);

    }
}
