Class Feature
java.lang.Object
io.github.projectunified.faststats.core.Feature
- Direct Known Subclasses:
ErrorTracker, FeatureFlagManager, PaperErrorTracker
An abstract representation of a feature that can submit telemetry payloads on demand.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(String json) Deserializes the given JSON string into a telemetry map.Gets the default context containing OS and platform information.Gets the default properties to assign to the configuration.getFeature(Class<T> featureClass) Finds a registered feature of the specified class.final StringgetProperty(String key, String defaultValue) Gets a configuration property.protected final TaskSchedulerGets the TaskScheduler instance.voidonConfigMigrate(Config config, int oldConfigVersion, int newConfigVersion) Called when the configuration needs migration.voidCalled when the Metrics coordinator is shutdown.voidonStart()Called when the Metrics coordinator is started.protected final Submitter.ResponseSubmits the given data map payload and returns the response.
-
Constructor Details
-
Feature
public Feature()
-
-
Method Details
-
onStart
public void onStart()Called when the Metrics coordinator is started. Subclasses can override this to initialize scheduling or start listeners. -
onShutdown
public void onShutdown()Called when the Metrics coordinator is shutdown. Subclasses can override this to release resources or stop listeners. -
getDefaultProperties
-
onConfigMigrate
Called when the configuration needs migration.- Parameters:
config- the configurationoldConfigVersion- the old configuration versionnewConfigVersion- the new configuration version
-
getDefaultContext
-
submit
protected final Submitter.Response submit(String path, Map<String, Object> dataMap, boolean compressed) throws ExceptionSubmits the given data map payload and returns the response.- Parameters:
path- the target path or URLdataMap- a map of keys to their data mapscompressed- whether to compress the payload using GZIP- Returns:
- the response context
- Throws:
Exception- if submission fails
-
deserialize
-
getProperty
-
getFeature
Finds a registered feature of the specified class.- Type Parameters:
T- the feature type- Parameters:
featureClass- the feature class- Returns:
- an Optional containing the feature if found, or empty if not found or metrics is not set
-
getScheduler
Gets the TaskScheduler instance.- Returns:
- the TaskScheduler instance
-