function setGauge(name, value)
%setGauge create a Prometheus metric event of type 'Gauge'.
%
%   prodserver.metrics.setGauge(NAME, VALUE) creates a
%   Prometheus metrics event that is collected by MATLAB Production Server,
%   when the MATLAB code is deployed and executed.
%   This information can be queried via MATLAB Production Server Metrics API.
%
%   Input arguments:
%       NAME     Scalar text which identifies the metrics gauge name.
%
%       VALUE    Scalar number that replaces to the gauge current value,
%                which is maintained by MATLAB Production Server.
%                Note that gauge value may go up or down over time.
%
%   Output:
%       This function does not have a return value.
%       This function emits an encoded metric event string to be collected
%       and processed by MATLAB Production Server, when the MATLAB code is
%       deployed and being executed.
%
%   Examples:
%       prodserver.metrics.setGauge("requests_in_progress", 4)
%       Set the value of "requests_in_progress" gauge to 4.
%
%       prodserver.metrics.setGauge('battery_voltage_volts', 12.48)
%       Set the value of "battery_voltage_volts" gauge to 12.48.
%
%   See also: prodserver.metrics.incrementCounter

% Copyright 2021 The MathWorks, Inc.

    p = inputParser;
    addRequired(p,'name', prodserver.metrics.internal.InputValidator.metricsString);
    addRequired(p,'value',prodserver.metrics.internal.InputValidator.metricsNumeric);
    parse(p, name, value);

    [~, archive, ~] = fileparts(ctfroot);
    fprintf('[metric:gauge] %s|%s %g\n', archive, name, value);
end

