ffwd-carbon 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/ffwd/plugin/carbon.rb +46 -0
- data/lib/ffwd/plugin/carbon/connection.rb +58 -0
- data/lib/ffwd/plugin/carbon/version.rb +22 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 98795ff993a41095884c17bbefd33bdd349abebe
|
4
|
+
data.tar.gz: 856f1b96d01ce897c0cf5d1f9709bde8c0b7f219
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 255e4f34102072ea06ac7f8d3a814d9b821d3ba676209bbd10757383562560da662c1b810978e8dc8325a8ecaeb0b22f2f6d9c0dee037ade8bf7b6942336317c
|
7
|
+
data.tar.gz: 16a244a571ab4314369fef6a8f046427f30c1a2bf75e26991646e249de087a21ae182e759cf396504b5ae13b274fb2ad7a642847ce199f1e5ff435248aa304b9
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# $LICENSE
|
2
|
+
# Copyright 2013-2014 Spotify AB. All rights reserved.
|
3
|
+
#
|
4
|
+
# The contents of this file are licensed under the Apache License, Version 2.0
|
5
|
+
# (the "License"); you may not use this file except in compliance with the
|
6
|
+
# License. You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
require 'ffwd/protocol'
|
17
|
+
require 'ffwd/plugin'
|
18
|
+
require 'ffwd/logging'
|
19
|
+
|
20
|
+
require_relative 'carbon/connection'
|
21
|
+
|
22
|
+
module FFWD::Plugin
|
23
|
+
module Carbon
|
24
|
+
include FFWD::Plugin
|
25
|
+
include FFWD::Logging
|
26
|
+
|
27
|
+
register_plugin "carbon"
|
28
|
+
|
29
|
+
DEFAULT_HOST = "localhost"
|
30
|
+
DEFAULT_PORT = 2003
|
31
|
+
DEFAULT_PROTOCOL = "tcp"
|
32
|
+
|
33
|
+
def self.setup_input opts, core
|
34
|
+
opts[:host] ||= DEFAULT_HOST
|
35
|
+
opts[:port] ||= DEFAULT_PORT
|
36
|
+
protocol = FFWD.parse_protocol(opts[:protocol] || DEFAULT_PROTOCOL)
|
37
|
+
protocol.bind opts, core, log, Connection
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.setup_tunnel opts, core, tunnel
|
41
|
+
opts[:port] ||= DEFAULT_PORT
|
42
|
+
protocol = FFWD.parse_protocol(opts[:protocol] || DEFAULT_PROTOCOL)
|
43
|
+
protocol.tunnel opts, core, tunnel, log, Connection
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# $LICENSE
|
2
|
+
# Copyright 2013-2014 Spotify AB. All rights reserved.
|
3
|
+
#
|
4
|
+
# The contents of this file are licensed under the Apache License, Version 2.0
|
5
|
+
# (the "License"); you may not use this file except in compliance with the
|
6
|
+
# License. You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
require 'eventmachine'
|
17
|
+
|
18
|
+
require 'ffwd/logging'
|
19
|
+
require 'ffwd/connection'
|
20
|
+
|
21
|
+
module FFWD::Plugin
|
22
|
+
module Carbon
|
23
|
+
class Connection < FFWD::Connection
|
24
|
+
include FFWD::Logging
|
25
|
+
include EM::Protocols::LineText2
|
26
|
+
|
27
|
+
def self.plugin_type
|
28
|
+
"carbon_in"
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize bind, core
|
32
|
+
@bind = bind
|
33
|
+
@core = core
|
34
|
+
end
|
35
|
+
|
36
|
+
def parse(line)
|
37
|
+
path, value, timestamp = line.split ' ', 3
|
38
|
+
raise "invalid frame" if timestamp.nil?
|
39
|
+
|
40
|
+
return nil if path.empty? or value.empty? or timestamp.empty?
|
41
|
+
|
42
|
+
value = value.to_f unless value.nil?
|
43
|
+
time = Time.at(timestamp.to_i)
|
44
|
+
|
45
|
+
return {:key => path, :value => value, :time => time}
|
46
|
+
end
|
47
|
+
|
48
|
+
def receive_line(ln)
|
49
|
+
metric = parse(ln)
|
50
|
+
return if metric.nil?
|
51
|
+
@core.input.metric metric
|
52
|
+
@bind.increment :received_metrics
|
53
|
+
rescue => e
|
54
|
+
log.error "Failed to receive data", e
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# $LICENSE
|
2
|
+
# Copyright 2013-2014 Spotify AB. All rights reserved.
|
3
|
+
#
|
4
|
+
# The contents of this file are licensed under the Apache License, Version 2.0
|
5
|
+
# (the "License"); you may not use this file except in compliance with the
|
6
|
+
# License. You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
module FFWD
|
17
|
+
module Plugin
|
18
|
+
module Carbon
|
19
|
+
VERSION = "0.1.0"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ffwd-carbon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Martin Parm
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffwd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- parmus@spotify.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- lib/ffwd/plugin/carbon/connection.rb
|
35
|
+
- lib/ffwd/plugin/carbon/version.rb
|
36
|
+
- lib/ffwd/plugin/carbon.rb
|
37
|
+
homepage: https://github.com/spotify/ffwd
|
38
|
+
licenses:
|
39
|
+
- Apache 2.0
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.0.3
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Carbon support for FFWD.
|
61
|
+
test_files: []
|