Documentation
¶
Index ¶
- Variables
- func CheckBuildMetadata(ctx context.Context, tracer otelTrace.Tracer, id string) (bool, error)
- func CheckTestMetadata(ctx context.Context, tracer otelTrace.Tracer, buildID string, testID string) (bool, error)
- func DownloadLogLines(ctx context.Context, tracer otelTrace.Tracer, buildID string, testID string) (chan *LogLineItem, error)
- func InsertLogLines(ctx context.Context, tracer otelTrace.Tracer, buildID string, testID string, ...) error
- func NewBuildID(ctx context.Context, tracer otelTrace.Tracer, builder string, buildNum int) (string, error)
- func NewTestID(startTime time.Time) string
- type Build
- type Iterator
- type LogChunk
- type LogChunkInfo
- type LogIterator
- func NewBatchedLogIterator(chunks []LogChunkInfo, batchSize int, timeRange TimeRange) LogIterator
- func NewMergingIterator(iterators ...LogIterator) LogIterator
- func NewParallelizedLogIterator(chunks []LogChunkInfo, timeRange TimeRange) LogIterator
- func NewSerializedLogIterator(chunks []LogChunkInfo, timeRange TimeRange) LogIterator
- type LogIteratorHeap
- func (h LogIteratorHeap) Len() int
- func (h LogIteratorHeap) Less(i, j int) bool
- func (h *LogIteratorHeap) Pop() interface{}
- func (h *LogIteratorHeap) Push(x interface{})
- func (h *LogIteratorHeap) SafePop() LogIterator
- func (h *LogIteratorHeap) SafePush(it LogIterator)
- func (h LogIteratorHeap) Swap(i, j int)
- type LogLineItem
- type Test
- type TimeRange
Constants ¶
This section is empty.
Variables ¶
var AllTime = TimeRange{StartAt: TimeRangeMin, EndAt: TimeRangeMax}
TimeRangeMax Chosen because it is effectively infinitely far in the future but UnixNano only works through 2262
var TimeRangeMin time.Time = time.Time{}
Functions ¶
func CheckBuildMetadata ¶
CheckBuildMetadata returns whether the metadata file exists for the given build.
func CheckTestMetadata ¶
func CheckTestMetadata(ctx context.Context, tracer otelTrace.Tracer, buildID string, testID string) (bool, error)
CheckTestMetadata returns whether the metadata file exists for the given test.
func DownloadLogLines ¶
func DownloadLogLines(ctx context.Context, tracer otelTrace.Tracer, buildID string, testID string) (chan *LogLineItem, error)
DownloadLogLines returns log lines for a given build ID and test ID. If the test ID is empty, this will return all logs lines in the build.
func InsertLogLines ¶
func InsertLogLines(ctx context.Context, tracer otelTrace.Tracer, buildID string, testID string, lines []LogLineItem, maxSize int) error
InsertLogLines uploads log lines for a given build or test to the pail-backed offline storage. If the test ID is not empty, the logs are appended to the test for the given build, otherwise the logs are appended to the top-level build. A build ID is required in both cases.
func NewBuildID ¶
func NewBuildID(ctx context.Context, tracer otelTrace.Tracer, builder string, buildNum int) (string, error)
NewBuildID generates a new build ID based on the hash of the given builder and build number.
func NewTestID ¶
NewTestID returns a new TestID with it's timestamp set to startTime. The ID is an ObjectID with its timestamp replaced with a nanosecond timestamp. It is represented as a hex string of 16 bytes. The first 8 bytes are the timestamp and replace the first 4 bytes of an ObjectID. The remaining 8 bytes are the rest of the ObjectID.
Types ¶
type Build ¶
type Build struct { ID string `json:"id"` Builder string `json:"builder"` BuildNum int `json:"buildnum"` TaskID string `json:"task_id"` TaskExecution int `json:"execution"` }
Build contains metadata about a build.
func FindBuildByID ¶
FindBuildByID returns the build metadata for the given ID from the pail-backed offline storage.
type Iterator ¶
type Iterator interface { // Next returns true if the iterator has not yet been exhausted or // closed, false otherwise. Next(context.Context) bool // Exhausted returns true if the iterator has not yet been exhausted, // regardless if it has been closed or not. Exhausted() bool // Err returns any errors that are captured by the iterator. Err() error // Close closes the iterator. This function should be called once the // iterator is no longer needed. Close() error }
Iterator represents a cursor for generic iteration over a sequence of items.
type LogChunkInfo ¶
type LogChunkInfo struct { BuildID string TestID string NumLines int Start time.Time End time.Time }
LogChunkInfo describes a chunk of log lines stored in pail-backed offline storage.
type LogIterator ¶
type LogIterator interface { Iterator // Item returns the current LogLine item held by the iterator. Item() LogLineItem // Reverse returns a reversed copy of the iterator. Reverse() LogIterator // IsReversed returns true if the iterator is in reverse order and // false otherwise. IsReversed() bool // Stream returns a chan of log lines from the iterator. Stream(context.Context) chan *LogLineItem }
LogIterator is an interface that enables iterating over lines of buildlogger logs.
func NewBatchedLogIterator ¶
func NewBatchedLogIterator(chunks []LogChunkInfo, batchSize int, timeRange TimeRange) LogIterator
NewBatchedLog returns a LogIterator that fetches batches (size set by the caller) of chunks from blob storage in parallel while iterating over lines of a buildlogger log.
func NewMergingIterator ¶
func NewMergingIterator(iterators ...LogIterator) LogIterator
NewMergeIterator returns a LogIterator that merges N buildlogger logs, passed in as LogIterators, respecting the order of each line's timestamp.
func NewParallelizedLogIterator ¶
func NewParallelizedLogIterator(chunks []LogChunkInfo, timeRange TimeRange) LogIterator
NewParallelizedLogIterator returns a LogIterator that fetches all chunks from blob storage in parallel while iterating over lines of a buildlogger log.
func NewSerializedLogIterator ¶
func NewSerializedLogIterator(chunks []LogChunkInfo, timeRange TimeRange) LogIterator
NewSerializedLogIterator returns a LogIterator that serially fetches chunks from blob storage while iterating over lines of a buildlogger log.
type LogIteratorHeap ¶
type LogIteratorHeap struct {
// contains filtered or unexported fields
}
LogIteratorHeap is a heap of LogIterator items.
func (LogIteratorHeap) Less ¶
func (h LogIteratorHeap) Less(i, j int) bool
Less returns true if the object at index i is less than the object at index j in the heap, false otherwise, when min is true. When min is false, the opposite is returned.
func (*LogIteratorHeap) Pop ¶
func (h *LogIteratorHeap) Pop() interface{}
Pop returns the next object (as an empty interface) from the heap. Note that if the heap is empty this will panic.
func (*LogIteratorHeap) Push ¶
func (h *LogIteratorHeap) Push(x interface{})
Push appends a new object of type LogIterator to the heap. Note that if x is not a LogIterator nothing happens.
func (*LogIteratorHeap) SafePop ¶
func (h *LogIteratorHeap) SafePop() LogIterator
SafePop is a wrapper function around heap.Pop that converts the returned interface into a LogIterator object before returning it.
func (*LogIteratorHeap) SafePush ¶
func (h *LogIteratorHeap) SafePush(it LogIterator)
SafePush is a wrapper function around heap.Push that ensures, during compile time, that the correct type of object is put in the heap.
func (LogIteratorHeap) Swap ¶
func (h LogIteratorHeap) Swap(i, j int)
Swap swaps the objects at indexes i and j.
type LogLineItem ¶
LogLineItem represents a single line in a log.
func UnmarshalLogJSON ¶
func UnmarshalLogJSON(ctx context.Context, tracer otelTrace.Tracer, r io.Reader) ([]LogLineItem, error)
UnmarshalLogJSON unmarshals log lines from JSON into a slice of LogLineItem. Unmarshalling directly is more efficient than implementing the Unmarshaller interface.
func (*LogLineItem) LoggerName ¶
func (item *LogLineItem) LoggerName() string
LoggerName returns the logger name for this line so it can be assigned a unique color when the log is displayed in the HTML view.
func (*LogLineItem) OneSecondNewer ¶
func (item *LogLineItem) OneSecondNewer(previousItem interface{}) bool
OneSecondNewer returns if this line's timestamp is greater than one second newer than the previous line's timestamp.
type Test ¶
type Test struct { ID string `json:"id"` Name string `json:"name"` BuildID string `json:"build_id"` TaskID string `json:"task_id"` TaskExecution int `json:"execution"` Phase string `json:"phase"` Command string `json:"command"` }
Test describes metadata of a test stored in pail-backed offline storage.
func FindTestByID ¶
func FindTestByID(ctx context.Context, tracer otelTrace.Tracer, buildID string, testID string) (*Test, error)
FindTestByID returns the test metadata for the given build ID and test ID from the pail-backed offline storage.
type TimeRange ¶
type TimeRange struct { StartAt time.Time `json:"start" yaml:"start"` EndAt time.Time `json:"end" yaml:"end"` }
func NewTimeRange ¶
NewTimeRange Creates a new time range. Use TimeRangeMin and TimeRangeMax for "open ended" time ranges
func (TimeRange) Intersects ¶
Intersects Check returns true if this TimeRange overlaps the other TimeRange