loggregator_emitter 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MzEyMzMwNDA5NTlkZWE5YTM0ZmJkOTQwNTMzYmQyYjljMmM1YzM2NQ==
5
+ data.tar.gz: !binary |-
6
+ YmVkNmIwOGM3MDVmZWFhN2Q4OThkYzFmMTRlZjQ1ZTgzY2ViOWQzZQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ M2RlMmQyMDVhYjY0NTJjYWI4OGU3ZGNiMTZmNGZhZWE2ZjI5ZmU1ODRjN2Nj
10
+ MzQ4ZDVhOWRjYTQwMGE1ODBmZjg0YmQzYmYwYjQ3NDY1ZGMxODBhNDg1MDcx
11
+ MThjMmQ1ZDE1MGNmMjc3Mjg0MzhjYTljN2EzYWUzOWMyOWU4ZmQ=
12
+ data.tar.gz: !binary |-
13
+ OTkxNjgwNjk5ZWYyNTg5M2IxMTI0MmNiZGRjZWZhYzBkNmRhYjUxMmExOTAx
14
+ YjZmNzU5ODQ2NDE4YmFmODNhYzQ3YjJkY2NjMjJlNGY5M2VjZGMwZGFhZTgw
15
+ NGQxYTk5ZTRlZDNhMjIxOWIwYTlhZTM1MTliZjNlNzUxNzAyMGY=
@@ -2,6 +2,9 @@ require 'socket'
2
2
 
3
3
  module LoggregatorEmitter
4
4
  class Emitter
5
+ MAX_MESSAGE_BYTE_SIZE = (9 * 1024) - 512
6
+ TRUNCATED_STRING = "TRUNCATED"
7
+
5
8
  def initialize(loggregator_server, source_type, source_id = nil)
6
9
  raise ArgumentError, "Must provide valid source type" unless valid_source_type?(source_type)
7
10
 
@@ -33,6 +36,10 @@ module LoggregatorEmitter
33
36
  def emit_message(app_id, message, type)
34
37
  return unless app_id && message && message.strip.length > 0
35
38
 
39
+ if message.bytesize > MAX_MESSAGE_BYTE_SIZE
40
+ message = message.byteslice(0, MAX_MESSAGE_BYTE_SIZE-TRUNCATED_STRING.bytesize) + TRUNCATED_STRING
41
+ end
42
+
36
43
  lm = create_log_message(app_id, message, type)
37
44
  send_message(lm)
38
45
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "loggregator_emitter"
5
- spec.version = '1.0.0'
5
+ spec.version = '1.0.1'
6
6
  spec.authors = ["Pivotal"]
7
7
  spec.email = ["cf-eng@pivotallabs.com"]
8
8
  spec.description = "Library to emit data to Loggregator"
@@ -112,6 +112,19 @@ describe LoggregatorEmitter do
112
112
  messages = @server.messages
113
113
  expect(messages.length).to eq 0
114
114
  end
115
+
116
+ it "truncates large messages" do
117
+ emitter = make_emitter("localhost")
118
+ message = (124*1024).times.collect { "a" }.join("")
119
+ emitter.send(emit_method, "my_app_id", message)
120
+ messages = @server.messages
121
+
122
+ sleep 0.5
123
+
124
+ expect(messages.length).to eq 1
125
+ expect(messages[0].message.bytesize <= LoggregatorEmitter::Emitter::MAX_MESSAGE_BYTE_SIZE).to be_true
126
+ expect(messages[0].message.slice(-9..-1)).to eq("TRUNCATED")
127
+ end
115
128
  end
116
129
  end
117
130
 
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loggregator_emitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Pivotal
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-17 00:00:00.000000000 Z
11
+ date: 2013-11-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: beefcake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -100,30 +91,26 @@ files:
100
91
  homepage: https://www.github.com/cloudfoundry/loggregator_emitter
101
92
  licenses:
102
93
  - Apache 2.0
94
+ metadata: {}
103
95
  post_install_message:
104
96
  rdoc_options: []
105
97
  require_paths:
106
98
  - lib
107
99
  required_ruby_version: !ruby/object:Gem::Requirement
108
- none: false
109
100
  requirements:
110
101
  - - ! '>='
111
102
  - !ruby/object:Gem::Version
112
103
  version: 1.9.3
113
104
  required_rubygems_version: !ruby/object:Gem::Requirement
114
- none: false
115
105
  requirements:
116
106
  - - ! '>='
117
107
  - !ruby/object:Gem::Version
118
108
  version: '0'
119
- segments:
120
- - 0
121
- hash: 2332041355352225628
122
109
  requirements: []
123
110
  rubyforge_project:
124
- rubygems_version: 1.8.25
111
+ rubygems_version: 2.0.5
125
112
  signing_key:
126
- specification_version: 3
113
+ specification_version: 4
127
114
  summary: Library to emit data to Loggregator
128
115
  test_files:
129
116
  - spec/loggregator_emitter/emit_spec.rb