All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hu.icellmobilsoft.coffee.grpc.metrics.micrometer.bundle.MetricsBundle Maven / Gradle / Ivy

/*-
 * #%L
 * Coffee
 * %%
 * Copyright (C) 2020 - 2023 i-Cell Mobilsoft Zrt.
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package hu.icellmobilsoft.coffee.grpc.metrics.micrometer.bundle;

import java.time.LocalDateTime;
import java.util.function.Function;

import io.grpc.Status.Code;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.Timer;

/**
 * Container for metrics data.
 * 
 * @author czenczl
 * @author Imre Scheffer
 * @since 2.5.0
 */
public class MetricsBundle {

    private Counter requestCounter;
    private Counter responseCounter;
    private Function timerCodeFunction;

    private LocalDateTime startTime;

    /**
     * Default constructor, constructs a new object.
     */
    public MetricsBundle() {
        super();
    }

    /**
     * Gets counter that counts requests.
     * 
     * @return counter for request metric
     */
    public Counter getRequestCounter() {
        return requestCounter;
    }

    /**
     * Sets counter that counts requests.
     * 
     * @param requestCounter
     *            counter that counts requests
     */
    public void setRequestCounter(Counter requestCounter) {
        this.requestCounter = requestCounter;
    }

    /**
     * Gets counter that counts response.
     * 
     * @return counter for response metric
     */
    public Counter getResponseCounter() {
        return responseCounter;
    }

    /**
     * Sets counter that counts response.
     * 
     * @param responseCounter
     *            counter that counts response
     */
    public void setResponseCounter(Counter responseCounter) {
        this.responseCounter = responseCounter;
    }

    /**
     * Gets the function that representing process duration
     * 
     * @return function for duration and status code
     */
    public Function getTimerCodeFunction() {
        return timerCodeFunction;
    }

    /**
     * Gets the function that representing process duration
     * 
     * @param timerCodeFunction
     *            function that representing process duration and status code
     */
    public void setTimerCodeFunction(Function timerCodeFunction) {
        this.timerCodeFunction = timerCodeFunction;
    }

    /**
     * Gets the start time of the process
     * 
     * @return process start time
     */
    public LocalDateTime getStartTime() {
        return startTime;
    }

    /**
     * Sets the start time of the process
     * 
     * @param startTime
     *            metric timer start time
     */
    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy