Skip to content

in_ebpf: Generate mostly monotonic event id for increasing traceability - #12002

Merged
edsiper merged 1 commit into
masterfrom
cosmo0920-generate-mostly-monotonic-event-id-traceability
Jul 3, 2026
Merged

in_ebpf: Generate mostly monotonic event id for increasing traceability#12002
edsiper merged 1 commit into
masterfrom
cosmo0920-generate-mostly-monotonic-event-id-traceability

Conversation

@cosmo0920

@cosmo0920 cosmo0920 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

This is because without IDs per CPU, it's really hard to trace the event sequence.
After adding event_id per CPU, it's easier to trace the sequence of events.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
Fluent Bit v5.0.8
* Copyright (C) 2015-2026 The Fluent Bit Authors
* Fluent Bit is a CNCF graduated project under the Fluent organization
* https://fluentbit.io

______ _                  _    ______ _ _           _____  _____ 
|  ___| |                | |   | ___ (_) |         |  ___||  _  |
| |_  | |_   _  ___ _ __ | |_  | |_/ /_| |_  __   _|___ \ | |/' |
|  _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / /   \ \|  /| |
| |   | | |_| |  __/ | | | |_  | |_/ / | |_   \ V //\__/ /\ |_/ /
\_|   |_|\__,_|\___|_| |_|\__| \____/|_|\__|   \_/ \____(_)\___/


[2026/06/25 14:35:23.136] [ info] Configuration:
[2026/06/25 14:35:23.158] [ info]  flush time     | 1.000000 seconds
[2026/06/25 14:35:23.163] [ info]  grace          | 5 seconds
[2026/06/25 14:35:23.164] [ info]  daemon         | 0
[2026/06/25 14:35:23.164] [ info] ___________
[2026/06/25 14:35:23.164] [ info]  inputs:
[2026/06/25 14:35:23.164] [ info]      ebpf
[2026/06/25 14:35:23.165] [ info] ___________
[2026/06/25 14:35:23.165] [ info]  filters:
[2026/06/25 14:35:23.165] [ info] ___________
[2026/06/25 14:35:23.165] [ info]  outputs:
[2026/06/25 14:35:23.166] [ info]      stdout.0
[2026/06/25 14:35:23.166] [ info] ___________
[2026/06/25 14:35:23.166] [ info]  collectors:
[2026/06/25 14:35:23.233] [ info] [fluent bit] version=5.0.8, commit=dc22be7406, pid=275420
[2026/06/25 14:35:23.241] [debug] [engine] coroutine stack size: 24576 bytes (24.0K)
[2026/06/25 14:35:23.247] [ info] [storage] ver=1.5.4, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2026/06/25 14:35:23.247] [ info] [simd    ] SSE2
[2026/06/25 14:35:23.248] [ info] [cmetrics] version=2.1.5
[2026/06/25 14:35:23.248] [ info] [ctraces ] version=0.7.1
[2026/06/25 14:35:23.263] [ info] [input:ebpf:ebpf.0] initializing
[2026/06/25 14:35:23.264] [ info] [input:ebpf:ebpf.0] storage_strategy='memory' (memory only)
[2026/06/25 14:35:23.266] [debug] [ebpf:ebpf.0] created event channels: read=21 write=22
[2026/06/25 14:35:23.266] [debug] [input:ebpf:ebpf.0] initializing eBPF input plugin
[2026/06/25 14:35:23.271] [debug] [input:ebpf:ebpf.0] processing trace: trace_openssl
[2026/06/25 14:35:23.271] [debug] [input:ebpf:ebpf.0] setting up trace configuration for: trace_openssl
[2026/06/25 14:35:28.323] [debug] [input:ebpf:ebpf.0] attaching BPF program for trace: trace_openssl
[2026/06/25 14:35:28.363] [debug] [input:ebpf:ebpf.0] registering trace handler for: trace_openssl
[2026/06/25 14:35:28.366] [ info] [input:ebpf:ebpf.0] registered trace handler for: trace_openssl
[2026/06/25 14:35:28.367] [ info] [input:ebpf:ebpf.0] trace configuration completed for: trace_openssl
[2026/06/25 14:35:28.367] [debug] [input:ebpf:ebpf.0] setting up collector with poll interval: 1000 ms
[2026/06/25 14:35:28.369] [ info] [input:ebpf:ebpf.0] eBPF input plugin initialized successfully
[2026/06/25 14:35:28.373] [debug] [stdout:stdout.0] created event channels: read=68 write=69
[2026/06/25 14:35:28.409] [ info] [sp] stream processor started
[2026/06/25 14:35:28.412] [ info] [engine] Shutdown Grace Period=5, Shutdown Input Grace Period=2
[2026/06/25 14:35:28.421] [ info] [output:stdout:stdout.0] worker #0 started
[2026/06/25 14:35:28.490] [debug] [input:ebpf:ebpf.0] collecting events from ring buffers
[2026/06/25 14:35:28.490] [debug] [input:ebpf:ebpf.0] consuming events from ring buffer trace_openssl
[2026/06/25 14:35:28.491] [debug] [input:ebpf:ebpf.0] successfully consumed events from ring buffer trace_openssl
[2026/06/25 14:35:29.471] [debug] [input:ebpf:ebpf.0] collecting events from ring buffers
[2026/06/25 14:35:29.472] [debug] [input:ebpf:ebpf.0] consuming events from ring buffer trace_openssl
[2026/06/25 14:35:29.472] [debug] [input:ebpf:ebpf.0] successfully consumed events from ring buffer trace_openssl
[2026/06/25 14:35:30.472] [debug] [input:ebpf:ebpf.0] collecting events from ring buffers
[2026/06/25 14:35:30.472] [debug] [input:ebpf:ebpf.0] consuming events from ring buffer trace_openssl
[2026/06/25 14:35:30.472] [debug] [input:ebpf:ebpf.0] successfully consumed events from ring buffer trace_openssl
[2026/06/25 14:35:31.472] [debug] [input:ebpf:ebpf.0] collecting events from ring buffers
[2026/06/25 14:35:31.472] [debug] [input:ebpf:ebpf.0] consuming events from ring buffer trace_openssl
[2026/06/25 14:35:31.521] [debug] [input:ebpf:ebpf.0] successfully consumed events from ring buffer trace_openssl
[0] ebpf.0: [[1782365731.482789467, {}], {"event_type"=>"tls_handshake", "event_id"=>562949953421312, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_handshake", "ssl_ptr"=>94797606761120, "latency_ns"=>20596999, "ret"=>-1}]
[1] ebpf.0: [[1782365731.516787242, {}], {"event_type"=>"tls_handshake", "event_id"=>562949953421313, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_handshake", "ssl_ptr"=>94797606761120, "latency_ns"=>822858, "ret"=>1}]
[2] ebpf.0: [[1782365731.517948490, {}], {"event_type"=>"tls_read", "event_id"=>562949953421314, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>94797606761120, "latency_ns"=>4463, "ret"=>-1}]
[3] ebpf.0: [[1782365731.518970179, {}], {"event_type"=>"tls_write", "event_id"=>562949953421315, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_write", "ssl_ptr"=>94797606761120, "latency_ns"=>15520, "ret"=>64}]
[4] ebpf.0: [[1782365731.519215011, {}], {"event_type"=>"tls_write", "event_id"=>562949953421316, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_write", "ssl_ptr"=>94797606761120, "latency_ns"=>2461, "ret"=>36}]
[5] ebpf.0: [[1782365731.519376038, {}], {"event_type"=>"tls_read", "event_id"=>3096224743817216, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>94797606761120, "latency_ns"=>104899, "ret"=>40}]
[6] ebpf.0: [[1782365731.519528389, {}], {"event_type"=>"tls_read", "event_id"=>3096224743817217, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>94797606761120, "latency_ns"=>3437, "ret"=>-1}]
[7] ebpf.0: [[1782365731.519692847, {}], {"event_type"=>"tls_write", "event_id"=>3096224743817218, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_write", "ssl_ptr"=>94797606761120, "latency_ns"=>45009, "ret"=>9}]
[8] ebpf.0: [[1782365731.519823016, {}], {"event_type"=>"tls_read", "event_id"=>3096224743817219, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>94797606761120, "latency_ns"=>9579, "ret"=>9}]
[9] ebpf.0: [[1782365731.519950765, {}], {"event_type"=>"tls_read", "event_id"=>3096224743817220, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>94797606761120, "latency_ns"=>2705, "ret"=>-1}]
[10] ebpf.0: [[1782365731.520095216, {}], {"event_type"=>"tls_read", "event_id"=>3096224743817221, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>94797606761120, "latency_ns"=>104819, "ret"=>406}]
[11] ebpf.0: [[1782365731.520475561, {}], {"event_type"=>"tls_read", "event_id"=>3096224743817222, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>94797606761120, "latency_ns"=>25431, "ret"=>239}]
[12] ebpf.0: [[1782365731.520785952, {}], {"event_type"=>"tls_read", "event_id"=>3096224743817223, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>94797606761120, "latency_ns"=>18871, "ret"=>9}]
[13] ebpf.0: [[1782365731.520937557, {}], {"event_type"=>"tls_read", "event_id"=>3096224743817224, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>94797606761120, "latency_ns"=>19203, "ret"=>17}]
[14] ebpf.0: [[1782365731.521070460, {}], {"event_type"=>"tls_write", "event_id"=>3096224743817225, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_write", "ssl_ptr"=>94797606761120, "latency_ns"=>127108, "ret"=>17}]
[15] ebpf.0: [[1782365731.521218835, {}], {"event_type"=>"tls_read", "event_id"=>3096224743817226, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>94797606761120, "latency_ns"=>18456, "ret"=>-1}]
[2026/06/25 14:35:32.490] [debug] [task] created task=0x8436270 id=0 OK
[16] ebpf.0: [[1782365731.521395834, {}], {"event_type"=>"tls_shutdown", "event_id"=>3096224743817227, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_shutdown", "ssl_ptr"=>94797606761120, "latency_ns"=>33546, "ret"=>0}]
[2026/06/25 14:35:32.492] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[17] ebpf.0: [[1782365731.521621631, {}], {"event_type"=>"tls_read", "event_id"=>3096224743817228, "pid"=>275438, "tid"=>275438, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>94797606761120, "latency_ns"=>24986, "ret"=>-1}]
[2026/06/25 14:35:32.493] [debug] [input:ebpf:ebpf.0] collecting events from ring buffers
[2026/06/25 14:35:32.493] [debug] [input:ebpf:ebpf.0] consuming events from ring buffer trace_openssl
[2026/06/25 14:35:32.493] [debug] [input:ebpf:ebpf.0] successfully consumed events from ring buffer trace_openssl
[2026/06/25 14:35:32.511] [debug] [out flush] cb_destroy coro_id=0
[2026/06/25 14:35:32.519] [debug] [task] destroy task=0x8436270 (task_id=0)
[2026/06/25 14:35:33.471] [debug] [input:ebpf:ebpf.0] collecting events from ring buffers
[2026/06/25 14:35:33.472] [debug] [input:ebpf:ebpf.0] consuming events from ring buffer trace_openssl
[2026/06/25 14:35:33.477] [debug] [input:ebpf:ebpf.0] successfully consumed events from ring buffer trace_openssl
[0] ebpf.0: [[1782365733.472626529, {}], {"event_type"=>"tls_handshake", "event_id"=>562949953421317, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_handshake", "ssl_ptr"=>98811799495600, "latency_ns"=>18017408, "ret"=>-1}]
[1] ebpf.0: [[1782365733.473756712, {}], {"event_type"=>"tls_handshake", "event_id"=>562949953421318, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_handshake", "ssl_ptr"=>98811799495600, "latency_ns"=>1369447, "ret"=>1}]
[2] ebpf.0: [[1782365733.474394499, {}], {"event_type"=>"tls_read", "event_id"=>562949953421319, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>5959, "ret"=>-1}]
[3] ebpf.0: [[1782365733.474979536, {}], {"event_type"=>"tls_write", "event_id"=>562949953421320, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_write", "ssl_ptr"=>98811799495600, "latency_ns"=>10399, "ret"=>64}]
[4] ebpf.0: [[1782365733.475540011, {}], {"event_type"=>"tls_write", "event_id"=>562949953421321, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_write", "ssl_ptr"=>98811799495600, "latency_ns"=>2646, "ret"=>40}]
[5] ebpf.0: [[1782365733.476068383, {}], {"event_type"=>"tls_read", "event_id"=>562949953421322, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>74936, "ret"=>49}]
[6] ebpf.0: [[1782365733.476549650, {}], {"event_type"=>"tls_read", "event_id"=>562949953421323, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>1990, "ret"=>-1}]
[7] ebpf.0: [[1782365733.476977758, {}], {"event_type"=>"tls_write", "event_id"=>562949953421324, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_write", "ssl_ptr"=>98811799495600, "latency_ns"=>24220, "ret"=>9}]
[2026/06/25 14:35:34.471] [debug] [task] created task=0x84e4b10 id=0 OK
[2026/06/25 14:35:34.472] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[2026/06/25 14:35:34.476] [debug] [out flush] cb_destroy coro_id=1
[2026/06/25 14:35:34.477] [debug] [input:ebpf:ebpf.0] collecting events from ring buffers
[2026/06/25 14:35:34.477] [debug] [input:ebpf:ebpf.0] consuming events from ring buffer trace_openssl
[2026/06/25 14:35:34.491] [debug] [input:ebpf:ebpf.0] successfully consumed events from ring buffer trace_openssl
[2026/06/25 14:35:34.491] [debug] [task] destroy task=0x84e4b10 (task_id=0)
^C[2026/06/25 14:35:35] [engine] caught signal (SIGINT)
[2026/06/25 14:35:35.317] [debug] [task] created task=0x8671ec0 id=0 OK
[2026/06/25 14:35:35.317] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[0] ebpf.0: [[1782365734.477942546, {}], {"event_type"=>"tls_read", "event_id"=>1970324836974592, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>102064, "ret"=>712}]
[1] ebpf.0: [[1782365734.479691113, {}], {"event_type"=>"tls_read", "event_id"=>0, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>102303, "ret"=>1369}]
[2] ebpf.0: [[1782365734.480538128, {}], {"event_type"=>"tls_read", "event_id"=>1, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>13056, "ret"=>1369}]
[3] ebpf.0: [[1782365734.480756998, {}], {"event_type"=>"tls_read", "event_id"=>2, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>12192, "ret"=>1369}]
[4] ebpf.0: [[1782365734.480963838, {}], {"event_type"=>"tls_read", "event_id"=>3, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>12275, "ret"=>1369}]
[5] ebpf.0: [[1782365734.481221763, {}], {"event_type"=>"tls_read", "event_id"=>4, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>12434, "ret"=>1369}]
[6] ebpf.0: [[1782365734.481440899, {}], {"event_type"=>"tls_read", "event_id"=>5, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>12392, "ret"=>1369}]
[7] ebpf.0: [[1782365734.481649497, {}], {"event_type"=>"tls_read", "event_id"=>6, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>11816, "ret"=>1369}]
[8] ebpf.0: [[1782365734.481844817, {}], {"event_type"=>"tls_read", "event_id"=>7, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>11983, "ret"=>1369}]
[9] ebpf.0: [[1782365734.482032464, {}], {"event_type"=>"tls_read", "event_id"=>8, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>11894, "ret"=>1369}]
[10] ebpf.0: [[1782365734.482275088, {}], {"event_type"=>"tls_read", "event_id"=>9, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>12006, "ret"=>1369}]
[11] ebpf.0: [[1782365734.482498432, {}], {"event_type"=>"tls_read", "event_id"=>10, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>12354, "ret"=>1369}]
[12] ebpf.0: [[1782365734.482723928, {}], {"event_type"=>"tls_read", "event_id"=>11, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>12647, "ret"=>1369}]
[13] ebpf.0: [[1782365734.482955318, {}], {"event_type"=>"tls_read", "event_id"=>12, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>12177, "ret"=>1369}]
[14] ebpf.0: [[1782365734.483201924, {}], {"event_type"=>"tls_read", "event_id"=>13, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>12448, "ret"=>1369}]
[15] ebpf.0: [[1782365734.483482424, {}], {"event_type"=>"tls_read", "event_id"=>14, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>12339, "ret"=>1369}]
[16] ebpf.0: [[1782365734.483724219, {}], {"event_type"=>"tls_read", "event_id"=>15, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>19928, "ret"=>-1}]
[17] ebpf.0: [[1782365734.483964639, {}], {"event_type"=>"tls_read", "event_id"=>16, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>22374, "ret"=>-1}]
[18] ebpf.0: [[1782365734.484233945, {}], {"event_type"=>"tls_read", "event_id"=>1407374883553280, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>69903, "ret"=>1369}]
[19] ebpf.0: [[1782365734.484464146, {}], {"event_type"=>"tls_read", "event_id"=>1407374883553281, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>15662, "ret"=>1369}]
[20] ebpf.0: [[1782365734.484716160, {}], {"event_type"=>"tls_read", "event_id"=>1407374883553282, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>11330, "ret"=>1369}]
[21] ebpf.0: [[1782365734.484926283, {}], {"event_type"=>"tls_read", "event_id"=>1407374883553283, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>10847, "ret"=>1369}]
[22] ebpf.0: [[1782365734.485135011, {}], {"event_type"=>"tls_read", "event_id"=>1407374883553284, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>11021, "ret"=>1369}]
[23] ebpf.0: [[1782365734.485369291, {}], {"event_type"=>"tls_read", "event_id"=>1407374883553285, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>11287, "ret"=>1369}]
[24] ebpf.0: [[1782365734.485580372, {}], {"event_type"=>"tls_read", "event_id"=>1407374883553286, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>11626, "ret"=>-1}]
[25] ebpf.0: [[1782365734.485805449, {}], {"event_type"=>"tls_read", "event_id"=>1407374883553287, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>53401, "ret"=>1369}]
[26] ebpf.0: [[1782365734.486002174, {}], {"event_type"=>"tls_read", "event_id"=>1407374883553288, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>39177, "ret"=>-1}]
[27] ebpf.0: [[1782365734.486839578, {}], {"event_type"=>"tls_read", "event_id"=>1407374883553289, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>6203, "ret"=>-1}]
[28] ebpf.0: [[1782365734.487054110, {}], {"event_type"=>"tls_read", "event_id"=>562949953421325, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>41550, "ret"=>1369}]
[29] ebpf.0: [[1782365734.487254716, {}], {"event_type"=>"tls_read", "event_id"=>562949953421326, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>9768, "ret"=>1369}]
[30] ebpf.0: [[1782365734.487489519, {}], {"event_type"=>"tls_read", "event_id"=>562949953421327, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>7239, "ret"=>1369}]
[31] ebpf.0: [[1782365734.487774716, {}], {"event_type"=>"tls_read", "event_id"=>562949953421328, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>7344, "ret"=>1369}]
[32] ebpf.0: [[1782365734.487992045, {}], {"event_type"=>"tls_read", "event_id"=>562949953421329, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>9558, "ret"=>-1}]
[33] ebpf.0: [[1782365734.488233285, {}], {"event_type"=>"tls_read", "event_id"=>562949953421330, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>3760, "ret"=>-1}]
[34] ebpf.0: [[1782365734.488649408, {}], {"event_type"=>"tls_read", "event_id"=>562949953421331, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>30460, "ret"=>1369}]
[35] ebpf.0: [[1782365734.488879253, {}], {"event_type"=>"tls_read", "event_id"=>562949953421332, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>10063, "ret"=>1369}]
[36] ebpf.0: [[1782365734.489095888, {}], {"event_type"=>"tls_read", "event_id"=>562949953421333, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>8392, "ret"=>1369}]
[37] ebpf.0: [[1782365734.489283707, {}], {"event_type"=>"tls_read", "event_id"=>562949953421334, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>8195, "ret"=>1369}]
[38] ebpf.0: [[1782365734.489465033, {}], {"event_type"=>"tls_read", "event_id"=>562949953421335, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>9041, "ret"=>1369}]
[39] ebpf.0: [[1782365734.489625034, {}], {"event_type"=>"tls_read", "event_id"=>562949953421336, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>8027, "ret"=>1369}]
[40] ebpf.0: [[1782365734.489787200, {}], {"event_type"=>"tls_read", "event_id"=>562949953421337, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>7975, "ret"=>1369}]
[41] ebpf.0: [[1782365734.489975962, {}], {"event_type"=>"tls_read", "event_id"=>562949953421338, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>7806, "ret"=>1369}]
[42] ebpf.0: [[1782365734.490146159, {}], {"event_type"=>"tls_read", "event_id"=>562949953421339, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>7839, "ret"=>1369}]
[43] ebpf.0: [[1782365734.490351961, {}], {"event_type"=>"tls_read", "event_id"=>562949953421340, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>7717, "ret"=>1369}]
[44] ebpf.0: [[1782365734.490535322, {}], {"event_type"=>"tls_read", "event_id"=>562949953421341, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>8009, "ret"=>1369}]
[45] ebpf.0: [[1782365734.490716568, {}], {"event_type"=>"tls_read", "event_id"=>562949953421342, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>8040, "ret"=>1369}]
[46] ebpf.0: [[1782365734.490920419, {}], {"event_type"=>"tls_read", "event_id"=>562949953421343, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>9330, "ret"=>-1}]
[47] ebpf.0: [[1782365734.491095188, {}], {"event_type"=>"tls_read", "event_id"=>1407374883553290, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>20274, "ret"=>-1}]
[48] ebpf.0: [[1782365734.491269282, {}], {"event_type"=>"tls_read", "event_id"=>562949953421344, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>63624, "ret"=>1369}]
[49] ebpf.0: [[1782365734.491454490, {}], {"event_type"=>"tls_read", "event_id"=>562949953421345, "pid"=>275499, "tid"=>275499, "comm"=>"curl", "trace"=>"openssl_tls_read", "ssl_ptr"=>98811799495600, "latency_ns"=>15188, "ret"=>4229}]
[2026/06/25 14:35:35.318] [ warn] [engine] service will shutdown in max 5 seconds
[2026/06/25 14:35:35.325] [debug] [engine] task 0 already scheduled to run, not re-scheduling it.
[2026/06/25 14:35:35.326] [ info] [engine] pausing all inputs..
[2026/06/25 14:35:35.327] [ info] [input] pausing ebpf.0
[2026/06/25 14:35:35.329] [debug] [input:ebpf:ebpf.0] collector paused
[2026/06/25 14:35:35.325] [debug] [out flush] cb_destroy coro_id=2
[2026/06/25 14:35:35.331] [debug] [task] destroy task=0x8671ec0 (task_id=0)
[2026/06/25 14:35:35.473] [ info] [engine] service has stopped (0 pending tasks)
[2026/06/25 14:35:35.473] [ info] [input] pausing ebpf.0
[2026/06/25 14:35:35.474] [debug] [input:ebpf:ebpf.0] collector paused
[2026/06/25 14:35:35.476] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2026/06/25 14:35:35.484] [ info] [output:stdout:stdout.0] thread worker #0 stopped
[2026/06/25 14:35:36.119] [ info] [input:ebpf:ebpf.0] eBPF input plugin exited
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found
==275420== 
==275420== HEAP SUMMARY:
==275420==     in use at exit: 0 bytes in 0 blocks
==275420==   total heap usage: 4,802 allocs, 4,802 frees, 21,056,824 bytes allocated
==275420== 
==275420== All heap blocks were freed -- no leaks are possible
==275420== 

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • New Features

    • Added event IDs to trace events across bind, DNS, exec, malloc/free, OpenSSL, scheduling, signal, TCP, and VFS paths.
    • Event payloads now include the new identifier in the common event data returned to consumers.
  • Bug Fixes

    • Improved trace event consistency by ensuring identifiers are generated before event submission in multiple capture flows.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new eBPF header defining a per-CPU sequence counter map and generate_event_id helper that combines CPU ID with a monotonic counter. Adds an event_id field to event_common, encodes it in encode_common_fields(), and calls generate_event_id across bind, dns, exec, malloc, openssl, sched, signal, tcp, and vfs trace programs.

Changes

Event ID generation across eBPF trace programs

Layer / File(s) Summary
Event ID generator, struct field, and encoder
plugins/in_ebpf/traces/includes/common/event_id.bpf.h, plugins/in_ebpf/traces/includes/common/events.h, plugins/in_ebpf/traces/includes/common/encoder.h
Adds seq_counter per-CPU map and generate_event_id helper combining CPU ID and counter; adds event_id field to event_common struct; encodes event_id as uint64 in encode_common_fields().
bind trace wiring
plugins/in_ebpf/traces/bind/bpf.c
Includes new header and calls generate_event_id in handle_bind_exit before submission.
dns trace wiring
plugins/in_ebpf/traces/dns/bpf.c
Includes new header and calls generate_event_id in fill_common.
exec trace wiring
plugins/in_ebpf/traces/exec/bpf.c
Includes new header and calls generate_event_id in submit_exec_event().
malloc/free trace wiring
plugins/in_ebpf/traces/malloc/bpf.c.in
Includes new header and calls generate_event_id in both allocation-exit and free paths.
openssl trace wiring
plugins/in_ebpf/traces/openssl/bpf.c.in
Includes new header and calls generate_event_id in fill_common.
sched trace wiring
plugins/in_ebpf/traces/sched/bpf.c
Includes new header and calls generate_event_id when creating EVENT_TYPE_SCHED events.
signal trace wiring
plugins/in_ebpf/traces/signal/bpf.c
Includes new header and calls generate_event_id in handle_signal_exit and ig_sig_generate.
tcp trace wiring
plugins/in_ebpf/traces/tcp/bpf.c
Includes new header and calls generate_event_id in fill_common.
vfs trace wiring
plugins/in_ebpf/traces/vfs/bpf.c
Includes new header and calls generate_event_id in trace_vfs_openat_exit.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • fluent/fluent-bit#11568: Both touch the VFS eBPF trace stack; this PR adds event_id generation to the VFS trace code introduced there.
  • fluent/fluent-bit#11714: This PR's event_id addition directly overlaps the exec trace emission path introduced there.
  • fluent/fluent-bit#11793: This PR modifies the same OpenSSL fill_common event-emission path introduced there.

Suggested reviewers: edsiper

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the core change: adding mostly monotonic event IDs to in_ebpf traces for better traceability.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cosmo0920-generate-mostly-monotonic-event-id-traceability

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cosmo0920 cosmo0920 changed the title in_ebpf: Generate mostly monotonic event id traceability in_ebpf: Generate mostly monotonic event id for incerasing traceability Jun 25, 2026
@cosmo0920 cosmo0920 changed the title in_ebpf: Generate mostly monotonic event id for incerasing traceability in_ebpf: Generate mostly monotonic event id for increasing traceability Jun 25, 2026
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
@cosmo0920
cosmo0920 force-pushed the cosmo0920-generate-mostly-monotonic-event-id-traceability branch from dc22be7 to e99db64 Compare July 3, 2026 09:10
@cosmo0920
cosmo0920 marked this pull request as ready for review July 3, 2026 09:19
@cosmo0920
cosmo0920 requested a review from edsiper as a code owner July 3, 2026 09:19
@cosmo0920 cosmo0920 added this to the Fluent Bit v5.0.9 milestone Jul 3, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e99db64db4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +7 to +11
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__type(key, __u32);
__type(value, __u64);
__uint(max_entries, 1);
} seq_counter SEC(".maps");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Share event counters across trace objects

When the Trace option is set multiple times (plugins/in_ebpf/in_ebpf.c:263-265), each selected trace is compiled and loaded as its own BPF object, so defining seq_counter in this included header creates a separate counter map for every trace. That means the first event on CPU N from exec, tcp, dns, etc. all receive the same event_id (N << 48), so IDs collide in the combined event stream and cannot reliably trace event order across enabled traces; use a shared/pinned counter or include a trace/object component in the ID.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
plugins/in_ebpf/traces/includes/common/event_id.bpf.h (2)

13-25: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Counter isn't masked before packing into the low 48 bits.

*counter is a free-running __u64 that is OR'd directly with cpu_id << 48 without masking to 48 bits first. If the per-CPU counter ever exceeds 2^48-1, it will bleed into the CPU-ID bits and corrupt/collide generated IDs. Given the astronomical threshold (~2.8×10^14 events per CPU), this is a very low-probability, long-horizon issue, but masking is trivial to add defensively.

🔧 Proposed fix
     if (counter) {
         /* ID is CPU shifted left by 48 bits, OR'd with per-CPU counter */
-        *event_id = ((__u64)bpf_get_smp_processor_id() << 48) | (*counter);
+        *event_id = ((__u64)bpf_get_smp_processor_id() << 48) | (*counter & 0xFFFFFFFFFFFFULL);
         (*counter)++;
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugins/in_ebpf/traces/includes/common/event_id.bpf.h` around lines 13 - 25,
The event ID packing in generate_event_id is combining the CPU ID and the
per-CPU sequence counter without constraining the counter to the low 48 bits.
Update the generate_event_id logic in event_id.bpf.h so the value read from
seq_counter is masked before OR-ing it with bpf_get_smp_processor_id(), keeping
the CPU-ID bits in the upper 16 bits and preventing counter overflow from
corrupting IDs.

22-24: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Fallback event_id of 0 can collide with a legitimately generated ID.

When bpf_map_lookup_elem fails, event_id is set to 0, which is indistinguishable from the actual first generated ID on CPU 0 (0 << 48 | 0). Consider using a distinct sentinel (e.g., all-ones) if consumers need to detect the lookup-failure case.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugins/in_ebpf/traces/includes/common/event_id.bpf.h` around lines 22 - 24,
The fallback path in event_id handling uses a zero value that can be mistaken
for a real generated ID; update the lookup-failure branch in event_id.bpf.h so
the event_id set by the helper used for bpf_map_lookup_elem failures is a
distinct sentinel instead of 0, and make sure any code that reads event_id can
recognize that failure state consistently. Use the existing event_id
generation/lookup logic in the event_id helper to keep the change localized and
avoid colliding with valid IDs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@plugins/in_ebpf/traces/includes/common/event_id.bpf.h`:
- Around line 13-25: The event ID packing in generate_event_id is combining the
CPU ID and the per-CPU sequence counter without constraining the counter to the
low 48 bits. Update the generate_event_id logic in event_id.bpf.h so the value
read from seq_counter is masked before OR-ing it with
bpf_get_smp_processor_id(), keeping the CPU-ID bits in the upper 16 bits and
preventing counter overflow from corrupting IDs.
- Around line 22-24: The fallback path in event_id handling uses a zero value
that can be mistaken for a real generated ID; update the lookup-failure branch
in event_id.bpf.h so the event_id set by the helper used for bpf_map_lookup_elem
failures is a distinct sentinel instead of 0, and make sure any code that reads
event_id can recognize that failure state consistently. Use the existing
event_id generation/lookup logic in the event_id helper to keep the change
localized and avoid colliding with valid IDs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d7da9461-435d-4602-a859-efef2072f66b

📥 Commits

Reviewing files that changed from the base of the PR and between b0fdb50 and e99db64.

📒 Files selected for processing (12)
  • plugins/in_ebpf/traces/bind/bpf.c
  • plugins/in_ebpf/traces/dns/bpf.c
  • plugins/in_ebpf/traces/exec/bpf.c
  • plugins/in_ebpf/traces/includes/common/encoder.h
  • plugins/in_ebpf/traces/includes/common/event_id.bpf.h
  • plugins/in_ebpf/traces/includes/common/events.h
  • plugins/in_ebpf/traces/malloc/bpf.c.in
  • plugins/in_ebpf/traces/openssl/bpf.c.in
  • plugins/in_ebpf/traces/sched/bpf.c
  • plugins/in_ebpf/traces/signal/bpf.c
  • plugins/in_ebpf/traces/tcp/bpf.c
  • plugins/in_ebpf/traces/vfs/bpf.c

@edsiper
edsiper merged commit b1e78c6 into master Jul 3, 2026
87 of 90 checks passed
@edsiper
edsiper deleted the cosmo0920-generate-mostly-monotonic-event-id-traceability branch July 3, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants