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

Commit

Permalink
Add metrics source info to the published file
Browse files Browse the repository at this point in the history
If m.Source() gives empty string, writes "unknown"
  • Loading branch information
IzabellaRaulin authored and pittma committed Oct 29, 2015
1 parent 3bd65c5 commit d68aacb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mgmt/rest/client/client_func_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func TestPulseClient(t *testing.T) {
Convey("invalid task (missing publisher)", func() {
tf := c.CreateTask(sch, wf, "baron", false)
So(tf.Err, ShouldNotBeNil)
So(tf.Err.Error(), ShouldContainSubstring, "Plugin not found: type(publisher) name(file) version(1)")
So(tf.Err.Error(), ShouldContainSubstring, "Plugin not found: type(publisher) name(file)")
})
Convey("plugin already loaded", func() {
p1 := c.LoadPlugin(DUMMY_PLUGIN_PATH1)
Expand Down
1 change: 0 additions & 1 deletion mgmt/rest/wmap_sample/1.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"publish": [
{
"plugin_name": "file",
"plugin_version": 1,
"config": {
"file": "/tmp/rest.test"
}
Expand Down
1 change: 0 additions & 1 deletion mgmt/rest/wmap_sample/bad.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"publish": [
{
"plugin_name": "file",
"plugin_version": 1,
"config": {
"file": "/tmp/rest.test"
}
Expand Down
6 changes: 5 additions & 1 deletion plugin/publisher/pulse-publisher-file/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ func (f *filePublisher) Publish(contentType string, content []byte, config map[s
}
w := bufio.NewWriter(file)
for _, m := range metrics {
w.WriteString(fmt.Sprintf("%v|%v|%v\n", time.Now().Local(), m.Namespace(), m.Data()))
source := m.Source()
if source == "" {
source = "unknown"
}
w.WriteString(fmt.Sprintf("%v|%v|%v|%v\n", time.Now().Local(), m.Namespace(), m.Data(), source))
}
w.Flush()

Expand Down

0 comments on commit d68aacb

Please sign in to comment.