honeycomb-beeline 2.1.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -1
- data/README.md +1 -0
- data/honeycomb-beeline.gemspec +1 -0
- data/lib/honeycomb/beeline/version.rb +1 -1
- data/lib/honeycomb/propagation.rb +4 -51
- data/lib/honeycomb/propagation/aws.rb +66 -0
- data/lib/honeycomb/propagation/honeycomb.rb +69 -0
- data/lib/honeycomb/propagation/w3c.rb +55 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 861b65eb2d7ef9f82cad990b966247465eebb0eac7ec4fa6d668491d979e9eee
|
4
|
+
data.tar.gz: 2e1b7ef3a15d2b2be27a4593eafabe399331909df925724abc3978cc47aed01c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b50cd4118393ff03349894bb4942bb166baafb51fdf587b76a5e8f1b34411d2a49c8698cc9bb8f28746211143f93bf88e5fc23de13479acbd526383f7065410d
|
7
|
+
data.tar.gz: f123f2ad239e1f72874199999d08a8b3137b318f1d92d9a295b3bfdb4d17d8097c3577ebca666e7b26d0d9d5940fe6b6db2ec92f9028dfbffa1740898e43281c
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
honeycomb-beeline (2.
|
4
|
+
honeycomb-beeline (2.2.0)
|
5
5
|
libhoney (~> 1.14, >= 1.14.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -19,6 +19,9 @@ GEM
|
|
19
19
|
byebug (10.0.2)
|
20
20
|
childprocess (0.9.0)
|
21
21
|
ffi (~> 1.0, >= 1.0.11)
|
22
|
+
codecov (0.2.8)
|
23
|
+
json
|
24
|
+
simplecov
|
22
25
|
coderay (1.1.2)
|
23
26
|
crack (0.4.3)
|
24
27
|
safe_yaml (~> 1.0.0)
|
@@ -43,6 +46,7 @@ GEM
|
|
43
46
|
ffi-compiler (>= 1.0, < 2.0)
|
44
47
|
iniparse (1.5.0)
|
45
48
|
jaro_winkler (1.5.4)
|
49
|
+
json (2.3.1)
|
46
50
|
libhoney (1.14.5)
|
47
51
|
addressable (~> 2.0)
|
48
52
|
http (>= 2.0, < 5.0)
|
@@ -113,6 +117,7 @@ DEPENDENCIES
|
|
113
117
|
appraisal
|
114
118
|
bump
|
115
119
|
bundler
|
120
|
+
codecov
|
116
121
|
honeycomb-beeline!
|
117
122
|
overcommit (~> 0.46.0)
|
118
123
|
pry (< 0.13.0)
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://circleci.com/gh/honeycombio/beeline-ruby)
|
4
4
|
[](https://badge.fury.io/rb/honeycomb-beeline)
|
5
|
+
[](https://codecov.io/gh/honeycombio/beeline-ruby)
|
5
6
|
|
6
7
|
This package makes it easy to instrument your Ruby web app to send useful events to [Honeycomb](https://www.honeycomb.io), a service for debugging your software in production.
|
7
8
|
- [Usage and Examples](https://docs.honeycomb.io/getting-data-in/beelines/ruby-beeline/)
|
data/honeycomb-beeline.gemspec
CHANGED
@@ -42,6 +42,7 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_development_dependency "appraisal"
|
43
43
|
spec.add_development_dependency "bump"
|
44
44
|
spec.add_development_dependency "bundler"
|
45
|
+
spec.add_development_dependency "codecov"
|
45
46
|
spec.add_development_dependency "overcommit", "~> 0.46.0"
|
46
47
|
spec.add_development_dependency "pry", "< 0.13.0"
|
47
48
|
spec.add_development_dependency "pry-byebug", "~> 3.6.0"
|
@@ -4,63 +4,16 @@ require "base64"
|
|
4
4
|
require "json"
|
5
5
|
require "uri"
|
6
6
|
|
7
|
+
require "honeycomb/propagation/honeycomb"
|
8
|
+
|
7
9
|
module Honeycomb
|
8
10
|
# Parse trace headers
|
9
11
|
module PropagationParser
|
10
|
-
|
11
|
-
unless serialized_trace.nil?
|
12
|
-
version, payload = serialized_trace.split(";", 2)
|
13
|
-
|
14
|
-
if version == "1"
|
15
|
-
trace_id, parent_span_id, trace_fields, dataset = parse_v1(payload)
|
16
|
-
|
17
|
-
if !trace_id.nil? && !parent_span_id.nil?
|
18
|
-
return [trace_id, parent_span_id, trace_fields, dataset]
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
[nil, nil, nil, nil]
|
24
|
-
end
|
25
|
-
|
26
|
-
def parse_v1(payload)
|
27
|
-
trace_id, parent_span_id, trace_fields, dataset = nil
|
28
|
-
payload.split(",").each do |entry|
|
29
|
-
key, value = entry.split("=", 2)
|
30
|
-
case key
|
31
|
-
when "dataset"
|
32
|
-
dataset = URI.decode_www_form_component(value)
|
33
|
-
when "trace_id"
|
34
|
-
trace_id = value
|
35
|
-
when "parent_id"
|
36
|
-
parent_span_id = value
|
37
|
-
when "context"
|
38
|
-
Base64.decode64(value).tap do |json|
|
39
|
-
begin
|
40
|
-
trace_fields = JSON.parse json
|
41
|
-
rescue JSON::ParserError
|
42
|
-
trace_fields = {}
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
[trace_id, parent_span_id, trace_fields, dataset]
|
49
|
-
end
|
12
|
+
include HoneycombPropagation::UnmarshalTraceContext
|
50
13
|
end
|
51
14
|
|
52
15
|
# Serialize trace headers
|
53
16
|
module PropagationSerializer
|
54
|
-
|
55
|
-
context = Base64.urlsafe_encode64(JSON.generate(trace.fields)).strip
|
56
|
-
encoded_dataset = URI.encode_www_form_component(builder.dataset)
|
57
|
-
data_to_propogate = [
|
58
|
-
"dataset=#{encoded_dataset}",
|
59
|
-
"trace_id=#{trace.id}",
|
60
|
-
"parent_id=#{id}",
|
61
|
-
"context=#{context}",
|
62
|
-
]
|
63
|
-
"1;#{data_to_propogate.join(',')}"
|
64
|
-
end
|
17
|
+
include HoneycombPropagation::MarshalTraceContext
|
65
18
|
end
|
66
19
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Honeycomb
|
4
|
+
# Parsing and propagation for AWS trace headers
|
5
|
+
module AWSPropagation
|
6
|
+
# Parse trace headers
|
7
|
+
module UnmarshalTraceContext
|
8
|
+
def parse(serialized_trace)
|
9
|
+
unless serialized_trace.nil?
|
10
|
+
split = serialized_trace.split(";")
|
11
|
+
|
12
|
+
trace_id, parent_span_id, trace_fields = get_fields(split)
|
13
|
+
|
14
|
+
parent_span_id = trace_id if parent_span_id.nil?
|
15
|
+
|
16
|
+
trace_fields = nil if trace_fields.empty?
|
17
|
+
|
18
|
+
if !trace_id.nil? && !parent_span_id.nil?
|
19
|
+
# return nil for dataset
|
20
|
+
return [trace_id, parent_span_id, trace_fields, nil]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
[nil, nil, nil, nil]
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_fields(fields)
|
28
|
+
trace_id, parent_span_id = nil
|
29
|
+
trace_fields = {}
|
30
|
+
fields.each do |entry|
|
31
|
+
key, value = entry.split("=", 2)
|
32
|
+
case key.downcase
|
33
|
+
when "root"
|
34
|
+
trace_id = value
|
35
|
+
when "self"
|
36
|
+
parent_span_id = value
|
37
|
+
when "parent"
|
38
|
+
parent_span_id = value if parent_span_id.nil?
|
39
|
+
else
|
40
|
+
trace_fields[key] = value unless key.empty?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
[trace_id, parent_span_id, trace_fields]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Serialize trace headers
|
49
|
+
module MarshalTraceContext
|
50
|
+
def to_trace_header
|
51
|
+
context = [""]
|
52
|
+
unless trace.fields.keys.nil?
|
53
|
+
trace.fields.keys.each do |key|
|
54
|
+
context.push("#{key}=#{trace.fields[key]}")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
data_to_propagate = [
|
59
|
+
"Root=#{trace.id}",
|
60
|
+
"Parent=#{id}",
|
61
|
+
]
|
62
|
+
"#{data_to_propagate.join(';')}#{context.join(';')}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "base64"
|
4
|
+
require "json"
|
5
|
+
require "uri"
|
6
|
+
|
7
|
+
module Honeycomb
|
8
|
+
# Parsing and propagation for honeycomb trace headers
|
9
|
+
module HoneycombPropagation
|
10
|
+
# Parse trace headers
|
11
|
+
module UnmarshalTraceContext
|
12
|
+
def parse(serialized_trace)
|
13
|
+
unless serialized_trace.nil?
|
14
|
+
version, payload = serialized_trace.split(";", 2)
|
15
|
+
|
16
|
+
if version == "1"
|
17
|
+
trace_id, parent_span_id, trace_fields, dataset = parse_v1(payload)
|
18
|
+
|
19
|
+
if !trace_id.nil? && !parent_span_id.nil?
|
20
|
+
return [trace_id, parent_span_id, trace_fields, dataset]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
[nil, nil, nil, nil]
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse_v1(payload)
|
29
|
+
trace_id, parent_span_id, trace_fields, dataset = nil
|
30
|
+
payload.split(",").each do |entry|
|
31
|
+
key, value = entry.split("=", 2)
|
32
|
+
case key.downcase
|
33
|
+
when "dataset"
|
34
|
+
dataset = URI.decode_www_form_component(value)
|
35
|
+
when "trace_id"
|
36
|
+
trace_id = value
|
37
|
+
when "parent_id"
|
38
|
+
parent_span_id = value
|
39
|
+
when "context"
|
40
|
+
Base64.decode64(value).tap do |json|
|
41
|
+
begin
|
42
|
+
trace_fields = JSON.parse json
|
43
|
+
rescue JSON::ParserError
|
44
|
+
trace_fields = {}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
[trace_id, parent_span_id, trace_fields, dataset]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Serialize trace headers
|
55
|
+
module MarshalTraceContext
|
56
|
+
def to_trace_header
|
57
|
+
context = Base64.urlsafe_encode64(JSON.generate(trace.fields)).strip
|
58
|
+
encoded_dataset = URI.encode_www_form_component(builder.dataset)
|
59
|
+
data_to_propogate = [
|
60
|
+
"dataset=#{encoded_dataset}",
|
61
|
+
"trace_id=#{trace.id}",
|
62
|
+
"parent_id=#{id}",
|
63
|
+
"context=#{context}",
|
64
|
+
]
|
65
|
+
"1;#{data_to_propogate.join(',')}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Honeycomb
|
4
|
+
# Parsing and propagation for W3C trace headers
|
5
|
+
module W3CPropagation
|
6
|
+
# Parse trace headers
|
7
|
+
module UnmarshalTraceContext
|
8
|
+
INVALID_TRACE_ID = "00000000000000000000000000000000".freeze
|
9
|
+
INVALID_SPAN_ID = "0000000000000000".freeze
|
10
|
+
|
11
|
+
def parse(serialized_trace)
|
12
|
+
unless serialized_trace.nil?
|
13
|
+
version, payload = serialized_trace.split("-", 2)
|
14
|
+
# version should be 2 hex characters
|
15
|
+
if version =~ /^[A-Fa-f0-9]{2}$/
|
16
|
+
trace_id, parent_span_id = parse_v1(payload)
|
17
|
+
|
18
|
+
if !trace_id.nil? && !parent_span_id.nil?
|
19
|
+
# return nil for dataset
|
20
|
+
return [trace_id, parent_span_id, nil, nil]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
[nil, nil, nil, nil]
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse_v1(payload)
|
28
|
+
trace_id, parent_span_id, trace_flags = payload.split("-", 3)
|
29
|
+
|
30
|
+
if trace_flags.nil?
|
31
|
+
# if trace_flags is nil, it means a field is missing
|
32
|
+
return [nil, nil]
|
33
|
+
end
|
34
|
+
|
35
|
+
if trace_id == INVALID_TRACE_ID || parent_span_id == INVALID_SPAN_ID
|
36
|
+
return [nil, nil]
|
37
|
+
end
|
38
|
+
|
39
|
+
[trace_id, parent_span_id]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Serialize trace headers
|
44
|
+
module MarshalTraceContext
|
45
|
+
def to_trace_header
|
46
|
+
# do not propagate malformed ids
|
47
|
+
if trace.id =~ /^[A-Fa-f0-9]{32}$/ && id =~ /^[A-Fa-f0-9]{16}$/
|
48
|
+
return "00-#{trace.id}-#{id}-01"
|
49
|
+
end
|
50
|
+
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: honeycomb-beeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Holman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libhoney
|
@@ -72,6 +72,20 @@ dependencies:
|
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: codecov
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
90
|
name: overcommit
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -259,6 +273,9 @@ files:
|
|
259
273
|
- lib/honeycomb/integrations/sinatra.rb
|
260
274
|
- lib/honeycomb/integrations/warden.rb
|
261
275
|
- lib/honeycomb/propagation.rb
|
276
|
+
- lib/honeycomb/propagation/aws.rb
|
277
|
+
- lib/honeycomb/propagation/honeycomb.rb
|
278
|
+
- lib/honeycomb/propagation/w3c.rb
|
262
279
|
- lib/honeycomb/rollup_fields.rb
|
263
280
|
- lib/honeycomb/span.rb
|
264
281
|
- lib/honeycomb/trace.rb
|