signalfx-tracing 1.4.3 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +9 -7
- data/bin/sfx-rb-trace-bootstrap +2 -2
- data/gem.deps.rb +3 -3
- data/lib/signalfx/tracing.rb +51 -27
- data/lib/signalfx/tracing/span.rb +27 -0
- data/lib/signalfx/tracing/tracer.rb +9 -1
- data/lib/signalfx/tracing/version.rb +1 -1
- data/signalfx-tracing.gemspec +6 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb69751bf1eff41423dfb43a0470b00194ee39ca02cd1647eecbe845e31e0472
|
4
|
+
data.tar.gz: c3d1bb44a2fda8b7aa96b68ed98be8e1d6a23a502f570e7e04eb5ef42f413b1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 977d6e639a0bd2098d23147cee9de114fca97e8156f67e186775a457c380a11ac52169765c3a5d796f170b89e8f4c04971366f6382428ddc4a015ccd8de1df33
|
7
|
+
data.tar.gz: c475b7183dcd21489595eb46d0168550b0b0f4b40bf0a9e8fe1f2f6321b9a4e5feee53913c93ba73d746f1ad3c6b89fd3cc4c1aa0f921542554ebf951f533cd0
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -29,12 +29,12 @@ Here are the requirements and supported software for the library.
|
|
29
29
|
| [ActiveRecord](#active-record) | activerecord-opentracing | ~> 5.0 |
|
30
30
|
| [Elasticsearch](#elasticsearch) | signalfx-elasticsearch-instrumentation | >= 6.0.2 |
|
31
31
|
| [Faraday](#faraday) | signalfx-faraday-instrumentation | >= 0.9.0 |
|
32
|
-
| [Grape](#grape) | grape-instrumentation | >= 0.
|
32
|
+
| [Grape](#grape) | grape-instrumentation | >= 0.2.0 |
|
33
33
|
| [Mongo](#mongo) | mongodb-instrumentation | >= 2.1.0 |
|
34
34
|
| [Mysql2](#mysql2) | mysql2-instrumentation | >= 0.4.0 |
|
35
35
|
| [Net::HTTP](#nethttp) | nethttp-instrumentation | Ruby >= 2.0 |
|
36
36
|
| [Pg](#pg) | pg-instrumentation | >= 0.18.0 |
|
37
|
-
| [Rack](#rack) | rack-tracer
|
37
|
+
| [Rack](#rack) | sfx-rack-tracer | >= 0.10.0 |
|
38
38
|
| [Rails](#rails) | rails-instrumentation | >= 3.0.0 |
|
39
39
|
| [Redis](#redis) | redis-instrumentation | >= 4.0.0 |
|
40
40
|
| [RestClient](#restclient) | restclient-instrumentation | >= 1.5.0 |
|
@@ -44,7 +44,7 @@ Here are the requirements and supported software for the library.
|
|
44
44
|
|
45
45
|
Instrumentation for routes using Puma or Passenger is provided through
|
46
46
|
Rack. If you use a framework that builds on top of Rack, such as Rails or
|
47
|
-
Sinatra, install the `rack-tracer` instrumentation with your dependency manager
|
47
|
+
Sinatra, install the `sfx-rack-tracer` instrumentation with your dependency manager
|
48
48
|
or with the bootstrap utility. In these cases, the routes through the web
|
49
49
|
server are automatically traced.
|
50
50
|
|
@@ -120,8 +120,10 @@ If the default configuration values don't apply for your environment, override t
|
|
120
120
|
| ingest_url | SIGNALFX_ENDPOINT_URL | `http://localhost:9080/v1/trace` | The endpoint the tracer sends spans to. Send spans to a Smart Agent, OpenTelemetry Collector, or a SignalFx ingest endpoint. |
|
121
121
|
| service_name | SIGNALFX_SERVICE_NAME | `signalfx-ruby-tracing` | The name to identify the service in SignalFx. |
|
122
122
|
| access_token | SIGNALFX_ACCESS_TOKEN | `''` | The SignalFx organization access token. |
|
123
|
+
| span_tags | SIGNALFX_SPAN_TAGS | `nil` | Comma-separated list of tags included in every reported span. For example, "key1:val1,key2:val2". Use only string values for tags.|
|
123
124
|
| N/A | SIGNALFX_RECORDED_VALUE_MAX_LENGTH | `1200` | Maximum length an attribute value can have. Values longer than this are truncated. |
|
124
125
|
|
126
|
+
|
125
127
|
### Automatically instrument code:
|
126
128
|
|
127
129
|
Configure the auto-instrumentor to check for modules defined in the code and
|
@@ -369,12 +371,12 @@ end
|
|
369
371
|
```
|
370
372
|
### Rack
|
371
373
|
|
372
|
-
Rack spans are created using the `rack-tracer` gem. This is enabled
|
374
|
+
Rack spans are created using the `sfx-rack-tracer` gem. This is enabled
|
373
375
|
automatically for other frameworks that are built on top of Rack, but it can
|
374
376
|
also be separately enabled.
|
375
377
|
|
376
378
|
The source for this instrumentation is located
|
377
|
-
[here](https://github.com/
|
379
|
+
[here](https://github.com/signalfx/ruby-rack-tracer).
|
378
380
|
|
379
381
|
#### Usage
|
380
382
|
|
@@ -394,7 +396,7 @@ use Rack::Tracer
|
|
394
396
|
### Rails
|
395
397
|
|
396
398
|
Rails applications can be traced using the notifications provided by ActiveSupport.
|
397
|
-
It will use `rack-tracer` to trace by requests.
|
399
|
+
It will use `sfx-rack-tracer` to trace by requests.
|
398
400
|
|
399
401
|
The forked source for this instrumentation is located
|
400
402
|
[here](https://github.com/signalfx/ruby-rails-instrumentation).
|
@@ -541,7 +543,7 @@ Arguments:
|
|
541
543
|
### Sinatra
|
542
544
|
|
543
545
|
Sinatra instrumentation traces requests and template rendering. The instrumenter
|
544
|
-
registers a Sinatra extension that uses `rack-tracer` to trace requests and
|
546
|
+
registers a Sinatra extension that uses `sfx-rack-tracer` to trace requests and
|
545
547
|
monkey-patches to trace view rendering. Rack instrumentation is automatically
|
546
548
|
enabled when using Sinatra instrumentation.
|
547
549
|
|
data/bin/sfx-rb-trace-bootstrap
CHANGED
@@ -7,12 +7,12 @@ instrumentations = {
|
|
7
7
|
"activerecord" => ["activerecord-opentracing", "~> 0.2.1"],
|
8
8
|
"elasticsearch" => ["signalfx-elasticsearch-instrumentation", "~> 0.1.0"],
|
9
9
|
"faraday" => ["signalfx-faraday-instrumentation", "~> 0.1.1"],
|
10
|
-
"grape" => ["grape-instrumentation", "~> 0.
|
10
|
+
"grape" => ["grape-instrumentation", "~> 0.2.0"],
|
11
11
|
"mongodb" => ["mongodb-instrumentation", "~> 0.1.1"],
|
12
12
|
"mysql2" => ["mysql2-instrumentation", "~> 0.2.1"],
|
13
13
|
"nethttp" => ["nethttp-instrumentation", "~> 0.1.2"],
|
14
14
|
"pg" => ["pg-instrumentation", "~> 0.1.0"],
|
15
|
-
"rack" => ["rack-tracer",
|
15
|
+
"rack" => ["sfx-rack-tracer", "~> 0.10.0"],
|
16
16
|
"rails" => ["rails-instrumentation", "~> 0.1.5"],
|
17
17
|
"redis" => ["redis-instrumentation", "~> 0.2.0"],
|
18
18
|
"restclient" => ["restclient-instrumentation", "~> 0.1.1"],
|
data/gem.deps.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
group :instrumentations do
|
2
2
|
gem 'activerecord-opentracing', '~> 0.2.1'
|
3
|
-
gem 'grape-instrumentation', "~> 0.
|
3
|
+
gem 'grape-instrumentation', "~> 0.2.0"
|
4
4
|
gem 'mongodb-instrumentation', '~> 0.1.1'
|
5
5
|
gem 'mysql2-instrumentation', '~> 0.2.1'
|
6
6
|
gem 'nethttp-instrumentation', '~> 0.1.2'
|
7
7
|
gem 'pg-instrumentation', '~> 0.1.0'
|
8
|
-
gem 'rack-tracer',
|
9
|
-
gem 'rails-instrumentation', '0.1.
|
8
|
+
gem 'sfx-rack-tracer', '~> 0.10.0'
|
9
|
+
gem 'rails-instrumentation', '~> 0.1.5'
|
10
10
|
gem 'redis-instrumentation', '~> 0.2.0'
|
11
11
|
gem 'restclient-instrumentation', '~> 0.1.1'
|
12
12
|
gem 'sequel-instrumentation', '~> 0.1.0'
|
data/lib/signalfx/tracing.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
require 'jaeger/client'
|
2
|
+
require 'jaeger/samplers'
|
3
|
+
require 'jaeger/injectors'
|
4
|
+
require 'jaeger/extractors'
|
2
5
|
require 'signalfx/tracing/http_sender'
|
3
6
|
require 'signalfx/tracing/register'
|
4
7
|
require 'signalfx/tracing/compat'
|
5
8
|
require 'signalfx/tracing/sfx_logger'
|
6
9
|
require 'signalfx/tracing/tags'
|
10
|
+
require 'signalfx/tracing/tracer'
|
11
|
+
require 'signalfx/tracing/span'
|
7
12
|
require 'thread'
|
8
13
|
|
9
14
|
module SignalFx
|
@@ -19,11 +24,14 @@ module SignalFx
|
|
19
24
|
ingest_url: ENV['SIGNALFX_ENDPOINT_URL'] || ENV['SIGNALFX_INGEST_URL'] || 'http://localhost:9080/v1/trace',
|
20
25
|
service_name: ENV['SIGNALFX_SERVICE_NAME'] || "signalfx-ruby-tracing",
|
21
26
|
access_token: ENV['SIGNALFX_ACCESS_TOKEN'],
|
22
|
-
auto_instrument: false
|
27
|
+
auto_instrument: false,
|
28
|
+
span_tags: {})
|
23
29
|
@ingest_url = ingest_url
|
24
30
|
@service_name = service_name
|
25
31
|
@access_token = access_token
|
26
|
-
|
32
|
+
|
33
|
+
span_tags = process_span_tags(span_tags)
|
34
|
+
set_tracer(tracer: tracer, service_name: service_name, access_token: access_token, span_tags: span_tags) if @tracer.nil?
|
27
35
|
|
28
36
|
if auto_instrument
|
29
37
|
Register.available_libs.each_pair do |key, value|
|
@@ -41,6 +49,17 @@ module SignalFx
|
|
41
49
|
Compat.apply
|
42
50
|
end
|
43
51
|
|
52
|
+
def process_span_tags(span_tags={})
|
53
|
+
span_tags_string = ENV['SIGNALFX_SPAN_TAGS']
|
54
|
+
if not span_tags_string.nil?
|
55
|
+
span_tags_string.split(',').each do |t|
|
56
|
+
k, v = t.strip.split(':')
|
57
|
+
span_tags[k] = v
|
58
|
+
end
|
59
|
+
end
|
60
|
+
return span_tags
|
61
|
+
end
|
62
|
+
|
44
63
|
def instrument(to_patch, **args)
|
45
64
|
if Register.available_libs[to_patch].nil?
|
46
65
|
logger.error { "instrumentation not found: #{to_patch}" }
|
@@ -54,33 +73,38 @@ module SignalFx
|
|
54
73
|
end
|
55
74
|
end
|
56
75
|
|
57
|
-
def
|
76
|
+
def new_tracer(service_name: nil, access_token: nil, span_tags: {})
|
77
|
+
# build a new tracer if one wasn't provided
|
78
|
+
headers = {}
|
79
|
+
|
80
|
+
# don't set the header if no token was provided
|
81
|
+
headers["X-SF-Token"] = access_token if access_token && !access_token.empty?
|
82
|
+
|
83
|
+
encoder = Jaeger::Client::Encoders::ThriftEncoder.new(service_name: service_name, tags: span_tags)
|
84
|
+
@http_sender = SignalFx::Tracing::HttpSenderWithFlag.new(url: @ingest_url, headers: headers, encoder: encoder)
|
85
|
+
@reporter = Jaeger::Client::Reporters::RemoteReporter.new(sender: @http_sender, flush_interval: 1)
|
86
|
+
|
87
|
+
injectors = {
|
88
|
+
OpenTracing::FORMAT_RACK => [Jaeger::Client::Injectors::B3RackCodec],
|
89
|
+
OpenTracing::FORMAT_TEXT_MAP => [Jaeger::Client::Injectors::B3RackCodec]
|
90
|
+
}
|
91
|
+
extractors = {
|
92
|
+
OpenTracing::FORMAT_RACK => [Jaeger::Client::Extractors::B3RackCodec],
|
93
|
+
OpenTracing::FORMAT_TEXT_MAP => [Jaeger::Client::Extractors::B3TextMapCodec]
|
94
|
+
}
|
95
|
+
|
96
|
+
Tracer.new(
|
97
|
+
reporter: reporter,
|
98
|
+
sampler: Jaeger::Samplers::Const.new(true),
|
99
|
+
injectors: Jaeger::Injectors.prepare(injectors),
|
100
|
+
extractors: Jaeger::Extractors.prepare(extractors)
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
def set_tracer(tracer: nil, service_name: nil, access_token: nil, span_tags: {})
|
58
105
|
# build a new tracer if one wasn't provided
|
59
106
|
if tracer.nil?
|
60
|
-
|
61
|
-
|
62
|
-
# don't set the header if no token was provided
|
63
|
-
headers["X-SF-Token"] = access_token if access_token && !access_token.empty?
|
64
|
-
|
65
|
-
encoder = Jaeger::Client::Encoders::ThriftEncoder.new(service_name: service_name)
|
66
|
-
@http_sender = SignalFx::Tracing::HttpSenderWithFlag.new(url: @ingest_url, headers: headers, encoder: encoder)
|
67
|
-
@reporter = Jaeger::Client::Reporters::RemoteReporter.new(sender: @http_sender, flush_interval: 1)
|
68
|
-
|
69
|
-
injectors = {
|
70
|
-
OpenTracing::FORMAT_RACK => [Jaeger::Client::Injectors::B3RackCodec],
|
71
|
-
OpenTracing::FORMAT_TEXT_MAP => [Jaeger::Client::Injectors::B3RackCodec]
|
72
|
-
}
|
73
|
-
extractors = {
|
74
|
-
OpenTracing::FORMAT_RACK => [Jaeger::Client::Extractors::B3RackCodec],
|
75
|
-
OpenTracing::FORMAT_TEXT_MAP => [Jaeger::Client::Extractors::B3TextMapCodec]
|
76
|
-
}
|
77
|
-
|
78
|
-
@tracer = Jaeger::Client.build(
|
79
|
-
service_name: service_name,
|
80
|
-
reporter: @reporter,
|
81
|
-
injectors: injectors,
|
82
|
-
extractors: extractors
|
83
|
-
)
|
107
|
+
@tracer = new_tracer(service_name: service_name, access_token: access_token, span_tags: span_tags)
|
84
108
|
OpenTracing.global_tracer = @tracer
|
85
109
|
else
|
86
110
|
@tracer = tracer
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'jaeger/span'
|
2
|
+
|
3
|
+
module SignalFx
|
4
|
+
module Tracing
|
5
|
+
module Span
|
6
|
+
def record_exception(exception, record_error=true)
|
7
|
+
set_tag('error', true) if record_error
|
8
|
+
|
9
|
+
fields = {
|
10
|
+
:event => 'error',
|
11
|
+
:'error.kind' => exception.class.to_s,
|
12
|
+
:'error.object' => exception,
|
13
|
+
:message => exception.message,
|
14
|
+
}
|
15
|
+
|
16
|
+
if not exception.backtrace.nil?
|
17
|
+
fields[:stack] = exception.backtrace.join('\n')
|
18
|
+
end
|
19
|
+
|
20
|
+
log_kv(**fields)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
Jaeger::Span.class_eval { include SignalFx::Tracing::Span }
|
@@ -1,14 +1,22 @@
|
|
1
|
+
require 'jaeger/tracer'
|
1
2
|
|
2
3
|
# The default jaeger tracer doesn't expose @reporter, and attr_accessor can't
|
3
4
|
# be added after the fact in a child class. So this just adds an old-fashioned
|
4
5
|
# setter for @reporter.
|
6
|
+
# This also adds the set_error method that can be used to add an exception to
|
7
|
+
# the currently active span.
|
5
8
|
|
6
9
|
module SignalFx
|
7
10
|
module Tracing
|
8
|
-
class Tracer < ::Jaeger::
|
11
|
+
class Tracer < ::Jaeger::Tracer
|
9
12
|
def set_reporter(reporter)
|
10
13
|
@reporter = reporter
|
11
14
|
end
|
15
|
+
|
16
|
+
def record_exception(exception, record_error=true)
|
17
|
+
span = active_span
|
18
|
+
span.record_exception(exception, record_error) if span
|
19
|
+
end
|
12
20
|
end
|
13
21
|
end
|
14
22
|
end
|
data/signalfx-tracing.gemspec
CHANGED
@@ -20,8 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_development_dependency "bundler", "~> 1
|
23
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "test-unit"
|
25
26
|
|
26
27
|
# TODO pin versions once consistent across all dependencies
|
27
28
|
spec.add_dependency "opentracing", "> 0.3.0"
|
@@ -34,4 +35,8 @@ Gem::Specification.new do |spec|
|
|
34
35
|
|
35
36
|
# stdlib instrumentations
|
36
37
|
spec.add_dependency "nethttp-instrumentation", "~> 0.1.2"
|
38
|
+
|
39
|
+
# uncomment and run `bundle install` in order to run the whole test suite
|
40
|
+
# spec.add_development_dependency "faraday", "~> 1.0"
|
41
|
+
# spec.add_development_dependency "signalfx-faraday-instrumentation"
|
37
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: signalfx-tracing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SignalFx, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '2.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: opentracing
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,6 +132,7 @@ files:
|
|
118
132
|
- lib/signalfx/tracing/register.rb
|
119
133
|
- lib/signalfx/tracing/reporter/auto_reviving_async_reporter.rb
|
120
134
|
- lib/signalfx/tracing/sfx_logger.rb
|
135
|
+
- lib/signalfx/tracing/span.rb
|
121
136
|
- lib/signalfx/tracing/tags.rb
|
122
137
|
- lib/signalfx/tracing/tracer.rb
|
123
138
|
- lib/signalfx/tracing/version.rb
|