stats

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package stats contains interfaces and utilities relating to the collection of statistics from Scalibr.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

type Collector interface {
	AfterInodeVisited(path string)
	AfterExtractorRun(name string, runtime time.Duration, err error)
	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)
}

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(name string, runtime time.Duration, err error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL