Skip to content

Report Fluentd drops on a configurable interval with stream and queue state - #8904

Draft
cjen1-msft wants to merge 8 commits into
microsoft:mainfrom
cjen1-msft:cjen1-msft-cautious-invention
Draft

cjen1-msft wants to merge 8 commits into
microsoft:mainfrom
cjen1-msft:cjen1-msft-cautious-invention

Conversation

@cjen1-msft

@cjen1-msft cjen1-msft commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Replace count-based Fluentd drop logging (once every 65536 dropped records) with per-collector time-based structured drop reports configured by observability.fluentd[].drop_report_interval (default "1min").

Count-based drop logging is noisy during sustained outages, silent during slow trickles, and did not identify which collector stream was dropping or its queue pressure.
Each collector now logs at most one failure-level key=value report per interval from the consumer thread (endpoint, tags, state, queued_records, queued_bytes, dropped, window), keeping producer threads off the clock and free of extra synchronization.
Drop-report log lines are themselves exported through FluentdLogger when a collector selects ccf.log, so a stalled collector can drop its own report (at most one self-inflicted drop per interval).

Alternatives

  • Read steady_clock::now() on producer drop paths: rejected to avoid clock reads on the producer hot path; checking on the consumer thread skips the clock entirely when no new drops occurred.
  • Sample SPSCQueue::size() separately from an atomic pushed_bytes counter: rejected because a concurrent push between the two reads can report an impossible combination (such as 0 records and 60 bytes); SPSCQueue::usage() computes both from one published tail snapshot on the consumer thread without touching the producer hot path.

Safety and compatibility

  • observability.fluentd[].drop_report_interval is optional (default "1min"). Zero, compound (e.g. "1m30s"), and fractional (e.g. "1.5s") durations are rejected for drop_report_interval at --check and startup.
  • Periodic drop log lines change format from Dropped N trace events (observed M) to Fluentd exporter dropped records: endpoint=... tags=... state=... queued_records=.../... queued_bytes=.../... dropped=... window=....
Log format example and operational details

Example drop report:

Fluentd exporter dropped records: endpoint=127.0.0.1:24224 tags=["ccf.log","ccf.cft"] state=connected queued_records=2/12 queued_bytes=120/800 dropped=1 window=60.04s
  • endpoint uses ccf::make_net_address (IPv6 literals are bracketed, e.g. [::1]:24224).
  • tags is a compact JSON-escaped array of the collector's tag-prefix-allow-list.
  • queued_records and queued_bytes sum per-queue snapshots (not one global lock across queues) against total hard capacity across all provisioned queues for that collector (one per producer thread plus the shared unbound queue), excluding any single in-flight record already popped by the consumer.
  • dropped counts records dropped in the elapsed window (formatted as seconds to two decimal places, e.g. 60.04s).
  • Shutdown does not force a final interval report, though an interval report that falls due during the shutdown drain can still be logged before each collector's shutdown total; no report is emitted after a transport finishes.

cjen1-msft and others added 5 commits December 4, 2026 13:37
Replace count-based drop reporting (every 65536 drops) with a time-based
report per sink, configured by observability.fluentd[].drop_report_interval
(default 1min). Producers still only increment an atomic counter; the
consumer reads the clock only when there are unreported drops.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Format periodic Fluentd drop reports as structured key=value fields:
endpoint, tags, state, queued_records, queued_bytes, dropped, and window.

Expose SPSCQueue::queued_bytes() using an atomic pushed_bytes counter
ordered before tail release so the consumer reads queued byte usage
without extra producer synchronization. Add integration tests covering
disconnected, quiet-interval, connected, and byte-limit drop reports,
plus config validation in cft_trace_e2e.py.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 807be547a28b492dadfae87eaa6d38e4
…shutdown guard, and strict TimeString parsing

- Replace SPSCQueue::queued_bytes() with consumer-only SPSCQueue::usage()
  that reads records and bytes from a single published tail snapshot
  (and restores non-atomic pushed_bytes on the producer hot path).
- Format endpoint via ccf::make_net_address() for bracketed IPv6 literals,
  encode tags as a compact escaped JSON array, and retain microsecond
  precision in DropReporter::format_duration().
- Validate Transport endpoints before constructing DropReporter (and clamp
  both ends in DropReporter); reject trailing garbage, multiplier overflow,
  and > INT64_MAX microseconds in unit_strings.h.
- Skip report_drops() after finish_if_done() marks a transport finished,
  clarify shutdown drain behavior in configuration.rst, and remove the test
  logger registry mutation and multi-drop wakeup race.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 807be547a28b492dadfae87eaa6d38e4
…yntax in FluentdSink::validate

Restore permissive prefix parsing in UnitStringConverter::convert() so
historical SizeString values stored in public:ccf.gov.nodes.info (e.g.
"1.5MB") continue to deserialize during recovery and ledger replay.
Keep checked integer multipliers in convert_time_string() and the
microseconds::max() bound in TimeString to reject only UB/wrapping
overflows. Enforce strict full-string numeric parsing specifically on
FluentdConfig::drop_report_interval in FluentdSink::validate().

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 807be547a28b492dadfae87eaa6d38e4
…ominators in docs

Document the accepted duration units (us, ms, s, min, h; bare numbers as
microseconds), exact key=value log message shape, aggregate provisioned-queue
denominators, and per-collector shutdown total in configuration.rst,
host_config.json, and the change note.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 807be547a28b492dadfae87eaa6d38e4
@cjen1-msft
cjen1-msft force-pushed the cjen1-msft-cautious-invention branch from fde6f83 to a212dbd Compare December 4, 2026 13:39
cjen1-msft and others added 3 commits December 4, 2026 13:45
Keep pre-existing TimeString overflow handling out of this PR (to be
addressed separately if needed).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 807be547a28b492dadfae87eaa6d38e4
Link to observability_export from host_config.json instead of
duplicating report details, and tighten the configuration.rst paragraph.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 807be547a28b492dadfae87eaa6d38e4
Remove hand-rolled format_tags and format_duration helpers: serialise
tags via nlohmann::json::dump with UTF-8 replacement and format window
as seconds to two decimal places ({:.2f}s).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 807be547a28b492dadfae87eaa6d38e4

This branch has not been deployed

No deployments
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.

1 participant