Skip to content

openssl: correct hex event timestamps - #1108

Merged
cfc4n merged 2 commits into
gojue:masterfrom
yunwei37:bugfix/openssl-hex-timestamp
Dec 2, 2026
Merged

cfc4n merged 2 commits into
gojue:masterfrom
yunwei37:bugfix/openssl-hex-timestamp

Conversation

@yunwei37

@yunwei37 yunwei37 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Problem

OpenSSL hook-text events carry a monotonic nanosecond timestamp. StringHex passes that value to time.Unix as seconds, so --hex prints dates such as [5780590-06-11 14:17:34.000]. Ordinary text already converts the same field to wall time correctly.

Change

Use the existing getClockOffset conversion in StringHex, matching String. Production scope is +5/-1 in one formatter, with a regression and a focused benchmark. The wire timestamp and event payload stay intact.

Validation

  • The new regression supplies a real CLOCK_MONOTONIC timestamp and checks the displayed wall time. On master 9c00018, it fails while parsing the resulting million-year date. It passes with the fix.
  • go test -race -count=1 ./internal/probe/openssl passes. The same package also passes with ebpfassets,dynamic and the existing core-only assets. The initial production-tag attempt lacked pcap.h; supplying the already-available libpcap headers and library completed that check.
  • The full go test -race -count=1 ./... run passes outside internal/probe/mysql. That package requires /usr/sbin/mysqld, which is absent; its configuration and initialization tests fail on that prerequisite.
  • Touched files are formatted. Production-tag golangci-lint was unavailable. This validates formatting of decoded events; it does not add a new live-capture result.

Performance

Same Linux x86-64 machine, Intel Core Ultra 9 285K, Go 1.26, CPU 2 pinned, five 200 ms benchmark rounds per revision, the same 103-byte event and benchmark source:

StringHex master change
Median 6.565 us/op 6.709 us/op
Range 6.132–6.679 us/op 6.655–6.859 us/op
Allocations 20/op 20/op
Allocated bytes 2244/op 2236/op

The measured median increases 2.19%. The formatter adds two clock reads for the existing offset calculation; a correctly sized date also uses fewer bytes. This work executes in the collector's hex-output formatting path. Probe callbacks, BPF helpers, maps and perf transport receive no changes.

Related investigation: eunomia-bpf/bpftime#1083.

Treat the BPF monotonic timestamp as nanoseconds and apply the existing
clock offset, matching the ordinary text formatter.
Keep external and local imports in the configured order.
Copilot AI balanced review requested due to automatic review settings December 1, 2026 18:53
@dosubot

dosubot Bot commented Dec 1, 2026

Copy link
Copy Markdown

📄 Knowledge review

✏️ Suggested updates

1 page suggestion needs review.

Page Library Status
CHANGELOG /ecapture/blob/master/CHANGELOG.md ecapture ⬆️ Pushed to this PR

Leave Feedback Ask Dosu about ecapture Add Dosu to your team

Copilot AI 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.

🟢 Approval recommended

No active review issues were identified for the OpenSSL hex-output timestamp correction.

No open issues 🎉

What changed in this PR

Corrects OpenSSL hook-text timestamps in hex output by converting monotonic nanoseconds to wall time, matching ordinary text output. Event payloads and wire timestamps remain unchanged.

Changes:

  • Apply the existing clock-offset conversion in StringHex.
  • Add a regression test using a real monotonic timestamp.
  • Add a focused hex-formatting benchmark with allocation reporting.
File Description
internal/​probe/​openssl/​event.go Convert hex-output timestamps to wall time.
internal/​probe/​openssl/​event_test.go Verify that hex output displays the current wall time.
internal/​probe/​openssl/​event_benchmark_test.go Benchmark hex formatting and allocations.

Review effort: Balanced

@cfc4n cfc4n left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM , Thanks.

@cfc4n
cfc4n merged commit f2e2a69 into gojue:master Dec 2, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants