Class MetricsRecorderServiceImpl
java.lang.Object
ch.tocco.nice2.metrics.impl.query.MetricsRecorderServiceImpl
- All Implemented Interfaces:
MetricsRecorderService
This is a threaded service so we can simply cache the
MetricsData
for the current thread.-
Constructor Summary
ConstructorDescriptionMetricsRecorderServiceImpl
(org.slf4j.Logger logger, SpyLoggerService spyLoggerService, SystemActivityService systemActivityService) -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
setEnabled
(boolean enabled) startRecording
(ActivityType activityType, Supplier<String> name, Supplier<String> details, Supplier<CategoryData> categoryData) Start collecting metrics for the current thread.startRecording
(ActivityType activityType, Supplier<String> name, Supplier<String> details, Supplier<CategoryData> categoryData, @Nullable String requestOrigin) void
void
updateCategoryOfActiveRecording
(Supplier<CategoryData> categoryData) Change theCategoryData
of the currently active recordingvoid
updateExceptionOfActiveRecording
(Exception exception) Update the exception of the currently active recording
-
Constructor Details
-
MetricsRecorderServiceImpl
public MetricsRecorderServiceImpl(org.slf4j.Logger logger, SpyLoggerService spyLoggerService, SystemActivityService systemActivityService)
-
-
Method Details
-
setEnabled
@Value("${nice2.metrics.enabled}") public void setEnabled(boolean enabled) -
startRecording
public MetricsData startRecording(ActivityType activityType, Supplier<String> name, Supplier<String> details, Supplier<CategoryData> categoryData) Description copied from interface:MetricsRecorderService
Start collecting metrics for the current thread.MetricsData.close()
must be called to stop the recording.- Specified by:
startRecording
in interfaceMetricsRecorderService
-
startRecording
public MetricsData startRecording(ActivityType activityType, Supplier<String> name, Supplier<String> details, Supplier<CategoryData> categoryData, @Nullable @Nullable String requestOrigin) - Specified by:
startRecording
in interfaceMetricsRecorderService
-
updateCategoryOfActiveRecording
Description copied from interface:MetricsRecorderService
Change theCategoryData
of the currently active recording- Specified by:
updateCategoryOfActiveRecording
in interfaceMetricsRecorderService
-
updateExceptionOfActiveRecording
Description copied from interface:MetricsRecorderService
Update the exception of the currently active recording- Specified by:
updateExceptionOfActiveRecording
in interfaceMetricsRecorderService
-
recordingInProgress
public boolean recordingInProgress()- Specified by:
recordingInProgress
in interfaceMetricsRecorderService
- Returns:
- true if metrics are already being collected for the current thread
-
threadDidDiscardService
@PreDestroy public void threadDidDiscardService()
-