Class Settings
- java.lang.Object
-
- com.intergral.deep.agent.settings.Settings
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Settings.InvalidConfigException
Used 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 Settings
build(Map<String,String> agentArgs)
Build a new settings service from the input arguments from the agent.static <T> T
coerc(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> T
getPlugin(Class<T> clazz)
Get the first plugin that matches the given type.<T> T
getPluginByName(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.Resource
getResource()
Returns the resource that describes this client.String
getServiceHost()
Get the deep service host name.int
getServicePort()
Get the deep service port number.<T> T
getSettingAs(String key, Class<T> clazz)
Get a setting from the config as a given type.ITracepointLogger
getTracepointLogger()
Get the current tracepoint logger.boolean
isActive()
Is deep currently active.void
logTracepoint(String logMsg, String tracepointId, String snapshotId)
Log the tracepoint log via the configured logger.void
setActive(boolean state)
Allows enabling or disabled deep.void
setPlugins(Collection<IDeepPlugin> plugins)
Set configured plugins.void
setResource(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:ISettings
Get 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:
getSettingAs
in 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:ISettings
Get 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:ISettings
Returns the resource that describes this client.- Specified by:
getResource
in 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
null
if 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:
true
if 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
null
if we couldn't find a plugin of this type.
-
-