loggregator_emitter 5.1.1 → 5.1.2

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
2
  SHA1:
3
- metadata.gz: ce623535025497b97a8f11adcae61e83d3da8f97
4
- data.tar.gz: edaff20710aef2d52d43ea383c808cbd21f86349
3
+ metadata.gz: 7ea729ed5d5e68b64496129d6efbde3e3485dacd
4
+ data.tar.gz: 19c63bbb1c7094d934446b440db65988ec92a9ea
5
5
  SHA512:
6
- metadata.gz: 2a19fe40d7843694e3e12c35e0928355ab56f83703838766460ec573533980445a4e4270e2db5e0f81e07ec64091b6572d1f2d84fafdde868b5f98c233b607df
7
- data.tar.gz: c037d51137815da7e2c1d6b0a541d9c5f1ef4524b35d87df326dbe578c96aeb7f47dd88ea78f4fda86aa3a17ed66a8898ae352f44c6883e9323f8d9709b4fd39
6
+ metadata.gz: 74bf3ea2ef16d396b33a6bb1d8550178d5050948349c34e9cb82851bd0333d66a77155af113a2f3a65df85668dd97649f6356296766d9ee631878c37b88280d8
7
+ data.tar.gz: afe8c77b9b85ba829d36be69f122947eabf5586ce88bcd493cb8642d1cd4f48c1f05876bcce56f29376de47ed7b9cd0f6a2012036e639ec0d6aeca58531280c2
@@ -73,6 +73,8 @@ module LoggregatorEmitter
73
73
  def set_tags(tags)
74
74
  envelope_tags = []
75
75
  tags.each do |k, v|
76
+ raise ArgumentError, "Tag key is too long: #{k.length} (max 256 characters)" unless k.length <= 256
77
+ raise ArgumentError, "Tag value is too long #{v.length} (max 256 characters)" unless v.length <= 256
76
78
  envelope_tags << ::Sonde::Envelope::TagsEntry.new(:key => k, :value => v)
77
79
  end
78
80
  envelope_tags
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "loggregator_emitter"
5
- spec.version = '5.1.1'
5
+ spec.version = '5.1.2'
6
6
  spec.authors = ["Pivotal"]
7
7
  spec.email = ["cf-eng@pivotallabs.com"]
8
8
  spec.description = "Library to emit data to Loggregator"
@@ -85,6 +85,52 @@ describe LoggregatorEmitter do
85
85
  expected_tags
86
86
  end
87
87
 
88
+ describe "max_tag_length" do
89
+ it "throws an exception when the key is too long" do
90
+ too_long = "x" * 257
91
+ tag = {too_long => "a"}
92
+
93
+ emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "origin", "API", 42)
94
+
95
+ Timecop.freeze timestamp do
96
+ expect { emitter.emit("my_app_id", "Hello there!", tag) }.to raise_error(ArgumentError)
97
+ end
98
+ end
99
+
100
+ it "throws an exception when the value is too long" do
101
+ too_long = "x" * 257
102
+ tag = {"a" => too_long}
103
+
104
+ emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "origin", "API", 42)
105
+
106
+ Timecop.freeze timestamp do
107
+ expect { emitter.emit("my_app_id", "Hello there!", tag) }.to raise_error(ArgumentError)
108
+ end
109
+ end
110
+
111
+ it "counts multi-byte unicode characters as single characters when checking key length" do
112
+ just_right = "x" * 255 + "Ω"
113
+ tag = {just_right => "a"}
114
+
115
+ emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "origin", "API", 42)
116
+
117
+ Timecop.freeze timestamp do
118
+ expect { emitter.emit("my_app_id", "Hello there!", tag) }.not_to raise_error
119
+ end
120
+ end
121
+
122
+ it "counts multi-byte unicode characters as single characters when checking value length" do
123
+ just_right = "x" * 255 + "Ω"
124
+ tag = {"a" => just_right}
125
+
126
+ emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "origin", "API", 42)
127
+
128
+ Timecop.freeze timestamp do
129
+ expect { emitter.emit("my_app_id", "Hello there!", tag) }.not_to raise_error
130
+ end
131
+ end
132
+ end
133
+
88
134
  let(:timestamp) {Time.now}
89
135
  describe "emit_log_envelope" do
90
136
  def make_emitter(host)
@@ -350,7 +396,7 @@ describe LoggregatorEmitter do
350
396
  messages = @server.messages
351
397
  expect(messages.length).to eq 1
352
398
  logMessage = messages[0].logMessage
353
- expect(logMessage.message.bytesize <= LoggregatorEmitter::Emitter::MAX_MESSAGE_BYTE_SIZE).to be_true
399
+ expect(logMessage.message.bytesize <= LoggregatorEmitter::Emitter::MAX_MESSAGE_BYTE_SIZE).to be true
354
400
  expect(logMessage.message.slice(-9..-1)).to eq("TRUNCATED")
355
401
  end
356
402
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loggregator_emitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.1
4
+ version: 5.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pivotal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-08 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: beefcake