-
Notifications
You must be signed in to change notification settings - Fork 6
Conversation
README.md
Outdated
|
||
Terminal 2: | ||
1. `echo "test.first 10 `date +%s`"|nc -c localhost <number from TCP listener>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the form of presentation:
current: echo "test.first 10
date +%s"|nc -c localhost <number from TCP listener>
suggested: echo "test.first 10 `date +%s`"|nc -c localhost <number from TCP listener>
README.md
Outdated
## How to test streaming plugin without Snap: | ||
Terminal 1: | ||
1. `cd relay-plugin` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean snap-relay
?
client/main.go
Outdated
log.Fields{ | ||
"metric": metric, | ||
}, | ||
).Debug("recieved metric") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo -> received
main.go
Outdated
/* | ||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
|
||
Copyright 2015 Intel Corporation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a new file - there should be 2017
relay/relay.go
Outdated
@@ -0,0 +1,122 @@ | |||
/* | |||
http://www.apache.org/licenses/LICENSE-2.0.txt | |||
Copyright 2016 Intel Corporation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a new file - should be 2017
relay/relay.go
Outdated
"github.com/intelsdi-x/snap-relay/graphite" | ||
) | ||
|
||
//TODO rename :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this "Todo" still valid?
relay/relay.go
Outdated
log.Fields{ | ||
"len(metrics)": len(metrics), | ||
}, | ||
).Debug("recieved metrics") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo -> received
Missing glide files To inform others - glides files have not been added until related PR (in snap-plugin-lib-go) will be merged to master |
@@ -144,6 +168,7 @@ func (g *graphite) stop() { | |||
} | |||
|
|||
func parse(data string) *plugin.Metric { | |||
data = strings.Trim(data, "\r") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@kjlyon, good catch! According to your question:
"-1" means: take the latest version of the plugin. In this case, this error message means that there is no influxdb publisher loaded. |
As an interesting follow up to my previous comment, that behavior occurs when I:
I get a different error when I do this:
It's interesting the difference I'm seeing between when @IzabellaRaulin what could be causing the different errors from when I unload relay and then stop the task vs when I unload influxdb then stop the task? |
hello @kjlyon, I am quite confused why running task does not change its status to disabled after plugin-in-use was unloaded. Besides that, could you tell me how you unload snap-relay plugin? I mean that
Defined flow for regular (I mean not streaming) plugin looks like below:
I reproduced your case with snap-relay plugin. As a first thing, I confirmed that unsubscription works fine in straightforward mechanism: stop running task and then start it again. So, it needs to be checked what happens during unloading streaming collector. I will look on that and let you know. FYI, I opened the issue addressing disunity in behavior across different type of plugins - intelsdi-x/snap#1659 |
) | ||
|
||
type tcpListener struct { | ||
port *int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jcooklin, why the port
is a pointer to int?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IzabellaRaulin, this has to remain a pointer to an int. The problem roots back to lines 37-38 of main.go. These two lines are evaluated before the cli has a chance to evaluate the flags. Thus the lines are evaluated with the default values and any value being passed in through flags is not being set in time. Having port
as a pointer to an int solves this problem, as the value that is being pointed to can be changed once the flags are evaluated.
From what I have found, it is not possible to have port
be an int. Please let me know if you find another way or if it is okay leaving it this way.
tcpAddr, err := net.ResolveTCPAddr("tcp", "localhost:0") | ||
addr := fmt.Sprintf("%v:0", plugin.ListenAddr) | ||
if t.port != nil { | ||
addr = fmt.Sprintf("%v:%v", plugin.ListenAddr, *t.port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider declaring t.port
as an int, so here the lines (81-82) would be changed into a single one:
addr = fmt.Sprintf("%v:%v", plugin.ListenAddr, t.port)
) | ||
|
||
type udpListener struct { | ||
port *int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
"udp", | ||
fmt.Sprintf("%v:%v", | ||
plugin.ListenAddr, | ||
*u.port, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the present state, *u.port might be "nil" - there is no check here (in comparison to the implementation of similar functionality for TCP) - please look on that. Also, changing declaration of u.port
as int
instead of *int
might be taken into consideration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible to get nil pointer dereference here
relay/relay.go
Outdated
for _, val := range vals { | ||
metric := plugin.Metric{ | ||
Namespace: plugin.NewNamespace("relay", val), | ||
Version: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend using pluginVersion
here to make this easier to manage in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
relay/relay.go
Outdated
|
||
policy.AddNewStringRule([]string{"relay", "collectd"}, | ||
"graphite", | ||
false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jcooklin, what can be provided as a value of "graphite" config option? It's not required, even there is no default value - it's not clear for me. It would be great if you can explain it. Thank You
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The graphite config option can be provided as a flag when starting the relay. There are default values for both TCP and UDP here.
relay/relay.go
Outdated
|
||
policy.AddNewStringRule([]string{"relay", "statsd"}, | ||
"statsd", | ||
false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above - it's not clear what can be passed via this config option.
cfg.AddItem("MaxMetricsBuffer", ctypes.ConfigValueInt{Value: 2}) | ||
requested_metrics := []core.Metric{ | ||
plugin.MetricType{ | ||
Namespace_: core.NewNamespace("relay", "collectd"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I see we didn't have relay for collectd. It is just graphite relay present here. Shouldn't the namespace consist of it instead of collectd?
limitations under the License. | ||
*/ | ||
|
||
package main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is ok to get 2 packages and functions main in the same repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know for sure. Though I kept it as a main package because that's how I run the client for testing purposes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's OK AFAIK.
).Debug("received metrics") | ||
|
||
//assign port values if any passed in | ||
if metric.Namespace[len(metric.Namespace)-1].Value == "collectd" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
graphite?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a subjective decision IMO. Since the primary intent was to communicate as clearly the ability to integrate snap into environments with collectd I choose to stick with collectd in the namespace knowing that the write_graphite plugin in collectd would be used. This being said I can see an argument for changing the namesapce and all references of collectd to graphite in this relay.
func (r *relay) GetConfigPolicy() (plugin.ConfigPolicy, error) { | ||
policy := plugin.NewConfigPolicy() | ||
|
||
policy.AddNewStringRule([]string{"relay", "collectd"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
graphite?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it should be graphite here instead of collectd, should it also be graphite on line 139 in place of statsd?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends. Statsd relay was wrote to support statsd utility in repeater mode - statsd passes through messages sent by user. If we configure statsd to run with graphite it will behave same as collectd relay
@kjlyon, please squash commits before merging it |
- Added core functions to relay.go - Create Client for testing purposes - Adds graphite UDP and TCP flags - Add capability for the relay to set MaxCollectDuration and MaxMetricsBuffer - Support for simultaneous streams - Renamed relay package to protocol for clarity
The docker-compose file and task used in this demo can be found here.
Note: this PR requires the latest commits from intelsdi-x/snap-plugin-lib-go#85