Skip to content

Commit

Permalink
Merge pull request #35 from muir/twentynine
Browse files Browse the repository at this point in the history
make the tests a bit more interesting
  • Loading branch information
muir committed Aug 24, 2022
2 parents a9beba6 + 067fc0a commit 2f07ad9
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 117 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ all: $(ZZZGENERATED)
test: $(ZZZGENERATED)
go generate ./...
go test -v ./xopjson/... -run TestASingleLine
go test -v ./xopjson/... -run TestNoBuffer
go test -v ./xopjson/... -run TestParameters
go test ./...
go test -race ./...

Expand Down Expand Up @@ -52,3 +52,7 @@ 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.45.2
golangci-lint --version

lint:;
golangci-lint run

44 changes: 12 additions & 32 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,19 @@

- support microsoft correlation vectors? https://github.com/Microsoft/CorrelationVector-Go

- How to do full-text (short-term) indexing of log lines

- Elastic
- [zinc](https://github.com/zinclabs/zinc)

# Just do it (build ready)

- move xoputil to internal/xoputil -- at least for now since
the APIs in xoputil are less stable than the rest of the code

- For enums from OTEL, generate them from the protobuf constants.

- Drop the makefile in favor of more sophisticated use of go:generate See example of enumer in zitadel/oidc
- Drop the makefile in favor of more sophisticated use of go:generate See example of enumer in zitadel/oidc. Well, keep the makefile since coverage is complicated.

- Round out the kinds of things that can be logged:

Expand Down Expand Up @@ -81,6 +86,8 @@
- Add tests:
Coverage needs to be up at 90+%
- subspans
- Span attributes
- Structued lines
Expand All @@ -97,7 +104,6 @@
- gateway to onelog
- gateway to zerolog
- gateway to zap
- gateway to phuslog
- emulation
Expand All @@ -118,17 +124,6 @@
- Console (emphasis on readable, but still retains full data)
- Bytes writers
- to console
- to io.Writer (same as console?)
- Add CI
Gitlab actions.
- Example in libschema for combining coverage from multiple source
- Performmance
- mark all places in the code where an allocation happens `// allocate`
Expand All @@ -137,10 +132,11 @@
- xop.Logger
- Replace flushers map with a flushers slice
- In xopjson
- track which spans have been modified
- pre-allocate span array
- use a priority queue instead of multiple channels for sending stuff to the writer
- Improve upon sync.Pool
Expand All @@ -159,23 +155,13 @@

- can *Sub be Sub instead? Would that have better performance?

- the Flush() and Done() code ends locking and releasing the same locks
multiple times. Refactor to put some parts of the work in functions that
must be called while locked so that fewer lock/release cycles. 200ns per
lock/release...

- Standard tracing

- figure out a way to modify trace State
- add methods to query trace State
- figure out a way to modify trace Baggage
- add methods to query trace Baggage

- How to do full-text (short-term) indexing of log lines

- Elastic
- [zinc](https://github.com/zinclabs/zinc)

# Not build ready

- benchmarking
Expand All @@ -191,20 +177,16 @@

Not ready because APIs should be more solid first

- Bytes writers

- Gateway into Jaeger
- Gateway into Open Telementry
- Improve the JSON logger

It can have a bunch more knobs and controls

- add additional time formats
- add ability to maintain and send dictionaries to compress logs

- keys for key/value
- span ids (use the spanSequenceCode)
- log line prefix sets

- Bytes writers:

- send to server (need to design server)

Expand All @@ -218,5 +200,3 @@
- Gets counted
- Re-use attributes?
- Attach arbitrary data


10 changes: 6 additions & 4 deletions xopjson/jsonlogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ func (logger *Logger) Request(ts time.Time, trace trace.Bundle, name string) xop

if logger.spanStarts {
rq := request.span.builder()
rq.AppendBytes([]byte(`{"type":"request"`))
rq.AppendBytes([]byte(`{"type":"request","request.ver":0`))
request.span.addRequestStartData(rq)
rq.AppendBytes([]byte{'}', '\n'})
request.serializationCount++
if logger.perRequestBufferLimit != 0 {
request.completedBuilders <- rq
} else {
Expand Down Expand Up @@ -232,10 +233,11 @@ func (s *span) Span(ts time.Time, trace trace.Bundle, name string, spanSequenceC

if s.logger.spanStarts {
rq := s.builder()
rq.AppendBytes([]byte(`{"type":"span","span.id":`))
rq.AppendBytes([]byte(`{"type":"span","span.ver":0,"span.id":`))
rq.AddSafeString(trace.Trace.SpanIDString())
s.spanStartData(rq)
n.spanStartData(rq)
rq.AppendBytes([]byte{'}', '\n'})
n.serializationCount++
if s.request.logger.perRequestBufferLimit != 0 {
s.request.completedBuilders <- rq
} else {
Expand Down Expand Up @@ -284,7 +286,6 @@ func (s *span) identifySpan(b *xoputil.JBuilder) {

func (s *span) FlushAttributes() {
rq := s.builder()
s.serializationCount++
if s == &s.request.span {
rq.AppendBytes([]byte(`{"type":"request"`)) // }
if !s.logger.spanStarts || !s.logger.spanChangesOnly {
Expand All @@ -302,6 +303,7 @@ func (s *span) FlushAttributes() {
rq.AddSafeKey("span.ver")
}
rq.AddInt64(int64(s.serializationCount))
s.serializationCount++
if s.request.logger.durationKey != nil {
rq.AppendBytes(s.request.logger.durationKey)
rq.AddDuration(time.Duration(s.endTime - s.startTime.UnixNano()))
Expand Down
10 changes: 6 additions & 4 deletions xopjson/jsonlogger.zzzgo
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ func (logger *Logger) Request(ts time.Time, trace trace.Bundle, name string) xop

if logger.spanStarts {
rq := request.span.builder()
rq.AppendBytes([]byte(`{"type":"request"`))
rq.AppendBytes([]byte(`{"type":"request","request.ver":0`))
request.span.addRequestStartData(rq)
rq.AppendBytes([]byte{'}', '\n'})
request.serializationCount++
if logger.perRequestBufferLimit != 0 {
request.completedBuilders <- rq
} else {
Expand Down Expand Up @@ -230,10 +231,11 @@ func (s *span) Span(ts time.Time, trace trace.Bundle, name string, spanSequenceC

if s.logger.spanStarts {
rq := s.builder()
rq.AppendBytes([]byte(`{"type":"span","span.id":`))
rq.AppendBytes([]byte(`{"type":"span","span.ver":0,"span.id":`))
rq.AddSafeString(trace.Trace.SpanIDString())
s.spanStartData(rq)
n.spanStartData(rq)
rq.AppendBytes([]byte{'}', '\n'})
n.serializationCount++
if s.request.logger.perRequestBufferLimit != 0 {
s.request.completedBuilders <- rq
} else {
Expand Down Expand Up @@ -282,7 +284,6 @@ func (s *span) identifySpan(b *xoputil.JBuilder) {

func (s *span) FlushAttributes() {
rq := s.builder()
s.serializationCount++
if s == &s.request.span {
rq.AppendBytes([]byte(`{"type":"request"`)) // }
if !s.logger.spanStarts || !s.logger.spanChangesOnly {
Expand All @@ -300,6 +301,7 @@ func (s *span) FlushAttributes() {
rq.AddSafeKey("span.ver")
}
rq.AddInt64(int64(s.serializationCount))
s.serializationCount++
if s.request.logger.durationKey != nil {
rq.AppendBytes(s.request.logger.durationKey)
rq.AddDuration(time.Duration(s.endTime - s.startTime.UnixNano()))
Expand Down
Loading

0 comments on commit 2f07ad9

Please sign in to comment.