fluentd 1.2.3 → 1.2.4.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 592df476adfeb30ef3a08865d03af3eeb7f60e1d27684f22dc3505b8dc7bcab4
4
- data.tar.gz: acc575bbf086686addf560a7a65e084221a609ce5eff6385b88a9aea65c4aca4
3
+ metadata.gz: 14bc521f8482997b686c3c465c84dd7a3ef10ac52e208883c068394384163f66
4
+ data.tar.gz: aefedb8e2a5917a6bc37c56ed4d9c33e7ba76a0883d4a877e932cc681a610d82
5
5
  SHA512:
6
- metadata.gz: c1f5ebc8c426c80c7b6501afba2ac9534aeceafe21945e58fd0530dbde099d8cdbd0a6c9533c7500d838db09f66dfbefd4fbed5cb6304ab71fe473ab0a63cd5c
7
- data.tar.gz: 6eef15e5140fc4547c59215ae01cd9eb661429bb7eb36067e6834f877c916bf78507345091002116129435e548525654e289db36c3a786f7aebc5780835458ef
6
+ metadata.gz: e767a398beb8858af702625ae9d900aac20eea0b8cf46efd126cd9281b1acb0a93bc66d5485fef0276d0ecf7e573ec092cad96d6f9146960a9ac6d5c79215604
7
+ data.tar.gz: dea6a30c9827ece7cb88801eebff7bd3425807e5d129400284d36f0059add10beb54390890e76c8b9de3eb9ec82aeab32322fd4aa41e36bb3487c333bee41a64
@@ -304,6 +304,10 @@ module Fluent
304
304
  raise Fluent::ConfigError, "<buffer ...> argument includes 'time', but timekey is not configured" unless @buffer_config.timekey
305
305
  Fluent::Timezone.validate!(@buffer_config.timekey_zone)
306
306
  @timekey_zone = @buffer_config.timekey_use_utc ? '+0000' : @buffer_config.timekey_zone
307
+ @timekey = @buffer_config.timekey
308
+ @timekey_use_utc = @buffer_config.timekey_use_utc
309
+ @offset = Fluent::Timezone.utc_offset(@timekey_zone)
310
+ @calculate_offset = @offset.respond_to?(:call) ? @offset : nil
307
311
  @output_time_formatter_cache = {}
308
312
  end
309
313
 
@@ -803,20 +807,17 @@ module Fluent
803
807
  if !@chunk_key_time && !@chunk_key_tag
804
808
  @buffer.metadata()
805
809
  elsif @chunk_key_time && @chunk_key_tag
806
- time_int = time.to_i
807
- timekey = (time_int - (time_int % @buffer_config.timekey)).to_i
810
+ timekey = calculate_timekey(time)
808
811
  @buffer.metadata(timekey: timekey, tag: tag)
809
812
  elsif @chunk_key_time
810
- time_int = time.to_i
811
- timekey = (time_int - (time_int % @buffer_config.timekey)).to_i
813
+ timekey = calculate_timekey(time)
812
814
  @buffer.metadata(timekey: timekey)
813
815
  else
814
816
  @buffer.metadata(tag: tag)
815
817
  end
816
818
  else
817
819
  timekey = if @chunk_key_time
818
- time_int = time.to_i
819
- (time_int - (time_int % @buffer_config.timekey)).to_i
820
+ calculate_timekey(time)
820
821
  else
821
822
  nil
822
823
  end
@@ -825,6 +826,16 @@ module Fluent
825
826
  end
826
827
  end
827
828
 
829
+ def calculate_timekey(time)
830
+ time_int = time.to_i
831
+ if @timekey_use_utc
832
+ (time_int - (time_int % @timekey)).to_i
833
+ else
834
+ offset = @calculate_offset ? @calculate_offset.call(time) : @offset
835
+ (time_int - ((time_int + offset)% @timekey)).to_i
836
+ end
837
+ end
838
+
828
839
  def chunk_for_test(tag, time, record)
829
840
  require 'fluent/plugin/buffer/memory_chunk'
830
841
 
@@ -318,7 +318,7 @@ module Fluent
318
318
  log.warn "send an error event stream to @ERROR:", error_info
319
319
  @error_collector.emit_stream(tag, es)
320
320
  else
321
- now = Time.now
321
+ now = Time.now.to_i
322
322
  if @suppress_emit_error_log_interval.zero? || now > @next_emit_error_log_time
323
323
  log.warn "emit transaction failed:", error_info
324
324
  log.warn_backtrace
@@ -347,7 +347,7 @@ module Fluent
347
347
  end
348
348
 
349
349
  def handle_emits_error(tag, es, e)
350
- now = EventTime.now
350
+ now = EventTime.now.to_i
351
351
  if @suppress_emit_error_log_interval.zero? || now > @next_emit_error_log_time
352
352
  log.warn "emit transaction failed in @ERROR:", error: e, tag: tag
353
353
  log.warn_backtrace
@@ -139,5 +139,19 @@ module Fluent
139
139
 
140
140
  return nil
141
141
  end
142
+
143
+ def self.utc_offset(timezone)
144
+ return 0 if timezone.nil?
145
+
146
+ case timezone
147
+ when NUMERIC_PATTERN
148
+ Time.zone_offset(timezone)
149
+ when NAME_PATTERN
150
+ tz = TZInfo::Timezone.get(timezone)
151
+ ->(time) {
152
+ tz.period_for_utc(time).utc_total_offset
153
+ }
154
+ end
155
+ end
142
156
  end
143
157
  end
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Fluent
18
18
 
19
- VERSION = '1.2.3'
19
+ VERSION = '1.2.4.rc1'
20
20
 
21
21
  end
@@ -561,6 +561,79 @@ class FileOutputTest < Test::Unit::TestCase
561
561
  check_gzipped_result(path, formatted_lines * 3)
562
562
  end
563
563
 
564
+ test 'append when JST' do
565
+ with_timezone(Fluent.windows? ? "JST-9" : "Asia/Tokyo") do
566
+ time = event_time("2011-01-02 03:14:15+09:00")
567
+ formatted_lines = %[2011-01-02T03:14:15+09:00\ttest\t{"a":1}\n] + %[2011-01-02T03:14:15+09:00\ttest\t{"a":2}\n]
568
+
569
+ write_once = ->(){
570
+ d = create_driver %[
571
+ path #{TMP_DIR}/out_file_test
572
+ compress gz
573
+ append true
574
+ <buffer>
575
+ timekey_use_utc false
576
+ timekey_zone Asia/Tokyo
577
+ </buffer>
578
+ ]
579
+ d.run(default_tag: 'test'){
580
+ d.feed(time, {"a"=>1})
581
+ d.feed(time, {"a"=>2})
582
+ }
583
+ d.instance.last_written_path
584
+ }
585
+
586
+ path = write_once.call
587
+ assert_equal "#{TMP_DIR}/out_file_test.20110102.log.gz", path
588
+ check_gzipped_result(path, formatted_lines)
589
+
590
+ path = write_once.call
591
+ assert_equal "#{TMP_DIR}/out_file_test.20110102.log.gz", path
592
+ check_gzipped_result(path, formatted_lines * 2)
593
+
594
+ path = write_once.call
595
+ assert_equal "#{TMP_DIR}/out_file_test.20110102.log.gz", path
596
+ check_gzipped_result(path, formatted_lines * 3)
597
+ end
598
+ end
599
+
600
+ test 'append when UTC-02 but timekey_zone is +0900' do
601
+ with_timezone("UTC-02") do # +0200
602
+ time = event_time("2011-01-02 17:14:15+02:00")
603
+ formatted_lines = %[2011-01-02T17:14:15+02:00\ttest\t{"a":1}\n] + %[2011-01-02T17:14:15+02:00\ttest\t{"a":2}\n]
604
+
605
+ write_once = ->(){
606
+ d = create_driver %[
607
+ path #{TMP_DIR}/out_file_test
608
+ compress gz
609
+ append true
610
+ <buffer>
611
+ timekey_use_utc false
612
+ timekey_zone +0900
613
+ </buffer>
614
+ ]
615
+ d.run(default_tag: 'test'){
616
+ d.feed(time, {"a"=>1})
617
+ d.feed(time, {"a"=>2})
618
+ }
619
+ d.instance.last_written_path
620
+ }
621
+
622
+ path = write_once.call
623
+ # Rotated at 2011-01-02 17:00:00+02:00
624
+ assert_equal "#{TMP_DIR}/out_file_test.20110103.log.gz", path
625
+ check_gzipped_result(path, formatted_lines)
626
+
627
+ path = write_once.call
628
+ assert_equal "#{TMP_DIR}/out_file_test.20110103.log.gz", path
629
+ check_gzipped_result(path, formatted_lines * 2)
630
+
631
+ path = write_once.call
632
+ assert_equal "#{TMP_DIR}/out_file_test.20110103.log.gz", path
633
+ check_gzipped_result(path, formatted_lines * 3)
634
+ end
635
+ end
636
+
564
637
  test '${chunk_id}' do
565
638
  time = event_time("2011-01-02 13:14:15 UTC")
566
639
  formatted_lines = %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n]
@@ -1,6 +1,7 @@
1
1
  require_relative 'helper'
2
2
  require 'fluent/event_router'
3
3
  require 'fluent/system_config'
4
+ require 'timecop'
4
5
  require_relative 'test_plugin_classes'
5
6
 
6
7
  class RootAgentTest < ::Test::Unit::TestCase
@@ -609,6 +610,38 @@ EOC
609
610
  end
610
611
  end
611
612
 
613
+ sub_test_case 'configure emit_error_interval' do
614
+ setup do
615
+ system_config = SystemConfig.new
616
+ system_config.emit_error_log_interval = 30
617
+ @ra = RootAgent.new(log: $log, system_config: system_config)
618
+ stub(Engine).root_agent { @ra }
619
+ @ra.log.out.reset
620
+ one_minute_ago = Time.now.to_i - 60
621
+ Timecop.freeze(one_minute_ago)
622
+ end
623
+
624
+ teardown do
625
+ Timecop.return
626
+ end
627
+
628
+ test 'suppresses errors' do
629
+ mock(@ra.log).warn_backtrace()
630
+ e = StandardError.new('standard error')
631
+ begin
632
+ @ra.handle_emits_error("tag", nil, e)
633
+ rescue
634
+ end
635
+
636
+ begin
637
+ @ra.handle_emits_error("tag", nil, e)
638
+ rescue
639
+ end
640
+
641
+ assert_equal 1, @ra.log.out.logs.size
642
+ end
643
+ end
644
+
612
645
  sub_test_case 'configured at worker2 with 4 workers environment' do
613
646
  setup do
614
647
  ENV['SERVERENGINE_WORKER_ID'] = '2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluentd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-11 00:00:00.000000000 Z
11
+ date: 2018-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -764,9 +764,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
764
764
  version: '2.1'
765
765
  required_rubygems_version: !ruby/object:Gem::Requirement
766
766
  requirements:
767
- - - ">="
767
+ - - ">"
768
768
  - !ruby/object:Gem::Version
769
- version: '0'
769
+ version: 1.3.1
770
770
  requirements: []
771
771
  rubyforge_project:
772
772
  rubygems_version: 2.7.6