Documentation
¶
Index ¶
- func ExportSeq2ToParquet(seq iter.Seq2[*LogEntry, error], filename string) error
- func ExportSeq2ToParquetWithFilter(seq iter.Seq2[*LogEntry, error], filename string, ...) error
- func FilterByGroupIter(entries iter.Seq2[ParquetLogEntry, error], groupPattern string) iter.Seq2[ParquetLogEntry, error]
- func GenerateBlobKey(org, pipeline, build, job string) string
- func GetDefaultStorageURL(storageURL string, noTempDir bool) (string, error)
- func GetRuntimeInfo() map[string]string
- func IsContainerizedEnvironment() bool
- func IsTerminalState(state JobState) bool
- func ReadParquetFileIter(filename string) iter.Seq2[ParquetLogEntry, error]
- func StripANSI(s string) string
- func StripANSIRegex(s string) string
- func ValidateAPIParams(org, pipeline, build, job string) error
- type AfterBlobStorageFunc
- type AfterCacheCheckFunc
- type AfterJobStatusFunc
- type AfterLocalCacheFunc
- type AfterLogDownloadFunc
- type AfterLogParsingFunc
- type BaseResult
- type BlobMetadata
- type BlobStorage
- func (bs *BlobStorage) Close() error
- func (bs *BlobStorage) Delete(ctx context.Context, key string) error
- func (bs *BlobStorage) Exists(ctx context.Context, key string) (bool, error)
- func (bs *BlobStorage) GetModTime(ctx context.Context, key string) (time.Time, error)
- func (bs *BlobStorage) ReadWithMetadata(ctx context.Context, key string) (*BlobMetadata, error)
- func (bs *BlobStorage) Reader(ctx context.Context, key string) (io.ReadCloser, error)
- func (bs *BlobStorage) WriteWithMetadata(ctx context.Context, key string, data []byte, metadata *BlobMetadata) error
- type BlobStorageOptions
- type BlobStorageResult
- type BuildkiteAPI
- type BuildkiteAPIClient
- type ByteParser
- type CacheCheckResult
- type Client
- func (c *Client) Close() error
- func (c *Client) DownloadAndCache(ctx context.Context, org, pipeline, build, job string, ttl time.Duration, ...) (string, error)
- func (c *Client) Hooks() *Hooks
- func (c *Client) NewReader(ctx context.Context, org, pipeline, build, job string, ttl time.Duration, ...) (*ParquetReader, error)
- type GroupInfo
- type Hooks
- func (h *Hooks) AddAfterBlobStorage(hook AfterBlobStorageFunc)
- func (h *Hooks) AddAfterCacheCheck(hook AfterCacheCheckFunc)
- func (h *Hooks) AddAfterJobStatus(hook AfterJobStatusFunc)
- func (h *Hooks) AddAfterLocalCache(hook AfterLocalCacheFunc)
- func (h *Hooks) AddAfterLogDownload(hook AfterLogDownloadFunc)
- func (h *Hooks) AddAfterLogParsing(hook AfterLogParsingFunc)
- type JobState
- type JobStatus
- type JobStatusProvider
- type JobStatusResult
- type LocalCacheResult
- type LogDownloadResult
- type LogEntry
- type LogFlag
- type LogFlags
- type LogIteratordeprecated
- type LogParsingResult
- type LogProvider
- type ParquetFileInfo
- type ParquetLogEntry
- type ParquetReader
- func (pr *ParquetReader) FilterByGroupIter(groupPattern string) iter.Seq2[ParquetLogEntry, error]
- func (pr *ParquetReader) GetFileInfo() (*ParquetFileInfo, error)
- func (pr *ParquetReader) ReadEntriesIter() iter.Seq2[ParquetLogEntry, error]
- func (pr *ParquetReader) SearchEntriesIter(options SearchOptions) iter.Seq2[SearchResult, error]
- func (pr *ParquetReader) SeekToRow(startRow int64) iter.Seq2[ParquetLogEntry, error]
- type ParquetWriter
- type Parser
- type QueryResult
- type QueryStats
- type SearchOptions
- type SearchResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportSeq2ToParquet ¶
ExportSeq2ToParquet exports log entries using Go 1.23+ iter.Seq2 for efficient iteration
func ExportSeq2ToParquetWithFilter ¶
func ExportSeq2ToParquetWithFilter(seq iter.Seq2[*LogEntry, error], filename string, filterFunc func(*LogEntry) bool) error
ExportSeq2ToParquetWithFilter exports filtered log entries using iter.Seq2
func FilterByGroupIter ¶
func FilterByGroupIter(entries iter.Seq2[ParquetLogEntry, error], groupPattern string) iter.Seq2[ParquetLogEntry, error]
FilterByGroupIter returns an iterator over entries that belong to groups matching the specified pattern
func GenerateBlobKey ¶
GenerateBlobKey creates a consistent key for blob storage
func GetDefaultStorageURL ¶
GetDefaultStorageURL returns the default storage URL based on environment
If noTempDir is true, the returned file:// URL will include the no_tmp_dir parameter, which causes gocloud.dev/blob/fileblob to create temporary files in the same directory as the final destination, avoiding cross-filesystem rename errors.
This function applies the noTempDir setting to both user-provided and default URLs.
func GetRuntimeInfo ¶
GetRuntimeInfo returns information about the current runtime environment
func IsContainerizedEnvironment ¶
func IsContainerizedEnvironment() bool
IsContainerizedEnvironment detects if we're running in a container
func IsTerminalState ¶
IsTerminalState returns true if the given job state is terminal
func ReadParquetFileIter ¶
func ReadParquetFileIter(filename string) iter.Seq2[ParquetLogEntry, error]
ReadParquetFileIter is a convenience function to get an iterator over entries from a Parquet file
func StripANSIRegex ¶
StripANSIRegex removes ANSI escape sequences from a string using regex
func ValidateAPIParams ¶
ValidateAPIParams validates that all required API parameters are provided
Types ¶
type AfterBlobStorageFunc ¶
type AfterBlobStorageFunc func(ctx context.Context, result *BlobStorageResult)
type AfterCacheCheckFunc ¶
type AfterCacheCheckFunc func(ctx context.Context, result *CacheCheckResult)
Hook function types for different stages of downloadAndCacheWithBlobStorage
type AfterJobStatusFunc ¶
type AfterJobStatusFunc func(ctx context.Context, result *JobStatusResult)
type AfterLocalCacheFunc ¶
type AfterLocalCacheFunc func(ctx context.Context, result *LocalCacheResult)
type AfterLogDownloadFunc ¶
type AfterLogDownloadFunc func(ctx context.Context, result *LogDownloadResult)
type AfterLogParsingFunc ¶
type AfterLogParsingFunc func(ctx context.Context, result *LogParsingResult)
type BaseResult ¶
BaseResult contains common fields for all hook results
type BlobMetadata ¶
type BlobMetadata struct {
JobID string `json:"job_id"`
JobState string `json:"job_state"`
IsTerminal bool `json:"is_terminal"`
CachedAt time.Time `json:"cached_at"`
TTL string `json:"ttl"` // duration string like "30s"
Organization string `json:"organization"`
Pipeline string `json:"pipeline"`
Build string `json:"build"`
}
BlobMetadata contains metadata for cached blobs
type BlobStorage ¶
type BlobStorage struct {
// contains filtered or unexported fields
}
BlobStorage provides an abstraction over blob storage backends
func NewBlobStorage ¶
func NewBlobStorage(ctx context.Context, storageURL string, opts *BlobStorageOptions) (*BlobStorage, error)
NewBlobStorage creates a new blob storage instance from a storage URL Supports file:// URLs for local filesystem storage
The opts parameter allows configuring blob storage behavior. Pass nil to use default options.
func (*BlobStorage) Close ¶
func (bs *BlobStorage) Close() error
Close closes the blob storage connection
func (*BlobStorage) Delete ¶
func (bs *BlobStorage) Delete(ctx context.Context, key string) error
Delete removes a blob from storage
func (*BlobStorage) GetModTime ¶
GetModTime returns the modification time of a blob
func (*BlobStorage) ReadWithMetadata ¶
func (bs *BlobStorage) ReadWithMetadata(ctx context.Context, key string) (*BlobMetadata, error)
ReadWithMetadata reads data from blob storage with metadata
func (*BlobStorage) Reader ¶ added in v0.6.1
func (bs *BlobStorage) Reader(ctx context.Context, key string) (io.ReadCloser, error)
Reader returns an io.ReadCloser for streaming blob data from the specified key. The caller is responsible for closing the returned reader when done.
func (*BlobStorage) WriteWithMetadata ¶
func (bs *BlobStorage) WriteWithMetadata(ctx context.Context, key string, data []byte, metadata *BlobMetadata) error
WriteWithMetadata writes data to blob storage with metadata
type BlobStorageOptions ¶ added in v0.6.3
type BlobStorageOptions struct {
// NoTempDir controls whether to use the no_tmp_dir URL parameter for file:// URLs.
// When true, temporary files are created in the same directory as the final destination,
// avoiding cross-filesystem rename errors. This may result in stranded .tmp files if
// the process crashes before cleanup runs.
//
// When false (default), temporary files are created in os.TempDir(), which may cause
// "invalid cross-device link" errors if the temp directory is on a different filesystem
// than the storage directory.
NoTempDir bool
}
BlobStorageOptions contains configuration options for blob storage
type BlobStorageResult ¶
type BlobStorageResult struct {
BaseResult
BlobKey string
DataSize int64
IsTerminal bool
TTL time.Duration
}
BlobStorageResult contains the result of storing data in blob storage
type BuildkiteAPI ¶
type BuildkiteAPI interface {
JobStatusProvider
LogProvider
}
BuildkiteAPI combines both job status and log providers
type BuildkiteAPIClient ¶
type BuildkiteAPIClient struct {
// contains filtered or unexported fields
}
BuildkiteAPIClient provides methods to interact with the Buildkite API Now wraps the official go-buildkite v4 client
func NewBuildkiteAPIClient ¶
func NewBuildkiteAPIClient(apiToken, version string) *BuildkiteAPIClient
NewBuildkiteAPIClient creates a new Buildkite API client using go-buildkite v4
func NewBuildkiteAPIExistingClient ¶
func NewBuildkiteAPIExistingClient(client *buildkite.Client) *BuildkiteAPIClient
NewBuildkiteAPI creates a new Buildkite API client using the provided go-buildkite client
func (*BuildkiteAPIClient) GetJobLog ¶
func (c *BuildkiteAPIClient) GetJobLog(ctx context.Context, org, pipeline, build, job string) (io.ReadCloser, error)
GetJobLog fetches the log output for a specific job using go-buildkite org: organization slug pipeline: pipeline slug build: build number or UUID job: job ID
func (*BuildkiteAPIClient) GetJobStatus ¶
func (c *BuildkiteAPIClient) GetJobStatus(ctx context.Context, org, pipeline, build, jobID string) (*JobStatus, error)
GetJobStatus gets the current status of a job
type ByteParser ¶
type ByteParser struct{}
ByteParser handles byte-level parsing of Buildkite log files
type CacheCheckResult ¶
type CacheCheckResult struct {
BaseResult
BlobKey string
Exists bool
}
CacheCheckResult contains the result of checking blob storage cache
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides a high-level convenience API for common buildkite-logs-parquet operations
func NewClientWithAPI ¶
NewClientWithAPI creates a new Client using a custom BuildkiteAPI implementation
func (*Client) DownloadAndCache ¶
func (c *Client) DownloadAndCache(ctx context.Context, org, pipeline, build, job string, ttl time.Duration, forceRefresh bool) (string, error)
DownloadAndCache downloads and caches job logs as Parquet format, returning the local file path
Parameters:
- org: Buildkite organization slug
- pipeline: Pipeline slug
- build: Build number or UUID
- job: Job ID
- ttl: Time-to-live for cache (use 0 for default 30s)
- forceRefresh: If true, forces re-download even if cache exists
Returns the local file path of the cached Parquet file
func (*Client) NewReader ¶
func (c *Client) NewReader(ctx context.Context, org, pipeline, build, job string, ttl time.Duration, forceRefresh bool) (*ParquetReader, error)
NewReader downloads and caches job logs (if needed) and returns a ParquetReader for querying
Parameters:
- org: Buildkite organization slug
- pipeline: Pipeline slug
- build: Build number or UUID
- job: Job ID
- ttl: Time-to-live for cache (use 0 for default 30s)
- forceRefresh: If true, forces re-download even if cache exists
Returns a ParquetReader for querying the log data
type GroupInfo ¶
type GroupInfo struct {
Name string `json:"name"`
EntryCount int `json:"entry_count"`
FirstSeen time.Time `json:"first_seen"`
LastSeen time.Time `json:"last_seen"`
}
GroupInfo contains statistical information about a log group
type Hooks ¶
type Hooks struct {
OnAfterCacheCheck []AfterCacheCheckFunc
OnAfterJobStatus []AfterJobStatusFunc
OnAfterLogDownload []AfterLogDownloadFunc
OnAfterLogParsing []AfterLogParsingFunc
OnAfterBlobStorage []AfterBlobStorageFunc
OnAfterLocalCache []AfterLocalCacheFunc
}
Hooks contains all registered hook functions
func (*Hooks) AddAfterBlobStorage ¶
func (h *Hooks) AddAfterBlobStorage(hook AfterBlobStorageFunc)
func (*Hooks) AddAfterCacheCheck ¶
func (h *Hooks) AddAfterCacheCheck(hook AfterCacheCheckFunc)
Hook registration methods
func (*Hooks) AddAfterJobStatus ¶
func (h *Hooks) AddAfterJobStatus(hook AfterJobStatusFunc)
func (*Hooks) AddAfterLocalCache ¶
func (h *Hooks) AddAfterLocalCache(hook AfterLocalCacheFunc)
func (*Hooks) AddAfterLogDownload ¶
func (h *Hooks) AddAfterLogDownload(hook AfterLogDownloadFunc)
func (*Hooks) AddAfterLogParsing ¶
func (h *Hooks) AddAfterLogParsing(hook AfterLogParsingFunc)
type JobState ¶
type JobState string
JobState represents the possible states of a Buildkite job
const ( JobStateFinished JobState = "finished" // Job completed (passed or failed) JobStatePassed JobState = "passed" // Job completed successfully JobStateFailed JobState = "failed" // Job completed with failure JobStateCanceled JobState = "canceled" // Job was canceled JobStateExpired JobState = "expired" // Job expired before being picked up JobStateTimedOut JobState = "timed_out" // Job timed out during execution JobStateSkipped JobState = "skipped" // Job was skipped JobStateBroken JobState = "broken" // Job configuration is broken )
Terminal job states - jobs in these states will not change
const ( JobStatePending JobState = "pending" // Job is pending JobStateWaiting JobState = "waiting" // Job is waiting JobStateWaitingFailed JobState = "waiting_failed" // Job waiting failed JobStateBlocked JobState = "blocked" // Job is blocked JobStateBlockedFailed JobState = "blocked_failed" // Job blocked failed JobStateUnblocked JobState = "unblocked" // Job is unblocked JobStateUnblockedFailed JobState = "unblocked_failed" // Job unblocked failed JobStateLimiting JobState = "limiting" // Job is limiting JobStateLimited JobState = "limited" // Job is limited JobStateScheduled JobState = "scheduled" // Job is scheduled JobStateAssigned JobState = "assigned" // Job is assigned JobStateAccepted JobState = "accepted" // Job is accepted JobStateRunning JobState = "running" // Job is currently running JobStateCanceling JobState = "canceling" // Job is being canceled JobStateTimingOut JobState = "timing_out" // Job is timing out )
Non-terminal job states - jobs in these states may still change
type JobStatus ¶
type JobStatus struct {
ID string `json:"id"`
State JobState `json:"state"`
IsTerminal bool `json:"is_terminal"`
WebURL string `json:"web_url,omitempty"`
ExitStatus *int `json:"exit_status,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
}
JobStatus contains information about a Buildkite job's current status
type JobStatusProvider ¶
type JobStatusProvider interface {
GetJobStatus(ctx context.Context, org, pipeline, build, job string) (*JobStatus, error)
}
JobStatusProvider defines the interface for getting job status
type JobStatusResult ¶
type JobStatusResult struct {
BaseResult
JobStatus *JobStatus
}
JobStatusResult contains the result of fetching job status
type LocalCacheResult ¶
type LocalCacheResult struct {
BaseResult
LocalPath string
FileSize int64
}
LocalCacheResult contains the result of creating local cache file
type LogDownloadResult ¶
type LogDownloadResult struct {
BaseResult
LogSize int64 // Size of downloaded logs in bytes
}
LogDownloadResult contains the result of downloading logs from API
type LogEntry ¶
type LogEntry struct {
Timestamp time.Time
Content string // Parsed content after OSC processing, may still contain ANSI codes
RawLine []byte // Original line bytes including all OSC sequences and formatting
Group string // The current section/group this entry belongs to
}
LogEntry represents a parsed Buildkite log entry
func (*LogEntry) ComputeFlags ¶
ComputeFlags returns the consolidated flags for this log entry
func (*LogEntry) HasTimestamp ¶
HasTimestamp returns true if the log entry has a valid timestamp
type LogFlags ¶
type LogFlags int32
LogFlags represents a bitwise combination of log flags
func (LogFlags) HasTimestamp ¶
HasTimestamp returns true if HasTimestamp flag is set
type LogIterator
deprecated
type LogIterator struct {
// contains filtered or unexported fields
}
LogIterator provides an iterator interface for processing log entries.
Deprecated: Use Parser.All() which returns an iter.Seq2 instead.
func (*LogIterator) Entry ¶
func (li *LogIterator) Entry() *LogEntry
Entry returns the current log entry Only valid after a successful call to Next()
func (*LogIterator) Err ¶
func (li *LogIterator) Err() error
Err returns any error encountered during iteration
func (*LogIterator) Next ¶
func (li *LogIterator) Next() bool
Next advances the iterator to the next log entry Returns true if there is a next entry, false if EOF or error
type LogParsingResult ¶
type LogParsingResult struct {
BaseResult
ParquetSize int64 // Size of generated Parquet data in bytes
LogEntries int // Number of log entries processed
}
LogParsingResult contains the result of parsing logs to Parquet
type LogProvider ¶
type LogProvider interface {
GetJobLog(ctx context.Context, org, pipeline, build, job string) (io.ReadCloser, error)
}
LogProvider defines the interface for getting job logs
type ParquetFileInfo ¶
type ParquetFileInfo struct {
RowCount int64 `json:"row_count"`
ColumnCount int `json:"column_count"`
FileSize int64 `json:"file_size_bytes"`
NumRowGroups int `json:"num_row_groups"`
}
ParquetFileInfo contains metadata about a Parquet file
type ParquetLogEntry ¶
type ParquetLogEntry struct {
RowNumber int64 `json:"row_number"` // 0-based row position in the Parquet file
Timestamp int64 `json:"timestamp"`
Content string `json:"content"`
Group string `json:"group"`
Flags LogFlags `json:"flags"`
}
ParquetLogEntry represents a log entry read from a Parquet file
func (*ParquetLogEntry) CleanContent ¶
func (entry *ParquetLogEntry) CleanContent(stripANSI bool) string
CleanContent returns the content with optional ANSI stripping and whitespace trimming
func (*ParquetLogEntry) CleanGroup ¶
func (entry *ParquetLogEntry) CleanGroup(stripANSI bool) string
CleanGroup returns the group name with optional ANSI stripping and whitespace trimming
func (*ParquetLogEntry) HasTime ¶
func (entry *ParquetLogEntry) HasTime() bool
HasTime returns true if the entry has a timestamp (backward compatibility)
func (*ParquetLogEntry) IsGroup ¶
func (entry *ParquetLogEntry) IsGroup() bool
IsGroup returns true if the entry is a group header (backward compatibility)
type ParquetReader ¶
type ParquetReader struct {
// contains filtered or unexported fields
}
ParquetReader provides functionality to read and query Parquet log files
func NewParquetReader ¶
func NewParquetReader(filename string) *ParquetReader
NewParquetReader creates a new ParquetReader for the specified file
func (*ParquetReader) FilterByGroupIter ¶
func (pr *ParquetReader) FilterByGroupIter(groupPattern string) iter.Seq2[ParquetLogEntry, error]
FilterByGroupIter returns an iterator over entries that belong to groups matching the specified name pattern
func (*ParquetReader) GetFileInfo ¶
func (pr *ParquetReader) GetFileInfo() (*ParquetFileInfo, error)
GetFileInfo returns metadata about the Parquet file
func (*ParquetReader) ReadEntriesIter ¶
func (pr *ParquetReader) ReadEntriesIter() iter.Seq2[ParquetLogEntry, error]
ReadEntriesIter returns an iterator over log entries from the Parquet file
func (*ParquetReader) SearchEntriesIter ¶
func (pr *ParquetReader) SearchEntriesIter(options SearchOptions) iter.Seq2[SearchResult, error]
SearchEntriesIter returns an iterator over search results with context
func (*ParquetReader) SeekToRow ¶
func (pr *ParquetReader) SeekToRow(startRow int64) iter.Seq2[ParquetLogEntry, error]
SeekToRow returns an iterator starting from the specified row number (0-based)
type ParquetWriter ¶
type ParquetWriter struct {
// contains filtered or unexported fields
}
ParquetWriter provides streaming Parquet writing capabilities
func NewParquetWriter ¶
func NewParquetWriter(file *os.File) (*ParquetWriter, error)
NewParquetWriter creates a new Parquet writer for streaming
func (*ParquetWriter) Close ¶
func (pw *ParquetWriter) Close() error
Close closes the Parquet writer
func (*ParquetWriter) WriteBatch ¶
func (pw *ParquetWriter) WriteBatch(entries []*LogEntry) error
WriteBatch writes a batch of log entries to the Parquet file
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser handles parsing of Buildkite log files
func (*Parser) All ¶
All returns an iterator over all log entries using Go 1.23+ iter.Seq2 pattern Each iteration yields a *LogEntry and an error, following Go's idiomatic error handling This method creates isolated parser state to prevent contamination between iterations
func (*Parser) NewIterator
deprecated
func (p *Parser) NewIterator(reader io.Reader) *LogIterator
NewIterator creates a new LogIterator for memory-efficient processing.
Deprecated: Use Parser.All() which returns an iter.Seq2 instead.
func (*Parser) Reset
deprecated
func (p *Parser) Reset()
Reset clears the parser's internal state, useful for reusing the parser for multiple independent parsing operations.
Deprecated: State isolation is now handled internally by All() and LogIterator. This method will be removed in a future major version.
type QueryResult ¶
type QueryResult struct {
Groups []GroupInfo `json:"groups,omitempty"`
Entries []ParquetLogEntry `json:"entries,omitempty"`
Stats QueryStats `json:"stats,omitempty"`
}
QueryResult holds the results of a query operation
type QueryStats ¶
type QueryStats struct {
TotalEntries int `json:"total_entries"`
MatchedEntries int `json:"matched_entries"`
TotalGroups int `json:"total_groups"`
QueryTime float64 `json:"query_time_ms"`
}
QueryStats contains performance and result statistics for queries
type SearchOptions ¶
type SearchOptions struct {
Pattern string // Regex pattern to search for
CaseSensitive bool // Enable case-sensitive matching
InvertMatch bool // Show non-matching lines
BeforeContext int // Lines to show before match
AfterContext int // Lines to show after match
Context int // Lines to show before and after (overrides BeforeContext/AfterContext)
Reverse bool // Search backwards from end/seek position
SeekStart int64 // Start search from this row (useful with Reverse)
}
SearchOptions configures regex search behavior
type SearchResult ¶
type SearchResult struct {
Match ParquetLogEntry `json:"match"`
BeforeContext []ParquetLogEntry `json:"before_context,omitempty"`
AfterContext []ParquetLogEntry `json:"after_context,omitempty"`
}
SearchResult represents a match with context lines
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
bklog
command
|
|
|
examples
|
|
|
high-level-client
command
|
|
|
query
command
|
|
|
smart-cache
command
|