-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add carbon parser #1309
Add carbon parser #1309
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1309 +/- ##
========================================
- Coverage 70.8% 70.3% -0.6%
========================================
Files 769 771 +2
Lines 64590 64702 +112
========================================
- Hits 45789 45493 -296
- Misses 15839 16269 +430
+ Partials 2962 2940 -22
Continue to review full report at Codecov.
|
7 similar comments
Codecov Report
@@ Coverage Diff @@
## master #1309 +/- ##
========================================
- Coverage 70.8% 70.3% -0.6%
========================================
Files 769 771 +2
Lines 64590 64702 +112
========================================
- Hits 45789 45493 -296
- Misses 15839 16269 +430
+ Partials 2962 2940 -22
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1309 +/- ##
========================================
- Coverage 70.8% 70.3% -0.6%
========================================
Files 769 771 +2
Lines 64590 64702 +112
========================================
- Hits 45789 45493 -296
- Misses 15839 16269 +430
+ Partials 2962 2940 -22
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1309 +/- ##
========================================
- Coverage 70.8% 70.3% -0.6%
========================================
Files 769 771 +2
Lines 64590 64702 +112
========================================
- Hits 45789 45493 -296
- Misses 15839 16269 +430
+ Partials 2962 2940 -22
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1309 +/- ##
========================================
- Coverage 70.8% 70.3% -0.6%
========================================
Files 769 771 +2
Lines 64590 64702 +112
========================================
- Hits 45789 45493 -296
- Misses 15839 16269 +430
+ Partials 2962 2940 -22
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1309 +/- ##
========================================
- Coverage 70.8% 70.3% -0.6%
========================================
Files 769 771 +2
Lines 64590 64702 +112
========================================
- Hits 45789 45493 -296
- Misses 15839 16269 +430
+ Partials 2962 2940 -22
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1309 +/- ##
========================================
- Coverage 70.8% 70.3% -0.6%
========================================
Files 769 771 +2
Lines 64590 64702 +112
========================================
- Hits 45789 45493 -296
- Misses 15839 16269 +430
+ Partials 2962 2940 -22
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1309 +/- ##
========================================
- Coverage 70.8% 70.3% -0.6%
========================================
Files 769 771 +2
Lines 64590 64702 +112
========================================
- Hits 45789 45493 -296
- Misses 15839 16269 +430
+ Partials 2962 2940 -22
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1309 +/- ##
========================================
- Coverage 70.8% 70.7% -0.2%
========================================
Files 769 770 +1
Lines 64590 64714 +124
========================================
- Hits 45789 45787 -2
- Misses 15839 15963 +124
- Partials 2962 2964 +2
Continue to review full report at Codecov.
|
src/metrics/carbon/parser.go
Outdated
// ParsePacket parses a carbon packet and returns the metrics and number of malformed lines. | ||
func ParsePacket(packet []byte) ([]Metric, int) { | ||
var malformed, prevIdx, i int | ||
mets := []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.
Maybe make this a param to pass in? So we can pool the slices.
Can split up into two methods to make both the nice and the efficient APIs available:
func ParsePacket(packet []byte) ([]Metric, int) {}
func AppendAndParsePacket(slice []Metric, packet []byte) ([]Metric, int) {}
src/metrics/carbon/parser.go
Outdated
timestamp time.Time | ||
path []byte | ||
value float64 | ||
recv time.Time |
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.
Can remove recv
, not used.
src/metrics/carbon/parser.go
Outdated
if val := strings.ToLower(s[valStart:valEnd]); val == negativeNanStr || val == nanStr { | ||
value = mathNan | ||
} else { | ||
value, err = strconv.ParseFloat(s[valStart:valEnd], 64) |
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.
nit: Replace 64
with floatBitSize
?
src/metrics/carbon/parser.go
Outdated
// allocating a string. | ||
var tsInSecs int64 | ||
unsafe.WithString(rest, func(s string) { | ||
tsInSecs, err = strconv.ParseInt(s[secStart:secEnd], 10, 64) |
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.
nit: Add a const intBitSize = 64
and use the existing intBase
?
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.
LGTM other than nits
Most of the code is copy-pasta from out statsdex repo, I just removed some old migration cruft and cleaned things up a tad.