Skip to content

Commit

Permalink
minor style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brycekahle committed Jul 29, 2024
1 parent 709cd70 commit 107c3f7
Showing 1 changed file with 26 additions and 35 deletions.
61 changes: 26 additions & 35 deletions pkg/network/tracer/connection/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,39 +343,34 @@ func NewTracer(config *config.Config, _ telemetryComponent.Component) (Tracer, e
}

func initFailedConnEventHandler(config *config.Config, failedCallback func(*netebpf.FailedConn), pool ddsync.Pool[netebpf.FailedConn]) (*perf.EventHandler, error) {
var failedConnsHandler *perf.EventHandler
var err error
if !config.FailedConnectionsSupported() {
return nil, nil
}

if config.FailedConnectionsSupported() {
fcopts := perf.EventHandlerOptions{
MapName: probes.FailedConnEventMap,
Handler: encoding.BinaryUnmarshalCallback(pool.Get, func(b *netebpf.FailedConn, err error) {
if err != nil {
if b != nil {
pool.Put(b)
}
log.Debug(err.Error())
return
fcopts := perf.EventHandlerOptions{
MapName: probes.FailedConnEventMap,
Handler: encoding.BinaryUnmarshalCallback(pool.Get, func(b *netebpf.FailedConn, err error) {
if err != nil {
if b != nil {
pool.Put(b)
}
failedCallback(b)
}),
TelemetryEnabled: config.InternalTelemetryEnabled,
UseRingBuffer: config.RingBufferSupportedNPM(),
UpgradePerfBuffer: true,
PerfOptions: perf.PerfBufferOptions{
BufferSize: util.ComputeDefaultFailedConnPerfBufferSize(),
Watermark: 1,
},
RingBufOptions: perf.RingBufferOptions{
BufferSize: util.ComputeDefaultFailedConnectionsRingBufferSize(),
},
}
failedConnsHandler, err = perf.NewEventHandler(fcopts)
if err != nil {
return nil, err
}
log.Debug(err.Error())
return
}
failedCallback(b)
}),
TelemetryEnabled: config.InternalTelemetryEnabled,
UseRingBuffer: config.RingBufferSupportedNPM(),
UpgradePerfBuffer: true,
PerfOptions: perf.PerfBufferOptions{
BufferSize: util.ComputeDefaultFailedConnPerfBufferSize(),
Watermark: 1,
},
RingBufOptions: perf.RingBufferOptions{
BufferSize: util.ComputeDefaultFailedConnectionsRingBufferSize(),
},
}
return failedConnsHandler, err
return perf.NewEventHandler(fcopts)
}

func initClosedConnEventHandler(config *config.Config, closedCallback func(*network.ConnectionStats), pool ddsync.Pool[network.ConnectionStats], extractor *batchExtractor) (*perf.EventHandler, error) {
Expand Down Expand Up @@ -433,11 +428,7 @@ func initClosedConnEventHandler(config *config.Config, closedCallback func(*netw
eopts.Handler = singleConnHandler
}

connCloseEventHandler, err := perf.NewEventHandler(eopts)
if err != nil {
return nil, err
}
return connCloseEventHandler, nil
return perf.NewEventHandler(eopts)
}

func boolConst(name string, value bool) manager.ConstantEditor {
Expand Down

0 comments on commit 107c3f7

Please sign in to comment.