Package com.mindscapehq.raygun4java.core
Class RaygunClientFactory
- java.lang.Object
-
- com.mindscapehq.raygun4java.core.RaygunClientFactory
-
- All Implemented Interfaces:
IRaygunClientFactory
public class RaygunClientFactory extends Object implements IRaygunClientFactory
An out-of-the-box RaygunClient factory. Developers are encouraged to hold this as a singleton and inject it into their main classes .newClient() should be called at the start of a process/request/thread. The instance could be stored as a staticThreadLocal<RaygunClient>so that it can be used statically throughout the process. Don't forget to remove the instance at the end of your process. RaygunClientFactory factory = new RaygunClientFactory(myApiKey).withBeforeSend(myRaygunOnBeforeSend); ... RaygunClient client = factory.getClient();
-
-
Field Summary
Fields Modifier and Type Field Description protected StringapiKeyprotected MapfactoryDataprotected Set<String>factoryTagsprotected Stringversion
-
Constructor Summary
Constructors Constructor Description RaygunClientFactory(String apiKey)This constructor will attempt to extract the app version from /META-INF/MANIFEST.MF of the executing jar
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends RaygunClient>
TbuildClient(T client)Map<?,?>getData()AbstractRaygunSendEventChainFactorygetRaygunOnAfterSendChainFactory()AbstractRaygunSendEventChainFactory<IRaygunOnBeforeSend>getRaygunOnBeforeSendChainFactory()AbstractRaygunSendEventChainFactorygetRaygunOnFailedSendChainFactory()Set<String>getTags()RaygunClientnewClient()voidsetData(Map<?,?> data)voidsetTags(Set<String> tags)RaygunClientFactorywithAfterSend(IRaygunSendEventFactory<IRaygunOnAfterSend> onAfterSend)Add a RaygunOnAfterSend handler factory.withAfterSend(myRaygunOnAfterSendFactory)RaygunClientFactorywithApiKey(String apiKey)Generates a factory with associated apiKeyRaygunClientFactorywithBeforeSend(IRaygunSendEventFactory<IRaygunOnBeforeSend> onBeforeSend)Add a RaygunOnBeforeSend handler factory.withBeforeSend(myRaygunOnBeforeSendFactory)RaygunClientFactorywithBreadcrumbLocations()BEWARE: enabling could seriously degrade performance of your applicationRaygunClientFactorywithData(Object key, Object value)This data will be added to every error sentRaygunClientFactorywithExcludedExceptions(Class... excludedWrappers)RaygunClientFactorywithFailedSend(IRaygunSendEventFactory<IRaygunOnFailedSend> onFailedSend)Add a RaygunOnFailedSend handler factory.withFailedSend(myRaygunOnFailedSendFactory)RaygunClientFactorywithMessageBuilder(IRaygunMessageBuilderFactory messageBuilderFactory)Generates a factory with associatedIRaygunMessageBuilderFactoryRaygunClientFactorywithOfflineStorage()Generates a factory with associated offline storage on default directoryRaygunClientFactorywithOfflineStorage(String storageDir)Generates a factory with associated offline storage on given directoryRaygunClientFactorywithTag(String tag)These tags will be added to every error sentRaygunClientFactorywithVersion(String version)Generates a factory with associated versionRaygunClientFactorywithVersionFrom(Class versionFromClass)Generates a factory with associated version derived from classRaygunClientFactorywithWrappedExceptionStripping(Class... stripWrappers)
-
-
-
Constructor Detail
-
RaygunClientFactory
public RaygunClientFactory(String apiKey)
This constructor will attempt to extract the app version from /META-INF/MANIFEST.MF of the executing jar- Parameters:
apiKey- your Raygun apiKey
-
-
Method Detail
-
withBeforeSend
public RaygunClientFactory withBeforeSend(IRaygunSendEventFactory<IRaygunOnBeforeSend> onBeforeSend)
Add a RaygunOnBeforeSend handler factory.withBeforeSend(myRaygunOnBeforeSendFactory)- Specified by:
withBeforeSendin interfaceIRaygunClientFactory- Parameters:
onBeforeSend-IRaygunSendEventFactory<IRaygunOnBeforeSend>to be executed before sending the error to Raygun- Returns:
- factory
-
withAfterSend
public RaygunClientFactory withAfterSend(IRaygunSendEventFactory<IRaygunOnAfterSend> onAfterSend)
Add a RaygunOnAfterSend handler factory.withAfterSend(myRaygunOnAfterSendFactory)- Specified by:
withAfterSendin interfaceIRaygunClientFactory- Parameters:
onAfterSend-IRaygunSendEventFactory<IRaygunOnAfterSend>to be executed after sending the- Returns:
- factory
-
withFailedSend
public RaygunClientFactory withFailedSend(IRaygunSendEventFactory<IRaygunOnFailedSend> onFailedSend)
Add a RaygunOnFailedSend handler factory.withFailedSend(myRaygunOnFailedSendFactory)- Specified by:
withFailedSendin interfaceIRaygunClientFactory- Parameters:
onFailedSend-IRaygunSendEventFactory<IRaygunOnFailedSend>to be executed on error- Returns:
- factory
-
withApiKey
public RaygunClientFactory withApiKey(String apiKey)
Generates a factory with associated apiKey- Parameters:
apiKey- Raygun apiKey- Returns:
- factory
-
withVersion
public RaygunClientFactory withVersion(String version)
Generates a factory with associated version- Parameters:
version- of your Java application- Returns:
- factory
-
withVersionFrom
public RaygunClientFactory withVersionFrom(Class versionFromClass)
Generates a factory with associated version derived from class- Parameters:
versionFromClass- the class object to derive your app's version from- Returns:
- factory
-
withMessageBuilder
public RaygunClientFactory withMessageBuilder(IRaygunMessageBuilderFactory messageBuilderFactory)
Generates a factory with associatedIRaygunMessageBuilderFactory- Parameters:
messageBuilderFactory- the message builder factory object- Returns:
- factory
-
withOfflineStorage
public RaygunClientFactory withOfflineStorage()
Generates a factory with associated offline storage on default directory- Returns:
- factory
-
withOfflineStorage
public RaygunClientFactory withOfflineStorage(String storageDir)
Generates a factory with associated offline storage on given directory- Parameters:
storageDir- the directory to store errors- Returns:
- factory
-
withBreadcrumbLocations
public RaygunClientFactory withBreadcrumbLocations()
BEWARE: enabling could seriously degrade performance of your application- Returns:
- factory
-
withTag
public RaygunClientFactory withTag(String tag)
These tags will be added to every error sent- Parameters:
tag- to be associated with the error- Returns:
- factory
-
getData
public Map<?,?> getData()
-
setData
public void setData(Map<?,?> data)
-
withData
public RaygunClientFactory withData(Object key, Object value)
This data will be added to every error sent- Parameters:
key- of key-value pairvalue- of key-value pair- Returns:
- factory
-
withWrappedExceptionStripping
public RaygunClientFactory withWrappedExceptionStripping(Class... stripWrappers)
-
withExcludedExceptions
public RaygunClientFactory withExcludedExceptions(Class... excludedWrappers)
-
newClient
public RaygunClient newClient()
- Specified by:
newClientin interfaceIRaygunClientFactory- Returns:
- a new RaygunClient configured by this factory
-
buildClient
public <T extends RaygunClient> T buildClient(T client)
-
getRaygunOnBeforeSendChainFactory
public AbstractRaygunSendEventChainFactory<IRaygunOnBeforeSend> getRaygunOnBeforeSendChainFactory()
- Specified by:
getRaygunOnBeforeSendChainFactoryin interfaceIRaygunClientFactory
-
getRaygunOnAfterSendChainFactory
public AbstractRaygunSendEventChainFactory getRaygunOnAfterSendChainFactory()
- Specified by:
getRaygunOnAfterSendChainFactoryin interfaceIRaygunClientFactory
-
getRaygunOnFailedSendChainFactory
public AbstractRaygunSendEventChainFactory getRaygunOnFailedSendChainFactory()
- Specified by:
getRaygunOnFailedSendChainFactoryin interfaceIRaygunClientFactory
-
-