MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / initEventTraceProps

Function initEventTraceProps

internal/etw/trace.go:37–75  ·  view source on GitHub ↗

initEventTraceProps builds the trace properties descriptor which influences the behaviour of event publishing to the trace session buffers.

(c config.EventSourceConfig)

Source from the content-addressed store, hash-verified

35// influences the behaviour of event publishing to the trace session
36// buffers.
37func initEventTraceProps(c config.EventSourceConfig) etw.EventTraceProperties {
38 bufferSize := c.BufferSize
39 if bufferSize > maxBufferSize {
40 bufferSize = maxBufferSize
41 }
42 // validate min/max buffers. The minimal
43 // number of buffers is 2 per CPU logical core
44 minBuffers := c.MinBuffers
45 if minBuffers < uint32(runtime.NumCPU()*2) {
46 minBuffers = uint32(runtime.NumCPU() * 2)
47 }
48 maxBuffers := c.MaxBuffers
49 maxBuffersAllowed := minBuffers + 20
50 if maxBuffers > maxBuffersAllowed {
51 maxBuffers = maxBuffersAllowed
52 }
53 if minBuffers > maxBuffers {
54 minBuffers = maxBuffers - 20
55 }
56 flushTimer := c.FlushTimer
57 if flushTimer < time.Second {
58 flushTimer = time.Second
59 }
60
61 mode := uint32(etw.ProcessTraceModeRealtime)
62
63 return etw.EventTraceProperties{
64 Wnode: etw.WnodeHeader{
65 BufferSize: uint32(unsafe.Sizeof(etw.EventTraceProperties{})) + maxTracePropsSize,
66 Flags: etw.WnodeTraceFlagGUID,
67 ClientContext: 1, // QPC clock resolution
68 },
69 BufferSize: bufferSize,
70 LogFileMode: mode,
71 MinimumBuffers: minBuffers,
72 MaximumBuffers: maxBuffers,
73 FlushTimer: uint32(flushTimer.Seconds()),
74 }
75}
76
77// ProviderInfo describes ETW provider metadata.
78type ProviderInfo struct {

Callers 1

StartMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected