Class PluginSystemInstrumentation
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:
InstrumentRegistryis present in the class loader- The boolean system property
com.atlassian.plugin.instrumentation.PluginSystemInstrumentation.enabledhas been set
Note to maintainers: extreme care must be taken to ensure that instrumentation classes are not accessed at runtime if they are not present.
- Since:
- 4.1
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringName of the system property that enables instrumentation.Optional<com.atlassian.instrumentation.InstrumentRegistry>Retrieve the instrument registry if instrumentation is enabled and present in the classloader.static PluginSystemInstrumentationinstance()Singleton accessorpullSingleTimer(String name) Pull a timer from the instrument registry, if instrumentation is enabled and present in the classloader.Pull a timer from the instrument registry, if instrumentation is enabled and present in the classloader.
-
Field Details
-
INSTRUMENT_REGISTRY_CLASS
- See Also:
-
REGISTRY_NAME
- See Also:
-
REGISTRY_HOME_DIRECTORY
-
-
Method Details
-
instance
Singleton accessor- Returns:
- one and only instance
-
getEnabledProperty
Name of the system property that enables instrumentation. Note that instrumentation defaults to "off".- Returns:
- property name
-
getInstrumentRegistry
Retrieve the instrument registry if instrumentation is enabled and present in the classloader.- Returns:
- one and only registry
-
pullTimer
Pull a timer from the instrument registry, if instrumentation is enabled and present in the classloader.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
Closeableand is expected to be used as per the following example:try (Timer ignored = PluginSystemInstrumentation.instance().pullTimer("getEnabledModuleDescriptorsByClass")) { // block we wish to repeatedly measure }- Parameters:
name- that the timer will report- Returns:
- timer that may be empty - if no instrumentation it is still safe to close, which is a no-op
- See Also:
-
pullSingleTimer
Pull a timer from the instrument registry, if instrumentation is enabled and present in the classloader.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
Closeableand 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 }- Parameters:
name- that the timer will report- Returns:
- timer that may be empty - if no instrumentation it is still safe to close, which is a no-op
- See Also:
-