public class PluginSystemInstrumentation extends Object
The instrumentation may be safely invoked in any plugin system code, however will no-op unless this provider is enabled, which requires the following conditions to be met:
InstrumentRegistry is present in the class loadercom.atlassian.plugin.instrumentation.PluginSystemInstrumentation.enabled has been setNote to maintainers: extreme care must be taken to ensure that instrumentation classes are not accessed at runtime if they are not present.
| Modifier and Type | Field and Description |
|---|---|
static String |
INSTRUMENT_REGISTRY_CLASS |
static File |
REGISTRY_HOME_DIRECTORY |
static String |
REGISTRY_NAME |
| Modifier and Type | Method and Description |
|---|---|
static String |
getEnabledProperty()
Name of the system property that enables instrumentation.
|
Optional<com.atlassian.instrumentation.InstrumentRegistry> |
getInstrumentRegistry()
Retrieve the instrument registry if instrumentation is enabled and present in the classloader.
|
static PluginSystemInstrumentation |
instance()
Singleton accessor
|
SingleTimer |
pullSingleTimer(String name)
Pull a timer from the instrument registry, if instrumentation is enabled and present in the classloader.
|
Timer |
pullTimer(String name)
Pull a timer from the instrument registry, if instrumentation is enabled and present in the classloader.
|
public static final String INSTRUMENT_REGISTRY_CLASS
public static final String REGISTRY_NAME
public static final File REGISTRY_HOME_DIRECTORY
@Nonnull public static PluginSystemInstrumentation instance()
@Nonnull public static String getEnabledProperty()
@Nonnull public Optional<com.atlassian.instrumentation.InstrumentRegistry> getInstrumentRegistry()
@Nonnull public Timer pullTimer(@Nonnull String name)
This timer records wall-clock time and CPU time on the thread it was instantiated from.
This should be used for a section of code that we wish to repeatedly measure and aggregate results for.
The timer is Closeable and is expected to be used as per the following example:
try (Timer ignored = PluginSystemInstrumentation.instance().pullTimer("getEnabledModuleDescriptorsByClass")) {
// block we wish to repeatedly measure
}
name - that the timer will reportpullSingleTimer(String)@Nonnull public SingleTimer pullSingleTimer(@Nonnull String name)
This timer records wall-clock time and CPU time on the thread it was instantiated from.
This should be used for a section of code that we wish to measure once - the date and time appended to its name.
The timer is Closeable and is expected to be used as per the following example:
try (Timer ignored = PluginSystemInstrumentation.instance().pullSingleTimer("earlyStartup")) {
// block we wish to measure once, with a unique name
}
name - that the timer will reportpullTimer(String)Copyright © 2019 Atlassian. All rights reserved.