out_file formatter with time_type float drops the fraction of a time under 0.1 second
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 86/100
Hướng nghiên cứu
Đọc NumericTimeFormatter#format_float trong lib/fluent/time.rb và các trường hợp định dạng hiện có trong test/test_time_formatter.rb. Bổ sung kiểm thử cho các thời điểm dạng phân số có phần nano giây ít hơn 9 chữ số, chẳng hạn 1700000000.012345678, và xác minh đầu ra giữ đủ cả 9 chữ số phần lẻ. Issue nêu tên phương thức và tệp kiểm thử bị ảnh hưởng, còn các giá trị mong đợi được báo cáo xác định khi nào bản sửa lỗi hoàn tất.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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).
- Ngôn ngữ chính
- Ruby
- Star
- 13.6k
- Fork
- 1.4k
- Merge trung bình
- 1 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 79
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của fluent/fluentd
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
A <secondary> output cannot roll back a chunk: rollback_write always raises ArgumentErrorCó thể đã có người làm @lbarrosby đã nhận 18 ngày trước. Đang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
parser_syslog: message_format auto parses RFC 3164 messages with an RFC 3339 timestamp as RFC 5424Có thể đã có người làm @rafayqayyum đã nhận 17 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
fluent/fluentd#5631 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
parser_syslog: the regexp engine for RFC 5424 can match the header later in the message and corrupt the recordCó thể đã có người làm @rafayqayyum đã nhận 17 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
fluent/fluentd#5630 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
in_tail with the multiline parser stops reading a file at a non-ASCII line when format_firstline is a UTF-8 regexpCó thể đã có người làm @RjyavardhanSingh đã nhận hôm nay. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
fluent/fluentd#5714 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của fluent/fluentd
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
🐛 bug 👩💻 équipe CE
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
betagouv/conseillers-entreprises#4835 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Action: a `test` glob with a gem older than 1.9.0 fails with `no such file` and no version hintĐang mởbacklog enhancement github_actions priority: low risk: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
davidteren/mutineer#646 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
metanorma/isodoc#965 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
verified
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
zammad/zammad#6636 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày