Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breaking change: split repository #103

Merged
merged 2 commits into from
Jan 23, 2024
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
54 changes: 27 additions & 27 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
doc.go linguist-documentation
*.md linguist-documentation
*.pb.go linguist-generated
basegroup.go linguist-generated
line.go linguist-generated
seed.go linguist-generated
span.go linguist-generated
sub.go linguist-generated
xopat/attributes.go linguist-generated
xopbase/abbr.go linguist-generated
xopbase/base.go linguist-generated
xopbase/skip.go linguist-generated
xopcon/console.go linguist-generated
xopconsole/attributes.go linguist-generated
xopconsole/replay.go linguist-generated
xopjson/jsonlogger.go linguist-generated
xopjson/replay.go linguist-generated
xopotel/buffered.go linguist-generated
xopotel/export.go linguist-generated
xopotel/otel.go linguist-generated
xoppb/pb.go linguist-generated
xoppb/replay.go linguist-generated
xoprecorder/recorder.go linguist-generated
xoprecorder/replay.go linguist-generated
xoptrace/hexbytes.go linguist-generated
xoputil/enumer_test.go linguist-generated
xopbase/xopbaseutil/metadata.go linguist-generated
xopjson/xopjsonutil/attributes.go linguist-generated
xoptest/xoptestutil/enums.go linguist-generated
xoptest/xoptestutil/verify_replay.go linguist-generated
../xop-go/basegroup.go linguist-generated
../xop-go/line.go linguist-generated
../xop-go/seed.go linguist-generated
../xop-go/span.go linguist-generated
../xop-go/sub.go linguist-generated
../xopotel-go/buffered.go linguist-generated
../xopotel-go/export.go linguist-generated
../xopotel-go/otel.go linguist-generated
../xop-go/xopat/attributes.go linguist-generated
../xop-go/xopbase/abbr.go linguist-generated
../xop-go/xopbase/base.go linguist-generated
../xop-go/xopbase/skip.go linguist-generated
../xop-go/xopcon/console.go linguist-generated
../xop-go/xopconsole/attributes.go linguist-generated
../xop-go/xopconsole/replay.go linguist-generated
../xop-go/xopjson/jsonlogger.go linguist-generated
../xop-go/xopjson/replay.go linguist-generated
../xop-go/xoppb/pb.go linguist-generated
../xop-go/xoppb/replay.go linguist-generated
../xop-go/xoprecorder/recorder.go linguist-generated
../xop-go/xoprecorder/replay.go linguist-generated
../xop-go/xoptrace/hexbytes.go linguist-generated
../xop-go/xoputil/enumer_test.go linguist-generated
../xop-go/xopbase/xopbaseutil/metadata.go linguist-generated
../xop-go/xopjson/xopjsonutil/attributes.go linguist-generated
../xop-go/xoptest/xoptestutil/enums.go linguist-generated
../xop-go/xoptest/xoptestutil/verify_replay.go linguist-generated
2 changes: 2 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: '1.18'
- name: Checkout peers
run: make ci_checkout_peers CLONE_DEPTH=2
- name: Run coverage
run: make calculate_coverage

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ jobs:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Checkout peers
run: make ci_checkout_peers
- name: Test
run: make citest
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021, 2022 David Sharnoff
Copyright (c) 2021-2024 David Sharnoff

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
60 changes: 10 additions & 50 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@

GOHOME ?= ${HOME}
GOPATH ?= ${GOHOME}
GOBIN ?= ${GOPATH}/bin
ME = xop-go
RELATED = xopresty-go xopotel-go
EXTRA_TEST_DEPS = testadjuster

ZZZGO = $(wildcard *.zzzgo */*.zzzgo */*/*.zzzgo)
ZZZGENERATED = $(patsubst %.zzzgo, %.go, $(ZZZGO))
PB = xopproto/ingest.pb.go xopproto/ingest_grpc.pb.go
TOOLS = ${GOBIN}/gofumpt ${GOBIN}/goimports ${GOBIN}/enumer
TEST_ONLY =?
include Makefile.common

all: $(ZZZGENERATED) $(PB) .gitattributes
go generate ./...
go build ./...

.gitattributes: $(ZZZGENERATED)
echo '*.zzzgo linguist-language=Go' > $@
echo 'doc.go linguist-documentation' >> $@
echo '*.md linguist-documentation' >> $@
echo '*.pb.go linguist-generated' >> $@
for i in $(ZZZGENERATED); do echo "$$i linguist-generated" >> $@; done
ci_checkout_peers:;
branch="$${GITHUB_REF##*/}"; for i in $(RELATED); do (cd ..; git clone https://github.com/xoplog/$$i --depth $(CLONE_DEPTH) -b $$branch || git clone https://github.com/xoplog/$$i --depth $(CLONE_DEPTH)); done

test: $(ZZZGENERATED) testadjuster
go generate ./...
go test -v ./xopjson/... -run TestASingleLine
go test -v ./xopjson/... -tags xoptesting -run TestParameters -failfast $(TEST_ONLY)
go test -tags xoptesting ./... -failfast $(TEST_ONLY)
for i in $(RELATED); do (echo $$i...; cd ../$$i && go test -tags xoptesting ./... $(TEST_ONLY) ); done
go test -tags xoptesting -race ./... -failfast $(TEST_ONLY)
for i in $(RELATED); do (echo $$i...; cd ../$$i && go test -tags xoptesting -race ./... $(TEST_ONLY) ); done


testadjuster: $(ZZZGenerated)
Expand All @@ -34,27 +24,12 @@ testadjuster: $(ZZZGenerated)

citest:
go test ./... -failfast
for i in $(RELATED); do (echo $$i...; cd ../$$i && go test -tags xoptesting ./... $(TEST_ONLY) ); done
go test -race ./... -failfast
for i in $(RELATED); do (echo $$i...; cd ../$$i && go test -tags xoptesting -race ./... $(TEST_ONLY) ); done
XOPLEVEL_xoptestutil=warn XOPLEVEL_foo=debug go test -tags xoptesting ./xoptest/xoptestutil -run TestAdjuster -count 1
XOPLEVEL_xoptestutil=debug XOPLEVEL_foo=warn go test -tags xoptesting ./xoptest/xoptestutil -run TestAdjuster -count 1

${GOBIN}/gofumpt:;
go install mvdan.cc/gofumpt@latest

${GOBIN}/goimports:;
go install golang.org/x/tools/cmd/goimports@latest

${GOBIN}/enumer:;
go install github.com/dmarkham/enumer@latest

%.go : %.zzzgo tools/xopzzz/xopzzz.go $(TOOLS) Makefile
go run tools/xopzzz/xopzzz.go < $< > [email protected]
-chmod +w $@
gofumpt -w [email protected]
goimports -w [email protected]
-mv [email protected] $@
-chmod -w $@

calculate_coverage:
echo "mode: atomic" > coverage.txt
for d in $$(go list ./...); do \
Expand All @@ -73,21 +48,6 @@ calculate_coverage:
egrep -v 'xoptestutil/|xopoteltest/' > coverage.txt.tmp
mv coverage.txt.tmp coverage.txt

coverage: calculate_coverage
go tool cover -html=coverage.txt

golanglint:
# binary will be $(go env GOPATH)/bin/golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.52.2
golangci-lint --version

lint:;
golangci-lint run

misspell:;
go install github.com/client9/misspell/cmd/misspell@latest
misspell -w `find . -name \*.md`

OTEL_TAG="v1.12.0"

../opentelemetry-specification:
Expand Down
55 changes: 55 additions & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

GOHOME ?= ${HOME}
GOPATH ?= ${GOHOME}
GOBIN ?= ${GOPATH}/bin

ZZZGO = $(wildcard ../xop*-go/*.zzzgo ../xop*-go/*/*.zzzgo ../xop*-go/*/*/*.zzzgo)
ZZZGENERATED = $(patsubst %.zzzgo, %.go, $(ZZZGO))
PB = xopproto/ingest.pb.go xopproto/ingest_grpc.pb.go
TOOLS = ${GOBIN}/gofumpt ${GOBIN}/goimports ${GOBIN}/enumer
TEST_ONLY ?=
CLONE_DEPTH ?= 1

all: $(ZZZGENERATED) $(PB) .gitattributes
go generate ./...
go build ./...
for i in $(RELATED); do (echo $$i ...; cd ../$$i && go generate ./... && go build ./...); done

.gitattributes: $(ZZZGENERATED)
echo '*.zzzgo linguist-language=Go' > $@
echo 'doc.go linguist-documentation' >> $@
echo '*.md linguist-documentation' >> $@
echo '*.pb.go linguist-generated' >> $@
for i in $(ZZZGENERATED); do echo "$$i linguist-generated" >> $@; done

${GOBIN}/gofumpt:;
go install mvdan.cc/gofumpt@latest

${GOBIN}/goimports:;
go install golang.org/x/tools/cmd/goimports@latest

${GOBIN}/enumer:;
go install github.com/dmarkham/enumer@latest

%.go : %.zzzgo tools/xopzzz/xopzzz.go $(TOOLS) Makefile
go run tools/xopzzz/xopzzz.go < $< > [email protected]
-chmod +w $@
gofumpt -w [email protected]
goimports -w [email protected]
-mv [email protected] $@
-chmod -w $@

coverage: calculate_coverage
go tool cover -html=coverage.txt

golanglint:
# binary will be $(go env GOPATH)/bin/golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.52.2
golangci-lint --version

lint:;
golangci-lint run

misspell:;
go install github.com/client9/misspell/cmd/misspell@latest
misspell -w `find . -name \*.md`
25 changes: 25 additions & 0 deletions Makefile.peer
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

include ../xop-go/Makefile.common

test: $(ZZZGENERATED)
go generate ./...
go test -tags xoptesting ./... -failfast $(TEST_ONLY)
go test -tags xoptesting -race ./... -failfast $(TEST_ONLY)

citest:
go test ./... -failfast
go test -race ./... -failfast

calculate_coverage:
echo "mode: atomic" > coverage.txt
for d in $$(go list ./...); do \
go test -race -covermode=atomic -coverprofile=profile.out -coverpkg=github.com/xoplog/$(ME)/... $$d; \
if [ -f profile.out ]; then \
grep -v ^mode profile.out >> coverage.txt; \
rm profile.out; \
fi; \
done
grep -v '\.pb.go:' coverage.txt | \
egrep -v 'xoptestutil/|xopoteltest/' > coverage.txt.tmp
mv coverage.txt.tmp coverage.txt

36 changes: 25 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,11 @@ to open pull requests, especially to added base loggers or propagators.

Expect the following changes as development continues:

- Log line keys (for key/value attributes) will become typed and
pre-registered (cheap, inline-possible registrations, not complex)

- API changes as additional features are added

Currently xop has no metrics support. That will change and adding
metrics will probably be the biggest API change

- xopresty and xopotel will split off to their own repos.

- Additional base loggers are coming

A full-fidelity console logger is expected soon.

- Additional gateway base loggers will be written

To make xop the best logging library for library writers, a full compliment
Expand Down Expand Up @@ -109,6 +100,28 @@ to strike a blance between safety and usability. Metadata on spans are
fully type-safe and keywords must be pre-registered. Data elements on log
lines are mostly type-safe but do not need to be pre-registered.

## Base loggers

Xop is a two-level logger. The top-level logger provides the API for
logging lines and spans, etc. The bottom-level loggers translate the logs
to different formats.

Some of the bottom-level loggers are "full fidelity" which means that
they are bundled with a function that can consume their own output and
re-log it to a different bottom-level logger thus translating from one
format to another. Xop bottom-level loggers must implement the
[xopbase](https://pkg.go.dev/github.com/xoplog/xop-go/xopbase) Logger interface.

| name | full fidelity | description |
| -- | -- | -- |
| [xopjson](https://pkg.go.dev/github.com/xoplog/xop-go/xopjson) | yes | JSON output |
| [xopotel](https://pkg.go.dev/github.com/xoplog/xopotel-go) | yes | Output though OpenTelemetry spans (Go logger not available) |
| [xopcon](https://pkg.go.dev/github.com/xoplog/xop-go/xopcon) | no | Console/text logger emphasizing human readability |
| [xopconsole](https://pkg.go.dev/github.com/xoplog/xop-go/xopconsole) | yes | Console/text logger with no information loss |
| [xoppb](https://pkg.go.dev/github.com/xoplog/xop-go/xoppb) | yes | Protobuf output |
| [xoprecorder](https://pkg.go.dev/github.com/xoplog/xop-go/xoprecorder) | yes | Output into a structured in-memory buffer |
| [xoptest](https://pkg.go.dev/github.com/xoplog/xop-go/xoptest) | no | Output to testing.T logger |

## Using xop

To log, you must have a `*Log` object. To create one you must start with a
Expand Down Expand Up @@ -218,11 +231,12 @@ into various http router frameworks.
Outgoing propagation is sharing the current trace id as the parent request
to another server when making a request. Xop currently only supports HTTP
and that only with [resty](https://github.com/go-resty/resty) in the
xopmiddle package. Adding additional outgoing propagators is an outstanding priority.
[xopresty](https://github.com/xoplog/xopresty-go) package. Adding additional
outgoing propagators is an outstanding priority.

### Version compatibility

xop is currently tested with go1.18 and go1.19. It is probably
xop is currently tested with go1.18 through go1.20. It is probably
compatible with go1.17 and perhaps earlier.

## Terminology
Expand Down
9 changes: 1 addition & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,17 @@ require (
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/muir/gwrap v0.1.0
github.com/muir/list v1.1.1
github.com/muir/reflectutils v0.7.0
github.com/muir/resty v0.0.1
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.2
go.opentelemetry.io/otel v1.14.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0
go.opentelemetry.io/otel/sdk v1.14.0
go.opentelemetry.io/otel/trace v1.14.0
golang.org/x/text v0.3.6
google.golang.org/grpc v1.50.1
google.golang.org/protobuf v1.28.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/net v0.0.0-20211029224645-99673261e6eb // indirect
golang.org/x/sys v0.5.0 // indirect
Expand Down
Loading
Loading