public final class JiraStats<T extends ManagedStats> extends com.google.common.reflect.AbstractInvocationHandler implements InvocationHandler, Closeable
JIRA_STATS_LOGGING_INTERVAL
and DEFAULT
).
Each report consists of two parts: a snapshot (stats collected since the last print) and total (stats collected since
Jira started).
Stats are node-specific (each node prints its own).
Gson
.
We recommend the implementations of SerializableStats
as building blocks of the class.
The class can be nested (i.e. have inner classes).
Supplier<M>
. This supplier will be used
to create objects storing stats. It will be called once for the total stats, as well as each time the snapshot stats
are reset.
JiraStats
can perform its periodic logging either within the thread running
the measured operation, or on a separate thread. For non-time-critical operations, or ones that take long time themselves,
the overhead of stats is low and it is ok to handle stats withing the same thread. However, to avoid the impact when
measuring methods that must remain very fast, or that are called many times per request, stats printing can be offloaded
to a separate thread. Alternatively, you can also limit the methods that can print stats, see MustNotPrintStats
.
void
return type.
public interface StatsInterface extends ManagedStats {
void onMethodA(long timeInMillis);
void onMethodB(long timeInMillis, long resultSize);
}
{@code private static class StatsClass implements StatsInterface { final MutableLongStats timeInMillisMethodA = new MutableLongStats(); final CountingSerializableStats timeInMillisMethodB = new CountingSerializableStats(); final MutableLongStats resultSizeMethodB = new MutableLongStats();
Modifier and Type | Field and Description |
---|---|
static String |
COMMON_PREFIX |
static String |
JIRA_STATS_LOGGING_INTERVAL |
Modifier and Type | Method and Description |
---|---|
void |
close() |
static <M extends ManagedStats> |
create(Class<M> interfaceClass,
java.util.function.Supplier<M> objectFactory,
boolean printOnSeparateThread) |
protected Object |
handleInvocation(Object proxyThatHasNoInterestingMethods,
Method method,
Object[] args)
This method is thread-safe
|
static long |
statsLoggingInterval(TimeUnit timeUnit) |
String |
toString() |
equals, hashCode, invoke
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
invoke
public static final String COMMON_PREFIX
public static final String JIRA_STATS_LOGGING_INTERVAL
public static long statsLoggingInterval(TimeUnit timeUnit)
public static <M extends ManagedStats> M create(Class<M> interfaceClass, java.util.function.Supplier<M> objectFactory, boolean printOnSeparateThread)
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
protected Object handleInvocation(Object proxyThatHasNoInterestingMethods, Method method, Object[] args) throws Throwable
handleInvocation
in class com.google.common.reflect.AbstractInvocationHandler
Throwable
public String toString()
toString
in class com.google.common.reflect.AbstractInvocationHandler
Copyright © 2002-2022 Atlassian. All Rights Reserved.