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

com.streamsets.pipeline.api.MetricContext Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2018 StreamSets Inc.
 *
 * 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.
 */
package com.streamsets.pipeline.api;

import com.codahale.metrics.Counter;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;

import java.util.Comparator;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.function.Function;

public interface MetricContext {
      /**
     * Returns the {@link MetricRegistry} used by the pipeline.
     *
     * @return the {@link MetricRegistry} used by the pipeline.
     */
    public MetricRegistry getMetrics();

    /**
     * Creates a {@link Timer} namespaced with the pipeline name and the stage instance name plus the given name.
     *
     * @param name the Timer name.
     * @return A Timer namespaced with the pipeline name and the stage instance name plus the given name.
     */
    public Timer createTimer(String name);

    /**
     * 

Invokes the given Callable stopping the local execution timer. Used for metering purposes.

*

For example, it should be used when a putting the stage to sleep, wrapping the {@code sleep()} call.

*/ @Deprecated default T localIdleCall(Callable callable, String msg, Object ... msgArgs){ return localIdleCall(callable, t -> true, msg, msgArgs); } /** *

Invokes the given Callable stopping the remote execution timer. Used for metering purposes.

*

For example, it should be used when calling a client library that blocks waiting for data.

*/ @Deprecated default T remoteIdleCall(Callable callable, String msg, Object ... msgArgs){ return remoteIdleCall(callable, t -> true, msg, msgArgs); } /** *

Invokes the given Callable stopping the local execution timer. Used for metering purposes.

*

For example, it should be used when a putting the stage to sleep, wrapping the {@code sleep()} call.

*

If the isIdleTime function is true the time will be deducted, if it is false it will be included.

*/ T localIdleCall(Callable callable, Function isIdleTime, String msg, Object ... msgArgs); /** *

Invokes the given Callable stopping the remote execution timer. Used for metering purposes.

*

For example, it should be used when calling a client library that blocks waiting for data.

*

If the isIdleTime function is true the time will be deducted, if it is false it will be included.

*/ T remoteIdleCall(Callable callable, Function isIdleTime, String msg, Object ... msgArgs); /** * Gets the already created {@link Timer} namespaced with the pipeline name and the stage instance name plus the given name. * * @param name the Timer name. * @return the already created Timer namespaced with the pipeline name and the stage instance name plus the given name. */ public Timer getTimer(String name); /** * Creates a {@link Meter} namespaced with the pipeline name and the stage instance name plus the given name. * * @param name the Meter name. * @return a Meter namespaced with the pipeline name and the stage instance name plus the given name. */ public Meter createMeter(String name); /** * Gets the already created {@link Meter} namespaced with the pipeline name and the stage instance name plus the given name. * * @param name the Meter name. * @return the already created Meter namespaced with the pipeline name and the stage instance name plus the given name. */ public Meter getMeter(String name); /** * Creates a {@link Counter} namespaced with the pipeline name and the stage instance name plus the given name. * * @param name the Counter name. * @return a Counter namespaced with the pipeline name and the stage instance name plus the given name. */ public Counter createCounter(String name); /** * Gets the already created {@link Counter} namespaced with the pipeline name and the stage instance name plus the given name. * * @param name the Counter name. * @return the already created Counter namespaced with the pipeline name and the stage instance name plus the given name. */ public Counter getCounter(String name); /** * Creates a {@link Histogram} namespaced with the pipeline name and the stage instance name plus the given name. * * Creates exponentially decaying histogram that biases the reservoir to the past 5 minutes of measurements. * * @param name the Histogram name. * @return a Histogram namespaced with the pipeline name and the stage instance name plus the given name. */ public Histogram createHistogram(String name); /** * Gets the already created {@link Histogram} namespaced with the pipeline name and the stage instance name plus the given name. * * @param name the Histogram name. * @return the already created Histogram namespaced with the pipeline name and the stage instance name plus the given name. */ public Histogram getHistogram(String name); /** * Creates a {@link Gauge} namespaced with the pipeline name and the stage instance name plus the given name. * * @param name the Gauge name. */ public Gauge> createGauge(String name); /** * Creates a {@link Gauge} namespaced with the pipeline name and the stage instance name plus the given name. * * This Gauge's underlying map will be sorted based on the comparator. * * @param name the Gauge name. */ public Gauge> createGauge(String name, Comparator comparator); /** * Gets the already created {@link Gauge} namespaced with the pipeline name and the stage instance name plus the given name. * * @param name the Gauge name. * @return the already created Gauge namespaced with the pipeline name and the stage instance name plus the given name. */ public Gauge> getGauge(String name); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy