Skip to content
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

Merged
merged 10 commits into from
Jan 21, 2019
Merged

Add carbon parser #1309

merged 10 commits into from
Jan 21, 2019

Conversation

richardartoul
Copy link
Contributor

@richardartoul richardartoul commented Jan 19, 2019

Most of the code is copy-pasta from out statsdex repo, I just removed some old migration cruft and cleaned things up a tad.

@codecov
Copy link

codecov bot commented Jan 19, 2019

Codecov Report

Merging #1309 into master will decrease coverage by 0.5%.
The diff coverage is 10.7%.

Impacted file tree graph

@@           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
Flag Coverage Δ
#aggregator 80.9% <ø> (ø) ⬆️
#cluster 85.6% <ø> (ø) ⬆️
#collector 78.4% <ø> (ø) ⬆️
#dbnode 80.9% <ø> (-0.1%) ⬇️
#m3em 57% <ø> (-16.2%) ⬇️
#m3ninx 74.6% <ø> (ø) ⬆️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 17.9% <0%> (-0.3%) ⬇️
#msg 74.9% <ø> (ø) ⬆️
#query 61.9% <ø> (ø) ⬆️
#x 76.2% <100%> (+0.3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65fadfe...66f6c62. Read the comment docs.

7 similar comments
@codecov
Copy link

codecov bot commented Jan 19, 2019

Codecov Report

Merging #1309 into master will decrease coverage by 0.5%.
The diff coverage is 10.7%.

Impacted file tree graph

@@           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
Flag Coverage Δ
#aggregator 80.9% <ø> (ø) ⬆️
#cluster 85.6% <ø> (ø) ⬆️
#collector 78.4% <ø> (ø) ⬆️
#dbnode 80.9% <ø> (-0.1%) ⬇️
#m3em 57% <ø> (-16.2%) ⬇️
#m3ninx 74.6% <ø> (ø) ⬆️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 17.9% <0%> (-0.3%) ⬇️
#msg 74.9% <ø> (ø) ⬆️
#query 61.9% <ø> (ø) ⬆️
#x 76.2% <100%> (+0.3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65fadfe...66f6c62. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 19, 2019

Codecov Report

Merging #1309 into master will decrease coverage by 0.5%.
The diff coverage is 10.7%.

Impacted file tree graph

@@           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
Flag Coverage Δ
#aggregator 80.9% <ø> (ø) ⬆️
#cluster 85.6% <ø> (ø) ⬆️
#collector 78.4% <ø> (ø) ⬆️
#dbnode 80.9% <ø> (-0.1%) ⬇️
#m3em 57% <ø> (-16.2%) ⬇️
#m3ninx 74.6% <ø> (ø) ⬆️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 17.9% <0%> (-0.3%) ⬇️
#msg 74.9% <ø> (ø) ⬆️
#query 61.9% <ø> (ø) ⬆️
#x 76.2% <100%> (+0.3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65fadfe...66f6c62. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 19, 2019

Codecov Report

Merging #1309 into master will decrease coverage by 0.5%.
The diff coverage is 10.7%.

Impacted file tree graph

@@           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
Flag Coverage Δ
#aggregator 80.9% <ø> (ø) ⬆️
#cluster 85.6% <ø> (ø) ⬆️
#collector 78.4% <ø> (ø) ⬆️
#dbnode 80.9% <ø> (-0.1%) ⬇️
#m3em 57% <ø> (-16.2%) ⬇️
#m3ninx 74.6% <ø> (ø) ⬆️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 17.9% <0%> (-0.3%) ⬇️
#msg 74.9% <ø> (ø) ⬆️
#query 61.9% <ø> (ø) ⬆️
#x 76.2% <100%> (+0.3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65fadfe...66f6c62. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 19, 2019

Codecov Report

Merging #1309 into master will decrease coverage by 0.5%.
The diff coverage is 10.7%.

Impacted file tree graph

@@           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
Flag Coverage Δ
#aggregator 80.9% <ø> (ø) ⬆️
#cluster 85.6% <ø> (ø) ⬆️
#collector 78.4% <ø> (ø) ⬆️
#dbnode 80.9% <ø> (-0.1%) ⬇️
#m3em 57% <ø> (-16.2%) ⬇️
#m3ninx 74.6% <ø> (ø) ⬆️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 17.9% <0%> (-0.3%) ⬇️
#msg 74.9% <ø> (ø) ⬆️
#query 61.9% <ø> (ø) ⬆️
#x 76.2% <100%> (+0.3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65fadfe...66f6c62. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 19, 2019

Codecov Report

Merging #1309 into master will decrease coverage by 0.5%.
The diff coverage is 10.7%.

Impacted file tree graph

@@           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
Flag Coverage Δ
#aggregator 80.9% <ø> (ø) ⬆️
#cluster 85.6% <ø> (ø) ⬆️
#collector 78.4% <ø> (ø) ⬆️
#dbnode 80.9% <ø> (-0.1%) ⬇️
#m3em 57% <ø> (-16.2%) ⬇️
#m3ninx 74.6% <ø> (ø) ⬆️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 17.9% <0%> (-0.3%) ⬇️
#msg 74.9% <ø> (ø) ⬆️
#query 61.9% <ø> (ø) ⬆️
#x 76.2% <100%> (+0.3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65fadfe...66f6c62. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 19, 2019

Codecov Report

Merging #1309 into master will decrease coverage by 0.5%.
The diff coverage is 10.7%.

Impacted file tree graph

@@           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
Flag Coverage Δ
#aggregator 80.9% <ø> (ø) ⬆️
#cluster 85.6% <ø> (ø) ⬆️
#collector 78.4% <ø> (ø) ⬆️
#dbnode 80.9% <ø> (-0.1%) ⬇️
#m3em 57% <ø> (-16.2%) ⬇️
#m3ninx 74.6% <ø> (ø) ⬆️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 17.9% <0%> (-0.3%) ⬇️
#msg 74.9% <ø> (ø) ⬆️
#query 61.9% <ø> (ø) ⬆️
#x 76.2% <100%> (+0.3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65fadfe...66f6c62. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 19, 2019

Codecov Report

Merging #1309 into master will decrease coverage by 0.5%.
The diff coverage is 10.7%.

Impacted file tree graph

@@           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
Flag Coverage Δ
#aggregator 80.9% <ø> (ø) ⬆️
#cluster 85.6% <ø> (ø) ⬆️
#collector 78.4% <ø> (ø) ⬆️
#dbnode 80.9% <ø> (-0.1%) ⬇️
#m3em 57% <ø> (-16.2%) ⬇️
#m3ninx 74.6% <ø> (ø) ⬆️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 17.9% <0%> (-0.3%) ⬇️
#msg 74.9% <ø> (ø) ⬆️
#query 61.9% <ø> (ø) ⬆️
#x 76.2% <100%> (+0.3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65fadfe...66f6c62. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 19, 2019

Codecov Report

Merging #1309 into master will decrease coverage by 0.1%.
The diff coverage is 0%.

Impacted file tree graph

@@           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
Flag Coverage Δ
#aggregator 80.9% <ø> (ø) ⬆️
#cluster 85.6% <ø> (ø) ⬆️
#collector 78.4% <ø> (ø) ⬆️
#dbnode 80.9% <ø> (-0.1%) ⬇️
#m3em 73.2% <ø> (ø) ⬆️
#m3ninx 74.6% <ø> (ø) ⬆️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 17.8% <0%> (-0.4%) ⬇️
#msg 74.9% <ø> (ø) ⬆️
#query 61.9% <ø> (ø) ⬆️
#x 75.9% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65fadfe...2c38b8b. Read the comment docs.

// 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{}
Copy link
Collaborator

@robskillington robskillington Jan 21, 2019

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) {}

timestamp time.Time
path []byte
value float64
recv time.Time
Copy link
Collaborator

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.

if val := strings.ToLower(s[valStart:valEnd]); val == negativeNanStr || val == nanStr {
value = mathNan
} else {
value, err = strconv.ParseFloat(s[valStart:valEnd], 64)
Copy link
Collaborator

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?

// allocating a string.
var tsInSecs int64
unsafe.WithString(rest, func(s string) {
tsInSecs, err = strconv.ParseInt(s[secStart:secEnd], 10, 64)
Copy link
Collaborator

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?

Copy link
Collaborator

@robskillington robskillington left a 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

@richardartoul richardartoul merged commit bcf5dd1 into master Jan 21, 2019
@justinjc justinjc deleted the ra/carbon branch January 22, 2019 15:49
robskillington pushed a commit that referenced this pull request Jan 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants