Documentation
¶
Overview ¶
Package stats contains interfaces and utilities relating to the collection of statistics from Scalibr.
Index ¶
- type AfterExtractorStats
- type Collector
- type FileExtractedResult
- type FileExtractedStats
- type FileRequiredResult
- type FileRequiredStats
- type NoopCollector
- func (c NoopCollector) AfterDetectorRun(name string, runtime time.Duration, err error)
- func (c NoopCollector) AfterExtractorRun(pluginName string, extractorstats *AfterExtractorStats)
- func (c NoopCollector) AfterFileExtracted(pluginName string, filestats *FileExtractedStats)
- func (c NoopCollector) AfterFileRequired(pluginName string, filestats *FileRequiredStats)
- func (c NoopCollector) AfterInodeVisited(path string)
- func (c NoopCollector) AfterResultsExported(destination string, bytes int, err error)
- func (c NoopCollector) AfterScan(runtime time.Duration, status *plugin.ScanStatus)
- func (c NoopCollector) MaxRSS(maxRSS int64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AfterExtractorStats ¶ added in v0.2.1
type AfterExtractorStats struct {
Path string
Root string
Runtime time.Duration
Inventory *inventory.Inventory
Error error
}
AfterExtractorStats is a struct containing stats about the results of a file extraction run.
type Collector ¶
type Collector interface {
AfterInodeVisited(path string)
AfterExtractorRun(pluginName string, extractorstats *AfterExtractorStats)
AfterDetectorRun(name string, runtime time.Duration, err error)
AfterScan(runtime time.Duration, status *plugin.ScanStatus)
// AfterResultsExported is called after results have been exported. destination should merely be
// a category of where the result was written to (e.g. 'file', 'http'), not the precise location.
AfterResultsExported(destination string, bytes int, err error)
// AfterFileRequired may be called by individual plugins after the
// `FileRequired` method is called on a file. This allows plugins to report
// why a certain file may have been skipped. Note that in general, extractor
// plugins will not record a metric if a file was skipped because it is deemed
// completely irrelevant (e.g. the Python extractor will not report that it
// skipped a JAR file).
AfterFileRequired(pluginName string, filestats *FileRequiredStats)
// AfterFileExtracted may be called by individual plugins after a file was seen in
// the `Extract` method, as opposed to `AfterExtractorRun`, which is called by
// the filesystem handling code. This allows plugins to report internal state
// for metric collection.
AfterFileExtracted(pluginName string, filestats *FileExtractedStats)
// MaxRSS is called when the scan is finished. It is used to report the maximum resident
// memory usage of the scan.
MaxRSS(maxRSS int64)
}
Collector is a component which is notified when certain events occur. It can be implemented with different metric backends to enable monitoring of Scalibr.
type FileExtractedResult ¶ added in v0.1.2
type FileExtractedResult string
FileExtractedResult is a string representation of the result of a call to `Extractor.Extract`.
const ( // FileExtractedResultSuccess indicates that the file was extracted // successfully. FileExtractedResultSuccess FileExtractedResult = "FILE_EXTRACTED_RESULT_SUCCESS" // FileExtractedResultErrorUnknown indicates that an unknown error occurred // during extraction. FileExtractedResultErrorUnknown FileExtractedResult = "FILE_EXTRACTED_RESULT_ERROR_UNKNOWN" // FileExtractedResultErrorMemoryLimitExceeded indicates that the extraction // failed because the memory limit inside the plugin was exceeded. FileExtractedResultErrorMemoryLimitExceeded = "FILE_EXTRACTED_RESULT_ERROR_MEMORY_LIMIT_EXCEEDED" )
type FileExtractedStats ¶ added in v0.1.2
type FileExtractedStats struct {
Path string
Result FileExtractedResult
FileSizeBytes int64
// Optional. For extractors that unarchive a compressed files, this reports
// the bytes that were opened during the unarchiving process.
UncompressedBytes int64
}
FileExtractedStats is a struct containing stats about a file that was extracted. If the file was skipped due to an error during extraction, `Error` will be populated.
type FileRequiredResult ¶ added in v0.1.2
type FileRequiredResult string
FileRequiredResult is a string representation of the result of a call to `Extractor.FileRequired`.
const ( // FileRequiredResultOK indicates that the file was required by the plugin. FileRequiredResultOK FileRequiredResult = "FILE_REQUIRED_RESULT_OK" // FileRequiredResultSizeLimitExceeded indicates that the file was skipped // because it was too large. FileRequiredResultSizeLimitExceeded FileRequiredResult = "FILE_REQUIRED_RESULT_SIZE_LIMIT_EXCEEDED" )
type FileRequiredStats ¶ added in v0.1.2
type FileRequiredStats struct {
Path string
Result FileRequiredResult
FileSizeBytes int64
}
FileRequiredStats is a struct containing stats about a file that was required or skipped by a plugin.
type NoopCollector ¶
type NoopCollector struct{}
NoopCollector implements Collector by doing nothing.
func (NoopCollector) AfterDetectorRun ¶
func (c NoopCollector) AfterDetectorRun(name string, runtime time.Duration, err error)
AfterDetectorRun implements Collector by doing nothing.
func (NoopCollector) AfterExtractorRun ¶
func (c NoopCollector) AfterExtractorRun(pluginName string, extractorstats *AfterExtractorStats)
AfterExtractorRun implements Collector by doing nothing.
func (NoopCollector) AfterFileExtracted ¶ added in v0.1.2
func (c NoopCollector) AfterFileExtracted(pluginName string, filestats *FileExtractedStats)
AfterFileExtracted implements Collector by doing nothing.
func (NoopCollector) AfterFileRequired ¶ added in v0.1.2
func (c NoopCollector) AfterFileRequired(pluginName string, filestats *FileRequiredStats)
AfterFileRequired implements Collector by doing nothing.
func (NoopCollector) AfterInodeVisited ¶
func (c NoopCollector) AfterInodeVisited(path string)
AfterInodeVisited implements Collector by doing nothing.
func (NoopCollector) AfterResultsExported ¶
func (c NoopCollector) AfterResultsExported(destination string, bytes int, err error)
AfterResultsExported implements Collector by doing nothing.
func (NoopCollector) AfterScan ¶
func (c NoopCollector) AfterScan(runtime time.Duration, status *plugin.ScanStatus)
AfterScan implements Collector by doing nothing.
func (NoopCollector) MaxRSS ¶ added in v0.1.4
func (c NoopCollector) MaxRSS(maxRSS int64)
MaxRSS implements Collector by doing nothing.