Skip to content

Commit

Permalink
Merge pull request #34 from muir/twentyeight
Browse files Browse the repository at this point in the history
Twentyeight
  • Loading branch information
muir authored Aug 22, 2022
2 parents 4a62c7b + 2b3e031 commit a9beba6
Show file tree
Hide file tree
Showing 19 changed files with 358 additions and 251 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ jobs:
with:
go-version: '1.18'
- name: Run coverage
run: go test ./... -race -coverprofile=coverage.txt -covermode=atomic -coverpkg github.com/muir/xop-go
run: make calculate_coverage

- name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash)
uses: codecov/codecov-action@v2
with:
verbose: true
flags: go_tests
fail_ci_if_error: true
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,21 @@ ${GOBIN}/enumer:;
-chmod -w $@
-rm $@.tmp

calculate_coverage:
echo "mode: atomic" > coverage.txt
for d in $$(go list ./...); do \
go test -race -covermode=atomic -coverprofile=profile.out -coverpkg=github.com/muir/xop-go/... $$d; \
if [ -f profile.out ]; then \
grep -v ^mode profile.out >> coverage.txt; \
rm profile.out; \
fi; \
done


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.45.2
golangci-lint --version
7 changes: 7 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
behavior. Baseloggers could choose to ignore levels that are too low. The logger itself
could choose to discard when the level is too low.

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

# Just do it (build ready)

- move xoputil to internal/xoputil -- at least for now since
Expand Down Expand Up @@ -169,6 +171,11 @@
- 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 Down
4 changes: 2 additions & 2 deletions basegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ func (s baseRequests) Flush() {
wg.Wait()
}

func (s baseSpans) Span(t time.Time, span trace.Bundle, descriptionOrName string) xopbase.Span {
func (s baseSpans) Span(t time.Time, span trace.Bundle, descriptionOrName string, spanSequenceCode string) xopbase.Span {
baseSpans := make(baseSpans, len(s))
for i, ele := range s {
baseSpans[i] = ele.Span(t, span, descriptionOrName)
baseSpans[i] = ele.Span(t, span, descriptionOrName, spanSequenceCode)
}
return baseSpans
}
Expand Down
4 changes: 2 additions & 2 deletions basegroup.zzzgo
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ func (s baseRequests) Flush() {
wg.Wait()
}

func (s baseSpans) Span(t time.Time, span trace.Bundle, descriptionOrName string) xopbase.Span {
func (s baseSpans) Span(t time.Time, span trace.Bundle, descriptionOrName string, spanSequenceCode string) xopbase.Span {
baseSpans := make(baseSpans, len(s))
for i, ele := range s {
baseSpans[i] = ele.Span(t, span, descriptionOrName)
baseSpans[i] = ele.Span(t, span, descriptionOrName, spanSequenceCode)
}
return baseSpans
}
Expand Down
3 changes: 1 addition & 2 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (old *Log) newChildLog(spanSeed spanSeed, description string, settings LogS
alloc.Log.span = &alloc.span
log := &alloc.Log

log.span.base = old.span.base.Span(time.Now(), spanSeed.traceBundle, description)
log.span.base = old.span.base.Span(time.Now(), spanSeed.traceBundle, description, log.span.seed.spanSequenceCode)
if len(spanSeed.loggers.Added) == 0 && len(spanSeed.loggers.Removed) == 0 {
log.span.buffered = old.span.buffered
log.span.referencesKept = old.span.referencesKept
Expand Down Expand Up @@ -217,7 +217,6 @@ func (old *Log) newChildLog(spanSeed spanSeed, description string, settings LogS
log.span.referencesKept = log.span.seed.loggers.List.ReferencesKept()
}
log.span.base.Boring(true)
log.Span().String(xopconst.SpanSequenceCode, log.span.seed.spanSequenceCode) // TODO: improve (not efficient)
log.sendPrefill()
log.addMyselfAsDependent()
return log
Expand Down
4 changes: 2 additions & 2 deletions trace/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ func TestSetRandom(t *testing.T) {
trace := trace.NewTrace()
trace.RebuildSetNonZero()
trace.RandomizeSpanID()
a := trace.SpanIDString()
a := trace.SpanID().String()
trace.RandomizeSpanID()
b := trace.SpanIDString()
b := trace.SpanID().String()
assert.NotEqual(t, a, b)
}
2 changes: 1 addition & 1 deletion xopbase/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type Request interface {

type Span interface {
// Span creates a new Span that should inherit prefil but not data
Span(ts time.Time, span trace.Bundle, descriptionOrName string) Span
Span(ts time.Time, span trace.Bundle, descriptionOrName string, spanSequenceCode string) Span

// MetadataAny adds a key/value pair to describe the span.
MetadataAny(*xopconst.AnyAttribute, interface{})
Expand Down
2 changes: 1 addition & 1 deletion xopbase/base.zzzgo
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Request interface {

type Span interface {
// Span creates a new Span that should inherit prefil but not data
Span(ts time.Time, span trace.Bundle, descriptionOrName string) Span
Span(ts time.Time, span trace.Bundle, descriptionOrName string, spanSequenceCode string) Span

// MACRO BaseAttribute
// MetadataZZZ adds a key/value pair to describe the span.
Expand Down
8 changes: 4 additions & 4 deletions xopjson/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ func (a *AttributeBuilder) Init(s *span) {
a.span = s
}

func (a *AttributeBuilder) Append(b *xoputil.JBuilder) {
func (a *AttributeBuilder) Append(b *xoputil.JBuilder, onlyChanged bool) {
a.lock.Lock()
defer a.lock.Unlock()
if !a.anyChanged {
if (!a.anyChanged && onlyChanged) || (len(a.multiMap) == 0 && len(a.singleMap) == 0) {
return
}
a.anyChanged = false
Expand All @@ -78,7 +78,7 @@ func (a *AttributeBuilder) Append(b *xoputil.JBuilder) {
b.AppendBytes([]byte(`"attributes":{`)) // }
}
for _, m := range a.multiMap {
if m.Changed {
if m.Changed || !onlyChanged {
b.Comma()
b.AppendBytes(m.Builder.B)
// [
Expand All @@ -87,7 +87,7 @@ func (a *AttributeBuilder) Append(b *xoputil.JBuilder) {
}
}
for _, s := range a.singleMap {
if s.Changed {
if s.Changed || !onlyChanged {
b.Comma()
b.AppendBytes(s.KeyValue)
s.Changed = false
Expand Down
8 changes: 4 additions & 4 deletions xopjson/attributes.zzzgo
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ func (a *AttributeBuilder) Init(s *span) {
a.span = s
}

func (a *AttributeBuilder) Append(b *xoputil.JBuilder) {
func (a *AttributeBuilder) Append(b *xoputil.JBuilder, onlyChanged bool) {
a.lock.Lock()
defer a.lock.Unlock()
if !a.anyChanged {
if (!a.anyChanged && onlyChanged) || (len(a.multiMap) == 0 && len(a.singleMap) == 0) {
return
}
a.anyChanged = false
Expand All @@ -72,7 +72,7 @@ func (a *AttributeBuilder) Append(b *xoputil.JBuilder) {
b.AppendBytes([]byte(`"attributes":{`)) // }
}
for _, m := range a.multiMap {
if m.Changed {
if m.Changed || !onlyChanged {
b.Comma()
b.AppendBytes(m.Builder.B)
// [
Expand All @@ -81,7 +81,7 @@ func (a *AttributeBuilder) Append(b *xoputil.JBuilder) {
}
}
for _, s := range a.singleMap {
if s.Changed {
if s.Changed || !onlyChanged {
b.Comma()
b.AppendBytes(s.KeyValue)
s.Changed = false
Expand Down
Loading

0 comments on commit a9beba6

Please sign in to comment.