Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Enable streaming collector #85

Merged
merged 1 commit into from
Jun 17, 2017

Conversation

jcooklin
Copy link
Collaborator

@jcooklin jcooklin commented May 11, 2017

img
The docker-compose file and task used in this demo can be found here.

TODO:

  • update example (currently hits are not reflected)

if err != nil {
log.Fatal(err)
}
}()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcooklin, could you provide me more details regardings those changes in func (p *StreamProxy) StreamMetrics()? It seems that this cause that streaming rand collector does not work as expected - running task still has Hits = 0.

app = cli.NewApp()
app.Flags = []cli.Flag{
// Flags required by the plugin lib flags - plugin authors can provide their
// own flags.
Copy link
Contributor

@IzabellaRaulin IzabellaRaulin Jun 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to point here to snap-plugin-collector-rand/rand/rand.go as a place where the example of usage (I mean adding a flag in the plugin) can be found.


s, err := stream.Recv()
if err != nil {
log.Debug(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcooklin , could you confirm this log should stay on debug level, or maybe "error" would be more appropriate here? What do you think about keeping the same pattern and defining log with the field "_block".

@@ -606,6 +617,26 @@ func printPreambleAndServe(srv server, m *meta, p *pluginProxy, port string, isP
return string(preambleJSON), nil
}

// getAddr if we were provided the addr 0.0.0.0 we need to determine the
// address we will advertise to the framework in the premable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in "premable" -> "preamble"

@IzabellaRaulin
Copy link
Contributor

IzabellaRaulin commented Jun 6, 2017

I noticed that I got log error twice:

$ ./snap-streaming --addr 119.50.30.3 --port 30 --stand-alone --stand-alone-port 8185 --log-level 5

ERRO[0000] listen tcp 119.50.30.3:30: bind: cannot assign requested address
ERRO[0000] listen tcp 119.50.30.3:30: bind: cannot assign requested address

I found out that this line duplicates log from here. @jcooklin, I will prepare a PR to your repo with the fix of this small issue
-> jcooklin#7

@@ -573,7 +580,7 @@ func printPreambleAndServe(srv server, m *meta, p *pluginProxy, port string, isP
}
l.Close()

addr := fmt.Sprintf("127.0.0.1:%v", l.Addr().(*net.TCPAddr).Port)
addr := fmt.Sprintf("%s:%v", grpcListenAddr, l.Addr().(*net.TCPAddr).Port)
Copy link
Contributor

@IzabellaRaulin IzabellaRaulin Jun 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pondering if lines above (577-581) should be also refactored based on the fact that determined own grpcListenAddress (different than localhost) is now possible.

This is the scenarios that I've tested.:
a) (OK) set unavailable address with port 30 (notice that the port is available on my localhost):

$ ./snap-streaming --addr 119.50.30.3 --port 30  (of course in standalone mode)
ERRO[0000] listen tcp 119.50.30.3:30: bind: cannot assign requested address  _block=StartStreanCollector

b) (NOT AS EXPECTED) set unavailable address with port 8181 (notice that the port is already in use on my localhost):

$ ./snap-streaming --addr 119.50.30.3 --port 8181  
ERRO[0000] listen tcp :8181: bind: address already in use 

In this "b" case I expected to get listen tcp 119.50.30.3:8181: bind: cannot assign requested address. In this case checking if provided port is available or not in localhost should not happen.

@IzabellaRaulin
Copy link
Contributor

@jcooklin - is there any plan to refactor examplary stest-rand-streamer? Together with these changes, the plugin does not work as expected - no Hits, no Misses

@jcooklin
Copy link
Collaborator Author

jcooklin commented Jun 6, 2017

is there any plan to refactor examplary stest-rand-streamer?

@IzabellaRaulin: Yes, before it lands the existing example should work as expected.

@IzabellaRaulin
Copy link
Contributor

IzabellaRaulin commented Jun 6, 2017

Yes, before it lands the existing example should work as expected

It's great. Could you add "todo" checklist with that in the pull request description - if there are any other things which need to be done before it lands, please add them as well. Thanks

resp := preamble{
Meta: *m,
ListenAddress: addr,
ListenAddress: fmt.Sprintf("%v:%v", advertisedAddr, l.Addr().(*net.TCPAddr).Port),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the listening address be separate from advertised address?

Here grpcListenAddr (--addr) is used both as -advertised address (reported in preamble) and -listening address net.Listen("tcp", addr).
It does matter in case a qualified domain name is added (in contrast to giving an ip). Then user doesn't have explicit control over address resolution, see also description for net.Listen.

@marcintao
Copy link
Contributor

@jcooklin it came to me that default port for plugin advertisement is the same as snapteld's default API port ==8181. Just to be sure: was it intentional to start http listeners on the same port for framework and plugins?

@jcooklin
Copy link
Collaborator Author

@marcintao this is addressed in 1e1089e.

@jcooklin
Copy link
Collaborator Author

258efba updates the example.

jun-15-2017 20-45-03

@@ -20,7 +20,7 @@ limitations under the License.
package main

import (
"github.com/intelsdi-x/snap-plugin-lib-go/examples/streaming/rand"
"github.com/intelsdi-x/snap-plugin-lib-go/examples/snap-plugin-collector-rand-streaming/rand"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on that, some changes are needed in links in README.md - for example here: https://github.com/intelsdi-x/snap-plugin-lib-go/blob/master/examples/streaming/README.md#ready-to-share:
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcooklin, I made PR with fix to your repo: jcooklin#10

@IzabellaRaulin
Copy link
Contributor

I do not why the behavior of aggregation by maxMetricsBuffer has changed - it does not work as I expected (and it does not work as before). As a user, I expect to get aggregated metrics when I request to collect single metrics and set maxMetricsBuffer to 2 (assuming that maxCollectDuration is not exceeded), I expect to get 2 metrics with different timestamp sending to snap framework together, not one by one. Below is a task manifest which I used:

{
    "version": 1,
    "schedule": {
        "type": "streaming"
    },
 "start": true,
  "max-failures": 10,
  "max-collect-duration": "10s",
  "max-metrics-buffer": 2,
    "workflow": {
        "collect": {
            "metrics": {
                "/random/integer": {}
            },
            "publish": [
        {
          "plugin_name": "file",
          "config": {
            "file": "/tmp/published_streaming.log"
          }
        }
           ]
        }
    }
}

@IzabellaRaulin
Copy link
Contributor

Ok, so then it LGTM.

Copy link
Contributor

@IzabellaRaulin IzabellaRaulin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please squash your commit into single one

@jcooklin jcooklin force-pushed the fb/enables-streaming branch from 7e1f8c8 to 0e78d6b Compare June 16, 2017 23:54
@jcooklin jcooklin force-pushed the fb/enables-streaming branch from 0e78d6b to 3a91475 Compare June 17, 2017 00:11
@jcooklin jcooklin merged commit 25d0f6c into intelsdi-x:master Jun 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants