fluent-plugin-honeycomb 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7083d11330f158765d8eb1e0079b7e50b1c0f979
4
- data.tar.gz: a25a7b1023946e9c3a28dbdfb700bf3046f48717
2
+ SHA256:
3
+ metadata.gz: 8138cd6ca1e9f12779f36bb584169c22908cfaf959d160d2cc749557ef3d6bda
4
+ data.tar.gz: 5f1f4af9e18dac5dc798bc072728258f95f0b7220cd3e17b1466c5c20a55db74
5
5
  SHA512:
6
- metadata.gz: 7be1985ff4cbe433a9fd29b3e97dfb9ffe92eab9be59089f27177081fcea34be4341aa9a8dbe310bf1c11fc5f6caa5494d78358d6a01d3d88216dc6de017ce73
7
- data.tar.gz: c8515220ffb762a2b3942795afb55460db2c2a41f64ae7a9c9b9f98d1ba22a52af110b29fcf1847004e7afce3a6fbe4203a1a0c79a271651372e7476652d43ce
6
+ metadata.gz: 86ad70b5484e9cbfb6c0ca7a51bf50190283a372674547b70a6d05a4a2eaa62ca5968c7257d126fccadf6bfe820a222db89c34aa8052a001e272eda3ded38ed4
7
+ data.tar.gz: 85de3ad6302b8f91f990e84ff6011da8fb74cb05fee8434d8696e0f29b65177ef43754e017a694e565eadc0bd185ba9376d38aaa33b9e6c3d3add6c21cee9e8a
data/README.md CHANGED
@@ -29,6 +29,7 @@ Parameter | Type | Required? | Description
29
29
  | `tag_key` | string | no | If `include_tag_key` is `true`, the tag key name in the event (default: `fluentd_tag`).
30
30
  | `flatten_keys` | array | no | Flatten nested JSON data under these keys into the top-level event.
31
31
  | `dataset_from_key` | string | no | Look for this key in each event, and use its value as the destination dataset. If an event doesn't contain the key, it'll be sent to the dataset given by the `dataset` parameter.
32
+ | `presampled_key` | string | no | Look for this key in each event, and use its value as the sample rate for the record. If an event doesn't contain the key, the logic around `sample_rate` will be used (1 out of every N events will be sent instead). If an event's `presampled_key` value is not a positive integer, the value is discarded, and the event is sent to Honeycomb with a `samplerate` of 1 (the default), ignoring the `sample_rate` configuration option. |
32
33
 
33
34
  ### Buffering options
34
35
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'fluent-plugin-honeycomb'
3
- spec.version = '0.5.0'
3
+ spec.version = '0.6.0'
4
4
 
5
5
  spec.summary = "Fluentd output plugin for Honeycomb.io"
6
6
  spec.description = "Fluentd output plugin for Honeycomb.io"
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "webmock", "~> 2.1"
26
26
  spec.add_development_dependency "test-unit"
27
+ spec.add_development_dependency "mocha"
27
28
  spec.add_development_dependency "simplecov"
28
29
  spec.add_development_dependency "coveralls"
29
30
  spec.add_development_dependency "bump"
@@ -19,6 +19,7 @@ module Fluent
19
19
  config_param :api_host, :string, :default => "https://api.honeycomb.io"
20
20
  config_param :flatten_keys, :array, value_type: :string, :default => []
21
21
  config_param :dataset_from_key, :string, :default => ""
22
+ config_param :presampled_key, :string, :default => nil
22
23
 
23
24
  # This method is called before starting.
24
25
  # 'conf' is a Hash that includes configuration parameters.
@@ -63,9 +64,23 @@ module Fluent
63
64
  log.debug "Skipping record #{record}"
64
65
  next
65
66
  end
66
- if @sample_rate > 1 && rand(1..@sample_rate) == 1
67
- next
67
+
68
+ if @presampled_key && record.include?(@presampled_key)
69
+ sample_rate = record.delete(@presampled_key)
70
+
71
+ if !sample_rate.is_a?(Integer) || sample_rate < 1
72
+ log.warn "Record emitted a presampled key (#{@presampled_key} = #{sample_rate}), but was not a valid sample rate #{record}"
73
+
74
+ sample_rate = 1
75
+ end
76
+ else
77
+ sample_rate = @sample_rate
78
+
79
+ if @sample_rate > 1 && rand(1..@sample_rate) > 1
80
+ next
81
+ end
68
82
  end
83
+
69
84
  if @include_tag_key
70
85
  record[@tag_key] = tag
71
86
  end
@@ -84,7 +99,7 @@ module Fluent
84
99
  batch = batches[dataset]
85
100
  batch.push({
86
101
  "data" => record,
87
- "samplerate" => @sample_rate,
102
+ "samplerate" => sample_rate,
88
103
  "time" => Time.at(time).utc.to_datetime.rfc3339
89
104
  })
90
105
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-honeycomb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Honeycomb.io Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-10 00:00:00.000000000 Z
11
+ date: 2017-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: mocha
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: simplecov
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -185,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
199
  version: '0'
186
200
  requirements: []
187
201
  rubyforge_project:
188
- rubygems_version: 2.6.14
202
+ rubygems_version: 2.7.2
189
203
  signing_key:
190
204
  specification_version: 4
191
205
  summary: Fluentd output plugin for Honeycomb.io