Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

`prec` is a Linux command execution observability tool where `precd` uses eBPF to continuously collect process execution events as JSON Lines and `prec` lets you quickly search and inspect those records from the CLI.

Implementation note:

- Go packages under `internal/` are private implementation details and are not a supported public import API

## Why use it

- Does not rely on shell history or `LD_PRELOAD`
Expand Down
2 changes: 1 addition & 1 deletion cmd/prec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"os"

"github.com/jfut/prec/pkg/cli"
"github.com/jfut/prec/internal/cli"
)

// Build metadata fields are injected by linker flags at build time.
Expand Down
6 changes: 3 additions & 3 deletions cmd/precd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (

"github.com/alecthomas/kong"

"github.com/jfut/prec/pkg/collector"
"github.com/jfut/prec/pkg/config"
"github.com/jfut/prec/pkg/logger"
"github.com/jfut/prec/internal/collector"
"github.com/jfut/prec/internal/config"
"github.com/jfut/prec/internal/logger"
)

// Build metadata fields are injected by linker flags at build time.
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/app.go → internal/cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/alecthomas/kong"

"github.com/jfut/prec/pkg/config"
"github.com/jfut/prec/pkg/query"
"github.com/jfut/prec/internal/config"
"github.com/jfut/prec/internal/query"
)

type listFilter struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/app_test.go → internal/cli/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/alecthomas/kong"

"github.com/jfut/prec/pkg/config"
"github.com/jfut/prec/internal/config"
)

func TestValidateModeFlags(t *testing.T) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/klauspost/compress/gzip"
"github.com/klauspost/compress/zstd"

"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/internal/events"
)

func collectFilteredEvents(logPaths []string, limit int, lf listFilter) ([]events.CommandEvent, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"path/filepath"
"testing"

"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/internal/events"
)

func TestCollectFilteredEventsAcrossRotatedLogs(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/event_merge.go → internal/cli/event_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package cli

import "github.com/jfut/prec/pkg/events"
import "github.com/jfut/prec/internal/events"

type commandJoinState struct {
pending map[string]events.CommandEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package cli
import (
"testing"

"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/internal/events"
)

func TestMergeEventsForListJoinsStartEnd(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"sync"
"testing"

"github.com/jfut/prec/pkg/config"
"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/internal/config"
"github.com/jfut/prec/internal/events"
)

func TestOpenLogReaderDetectsCompressionByMagic(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"
"time"

"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/internal/events"
)

// outputFormatter hides per-format encoding details from list/follow flows.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"testing"

"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/internal/events"
)

func TestFormatEventSimple(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/query_filter.go → internal/cli/query_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
package cli

import (
"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/pkg/query"
"github.com/jfut/prec/internal/events"
"github.com/jfut/prec/internal/query"
)

func buildQueryFilter(specs []string) (listFilter, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
"time"

"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/internal/events"
)

func TestBuildQueryFilterValid(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/tail.go → internal/cli/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"
"time"

"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/internal/events"
)

func runList(logPaths []string, limit int, lf listFilter, opt outputOptions) int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/klauspost/compress/zstd"

"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/internal/events"
)

func intPtr(v int) *int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
"github.com/cilium/ebpf/rlimit"
"golang.org/x/sys/unix"

"github.com/jfut/prec/pkg/config"
"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/pkg/filter"
"github.com/jfut/prec/pkg/logger"
"github.com/jfut/prec/internal/config"
"github.com/jfut/prec/internal/events"
"github.com/jfut/prec/internal/filter"
"github.com/jfut/prec/internal/logger"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
"testing"

"github.com/cilium/ebpf/asm"
"github.com/jfut/prec/pkg/config"
"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/pkg/logger"
"github.com/jfut/prec/internal/config"
"github.com/jfut/prec/internal/events"
"github.com/jfut/prec/internal/logger"
)

func TestParseOffsetFromFormat(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions pkg/filter/filter.go → internal/filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"fmt"
"strings"

"github.com/jfut/prec/pkg/config"
"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/pkg/query"
"github.com/jfut/prec/internal/config"
"github.com/jfut/prec/internal/events"
"github.com/jfut/prec/internal/query"
)

type compiledRule struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/filter/filter_test.go → internal/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package filter
import (
"testing"

"github.com/jfut/prec/pkg/config"
"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/internal/config"
"github.com/jfut/prec/internal/events"
)

func TestMatcherRulesFirstMatchWins(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/logger/jsonl.go → internal/logger/jsonl.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"github.com/klauspost/compress/gzip"
"github.com/klauspost/compress/zstd"

"github.com/jfut/prec/pkg/config"
"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/internal/config"
"github.com/jfut/prec/internal/events"
)

// JSONLWriter appends events line by line to a root-owned log file.
Expand Down
4 changes: 2 additions & 2 deletions pkg/logger/jsonl_test.go → internal/logger/jsonl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/klauspost/compress/gzip"
"github.com/klauspost/compress/zstd"

"github.com/jfut/prec/pkg/config"
"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/internal/config"
"github.com/jfut/prec/internal/events"
)

func TestJSONLWriterReopenSwitchesOutputFile(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/query/filter.go → internal/query/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"sync"
"time"

"github.com/jfut/prec/pkg/events"
"github.com/jfut/prec/internal/events"
)

var operators = []string{"!~=", ">=", "<=", "!=", "~=", ">", "<", "="}
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ deps:
#

fmt:
gofmt -w ./cmd ./pkg
gofmt -w .

lint:
golangci-lint run ./...
Expand Down