signalfx-tracing 1.3.2 → 1.3.3
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/README.md +218 -183
- data/lib/signalfx/tracing.rb +21 -3
- data/lib/signalfx/tracing/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8255be0adcf8bd4fe4412bfed79136715ec13962fa187d08e6e199bba5b3311
|
4
|
+
data.tar.gz: 93708387b7486bd4995b0b509f0ba02cb9fa544f963666b5f2d56eb489395735
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b1a21c3a139f0accc57cebd68c736112eeae7b9c6c4d63cbad374969f677c8901026ec06acec13d458c34dccb04d541528b395f2f2adb8c2715f5d67187d05f
|
7
|
+
data.tar.gz: 61fbd5998c46d0c44551308598da14a92e8a7f1d08a00715ee8ca1e4bfd508c1bd4fad991fe76fa5913e857fab28eed35fa593404524c2b6a15f9f7105892f79
|
data/README.md
CHANGED
@@ -1,157 +1,163 @@
|
|
1
|
-
# SignalFx
|
1
|
+
# SignalFx Tracing Library for Ruby
|
2
2
|
|
3
|
-
|
3
|
+
The SignalFx Tracing Library for Ruby helps you instrument Ruby applications
|
4
|
+
with the OpenTracing API to capture and report distributed traces to SignalFx.
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
The library consists of an auto-instrumentor that works with OpenTracing
|
7
|
+
community-provided instrumentations, and provides a bootstrap utility to help
|
8
|
+
install instrumentations. It also configures and uses a
|
9
|
+
[Jaeger tracer](https://github.com/salemove/jaeger-client-ruby) to send trace
|
10
|
+
data to SignalFx.
|
7
11
|
|
8
|
-
|
9
|
-
```
|
12
|
+
## Requirements and supported software
|
10
13
|
|
11
|
-
|
14
|
+
Here are the requirements and supported software for the library.
|
12
15
|
|
13
|
-
###
|
16
|
+
### Supported runtimes
|
14
17
|
|
15
|
-
|
16
|
-
$ gem install signalfx-tracing
|
17
|
-
```
|
18
|
-
|
19
|
-
The SignalFx Tracing Library for Ruby requires just enough dependencies to allow custom instrumentation for your application, with target library instrumentations needing to be installed manually.
|
20
|
-
The basic installation provides an `sfx-rb-trace-bootstrap` executable to assist with this process, which allows you to specify the desired libraries for instrumentation as a comma-separated list:
|
21
|
-
|
22
|
-
```bash
|
23
|
-
$ sfx-rb-trace-bootstrap --install-deps rack,rails,activerecord,restclient
|
24
|
-
$ # use the --list option to see all available instrumentations
|
25
|
-
$ sfx-rb-trace-bootstrap --list
|
26
|
-
Available target libraries:
|
27
|
-
{"activerecord"=>["activerecord-opentracing", "~> 0.2.1"],
|
28
|
-
< ... >
|
29
|
-
"sinatra"=>["sinatra-instrumentation", "~> 0.1.2"]}
|
30
|
-
```
|
18
|
+
- MRI Ruby (CRuby) 2.0+
|
31
19
|
|
32
|
-
|
20
|
+
### Supported servers
|
33
21
|
|
34
|
-
|
35
|
-
|
36
|
-
$ cd signalfx-ruby-tracing
|
37
|
-
$ bundle install
|
38
|
-
$ gem install -g
|
39
|
-
```
|
40
|
-
|
41
|
-
### Installation in existing application
|
22
|
+
- Puma >= 3.0.0
|
23
|
+
- Passenger >= 5.0.25
|
42
24
|
|
43
|
-
|
25
|
+
### Supported libraries
|
26
|
+
|
27
|
+
| Library | Instrumentation name | Versions Supported |
|
28
|
+
| ------------------------------- | -------------------------------------- | ------------------ |
|
29
|
+
| [ActiveRecord](#active-record) | activerecord-opentracing | ~> 5.0 |
|
30
|
+
| [Elasticsearch](#elasticsearch) | signalfx-elasticsearch-instrumentation | >= 6.0.2 |
|
31
|
+
| [Faraday](#faraday) | signalfx-faraday-instrumentation | >= 0.9.0 |
|
32
|
+
| [Grape](#grape) | grape-instrumentation | >= 0.13.0 |
|
33
|
+
| [Mongo](#mongo) | mongodb-instrumentation | >= 2.1.0 |
|
34
|
+
| [Mysql2](#mysql2) | mysql2-instrumentation | >= 0.4.0 |
|
35
|
+
| [Net::HTTP](#nethttp) | nethttp-instrumentation | Ruby >= 2.0 |
|
36
|
+
| [Pg](#pg) | pg-instrumentation | >= 0.18.0 |
|
37
|
+
| [Rack](#rack) | rack-tracer | >= 0.1 |
|
38
|
+
| [Rails](#rails) | rails-instrumentation | >= 3.0.0 |
|
39
|
+
| [Redis](#redis) | redis-instrumentation | >= 4.0.0 |
|
40
|
+
| [RestClient](#restclient) | restclient-instrumentation | >= 1.5.0 |
|
41
|
+
| [Sequel](#sequel) | sequel-instrumentation | >= 3.47.0 |
|
42
|
+
| [Sidekiq](#sidekiq) | sfx-sidekiq-opentracing | >= 0.7.0 |
|
43
|
+
| [Sinatra](#sinatra) | sinatra-instrumentation | >= 1.0.0 |
|
44
|
+
|
45
|
+
Instrumentation for routes using Puma or Passenger is provided through
|
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
|
48
|
+
or with the bootstrap utility. In these cases, the routes through the web
|
49
|
+
server are automatically traced.
|
50
|
+
|
51
|
+
## Install the SignalFx Tracing Library for Ruby
|
52
|
+
|
53
|
+
Follow these steps to install the tracing library. You can either use the
|
54
|
+
bootstrap utility to install the tracing library and its dependencies or
|
55
|
+
manually install everything.
|
56
|
+
|
57
|
+
The bootstrap utility updates your Gemfile and installs the required
|
58
|
+
dependencies for you. For information about the bootstrap utility, see the
|
59
|
+
[sfx-rb-trace-bootstrap](bin/sfx-rb-trace-bootstrap) file.
|
60
|
+
|
61
|
+
The steps assume you have RubyGems and Bundler.
|
62
|
+
|
63
|
+
### Install the library with the bootstrap utility
|
64
|
+
|
65
|
+
1. Install the tracing library:
|
66
|
+
```bash
|
67
|
+
$ gem install signalfx-tracing
|
68
|
+
```
|
69
|
+
2. View the list of instrumentations you can install with the bootstrap utility:
|
70
|
+
```bash
|
71
|
+
$ sfx-rb-trace-bootstrap --list
|
72
|
+
```
|
73
|
+
3. Use the bootstrap utility to install applicable instrumentations for your
|
74
|
+
application. For example, this is how you add Rails and Redis:
|
75
|
+
```bash
|
76
|
+
$ sfx-rb-trace-bootstrap --install-deps rails,redis
|
77
|
+
```
|
78
|
+
For information about instrumentation names, see supported libraries and their
|
79
|
+
current versions in `gem.deps.rb`. If you configure Rails instrumentation, it
|
80
|
+
also configures Active Record instrumentation, so you don't need to instrument both.
|
81
|
+
|
82
|
+
### Manually install the library
|
83
|
+
|
84
|
+
1. Download the [latest release](https://github.com/signalfx/signalfx-ruby-tracing/releases/latest) of the tracing library.
|
85
|
+
2. Add `signalfx-tracing` to your application's Gemfile:
|
86
|
+
```bash
|
87
|
+
$ gem 'signalfx-tracing'
|
88
|
+
```
|
89
|
+
3. Add each applicable instrumentation to your application's Gemfile. For
|
90
|
+
example, this is how you add Rails and Redis:
|
91
|
+
```bash
|
92
|
+
$ gem 'rails-instrumentation'
|
93
|
+
$ gem 'redis-instrumentation'
|
94
|
+
```
|
95
|
+
For information about instrumentation names, see supported libraries and their
|
96
|
+
current versions in `gem.deps.rb`. If you configure Rails instrumentation, it
|
97
|
+
also configures Active Record instrumentation, so you don't need to instrument both.
|
98
|
+
4. Install the gems for the tracing library and instrumentations:
|
99
|
+
```bash
|
100
|
+
$ bundle install
|
101
|
+
```
|
102
|
+
|
103
|
+
## Configure instrumentation for a Ruby application
|
104
|
+
|
105
|
+
Configure the instrumentation anywhere in the setup portion of your code or
|
106
|
+
before importing and using any libraries that need to be traced.
|
107
|
+
|
108
|
+
For example, with Rails, configure instrumentation in `config/initializer/tracing.rb`.
|
109
|
+
|
110
|
+
You can configure instrumentation automatically or manually. Manual
|
111
|
+
instrumentation is convenient when you want to trace only some libraries.
|
112
|
+
|
113
|
+
### Set configuration values
|
114
|
+
|
115
|
+
If the default configuration values don't apply for your environment, override them before running the process you instrument.
|
116
|
+
|
117
|
+
| `configure` parameter | Environment variable | Default | Notes |
|
118
|
+
| ------------------- | -------------------- | -------------------------------- | ----- |
|
119
|
+
| tracer | N/A | `nil` | The OpenTracing global tracer. |
|
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
|
+
| service_name | SIGNALFX_SERVICE_NAME | `signalfx-ruby-tracing` | The name to identify the service in SignalFx. |
|
122
|
+
| access_token | SIGNALFX_ACCESS_TOKEN | `''` | The SignalFx organization access token. |
|
123
|
+
|
124
|
+
### Automatically instrument code:
|
125
|
+
|
126
|
+
Configure the auto-instrumentor to check for modules defined in the code and
|
127
|
+
instrument them if available:
|
44
128
|
|
45
129
|
```ruby
|
46
|
-
|
47
|
-
```
|
48
|
-
|
49
|
-
Then execute the following (or use your desired installation method for your application).
|
130
|
+
require 'signalfx/tracing'
|
50
131
|
|
51
|
-
|
52
|
-
$ bundle install
|
132
|
+
SignalFx::Tracing::Instrumenter.configure(auto_instrument:true)
|
53
133
|
```
|
54
134
|
|
55
|
-
|
56
|
-
|
57
|
-
Configure the instrumentation anywhere in the setup portion of your code or before doing anything
|
58
|
-
that needs to be traced.
|
135
|
+
### Manually specify which libraries to instrument
|
59
136
|
|
60
|
-
|
61
|
-
|
62
|
-
The instrumentation can be done automatically, where the auto-instrumenter will
|
63
|
-
check for modules defined in the code and instrument them if available:
|
137
|
+
Specify which libraries to instrument:
|
64
138
|
|
65
139
|
```ruby
|
66
140
|
require 'signalfx/tracing'
|
67
141
|
|
68
|
-
SignalFx::Tracing::Instrumenter.configure
|
69
|
-
|
70
|
-
|
71
|
-
Manual configuration may be desirable when only some libraries should be traced.
|
72
|
-
These instrumentations to can be selected in a block:
|
73
|
-
|
74
|
-
```ruby
|
75
|
-
SignalFx::Tracing::Instrumenter.configure do |patcher|
|
76
|
-
patcher.instrument(:LibName)
|
142
|
+
SignalFx::Tracing::Instrumenter.configure do |p|
|
143
|
+
p.instrument(<:myLibName>)
|
77
144
|
...
|
78
145
|
end
|
79
146
|
```
|
80
147
|
|
81
|
-
|
82
|
-
|
83
|
-
`configure` accepts several optional parameters:
|
84
|
-
- `tracer`: a preconfigured OpenTracing tracer to use. If one is not provided,
|
85
|
-
a new tracer will be initialized.
|
86
|
-
- Default: `nil`
|
87
|
-
- `ingest_url`: this is the Smart Agent or Smart Gateway endpoint to which spans are sent by the tracer.
|
88
|
-
- Default: `http://localhost:9080/v1/trace`
|
89
|
-
- `service_name`: service name to send spans under.
|
90
|
-
- Default: `signalfx-ruby-tracing`
|
91
|
-
- `access_token`: SignalFx access token for authentication. Unnecessary for most deployments.
|
92
|
-
- Default: `''`
|
93
|
-
|
94
|
-
Environment variables can be used to configure `service_name` and `access_token`
|
95
|
-
if not given to the `configure` method.
|
148
|
+
## Usage information for each library
|
96
149
|
|
97
|
-
|
98
|
-
export SIGNALFX_SERVICE_NAME="<service_name>"
|
99
|
-
export SIGNALFX_ENDPOINT_URL="<url>"
|
100
|
-
export SIGNALFX_ACCESS_TOKEN="<token>"
|
101
|
-
```
|
102
|
-
|
103
|
-
If these environment variables are not set, the values will default to the ones
|
104
|
-
listed above.
|
105
|
-
|
106
|
-
# Instrumentation
|
107
|
-
|
108
|
-
This section contains details and configuration for specific frameworks.
|
109
|
-
|
110
|
-
### Runtimes
|
111
|
-
|
112
|
-
- MRI Ruby (CRuby) 2.0+
|
113
|
-
|
114
|
-
### Web servers
|
115
|
-
|
116
|
-
- Puma >= 3.0.0
|
117
|
-
- Passenger >= 5.0.25
|
150
|
+
Here's information about instrumenting each supported library.
|
118
151
|
|
119
|
-
|
120
|
-
If using a framework that builds on top of Rack, such as Rails or Sinatra, our
|
121
|
-
instrumentation includes Rack instrumentation. In these cases, the routes
|
122
|
-
through the web server will be automatically traced.
|
123
|
-
|
124
|
-
When interfacing with these web servers as a Rack application, please configure
|
125
|
-
[Rack instrumentation](#rack) and insert it as middleware.
|
126
|
-
|
127
|
-
### Libraries/Frameworks
|
128
|
-
|
129
|
-
| Library | Versions Supported |
|
130
|
-
| ----------------------------------- | ------------------ |
|
131
|
-
| [ActiveRecord](#active-record) | ~> 5.0 |
|
132
|
-
| [Elasticsearch](#elasticsearch) | >= 6.0.2 |
|
133
|
-
| [Faraday](#faraday) | >= 0.9.0 |
|
134
|
-
| [Grape](#grape) | >= 0.13.0 |
|
135
|
-
| [Mongo](#mongo) | >= 2.1.0 |
|
136
|
-
| [Mysql2](#mysql2) | >= 0.4.0 |
|
137
|
-
| [Net::HTTP](#nethttp) | Ruby >= 2.0 |
|
138
|
-
| [Pg](#pg) | >= 0.18.0 |
|
139
|
-
| [Rack](#rack) | >= 0.1 |
|
140
|
-
| [Rails](#rails) | >= 3.0.0 |
|
141
|
-
| [Redis](#redis) | >= 4.0.0 |
|
142
|
-
| [RestClient](#restclient) | >= 1.5.0 |
|
143
|
-
| [Sequel](#sequel) | >= 3.47.0 |
|
144
|
-
| [Sidekiq](#sidekiq) | >= 0.7.0 |
|
145
|
-
| [Sinatra](#sinatra) | >= 1.0.0 |
|
146
|
-
|
147
|
-
## Active Record
|
152
|
+
### Active Record
|
148
153
|
|
149
154
|
This instrumentation creates spans for each Active Record query using the Active
|
150
|
-
Support notifications framework.
|
155
|
+
Support notifications framework. If you configure Rails instrumentation, it also configures Active Record instrumentation, so you don't need to instrument both.
|
151
156
|
|
152
|
-
The source for this instrumentation is located
|
157
|
+
The source for this instrumentation is located
|
158
|
+
[here](https://github.com/salemove/ruby-activerecord-opentracing).
|
153
159
|
|
154
|
-
|
160
|
+
#### Usage
|
155
161
|
|
156
162
|
```bash
|
157
163
|
$ # install the instrumentation if not done previously
|
@@ -164,14 +170,15 @@ SignalFx::Tracing::Instrumenter.configure do |p|
|
|
164
170
|
end
|
165
171
|
```
|
166
172
|
|
167
|
-
|
173
|
+
### Elasticsearch
|
168
174
|
|
169
175
|
Elasticsearch queries through the Ruby client are traced using a wrapper around
|
170
176
|
the transport.
|
171
177
|
|
172
|
-
The forked source for the instrumentation is located
|
178
|
+
The forked source for the instrumentation is located
|
179
|
+
[here](https://github.com/signalfx/ruby-elasticsearch-tracer).
|
173
180
|
|
174
|
-
|
181
|
+
#### Usage
|
175
182
|
|
176
183
|
```bash
|
177
184
|
$ # install the instrumentation if not done previously
|
@@ -201,15 +208,16 @@ client.transport = Elasticsearch::Tracer::Transport.new(tracer: OpenTracing.glob
|
|
201
208
|
transport: client.transport)
|
202
209
|
```
|
203
210
|
|
204
|
-
|
211
|
+
### Faraday
|
205
212
|
|
206
213
|
Faraday HTTP client instrumentation automatically creates spans for outgoing
|
207
214
|
requests. If the remote service has instrumentation that is aware of Rack,
|
208
215
|
those spans will be automatically nested with Faraday's spans.
|
209
216
|
|
210
|
-
The source for this instrumentation is located
|
217
|
+
The source for this instrumentation is located
|
218
|
+
[here](https://github.com/opentracing-contrib/ruby-faraday-tracer).
|
211
219
|
|
212
|
-
|
220
|
+
#### Usage
|
213
221
|
|
214
222
|
```bash
|
215
223
|
$ # install the instrumentation if not done previously
|
@@ -232,15 +240,16 @@ end
|
|
232
240
|
|
233
241
|
For more detailed usage, please check the instrumentation's page.
|
234
242
|
|
235
|
-
|
243
|
+
### Grape
|
236
244
|
|
237
245
|
This instrumentation subscribes to ActiveSupport notifications emitted by the
|
238
246
|
Grape API. It patches `Grape::API` to automatically insert the `Rack::Tracer`
|
239
247
|
middleware and trace requests.
|
240
248
|
|
241
|
-
The source for this instrumentation is located
|
249
|
+
The source for this instrumentation is located
|
250
|
+
[here](https://github.com/signalfx/ruby-grape-instrumentation)
|
242
251
|
|
243
|
-
|
252
|
+
#### Usage
|
244
253
|
|
245
254
|
```bash
|
246
255
|
$ # install the instrumentation if not done previously
|
@@ -255,8 +264,10 @@ end
|
|
255
264
|
|
256
265
|
`instrument` takes these optional arguments:
|
257
266
|
- `tracer`: custom tracer to use. Defaults to `OpenTracing.global_tracer`
|
258
|
-
- `parent_span`: parent span to group spans or block that returns a span.
|
259
|
-
|
267
|
+
- `parent_span`: parent span to group spans or block that returns a span.
|
268
|
+
Default: `nil`
|
269
|
+
- `disable_patching`: disable patching if managing the middleware stack
|
270
|
+
manually. Default: `false`
|
260
271
|
|
261
272
|
If patching is disabled, but spans nested by request are still desired, then the
|
262
273
|
Rack middleware must be manually added to the API class.
|
@@ -277,13 +288,15 @@ end
|
|
277
288
|
|
278
289
|
Please see the instrumentation's page for more details.
|
279
290
|
|
280
|
-
|
291
|
+
### Mongo
|
281
292
|
|
282
|
-
Mongo driver instrumentation traces queries performed through the Ruby Mongodb
|
293
|
+
Mongo driver instrumentation traces queries performed through the Ruby Mongodb
|
294
|
+
driver.
|
283
295
|
|
284
|
-
The source for this instrumentation is located
|
296
|
+
The source for this instrumentation is located
|
297
|
+
[here](https://github.com/signalfx/ruby-mongodb-instrumentation)
|
285
298
|
|
286
|
-
|
299
|
+
#### Usage
|
287
300
|
|
288
301
|
```bash
|
289
302
|
$ # install the instrumentation if not done previously
|
@@ -296,13 +309,14 @@ SignalFx::Tracing::Instrumenter.configure do |p|
|
|
296
309
|
end
|
297
310
|
```
|
298
311
|
|
299
|
-
|
312
|
+
### Mysql2
|
300
313
|
|
301
314
|
Mysql2 instrumentation traces all queries performed with the Mysql2 client.
|
302
315
|
|
303
|
-
The source for this instrumentation is located
|
316
|
+
The source for this instrumentation is located
|
317
|
+
[here](https://github.com/signalfx/ruby-mysql2-instrumentation)
|
304
318
|
|
305
|
-
|
319
|
+
#### Usage
|
306
320
|
|
307
321
|
```bash
|
308
322
|
$ # install the instrumentation if not done previously
|
@@ -315,13 +329,14 @@ SignalFx::Tracing::Instrumenter.configure do |p|
|
|
315
329
|
end
|
316
330
|
```
|
317
331
|
|
318
|
-
|
332
|
+
### Net::HTTP
|
319
333
|
|
320
334
|
This automatically traces all requests using Net::HTTP.
|
321
335
|
|
322
|
-
The source for this instrumentation is located
|
336
|
+
The source for this instrumentation is located
|
337
|
+
[here](https://github.com/signalfx/ruby-net-http-instrumentation).
|
323
338
|
|
324
|
-
|
339
|
+
#### Usage
|
325
340
|
|
326
341
|
```ruby
|
327
342
|
SignalFx::Tracing::Instrumenter.configure do |p|
|
@@ -329,15 +344,17 @@ SignalFx::Tracing::Instrumenter.configure do |p|
|
|
329
344
|
end
|
330
345
|
```
|
331
346
|
|
332
|
-
An optional `tracer` named argument can be provided to use a custom tracer.
|
347
|
+
An optional `tracer` named argument can be provided to use a custom tracer.
|
348
|
+
It will default to `OpenTracing.global_tracer` if not provided.
|
333
349
|
|
334
|
-
|
350
|
+
### Pg
|
335
351
|
|
336
352
|
Pg instrumentation traces all queries performed with the pg client.
|
337
353
|
|
338
|
-
The source for this instrumentation is located
|
354
|
+
The source for this instrumentation is located
|
355
|
+
[here](https://github.com/signalfx/ruby-pg-instrumentation)
|
339
356
|
|
340
|
-
|
357
|
+
#### Usage
|
341
358
|
|
342
359
|
```bash
|
343
360
|
$ # install the instrumentation if not done previously
|
@@ -349,15 +366,16 @@ SignalFx::Tracing::Instrumenter.configure do |p|
|
|
349
366
|
p.instrument(:pg)
|
350
367
|
end
|
351
368
|
```
|
352
|
-
|
369
|
+
### Rack
|
353
370
|
|
354
371
|
Rack spans are created using the `rack-tracer` gem. This is enabled
|
355
372
|
automatically for other frameworks that are built on top of Rack, but it can
|
356
373
|
also be separately enabled.
|
357
374
|
|
358
|
-
The source for this instrumentation is located
|
375
|
+
The source for this instrumentation is located
|
376
|
+
[here](https://github.com/opentracing-contrib/ruby-rack-tracer).
|
359
377
|
|
360
|
-
|
378
|
+
#### Usage
|
361
379
|
|
362
380
|
```bash
|
363
381
|
$ # install the instrumentation if not done previously
|
@@ -372,14 +390,15 @@ end
|
|
372
390
|
use Rack::Tracer
|
373
391
|
```
|
374
392
|
|
375
|
-
|
393
|
+
### Rails
|
376
394
|
|
377
395
|
Rails applications can be traced using the notifications provided by ActiveSupport.
|
378
396
|
It will use `rack-tracer` to trace by requests.
|
379
397
|
|
380
|
-
The forked source for this instrumentation is located
|
398
|
+
The forked source for this instrumentation is located
|
399
|
+
[here](https://github.com/signalfx/ruby-rails-instrumentation).
|
381
400
|
|
382
|
-
|
401
|
+
#### Usage
|
383
402
|
|
384
403
|
```bash
|
385
404
|
$ # install the instrumentation if not done previously
|
@@ -408,13 +427,15 @@ Note that if `rack_tracer` is set to `false`, requests propagated to the Rails
|
|
408
427
|
app will not be extracted. For example, if a traced service makes a request to
|
409
428
|
an endpoint served by the Rails app, it will not be automatically nested.
|
410
429
|
|
411
|
-
|
430
|
+
### Redis
|
412
431
|
|
413
|
-
This instrumentation traces commands performed using the
|
432
|
+
This instrumentation traces commands performed using the
|
433
|
+
[Redis client](https://github.com/redis/redis-rb).
|
414
434
|
|
415
|
-
The source for this instrumentation is located
|
435
|
+
The source for this instrumentation is located
|
436
|
+
[here](https://github.com/signalfx/ruby-redis-instrumentation).
|
416
437
|
|
417
|
-
|
438
|
+
#### Usage
|
418
439
|
|
419
440
|
```bash
|
420
441
|
$ # install the instrumentation if not done previously
|
@@ -431,14 +452,15 @@ Arguments:
|
|
431
452
|
- `tracer`: Optional custom tracer to use for this instrumentation
|
432
453
|
- Default: `OpenTracing.global_tracer`
|
433
454
|
|
434
|
-
|
455
|
+
### RestClient
|
435
456
|
|
436
457
|
RestClient requests can be patched to automatically be wrapped in a span. It
|
437
458
|
will also inject the span context so remote services can extract it.
|
438
459
|
|
439
|
-
The source for this instrumentation is located
|
460
|
+
The source for this instrumentation is located
|
461
|
+
[here](https://github.com/signalfx/ruby-restclient-instrumentation).
|
440
462
|
|
441
|
-
|
463
|
+
#### Usage
|
442
464
|
|
443
465
|
```bash
|
444
466
|
$ # install the instrumentation if not done previously
|
@@ -457,13 +479,15 @@ Arguments:
|
|
457
479
|
- `propagate`: Propagate spans to the request endpoint.
|
458
480
|
- Default: `false`
|
459
481
|
|
460
|
-
|
482
|
+
### Sequel
|
461
483
|
|
462
|
-
Sequel instrumentation adds extensions to the Database and Dataset to trace
|
484
|
+
Sequel instrumentation adds extensions to the Database and Dataset to trace
|
485
|
+
queries.
|
463
486
|
|
464
|
-
The source for this instrumentation is located
|
487
|
+
The source for this instrumentation is located
|
488
|
+
[here](https://github.com/signalfx/ruby-sequel-instrumentation).
|
465
489
|
|
466
|
-
|
490
|
+
#### Usage
|
467
491
|
|
468
492
|
```bash
|
469
493
|
$ # install the instrumentation if not done previously
|
@@ -480,16 +504,19 @@ Arguments:
|
|
480
504
|
- `tracer`: Optional custom tracer for this instrumentation
|
481
505
|
- Default: `OpenTracing.global_tracer`
|
482
506
|
|
483
|
-
|
507
|
+
### Sidekiq
|
484
508
|
|
485
|
-
Sidekiq instrumentation traces worker job submissions and execution via
|
486
|
-
|
487
|
-
|
488
|
-
|
509
|
+
Sidekiq instrumentation traces worker job submissions and execution via
|
510
|
+
[Sidekiq middleware](https://github.com/mperham/sidekiq/wiki/Middleware).
|
511
|
+
The instrumenter registers both client and server middleware that use job
|
512
|
+
metadata to represent all job submissions and their invocations. Trace
|
513
|
+
context propagation adds to this job metadata to unifiy distributed client
|
514
|
+
and server requests and processing.
|
489
515
|
|
490
|
-
The source for this instrumentation is located
|
516
|
+
The source for this instrumentation is located
|
517
|
+
[here](https://github.com/signalfx/ruby-sidekiq-tracer).
|
491
518
|
|
492
|
-
|
519
|
+
#### Usage
|
493
520
|
|
494
521
|
```bash
|
495
522
|
$ # install the instrumentation if not done previously
|
@@ -505,20 +532,22 @@ end
|
|
505
532
|
Arguments:
|
506
533
|
- `tracer`: Optional custom tracer for this instrumentation
|
507
534
|
- Default: `OpenTracing.global_tracer`
|
508
|
-
- `propagate`: Optional boolean to enable/disable trace context injection via
|
535
|
+
- `propagate`: Optional boolean to enable/disable trace context injection via
|
536
|
+
job metadata
|
509
537
|
- Default: `true`
|
510
538
|
|
511
539
|
|
512
|
-
|
540
|
+
### Sinatra
|
513
541
|
|
514
542
|
Sinatra instrumentation traces requests and template rendering. The instrumenter
|
515
543
|
registers a Sinatra extension that uses `rack-tracer` to trace requests and
|
516
544
|
monkey-patches to trace view rendering. Rack instrumentation is automatically
|
517
545
|
enabled when using Sinatra instrumentation.
|
518
546
|
|
519
|
-
The source for this instrumentation is located
|
547
|
+
The source for this instrumentation is located
|
548
|
+
[here](https://github.com/signalfx/ruby-sinatra-instrumentation).
|
520
549
|
|
521
|
-
|
550
|
+
#### Usage
|
522
551
|
|
523
552
|
```bash
|
524
553
|
$ # install the instrumentation if not done previously
|
@@ -531,9 +560,10 @@ SignalFx::Tracing::Instrumenter.configure do |p|
|
|
531
560
|
end
|
532
561
|
```
|
533
562
|
|
534
|
-
##
|
563
|
+
## Configure the logger
|
535
564
|
|
536
|
-
The logger, based on the [Ruby Logger](https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html),
|
565
|
+
The logger, based on the [Ruby Logger](https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html),
|
566
|
+
can be configured by setting the following environment variables:
|
537
567
|
|
538
568
|
| Environmental Variable Name | Description | Default |
|
539
569
|
|:------------------------------|:----------------------|:-------------------- |
|
@@ -542,8 +572,13 @@ The logger, based on the [Ruby Logger](https://ruby-doc.org/stdlib-2.4.0/libdoc/
|
|
542
572
|
| `SIGNALFX_LOG_SHIFT_SIZE` | The desired maximum size of log files (this only applies when. A new one would be created when the maximum is reached. | `1048576` (1 MB) |
|
543
573
|
| `SIGNALFX_LOG_LEVEL` | The severity criteria for recording logs (from least to most severe). Options: `debug`, `info`, `warn`, `error`, `fatal`, `unknown` | `warn` |
|
544
574
|
|
545
|
-
More information regarding the logging configuration may be found
|
575
|
+
More information regarding the logging configuration may be found
|
576
|
+
[here](https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html).
|
546
577
|
|
547
578
|
**NB**:
|
548
|
-
- If the default path for `SIGNALFX_LOG_PATH` (that is, `/var/log/signalfx/signalfx-ruby-tracing.log`)
|
549
|
-
|
579
|
+
- If the default path for `SIGNALFX_LOG_PATH` (that is, `/var/log/signalfx/signalfx-ruby-tracing.log`)
|
580
|
+
is to be used, then please create the directory and or file (if necessary)
|
581
|
+
and grant the relevant access permissions to the instrumentation user process.
|
582
|
+
If there are permission issues, the instrumentation will default to logging to
|
583
|
+
the standard error (STDERR) handle, until the path is provided to which logs
|
584
|
+
can be written without any access issues.
|
data/lib/signalfx/tracing.rb
CHANGED
@@ -2,6 +2,7 @@ require 'jaeger/client'
|
|
2
2
|
require 'signalfx/tracing/http_sender'
|
3
3
|
require 'signalfx/tracing/register'
|
4
4
|
require 'signalfx/tracing/compat'
|
5
|
+
require 'signalfx/tracing/sfx_logger'
|
5
6
|
require 'thread'
|
6
7
|
|
7
8
|
module SignalFx
|
@@ -25,7 +26,12 @@ module SignalFx
|
|
25
26
|
|
26
27
|
if auto_instrument
|
27
28
|
Register.available_libs.each_pair do |key, value|
|
28
|
-
|
29
|
+
begin
|
30
|
+
value.instrument
|
31
|
+
rescue Exception => e
|
32
|
+
logger.error { "failed to initialize instrumentation '#{key}': #{e.inspect}" }
|
33
|
+
logger.error { e.backtrace }
|
34
|
+
end
|
29
35
|
end
|
30
36
|
else
|
31
37
|
yield self
|
@@ -36,9 +42,14 @@ module SignalFx
|
|
36
42
|
|
37
43
|
def instrument(to_patch, **args)
|
38
44
|
if Register.available_libs[to_patch].nil?
|
39
|
-
|
45
|
+
logger.error { "instrumentation not found: #{to_patch}" }
|
40
46
|
else
|
41
|
-
|
47
|
+
begin
|
48
|
+
Register.available_libs[to_patch].instrument(**args)
|
49
|
+
rescue Exception => e
|
50
|
+
logger.error { "failed to initialize instrumentation '#{to_patch}': #{e.inspect}" }
|
51
|
+
logger.error { e.backtrace }
|
52
|
+
end
|
42
53
|
end
|
43
54
|
end
|
44
55
|
|
@@ -78,6 +89,13 @@ module SignalFx
|
|
78
89
|
def revive
|
79
90
|
set_tracer(service_name: @service_name, access_token: @access_token)
|
80
91
|
end
|
92
|
+
|
93
|
+
def logger()
|
94
|
+
if @_logger == nil
|
95
|
+
@_logger = Logging.logger
|
96
|
+
end
|
97
|
+
return @_logger
|
98
|
+
end
|
81
99
|
end
|
82
100
|
end
|
83
101
|
|
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.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SignalFx, Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.1.2
|
83
|
-
description:
|
83
|
+
description:
|
84
84
|
email:
|
85
85
|
- info@signalfx.com
|
86
86
|
executables:
|
@@ -125,7 +125,7 @@ homepage: https://github.com/signalfx/signalfx-ruby-tracing
|
|
125
125
|
licenses:
|
126
126
|
- Apache-2.0
|
127
127
|
metadata: {}
|
128
|
-
post_install_message:
|
128
|
+
post_install_message:
|
129
129
|
rdoc_options: []
|
130
130
|
require_paths:
|
131
131
|
- lib
|
@@ -140,8 +140,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
|
-
|
144
|
-
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.7.6.2
|
145
|
+
signing_key:
|
145
146
|
specification_version: 4
|
146
147
|
summary: Auto-instrumentation framework for Ruby
|
147
148
|
test_files: []
|