loggregator_emitter 4.0.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/loggregator_emitter/emit.rb +18 -21
- data/lib/sonde/sonde.pb.rb +42 -0
- data/lib/sonde/sonde.proto +39 -0
- data/lib/sonde/sonde_extender.rb +19 -0
- data/loggregator_emitter.gemspec +2 -2
- data/spec/loggregator_emitter/emit_performance_spec.rb +1 -1
- data/spec/loggregator_emitter/emit_spec.rb +45 -45
- data/spec/support/fake_loggregator_server.rb +5 -9
- metadata +22 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf819100b9ada951567d64e0d8e95bbadadb394f
|
4
|
+
data.tar.gz: a9659c18062b4c13a2a4b4e0b5bc028348f7407a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44999954cf8adb80fd69b1c287fcf01e86b2eb7eb7d1af81105c95cd4c8e0c07fc3df5afd007a2ead1b6830b107cad66b78187e4ab6434903ec0f241bdb9306f
|
7
|
+
data.tar.gz: 818ebb9490ddafb9c96d601c0af77fac9539c6519eba2fbe73a125249a72176c0fe4230891b62d371676bc6c022b6aa7de16c68aa28938212ec87c8ce8116778
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
This gem provides an API to emit messages to the loggregator agent from Ruby applications.
|
8
8
|
|
9
|
-
Create an emitter object with the loggregator router host and port, a source name of the emitter
|
9
|
+
Create an emitter object with the loggregator router host and port, an origin, and a source name of the emitter.
|
10
10
|
|
11
11
|
Call emit() or emit_error() on this emitter with the application GUID and the message string.
|
12
12
|
|
@@ -29,7 +29,7 @@ Call emit() or emit_error() on this emitter with the application GUID and the me
|
|
29
29
|
|
30
30
|
require "loggregator_emitter"
|
31
31
|
|
32
|
-
emitter = LoggregatorEmitter::Emitter.new("10.10.10.16:38452", "API")
|
32
|
+
emitter = LoggregatorEmitter::Emitter.new("10.10.10.16:38452", "origin", API")
|
33
33
|
|
34
34
|
app_guid = "a8977cb6-3365-4be1-907e-0c878b3a4c6b" # The GUID(UUID) for the user's application
|
35
35
|
|
@@ -38,7 +38,8 @@ Call emit() or emit_error() on this emitter with the application GUID and the me
|
|
38
38
|
emitter.emit_error(app_guid,error_message) # Emits messages with a message type of ERR
|
39
39
|
|
40
40
|
### Regenerating Protobuf library
|
41
|
-
|
41
|
+
|
42
|
+
BEEFCAKE_NAMESPACE=Sonde protoc --beefcake_out lib/sonde -I lib/sonde lib/sonde/sonde.proto
|
42
43
|
|
43
44
|
### Versioning
|
44
45
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'socket'
|
2
2
|
require 'resolv'
|
3
|
+
require 'sonde/sonde.pb'
|
4
|
+
require 'sonde/sonde_extender'
|
3
5
|
|
4
6
|
module LoggregatorEmitter
|
5
7
|
class Emitter
|
@@ -11,21 +13,22 @@ module LoggregatorEmitter
|
|
11
13
|
MAX_MESSAGE_BYTE_SIZE = (9 * 1024) - 512
|
12
14
|
TRUNCATED_STRING = "TRUNCATED"
|
13
15
|
|
14
|
-
def initialize(loggregator_server,
|
16
|
+
def initialize(loggregator_server, origin, source_type, source_instance = nil)
|
15
17
|
@host, @port = loggregator_server.split(/:([^:]*$)/)
|
16
18
|
|
17
19
|
raise ArgumentError, "Must provide valid loggregator server: #{loggregator_server}" if !valid_hostname || !valid_port
|
18
20
|
@host = ::Resolv.getaddresses(@host).last
|
19
21
|
raise ArgumentError, "Must provide valid loggregator server: #{loggregator_server}" unless @host
|
20
22
|
|
21
|
-
raise ArgumentError, "Must provide valid
|
23
|
+
raise ArgumentError, "Must provide a valid origin" unless origin
|
24
|
+
raise ArgumentError, "Must provide valid source_type: #{source_type}" unless source_type
|
22
25
|
|
23
|
-
raise ArgumentError, "
|
24
|
-
raise ArgumentError, "Custom Source String must be 3 characters" unless
|
25
|
-
@
|
26
|
+
raise ArgumentError, "source_type must be a 3-character string" unless source_type.is_a? String
|
27
|
+
raise ArgumentError, "Custom Source String must be 3 characters" unless source_type.size == 3
|
28
|
+
@origin = origin
|
29
|
+
@source_type = source_type
|
26
30
|
|
27
|
-
@
|
28
|
-
@source_id = source_id && source_id.to_s
|
31
|
+
@source_instance = source_instance && source_instance.to_s
|
29
32
|
end
|
30
33
|
|
31
34
|
def emit(app_id, message)
|
@@ -58,32 +61,26 @@ module LoggregatorEmitter
|
|
58
61
|
m = m.byteslice(0, MAX_MESSAGE_BYTE_SIZE-TRUNCATED_STRING.bytesize) + TRUNCATED_STRING
|
59
62
|
end
|
60
63
|
|
61
|
-
|
62
|
-
send_protobuffer(create_log_message(app_id, m, type))
|
63
|
-
else
|
64
|
-
send_protobuffer(create_log_envelope(app_id, m, type))
|
65
|
-
end
|
64
|
+
send_protobuffer(create_log_envelope(app_id, m, type))
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
69
68
|
def create_log_message(app_id, message, type)
|
70
|
-
lm = LogMessage.new()
|
69
|
+
lm = ::Sonde::LogMessage.new()
|
71
70
|
lm.time = Time.now
|
72
71
|
lm.message = message
|
73
72
|
lm.app_id = app_id
|
74
|
-
lm.
|
75
|
-
lm.
|
73
|
+
lm.source_instance = @source_instance
|
74
|
+
lm.source_type = @source_type
|
76
75
|
lm.message_type = type
|
77
76
|
lm
|
78
77
|
end
|
79
78
|
|
80
79
|
def create_log_envelope(app_id, message, type)
|
81
|
-
|
82
|
-
le =
|
83
|
-
le.
|
84
|
-
le.
|
85
|
-
digest = crypter.digest(le.log_message.message)
|
86
|
-
le.signature = crypter.encrypt(@secret, digest)
|
80
|
+
le = ::Sonde::Envelope.new()
|
81
|
+
le.origin = @origin
|
82
|
+
le.eventType = ::Sonde::Envelope::EventType::LogMessage
|
83
|
+
le.logMessage = create_log_message(app_id, message, type)
|
87
84
|
le
|
88
85
|
end
|
89
86
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
## Generated from sonde.proto for events
|
2
|
+
require "beefcake"
|
3
|
+
|
4
|
+
module Sonde
|
5
|
+
|
6
|
+
class Envelope
|
7
|
+
include Beefcake::Message
|
8
|
+
|
9
|
+
module EventType
|
10
|
+
LogMessage = 5
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class LogMessage
|
15
|
+
include Beefcake::Message
|
16
|
+
|
17
|
+
module MessageType
|
18
|
+
OUT = 1
|
19
|
+
ERR = 2
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Envelope
|
24
|
+
required :origin, :string, 1
|
25
|
+
required :eventType, Envelope::EventType, 2
|
26
|
+
optional :timestamp, :int64, 6
|
27
|
+
optional :deployment, :string, 13
|
28
|
+
optional :job, :string, 14
|
29
|
+
optional :index, :string, 15
|
30
|
+
optional :ip, :string, 16
|
31
|
+
optional :logMessage, LogMessage, 8
|
32
|
+
end
|
33
|
+
|
34
|
+
class LogMessage
|
35
|
+
required :message, :bytes, 1
|
36
|
+
required :message_type, LogMessage::MessageType, 2
|
37
|
+
required :timestamp, :int64, 3
|
38
|
+
optional :app_id, :string, 4
|
39
|
+
optional :source_type, :string, 5
|
40
|
+
optional :source_instance, :string, 6
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
package events;
|
2
|
+
|
3
|
+
/// Envelope wraps an Event and adds metadata.
|
4
|
+
message Envelope {
|
5
|
+
/// Type of the wrapped event.
|
6
|
+
enum EventType {
|
7
|
+
LogMessage = 5;
|
8
|
+
}
|
9
|
+
|
10
|
+
required string origin = 1; /// Unique description of the origin of this event.
|
11
|
+
required EventType eventType = 2; /// Type of wrapped event. Only the optional field corresponding to the value of eventType should be set.
|
12
|
+
|
13
|
+
optional int64 timestamp = 6; /// UNIX timestamp (in nanoseconds) event was wrapped in this Envelope.
|
14
|
+
|
15
|
+
optional string deployment = 13; /// Deployment name (used to uniquely identify source).
|
16
|
+
optional string job = 14; /// Job name (used to uniquely identify source).
|
17
|
+
optional string index = 15; /// Index of job (used to uniquely identify source).
|
18
|
+
optional string ip = 16; /// IP address (used to uniquely identify source).
|
19
|
+
|
20
|
+
// Removed Heartbeat at position 3
|
21
|
+
optional LogMessage logMessage = 8;
|
22
|
+
}
|
23
|
+
|
24
|
+
/// A LogMessage contains a "log line" and associated metadata.
|
25
|
+
message LogMessage {
|
26
|
+
|
27
|
+
/// MessageType stores the destination of the message (corresponding to STDOUT or STDERR).
|
28
|
+
enum MessageType {
|
29
|
+
OUT = 1;
|
30
|
+
ERR = 2;
|
31
|
+
}
|
32
|
+
|
33
|
+
required bytes message = 1; /// Bytes of the log message. (Note that it is not required to be a single line.)
|
34
|
+
required MessageType message_type = 2; /// Type of the message (OUT or ERR).
|
35
|
+
required int64 timestamp = 3; /// UNIX timestamp (in nanoseconds) when the log was written.
|
36
|
+
optional string app_id = 4; /// Application that emitted the message (or to which the application is related).
|
37
|
+
optional string source_type = 5; /// Source of the message. For Cloud Foundry, this can be "APP", "RTR", "DEA", "STG", etc.
|
38
|
+
optional string source_instance = 6; /// Instance that emitted the message.
|
39
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Sonde
|
2
|
+
|
3
|
+
class LogMessage
|
4
|
+
def message_type_name
|
5
|
+
{MessageType::OUT => 'STDOUT', MessageType::ERR => 'STDERR'}[message_type]
|
6
|
+
end
|
7
|
+
|
8
|
+
def time=(time)
|
9
|
+
self.timestamp = (time.tv_sec * 1000000000) + time.tv_nsec
|
10
|
+
end
|
11
|
+
|
12
|
+
def time
|
13
|
+
num_secs = @timestamp / 1000000000
|
14
|
+
fractional_usecs = (@timestamp % 1000000000).to_f / 1000
|
15
|
+
Time.at(num_secs, fractional_usecs)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/loggregator_emitter.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "loggregator_emitter"
|
5
|
-
spec.version = '
|
5
|
+
spec.version = '5.0.0'
|
6
6
|
spec.authors = ["Pivotal"]
|
7
7
|
spec.email = ["cf-eng@pivotallabs.com"]
|
8
8
|
spec.description = "Library to emit data to Loggregator"
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_dependency "beefcake", "~> 1.0.0"
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
-
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rake"
|
24
24
|
spec.add_development_dependency "rspec", "~> 2.14.1"
|
25
25
|
spec.add_development_dependency "coveralls"
|
26
26
|
end
|
@@ -21,7 +21,7 @@ shared_examples "a performance test" do |fixture, using_server|
|
|
21
21
|
let(:iterations) { using_server ? 100 : 1000 }
|
22
22
|
|
23
23
|
before do
|
24
|
-
@emitter = LoggregatorEmitter::Emitter.new("localhost:#{@free_port}", "API", 42
|
24
|
+
@emitter = LoggregatorEmitter::Emitter.new("localhost:#{@free_port}", "origin", "API", 42)
|
25
25
|
if !using_server
|
26
26
|
@emitter.should_receive(:send_protobuffer).at_least(iterations).times
|
27
27
|
end
|
@@ -22,47 +22,51 @@ describe LoggregatorEmitter do
|
|
22
22
|
describe "configuring emitter" do
|
23
23
|
describe "valid configurations" do
|
24
24
|
it "is valid with IP and proper source name" do
|
25
|
-
expect { LoggregatorEmitter::Emitter.new("0.0.0.0:12345", "DEA") }.not_to raise_error
|
25
|
+
expect { LoggregatorEmitter::Emitter.new("0.0.0.0:12345", "origin", "DEA") }.not_to raise_error
|
26
26
|
end
|
27
27
|
|
28
28
|
it "is valid with resolveable hostname and proper source name" do
|
29
|
-
expect { LoggregatorEmitter::Emitter.new("localhost:12345", "DEA") }.not_to raise_error
|
29
|
+
expect { LoggregatorEmitter::Emitter.new("localhost:12345", "origin", "DEA") }.not_to raise_error
|
30
30
|
end
|
31
31
|
|
32
32
|
it "accepts a string as source type/name" do
|
33
|
-
expect { LoggregatorEmitter::Emitter.new("localhost:12345", "STG") }.not_to raise_error
|
33
|
+
expect { LoggregatorEmitter::Emitter.new("localhost:12345", "origin", "STG") }.not_to raise_error
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "invalid configurations" do
|
38
38
|
describe "error based on loggregator_server" do
|
39
39
|
it "raises if host has protocol" do
|
40
|
-
expect { LoggregatorEmitter::Emitter.new("http://0.0.0.0:12345", "DEA") }.to raise_error(ArgumentError)
|
40
|
+
expect { LoggregatorEmitter::Emitter.new("http://0.0.0.0:12345", "origin", "DEA") }.to raise_error(ArgumentError)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "raises if host is blank" do
|
44
|
-
expect { LoggregatorEmitter::Emitter.new(":12345", "DEA") }.to raise_error(ArgumentError)
|
44
|
+
expect { LoggregatorEmitter::Emitter.new(":12345", "origin", "DEA") }.to raise_error(ArgumentError)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "raises if host is unresolvable" do
|
48
|
-
expect { LoggregatorEmitter::Emitter.new("i.cant.resolve.foo:12345", "DEA") }.to raise_error(ArgumentError)
|
48
|
+
expect { LoggregatorEmitter::Emitter.new("i.cant.resolve.foo:12345", "origin", "DEA") }.to raise_error(ArgumentError)
|
49
49
|
end
|
50
50
|
|
51
|
-
it "raises if
|
52
|
-
expect { LoggregatorEmitter::Emitter.new("
|
51
|
+
it "raises if origin is blank" do
|
52
|
+
expect { LoggregatorEmitter::Emitter.new(":12345", "", "DEA") }.to raise_error(ArgumentError)
|
53
53
|
end
|
54
54
|
|
55
|
-
it "raises if
|
56
|
-
expect { LoggregatorEmitter::Emitter.new("localhost:12345",
|
57
|
-
expect { LoggregatorEmitter::Emitter.new("localhost:12345", 12.0) }.to raise_error(ArgumentError)
|
55
|
+
it "raises if source_type is an unknown integer" do
|
56
|
+
expect { LoggregatorEmitter::Emitter.new("localhost:12345", "origin", 7) }.to raise_error(ArgumentError)
|
58
57
|
end
|
59
58
|
|
60
|
-
it "raises if
|
61
|
-
expect { LoggregatorEmitter::Emitter.new("localhost:12345", "
|
59
|
+
it "raises if source_type is not an integer or string" do
|
60
|
+
expect { LoggregatorEmitter::Emitter.new("localhost:12345", "origin", nil) }.to raise_error(ArgumentError)
|
61
|
+
expect { LoggregatorEmitter::Emitter.new("localhost:12345", "origin", 12.0) }.to raise_error(ArgumentError)
|
62
62
|
end
|
63
63
|
|
64
|
-
it "raises if
|
65
|
-
expect { LoggregatorEmitter::Emitter.new("localhost:12345", "
|
64
|
+
it "raises if source_type is too large of a string" do
|
65
|
+
expect { LoggregatorEmitter::Emitter.new("localhost:12345", "origin", "ABCD") }.to raise_error(ArgumentError)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "raises if source_type is too small of a string" do
|
69
|
+
expect { LoggregatorEmitter::Emitter.new("localhost:12345", "origin", "AB") }.to raise_error(ArgumentError)
|
66
70
|
end
|
67
71
|
end
|
68
72
|
end
|
@@ -71,7 +75,7 @@ describe LoggregatorEmitter do
|
|
71
75
|
|
72
76
|
describe "emit_log_envelope" do
|
73
77
|
def make_emitter(host)
|
74
|
-
LoggregatorEmitter::Emitter.new("#{host}:#{@free_port}", "API", 42
|
78
|
+
LoggregatorEmitter::Emitter.new("#{host}:#{@free_port}", "origin", "API", 42)
|
75
79
|
end
|
76
80
|
|
77
81
|
it "successfully writes envelope protobuffers" do
|
@@ -84,16 +88,11 @@ describe LoggregatorEmitter do
|
|
84
88
|
|
85
89
|
expect(messages.length).to eq 1
|
86
90
|
message = messages[0]
|
87
|
-
expect(message.routing_key).to eq "my_app_id"
|
88
|
-
|
89
|
-
actual_digest = Encryption::Symmetric.new.decrypt("secret", message.signature)
|
90
|
-
expected_digest = Encryption::Symmetric.new.digest(message.log_message.message)
|
91
|
-
expect(actual_digest).to eq expected_digest
|
92
91
|
|
93
|
-
expect(message.
|
94
|
-
expect(message.
|
95
|
-
expect(message.
|
96
|
-
expect(message.
|
92
|
+
expect(message.logMessage.message).to eq "Hello there!"
|
93
|
+
expect(message.logMessage.app_id).to eq "my_app_id"
|
94
|
+
expect(message.logMessage.source_instance).to eq "42"
|
95
|
+
expect(message.logMessage.message_type).to eq ::Sonde::LogMessage::MessageType::OUT
|
97
96
|
end
|
98
97
|
|
99
98
|
it "gracefully handles failures to send messages" do
|
@@ -122,7 +121,7 @@ describe LoggregatorEmitter do
|
|
122
121
|
{"emit" => LogMessage::MessageType::OUT, "emit_error" => LogMessage::MessageType::ERR}.each do |emit_method, message_type|
|
123
122
|
describe "##{emit_method}" do
|
124
123
|
def make_emitter(host)
|
125
|
-
LoggregatorEmitter::Emitter.new("#{host}:#{@free_port}", "API", 42)
|
124
|
+
LoggregatorEmitter::Emitter.new("#{host}:#{@free_port}", "origin", "API", 42)
|
126
125
|
end
|
127
126
|
|
128
127
|
it "successfully writes protobuffers using ipv4" do
|
@@ -136,13 +135,13 @@ describe LoggregatorEmitter do
|
|
136
135
|
messages = @server.messages
|
137
136
|
|
138
137
|
expect(messages.length).to eq 2
|
139
|
-
message = messages[0]
|
138
|
+
message = messages[0].logMessage
|
140
139
|
expect(message.message).to eq "Hello there!"
|
141
140
|
expect(message.app_id).to eq "my_app_id"
|
142
|
-
expect(message.
|
141
|
+
expect(message.source_instance).to eq "42"
|
143
142
|
expect(message.message_type).to eq message_type
|
144
143
|
|
145
|
-
message = messages[1]
|
144
|
+
message = messages[1].logMessage
|
146
145
|
expect(message.message).to eq "Hello again!"
|
147
146
|
end
|
148
147
|
|
@@ -154,7 +153,7 @@ describe LoggregatorEmitter do
|
|
154
153
|
|
155
154
|
messages = @server.messages
|
156
155
|
expect(messages.length).to eq 1
|
157
|
-
expect(messages[0].message).to eq "Hello there!"
|
156
|
+
expect(messages[0].logMessage.message).to eq "Hello there!"
|
158
157
|
end
|
159
158
|
|
160
159
|
it "successfully writes protobuffers using a dns name" do
|
@@ -165,7 +164,7 @@ describe LoggregatorEmitter do
|
|
165
164
|
|
166
165
|
messages = @server.messages
|
167
166
|
expect(messages.length).to eq 1
|
168
|
-
expect(messages[0].message).to eq "Hello there!"
|
167
|
+
expect(messages[0].logMessage.message).to eq "Hello there!"
|
169
168
|
end
|
170
169
|
|
171
170
|
it "swallows empty messages" do
|
@@ -189,8 +188,9 @@ describe LoggregatorEmitter do
|
|
189
188
|
|
190
189
|
messages = @server.messages
|
191
190
|
expect(messages.length).to eq 1
|
192
|
-
|
193
|
-
expect(
|
191
|
+
logMessage = messages[0].logMessage
|
192
|
+
expect(logMessage.message.bytesize <= LoggregatorEmitter::Emitter::MAX_MESSAGE_BYTE_SIZE).to be_true
|
193
|
+
expect(logMessage.message.slice(-9..-1)).to eq("TRUNCATED")
|
194
194
|
end
|
195
195
|
|
196
196
|
it "splits messages by newlines" do
|
@@ -212,7 +212,7 @@ describe LoggregatorEmitter do
|
|
212
212
|
|
213
213
|
messages = @server.messages
|
214
214
|
expect(messages.length).to eq 1
|
215
|
-
expect(messages[0].message.force_encoding("utf-8")).to eq "測試"
|
215
|
+
expect(messages[0].logMessage.message.force_encoding("utf-8")).to eq "測試"
|
216
216
|
end
|
217
217
|
end
|
218
218
|
end
|
@@ -224,32 +224,32 @@ describe LoggregatorEmitter do
|
|
224
224
|
|
225
225
|
@server.wait_for_messages(2)
|
226
226
|
|
227
|
-
@server.messages[0]
|
227
|
+
@server.messages[0].logMessage
|
228
228
|
end
|
229
229
|
|
230
230
|
it "when type is known" do
|
231
|
-
@emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "API")
|
232
|
-
expect(emit_message.
|
231
|
+
@emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "origin", "API")
|
232
|
+
expect(emit_message.source_type).to eq "API"
|
233
233
|
end
|
234
234
|
|
235
235
|
it "when type is unknown" do
|
236
|
-
@emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "STG")
|
237
|
-
expect(emit_message.
|
236
|
+
@emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "origin", "STG")
|
237
|
+
expect(emit_message.source_type).to eq "STG"
|
238
238
|
end
|
239
239
|
|
240
240
|
it "id can be nil" do
|
241
|
-
@emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "API")
|
242
|
-
expect(emit_message.
|
241
|
+
@emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "origin", "API")
|
242
|
+
expect(emit_message.source_instance).to eq nil
|
243
243
|
end
|
244
244
|
|
245
245
|
it "id can be passed in as a string" do
|
246
|
-
@emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "API", "some_source_id")
|
247
|
-
expect(emit_message.
|
246
|
+
@emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "origin", "API", "some_source_id")
|
247
|
+
expect(emit_message.source_instance).to eq "some_source_id"
|
248
248
|
end
|
249
249
|
|
250
250
|
it "id can be passed in as an integer" do
|
251
|
-
@emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "API", 13)
|
252
|
-
expect(emit_message.
|
251
|
+
@emitter = LoggregatorEmitter::Emitter.new("0.0.0.0:#{@free_port}", "origin", "API", 13)
|
252
|
+
expect(emit_message.source_instance).to eq "13"
|
253
253
|
end
|
254
254
|
end
|
255
255
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'socket'
|
2
|
-
require '
|
2
|
+
require 'sonde/sonde.pb'
|
3
|
+
require 'sonde/sonde_extender'
|
3
4
|
|
4
5
|
class FakeLoggregatorServer
|
5
6
|
|
@@ -47,16 +48,11 @@ class FakeLoggregatorServer
|
|
47
48
|
while true
|
48
49
|
begin
|
49
50
|
stuff = socket.recv(65536)
|
50
|
-
decoded_data =
|
51
|
+
decoded_data = ::Sonde::Envelope.decode(stuff.dup)
|
51
52
|
messages << decoded_data
|
52
53
|
rescue Beefcake::Message::WrongTypeError, Beefcake::Message::RequiredFieldNotSetError, Beefcake::Message::InvalidValueError => e
|
53
|
-
|
54
|
-
|
55
|
-
messages << decoded_data
|
56
|
-
rescue Beefcake::Message::WrongTypeError, Beefcake::Message::RequiredFieldNotSetError, Beefcake::Message::InvalidValueError => e
|
57
|
-
puts "ERROR: neither envelope nor message extraction worked"
|
58
|
-
puts e
|
59
|
-
end
|
54
|
+
puts "ERROR: envelope extraction failed"
|
55
|
+
puts e
|
60
56
|
end
|
61
57
|
end
|
62
58
|
end
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loggregator_emitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pivotal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: beefcake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 2.14.1
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 2.14.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: coveralls
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: Library to emit data to Loggregator
|
@@ -87,8 +87,8 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
-
- .gitignore
|
91
|
-
- .travis.yml
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
92
|
- Gemfile
|
93
93
|
- LICENSE
|
94
94
|
- README.md
|
@@ -98,6 +98,9 @@ files:
|
|
98
98
|
- lib/loggregator_messages/log_message.pb.rb
|
99
99
|
- lib/loggregator_messages/log_message.proto
|
100
100
|
- lib/loggregator_messages/log_message_extender.rb
|
101
|
+
- lib/sonde/sonde.pb.rb
|
102
|
+
- lib/sonde/sonde.proto
|
103
|
+
- lib/sonde/sonde_extender.rb
|
101
104
|
- lib/symmetric/encryption.rb
|
102
105
|
- loggregator_emitter.gemspec
|
103
106
|
- spec/loggregator_emitter/emit_performance_spec.rb
|
@@ -116,17 +119,17 @@ require_paths:
|
|
116
119
|
- lib
|
117
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
118
121
|
requirements:
|
119
|
-
- -
|
122
|
+
- - ">="
|
120
123
|
- !ruby/object:Gem::Version
|
121
124
|
version: 1.9.3
|
122
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
126
|
requirements:
|
124
|
-
- -
|
127
|
+
- - ">="
|
125
128
|
- !ruby/object:Gem::Version
|
126
129
|
version: '0'
|
127
130
|
requirements: []
|
128
131
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
132
|
+
rubygems_version: 2.4.5.1
|
130
133
|
signing_key:
|
131
134
|
specification_version: 4
|
132
135
|
summary: Library to emit data to Loggregator
|