loggregator_emitter 5.1.2 → 5.2.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
2
  SHA1:
3
- metadata.gz: 7ea729ed5d5e68b64496129d6efbde3e3485dacd
4
- data.tar.gz: 19c63bbb1c7094d934446b440db65988ec92a9ea
3
+ metadata.gz: 588d56d832f366916e69f02a18d729dc56380661
4
+ data.tar.gz: b03beb2af10129ab6dd0d99db3da532038457441
5
5
  SHA512:
6
- metadata.gz: 74bf3ea2ef16d396b33a6bb1d8550178d5050948349c34e9cb82851bd0333d66a77155af113a2f3a65df85668dd97649f6356296766d9ee631878c37b88280d8
7
- data.tar.gz: afe8c77b9b85ba829d36be69f122947eabf5586ce88bcd493cb8642d1cd4f48c1f05876bcce56f29376de47ed7b9cd0f6a2012036e639ec0d6aeca58531280c2
6
+ metadata.gz: a009d14ede8e246230d02943bab941ab1c782f758a0b0f6fde6847ba9846ddd6d2f716e16c651c37e0a718ae9700bc530272c5065bf6373eeacb6b19b44015e1
7
+ data.tar.gz: 43aeced8dd382681a66e5be85aa678ce70669acd0b3ab2d7890ee5d896e1932c47e5c9351531e4cf1a2535dcf4023e48e040b5bae474253eac3997f88bff4ba7
@@ -11,6 +11,8 @@ module LoggregatorEmitter
11
11
 
12
12
  MAX_MESSAGE_BYTE_SIZE = (9 * 1024) - 512
13
13
  TRUNCATED_STRING = "TRUNCATED"
14
+ MAX_TAG_LENGTH = 256
15
+ MAX_TAGS = 10
14
16
 
15
17
  def initialize(loggregator_server, origin, source_type, source_instance = nil)
16
18
  @host, @port = loggregator_server.split(/:([^:]*$)/)
@@ -71,10 +73,13 @@ module LoggregatorEmitter
71
73
  end
72
74
 
73
75
  def set_tags(tags)
76
+ if tags.length > MAX_TAGS
77
+ raise ArgumentError, "Too many tags. Max is #{MAX_TAGS}"
78
+ end
74
79
  envelope_tags = []
75
80
  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
81
+ raise ArgumentError, "Tag key is too long: #{k.length} (max #{MAX_TAG_LENGTH} characters)" unless k.length <= MAX_TAG_LENGTH
82
+ raise ArgumentError, "Tag value is too long #{v.length} (max #{MAX_TAG_LENGTH} characters)" unless v.length <= MAX_TAG_LENGTH
78
83
  envelope_tags << ::Sonde::Envelope::TagsEntry.new(:key => k, :value => v)
79
84
  end
80
85
  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.2'
5
+ spec.version = '5.2.0'
6
6
  spec.authors = ["Pivotal"]
7
7
  spec.email = ["cf-eng@pivotallabs.com"]
8
8
  spec.description = "Library to emit data to Loggregator"
@@ -4,18 +4,17 @@ require "support/fake_loggregator_server"
4
4
  require "loggregator_emitter"
5
5
 
6
6
  describe LoggregatorEmitter do
7
-
8
- before :all do
7
+ before do
9
8
  @free_port = test_port
10
9
  @server = FakeLoggregatorServer.new(@free_port)
11
- @server.start
12
10
  end
13
11
 
14
- after :all do
15
- @server.stop
12
+ before :each do
13
+ @server.start
16
14
  end
17
15
 
18
- before do
16
+ after :each do
17
+ @server.stop
19
18
  @server.reset
20
19
  end
21
20
 
@@ -85,6 +84,22 @@ describe LoggregatorEmitter do
85
84
  expected_tags
86
85
  end
87
86
 
87
+ describe "max_tags" do
88
+ it "throws an exception when there are more than 10 tags" do
89
+ tags = {}
90
+ for i in 0..10
91
+ tags["tag#{i}"] = "value#{i}"
92
+ end
93
+
94
+ emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "origin", "API", 42)
95
+
96
+ Timecop.freeze timestamp do
97
+ expect { emitter.emit("my_app_id", "Hello there!", tags) }.to raise_error(ArgumentError)
98
+ end
99
+ end
100
+ end
101
+
102
+
88
103
  describe "max_tag_length" do
89
104
  it "throws an exception when the key is too long" do
90
105
  too_long = "x" * 257
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.2
4
+ version: 5.2.0
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-20 00:00:00.000000000 Z
11
+ date: 2016-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: beefcake