out_file formatter with time_type float drops the fraction of a time under 0.1 second
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 86/100
調査の方向性
lib/fluent/time.rb の NumericTimeFormatter#format_float と、test/test_time_formatter.rb にある既存のフォーマッターのケースを確認してください。ナノ秒が9桁未満の小数時刻(1700000000.012345678 など)のテストを追加し、出力に小数部の9桁すべてが保持されることを確認してください。Issueには影響を受けるメソッドとテストファイルが記載されており、報告された期待値によって修正完了の条件が定まります。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
With time_type float, the out_file formatter drops the fractional part of a time when it is less than 0.1 second. For example, 1700000000.012345678 is written as 1700000000.0, and 1700000000.000005000 as 1700000000.00000.
NumericTimeFormatter#format_float should pad the nanoseconds with leading zeros to 9 digits. Instead, it replaces them with the zeros (time.rb L460):
nsec_s = time.nsec.to_s
nsec_s = '0' * (9 - nsec_s.size) if nsec_s.size < 9
This affects out_file and any output that uses <format> @type out_file with time_type float. time_type float in <inject> uses a different conversion and is not affected. The existing test only uses .123456789 (test_time_formatter.rb L356-L362).
To Reproduce
- Create the input file below.
- Run Fluentd with the configuration below.
{"time":"1700000000.123456789","case":"control"}
{"time":"1700000000.012345678","case":"under 0.1 s"}
{"time":"1700000000.000005000","case":"5 microseconds"}
{"time":"1700000000.000000000","case":"zero"}
Output of the out_file formatter on master (31157cba) and v1.20.1:
1700000000.123456789 test {"time":"1700000000.123456789","case":"control"}
1700000000.0 test {"time":"1700000000.012345678","case":"under 0.1 s"}
1700000000.00000 test {"time":"1700000000.000005000","case":"5 microseconds"}
1700000000.00000000 test {"time":"1700000000.000000000","case":"zero"}
With the same configuration, <inject> gives 1700000000.012345 and 1700000000.000005.
Expected behavior
The fractional part is padded to 9 digits:
1700000000.123456789
1700000000.012345678
1700000000.000005000
1700000000.000000000
Your Environment
- Fluentd version: master (31157cba) and v1.20.1
- Package version: -
- Operating system: Ubuntu 24.04.5 LTS
- Kernel version: 6.8.0-151-generic
- Ruby: 4.0.10
Your Configuration
<source>
@type tail
tag test
path /path/to/input.log
pos_file /path/to/input.pos
read_from_head true
<parse>
@type json
time_key time
time_type string
time_format %s.%N
keep_time_key true
</parse>
</source>
<match test>
@type copy
<store>
@type stdout
<format>
@type out_file
time_type float
</format>
</store>
<store>
@type stdout
<inject>
time_key float_time
time_type float
</inject>
</store>
</match>
Your Error Log
No error is logged.
Additional context
A possible fix is nsec_s = nsec_s.rjust(9, '0') and a test with a time whose nanoseconds have fewer than 9 digits. The code has been like this since 3a8038d9 (2016).
- 主要言語
- Ruby
- スター
- 13.6k
- フォーク
- 1.4k
- 平均マージ
- 1日 10時間
- マージ済み PR(30日)
- 79
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fluent/fluentd のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
A <secondary> output cannot roll back a chunk: rollback_write always raises ArgumentError対応中かも @lbarrosby が 18 日前に担当しました。 オープンbug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
parser_syslog: message_format auto parses RFC 3164 messages with an RFC 3339 timestamp as RFC 5424対応中かも @rafayqayyum が 17 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
fluent/fluentd#5631 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
parser_syslog: the regexp engine for RFC 5424 can match the header later in the message and corrupt the record対応中かも @rafayqayyum が 17 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
fluent/fluentd#5630 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
in_tail with the multiline parser stops reading a file at a non-ASCII line when format_firstline is a UTF-8 regexp対応中かも @RjyavardhanSingh が今日担当しました。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
fluent/fluentd#5714 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
🐛 bug 👩💻 équipe CE
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
betagouv/conseillers-entreprises#4835 ·
メンテナーはふだん 1 日以内に返信
-
Action: a `test` glob with a gem older than 1.9.0 fails with `no such file` and no version hintオープンbacklog enhancement github_actions priority: low risk: low
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
davidteren/mutineer#646 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
metanorma/isodoc#965 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
verified
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
zammad/zammad#6636 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信