Class ErrorTracker
java.lang.Object
io.github.projectunified.faststats.core.Feature
io.github.projectunified.faststats.errortracker.ErrorTracker
A feature that tracks uncaught and handled errors, anonymizes sensitive info,
and submits report payloads.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new error tracker feature that is context-unaware.ErrorTracker(ClassLoader loader) Creates a new error tracker feature with the specified class loader. -
Method Summary
Modifier and TypeMethodDescriptionAdds an anonymization pattern replacement rule.Adds an anonymization pattern replacement rule.voidattachErrorContext(ClassLoader classLoader) Attaches uncaught error handling using the specified class loader.static ErrorTrackerCreates a context-aware error tracker feature.static ErrorTrackerCreates a context-unaware error tracker feature.voidDetaches error context handling and restores the original handler.Gets the error event handler.Gets the default properties to assign to the configuration.ignoreError(Class<? extends Throwable> type) Adds an error type that will not be reported.ignoreError(Class<? extends Throwable> type, String pattern) Adds an error type and message pattern string that will be ignored.ignoreError(Class<? extends Throwable> type, Pattern pattern) Adds an error type and message pattern that will be ignored.ignoreError(String pattern) Adds a pattern string that will be matched against error messages to ignore them.ignoreError(Pattern pattern) Adds a pattern that will be matched against error messages to ignore them.booleanGets whether an error context is currently attached.voidCalled when the Metrics coordinator is shutdown.voidonStart()Called when the Metrics coordinator is started.voidsetContextErrorHandler(BiConsumer<ClassLoader, Throwable> errorEvent) Sets the error event handler.voidtrackError(String message) Tracks a handled error with the given message.voidtrackError(String message, boolean handled) Tracks an error with the given message.voidtrackError(Throwable error) Tracks a handled error.voidtrackError(Throwable error, boolean handled) Tracks an error.Methods inherited from class Feature
getFeature, getProperty, getScheduler, submit
-
Constructor Details
-
ErrorTracker
public ErrorTracker()Creates a new error tracker feature that is context-unaware. -
ErrorTracker
Creates a new error tracker feature with the specified class loader.- Parameters:
loader- the class loader context
-
-
Method Details
-
contextAware
Creates a context-aware error tracker feature.- Returns:
- a new error tracker feature
-
contextUnaware
Creates a context-unaware error tracker feature.- Returns:
- a new error tracker feature
-
getDefaultProperties
-
onStart
-
onShutdown
public void onShutdown()Description copied from class:FeatureCalled when the Metrics coordinator is shutdown. Subclasses can override this to release resources or stop listeners.- Overrides:
onShutdownin classFeature
-
trackError
Tracks a handled error with the given message.- Parameters:
message- the error message
-
trackError
-
trackError
Tracks an error with the given message.- Parameters:
message- the error messagehandled- whether the error was handled
-
trackError
Tracks an error.- Parameters:
error- the errorhandled- whether the error was handled
-
ignoreError
Adds an error type that will not be reported.- Parameters:
type- the error type- Returns:
- this instance
-
ignoreError
Adds a pattern that will be matched against error messages to ignore them.- Parameters:
pattern- the pattern- Returns:
- this instance
-
ignoreError
Adds a pattern string that will be matched against error messages to ignore them.- Parameters:
pattern- the regex pattern- Returns:
- this instance
-
ignoreError
Adds an error type and message pattern that will be ignored.- Parameters:
type- the error typepattern- the pattern- Returns:
- this instance
-
ignoreError
Adds an error type and message pattern string that will be ignored.- Parameters:
type- the error typepattern- the regex pattern- Returns:
- this instance
-
anonymize
Adds an anonymization pattern replacement rule.- Parameters:
pattern- the pattern to matchreplacement- the replacement string- Returns:
- this instance
-
anonymize
Adds an anonymization pattern replacement rule.- Parameters:
pattern- the regex pattern to matchreplacement- the replacement string- Returns:
- this instance
-
attachErrorContext
Attaches uncaught error handling using the specified class loader.- Parameters:
classLoader- the class loader- Throws:
IllegalStateException- if already attached
-
detachErrorContext
public void detachErrorContext()Detaches error context handling and restores the original handler. -
isContextAttached
public boolean isContextAttached()Gets whether an error context is currently attached.- Returns:
- true if attached, false otherwise
-
getContextErrorHandler
Gets the error event handler.- Returns:
- the handler
-
setContextErrorHandler
Sets the error event handler.- Parameters:
errorEvent- the handler
-