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

add a generic Debug() function to the connection tracer #2909

Merged
merged 1 commit into from
Dec 6, 2020
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
1 change: 1 addition & 0 deletions integrationtests/self/key_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func (t *connTracer) DroppedKey(logging.KeyPhase)
func (t *connTracer) SetLossTimer(logging.TimerType, logging.EncryptionLevel, time.Time) {}
func (t *connTracer) LossTimerExpired(logging.TimerType, logging.EncryptionLevel) {}
func (t *connTracer) LossTimerCanceled() {}
func (t *connTracer) Debug(string, string) {}
func (t *connTracer) Close() {}

var _ = Describe("Key Update tests", func() {
Expand Down
12 changes: 12 additions & 0 deletions internal/mocks/logging/connection_tracer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions logging/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,5 @@ type ConnectionTracer interface {
LossTimerCanceled()
// Close is called when the connection is closed.
Close()
Debug(name, msg string)
}
12 changes: 12 additions & 0 deletions logging/mock_connection_tracer_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions logging/multiplex.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ func (m *connTracerMultiplexer) LossTimerCanceled() {
}
}

func (m *connTracerMultiplexer) Debug(name, msg string) {
for _, t := range m.tracers {
t.Debug(name, msg)
}
}

func (m *connTracerMultiplexer) Close() {
for _, t := range m.tracers {
t.Close()
Expand Down
1 change: 1 addition & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,5 @@ func (t *connTracer) DroppedKey(logging.KeyPhase)
func (t *connTracer) SetLossTimer(logging.TimerType, logging.EncryptionLevel, time.Time) {}
func (t *connTracer) LossTimerExpired(logging.TimerType, logging.EncryptionLevel) {}
func (t *connTracer) LossTimerCanceled() {}
func (t *connTracer) Debug(string, string) {}
func (t *connTracer) Close() {}
13 changes: 13 additions & 0 deletions qlog/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,16 @@ func (e eventCongestionStateUpdated) IsNil() bool { return false }
func (e eventCongestionStateUpdated) MarshalJSONObject(enc *gojay.Encoder) {
enc.StringKey("new", e.state.String())
}

type eventGeneric struct {
name string
msg string
}

func (e eventGeneric) Category() category { return categoryTransport }
func (e eventGeneric) Name() string { return e.name }
func (e eventGeneric) IsNil() bool { return false }

func (e eventGeneric) MarshalJSONObject(enc *gojay.Encoder) {
enc.StringKey("details", e.msg)
}
9 changes: 9 additions & 0 deletions qlog/qlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,12 @@ func (t *connectionTracer) LossTimerCanceled() {
t.recordEvent(time.Now(), &eventLossTimerCanceled{})
t.mutex.Unlock()
}

func (t *connectionTracer) Debug(name, msg string) {
t.mutex.Lock()
t.recordEvent(time.Now(), &eventGeneric{
name: name,
msg: msg,
})
t.mutex.Unlock()
}
11 changes: 11 additions & 0 deletions qlog/qlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,17 @@ var _ = Describe("Tracing", func() {
Expect(ev).To(HaveLen(1))
Expect(ev).To(HaveKeyWithValue("event_type", "cancelled"))
})

It("records a generic event", func() {
tracer.Debug("foo", "bar")
entry := exportAndParseSingle()
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
Expect(entry.Category).To(Equal("transport"))
Expect(entry.Name).To(Equal("foo"))
ev := entry.Event
Expect(ev).To(HaveLen(1))
Expect(ev).To(HaveKeyWithValue("details", "bar"))
})
})
})
})