forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prints the delta since the last period, if it's non-zero. The idea is to help with troubleshooting while still creating relatively little output in the logs. 30s seems like a good compromise. Part of/related to elastic#1931
- Loading branch information
Tudor Golubenco
committed
Jul 5, 2016
1 parent
fefa0f3
commit b378ed8
Showing
11 changed files
with
205 additions
and
0 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
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,57 @@ | ||
// +build !integration | ||
|
||
package logp | ||
|
||
import ( | ||
"expvar" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSnapshotExpvars(t *testing.T) { | ||
test := expvar.NewInt("test") | ||
test.Add(42) | ||
|
||
vals := map[string]int64{} | ||
snapshotExpvars(vals) | ||
|
||
assert.Equal(t, vals["test"], int64(42)) | ||
} | ||
|
||
func TestBuildMetricsOutput(t *testing.T) { | ||
test := expvar.NewInt("testLog") | ||
test.Add(1) | ||
|
||
prevVals := map[string]int64{} | ||
snapshotExpvars(prevVals) | ||
|
||
test.Add(5) | ||
|
||
vals := map[string]int64{} | ||
snapshotExpvars(vals) | ||
|
||
metrics := buildMetricsOutput(prevVals, vals) | ||
assert.Equal(t, " testLog=5", metrics) | ||
prevVals = vals | ||
|
||
test.Add(3) | ||
vals = map[string]int64{} | ||
snapshotExpvars(vals) | ||
metrics = buildMetricsOutput(prevVals, vals) | ||
assert.Equal(t, " testLog=3", metrics) | ||
} | ||
|
||
func TestBuildMetricsOutputMissing(t *testing.T) { | ||
|
||
prevVals := map[string]int64{} | ||
snapshotExpvars(prevVals) | ||
|
||
test := expvar.NewInt("testLogEmpty") | ||
test.Add(7) | ||
|
||
vals := map[string]int64{} | ||
snapshotExpvars(vals) | ||
metrics := buildMetricsOutput(prevVals, vals) | ||
assert.Equal(t, " testLogEmpty=7", metrics) | ||
} |
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