-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from maier/master
v0.0.39 [CIRC-7530]
- Loading branch information
Showing
13 changed files
with
1,098 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package circhttpjson | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func TestCHJ_hasStreamtags(t *testing.T) { | ||
testDir := "testdata" | ||
tests := []struct { | ||
name string | ||
file string | ||
wantErr bool | ||
}{ | ||
{"invalid json -- empty", filepath.Join(testDir, "invalid1.json"), true}, | ||
{"invalid json -- no metrics", filepath.Join(testDir, "invalid2.json"), true}, | ||
// the following format is valid for the broker, it is not valid for this plugin | ||
{"invalid json -- non-streamtag", filepath.Join(testDir, "invalid3.json"), true}, | ||
{"invalid json -- non-streamtag idb sample", filepath.Join(testDir, "untagged-stats.json"), true}, | ||
{"valid", filepath.Join(testDir, "valid1.json"), false}, | ||
{"valid w/ts", filepath.Join(testDir, "valid2.json"), false}, | ||
{"valid -- idb sample", filepath.Join(testDir, "tagged-stats.json"), false}, | ||
} | ||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
chj := &CHJ{} | ||
data, err := os.ReadFile(tt.file) | ||
if err != nil { | ||
t.Fatalf("reading %s", err) | ||
} | ||
if err := chj.hasStreamtags(data); (err != nil) != tt.wantErr { | ||
t.Errorf("CHJ.hasStreamtags() error = %v, wantErr %v", err, tt.wantErr) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package circhttpjson | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/circonus-labs/circonus-unified-agent/cua" | ||
) | ||
|
||
// Logshim is for retryablehttp | ||
type Logshim struct { | ||
logh cua.Logger | ||
prefix string | ||
debug bool | ||
} | ||
|
||
func (l Logshim) Printf(fmt string, args ...interface{}) { | ||
if strings.Contains(fmt, "[DEBUG]") { | ||
// for retryablehttp (it only logs using Printf, and everything is DEBUG) | ||
if l.debug { | ||
l.logh.Infof(l.prefix+": "+fmt, args...) | ||
} | ||
} else { | ||
l.logh.Infof(l.prefix+": "+fmt, args...) | ||
} | ||
} | ||
func (l Logshim) Debugf(fmt string, args ...interface{}) { | ||
l.logh.Debugf(l.prefix+": "+fmt, args...) | ||
} | ||
func (l Logshim) Infof(fmt string, args ...interface{}) { | ||
l.logh.Infof(l.prefix+": "+fmt, args...) | ||
} | ||
func (l Logshim) Warnf(fmt string, args ...interface{}) { | ||
l.logh.Warnf(l.prefix+": "+fmt, args...) | ||
} | ||
func (l Logshim) Errorf(fmt string, args ...interface{}) { | ||
l.logh.Errorf(l.prefix+": "+fmt, args...) | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"number": 1.23, | ||
"bignum_as_string": "281474976710656", | ||
"test": "a text string", | ||
"container": { | ||
"key1": 1234 | ||
}, | ||
"array": [ | ||
1234, | ||
"string", | ||
{ | ||
"crazy": "like a fox" | ||
} | ||
] | ||
} |
Oops, something went wrong.