export the TraceEvt (#40)

This commit is contained in:
Marten Seemann 2022-06-04 15:43:35 +02:00 committed by GitHub
parent 4316554cd3
commit 5224eb6ad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,7 +46,7 @@ const (
traceRemoveConnEvt = "remove_conn" traceRemoveConnEvt = "remove_conn"
) )
type traceEvt struct { type TraceEvt struct {
Time string Time string
Type string Type string
@ -71,7 +71,7 @@ type traceEvt struct {
FD int `json:",omitempty"` FD int `json:",omitempty"`
} }
func (t *trace) push(evt traceEvt) { func (t *trace) push(evt TraceEvt) {
t.mx.Lock() t.mx.Lock()
defer t.mx.Unlock() defer t.mx.Unlock()
@ -176,7 +176,7 @@ func (t *trace) Start(limits Limiter) error {
go t.background(out) go t.background(out)
t.push(traceEvt{ t.push(TraceEvt{
Type: traceStartEvt, Type: traceStartEvt,
Limit: limits, Limit: limits,
}) })
@ -209,7 +209,7 @@ func (t *trace) CreateScope(scope string, limit Limit) {
return return
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceCreateScopeEvt, Type: traceCreateScopeEvt,
Scope: scope, Scope: scope,
Limit: limit, Limit: limit,
@ -221,7 +221,7 @@ func (t *trace) DestroyScope(scope string) {
return return
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceDestroyScopeEvt, Type: traceDestroyScopeEvt,
Scope: scope, Scope: scope,
}) })
@ -236,7 +236,7 @@ func (t *trace) ReserveMemory(scope string, prio uint8, size, mem int64) {
return return
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceReserveMemoryEvt, Type: traceReserveMemoryEvt,
Scope: scope, Scope: scope,
Priority: prio, Priority: prio,
@ -254,7 +254,7 @@ func (t *trace) BlockReserveMemory(scope string, prio uint8, size, mem int64) {
return return
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceBlockReserveMemoryEvt, Type: traceBlockReserveMemoryEvt,
Scope: scope, Scope: scope,
Priority: prio, Priority: prio,
@ -272,7 +272,7 @@ func (t *trace) ReleaseMemory(scope string, size, mem int64) {
return return
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceReleaseMemoryEvt, Type: traceReleaseMemoryEvt,
Scope: scope, Scope: scope,
Delta: size, Delta: size,
@ -292,7 +292,7 @@ func (t *trace) AddStream(scope string, dir network.Direction, nstreamsIn, nstre
deltaOut = 1 deltaOut = 1
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceAddStreamEvt, Type: traceAddStreamEvt,
Scope: scope, Scope: scope,
DeltaIn: deltaIn, DeltaIn: deltaIn,
@ -314,7 +314,7 @@ func (t *trace) BlockAddStream(scope string, dir network.Direction, nstreamsIn,
deltaOut = 1 deltaOut = 1
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceBlockAddStreamEvt, Type: traceBlockAddStreamEvt,
Scope: scope, Scope: scope,
DeltaIn: deltaIn, DeltaIn: deltaIn,
@ -336,7 +336,7 @@ func (t *trace) RemoveStream(scope string, dir network.Direction, nstreamsIn, ns
deltaOut = -1 deltaOut = -1
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceRemoveStreamEvt, Type: traceRemoveStreamEvt,
Scope: scope, Scope: scope,
DeltaIn: deltaIn, DeltaIn: deltaIn,
@ -355,7 +355,7 @@ func (t *trace) AddStreams(scope string, deltaIn, deltaOut, nstreamsIn, nstreams
return return
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceAddStreamEvt, Type: traceAddStreamEvt,
Scope: scope, Scope: scope,
DeltaIn: deltaIn, DeltaIn: deltaIn,
@ -374,7 +374,7 @@ func (t *trace) BlockAddStreams(scope string, deltaIn, deltaOut, nstreamsIn, nst
return return
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceBlockAddStreamEvt, Type: traceBlockAddStreamEvt,
Scope: scope, Scope: scope,
DeltaIn: deltaIn, DeltaIn: deltaIn,
@ -393,7 +393,7 @@ func (t *trace) RemoveStreams(scope string, deltaIn, deltaOut, nstreamsIn, nstre
return return
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceRemoveStreamEvt, Type: traceRemoveStreamEvt,
Scope: scope, Scope: scope,
DeltaIn: -deltaIn, DeltaIn: -deltaIn,
@ -418,7 +418,7 @@ func (t *trace) AddConn(scope string, dir network.Direction, usefd bool, nconnsI
deltafd = 1 deltafd = 1
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceAddConnEvt, Type: traceAddConnEvt,
Scope: scope, Scope: scope,
DeltaIn: deltaIn, DeltaIn: deltaIn,
@ -445,7 +445,7 @@ func (t *trace) BlockAddConn(scope string, dir network.Direction, usefd bool, nc
deltafd = 1 deltafd = 1
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceBlockAddConnEvt, Type: traceBlockAddConnEvt,
Scope: scope, Scope: scope,
DeltaIn: deltaIn, DeltaIn: deltaIn,
@ -472,7 +472,7 @@ func (t *trace) RemoveConn(scope string, dir network.Direction, usefd bool, ncon
deltafd = -1 deltafd = -1
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceRemoveConnEvt, Type: traceRemoveConnEvt,
Scope: scope, Scope: scope,
DeltaIn: deltaIn, DeltaIn: deltaIn,
@ -493,7 +493,7 @@ func (t *trace) AddConns(scope string, deltaIn, deltaOut, deltafd, nconnsIn, nco
return return
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceAddConnEvt, Type: traceAddConnEvt,
Scope: scope, Scope: scope,
DeltaIn: deltaIn, DeltaIn: deltaIn,
@ -514,7 +514,7 @@ func (t *trace) BlockAddConns(scope string, deltaIn, deltaOut, deltafd, nconnsIn
return return
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceBlockAddConnEvt, Type: traceBlockAddConnEvt,
Scope: scope, Scope: scope,
DeltaIn: deltaIn, DeltaIn: deltaIn,
@ -535,7 +535,7 @@ func (t *trace) RemoveConns(scope string, deltaIn, deltaOut, deltafd, nconnsIn,
return return
} }
t.push(traceEvt{ t.push(TraceEvt{
Type: traceRemoveConnEvt, Type: traceRemoveConnEvt,
Scope: scope, Scope: scope,
DeltaIn: -deltaIn, DeltaIn: -deltaIn,