Class Settings
- java.lang.Object
-
- com.intergral.deep.agent.settings.Settings
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSettings.InvalidConfigExceptionUsed to indicate an invalid config value.
-
Field Summary
-
Fields inherited from interface com.intergral.deep.agent.api.settings.ISettings
APP_FRAMES_EXCLUDES, APP_FRAMES_INCLUDES, JSP_PACKAGES, JSP_SUFFIX, KEY_AUTH_PROVIDER, KEY_ENABLED, KEY_SERVICE_SECURE, KEY_SERVICE_URL
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IRegistration<IDeepPlugin>addPlugin(IDeepPlugin plugin)Add a plugin to the current config.static Settingsbuild(Map<String,String> agentArgs)Build a new settings service from the input arguments from the agent.static <T> Tcoerc(String str, Class<T> type)Coerce a value into a given type.List<String>getAsList(String key)Get the value as a list.Map<String,String>getMap(String key)Get the property as a map.<T> TgetPlugin(Class<T> clazz)Get the first plugin that matches the given type.<T> TgetPluginByName(Class<T> clazz, String name)Get the plugin that is on the provided type and has the given name.Collection<IDeepPlugin>getPlugins()Get all configured plugins.<T> Collection<T>getPlugins(Class<T> target)Get all plugins of the provided type.ResourcegetResource()Returns the resource that describes this client.StringgetServiceHost()Get the deep service host name.intgetServicePort()Get the deep service port number.<T> TgetSettingAs(String key, Class<T> clazz)Get a setting from the config as a given type.ITracepointLoggergetTracepointLogger()Get the current tracepoint logger.booleanisActive()Is deep currently active.voidlogTracepoint(String logMsg, String tracepointId, String snapshotId)Log the tracepoint log via the configured logger.voidsetActive(boolean state)Allows enabling or disabled deep.voidsetPlugins(Collection<IDeepPlugin> plugins)Set configured plugins.voidsetResource(Resource resource)Get the resource value for this agent.
-
-
-
Method Detail
-
build
public static Settings build(Map<String,String> agentArgs)
Build a new settings service from the input arguments from the agent.- Parameters:
agentArgs- the agent input arguments- Returns:
- the new settings service
-
coerc
public static <T> T coerc(String str, Class<T> type)
Coerce a value into a given type.- Type Parameters:
T- the type to return as- Parameters:
str- the value to coercetype- the type to change to- Returns:
- the value as the given type, or
null
-
getSettingAs
public <T> T getSettingAs(String key, Class<T> clazz)
Description copied from interface:ISettingsGet a setting from the config as a given type.When reading a config value, deep will scan the config file, system properties and environment variables. We will read the values in order:
- Environment Variables
- System Property
- Config Value
When we read a value we will scope the keys to suit the place from which we are reading. This means that if we are looking for 'service.name' we will use the following keys:
- DEEP_SERVICE_NAME - When looking in Environment variables we uppercase and use underscores
- deep.service.name - When looking in System Properties we lowercase and use dots
- service.name - When looking in config file we use the normalised value
- Specified by:
getSettingAsin interfaceISettings- Type Parameters:
T- the type to return as- Parameters:
key- the key for the settingclazz- the type to return as- Returns:
- the value as the given type
-
getMap
public Map<String,String> getMap(String key)
Description copied from interface:ISettingsGet the property as a map.
-
getServiceHost
public String getServiceHost()
Get the deep service host name.- Returns:
- the service host name
- Throws:
Settings.InvalidConfigException- if the value cannot be obtained
-
getServicePort
public int getServicePort()
Get the deep service port number.- Returns:
- the service port number
- Throws:
Settings.InvalidConfigException- if the value cannot be obtained
-
getResource
public Resource getResource()
Description copied from interface:ISettingsReturns the resource that describes this client.- Specified by:
getResourcein interfaceISettings- Returns:
- the
Resource
-
setResource
public void setResource(Resource resource)
Get the resource value for this agent.- Parameters:
resource- the resource that describes this agent
-
getPluginByName
public <T> T getPluginByName(Class<T> clazz, String name)
Get the plugin that is on the provided type and has the given name.- Type Parameters:
T- the type of the plugin- Parameters:
clazz- the type of the plugin to matchname- the class name of the plugin to match- Returns:
- the discovered plugin with the given name, or
nullif a plugin with the provided name and type cannot be found.
-
getPlugins
public Collection<IDeepPlugin> getPlugins()
Get all configured plugins.- Returns:
- the full list on plugins
-
getPlugins
public <T> Collection<T> getPlugins(Class<T> target)
Get all plugins of the provided type.- Type Parameters:
T- the type of the plugin- Parameters:
target- the type of plugin we want- Returns:
- the list of plugins
-
setPlugins
public void setPlugins(Collection<IDeepPlugin> plugins)
Set configured plugins.- Parameters:
plugins- the plugins to use
-
isActive
public boolean isActive()
Is deep currently active.- Returns:
trueif deep is active, elsefalse
-
setActive
public void setActive(boolean state)
Allows enabling or disabled deep.A disabled deep will remove installed tracepoints and stop polling. It will not remove itself.
- Parameters:
state- the new state
-
logTracepoint
public void logTracepoint(String logMsg, String tracepointId, String snapshotId)
Log the tracepoint log via the configured logger.- Parameters:
logMsg- the log messagetracepointId- the tracepoint idsnapshotId- the snapshot id
-
getTracepointLogger
public ITracepointLogger getTracepointLogger()
Get the current tracepoint logger.- Returns:
- the tracepoint logger
-
addPlugin
public IRegistration<IDeepPlugin> addPlugin(IDeepPlugin plugin)
Add a plugin to the current config.- Parameters:
plugin- the new plugin- Returns:
- the plugin registration
-
getPlugin
public <T> T getPlugin(Class<T> clazz)
Get the first plugin that matches the given type.- Type Parameters:
T- the plugin type- Parameters:
clazz- the type of plugin we need- Returns:
- the discovered plugin or
nullif we couldn't find a plugin of this type.
-
-