signalfx-tracing 1.3.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +219 -183
- data/Rakefile +8 -0
- data/bin/sfx-rb-trace-bootstrap +1 -1
- data/lib/signalfx/tracing.rb +22 -3
- data/lib/signalfx/tracing/instrumentation/faraday.rb +2 -2
- data/lib/signalfx/tracing/tags.rb +47 -0
- 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: 1d8084beade571589adf44ec1abf80119b97ec39a003cbbb140ea4c773295988
|
4
|
+
data.tar.gz: 117f57ee3d8c08085774660863c10aa80c2cc0b8c39447519ce0372ac41e85b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8827b0f0b970821aa91b193256d1e7ab0c080bb740421f6739fd2446a4e06e56eb38ea38fef65d3b94efaa7487d642ab9101e2bc61eb2ebbaa1e3c819fc3144c
|
7
|
+
data.tar.gz: 0caaf7c27b8510d3f2473775787496e52a2386e052f24c380bf9584c2c24a21a1750e1e4475a5c727dc1281b403f7280e8aa3bf88a3c845edcd883b38ecf138a
|
data/README.md
CHANGED
@@ -1,157 +1,164 @@
|
|
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
|
+
| N/A | SIGNALFX_RECORDED_VALUE_MAX_LENGTH | `1200` | Maximum length an attribute value can have. Values longer than this are truncated. |
|
124
|
+
|
125
|
+
### Automatically instrument code:
|
126
|
+
|
127
|
+
Configure the auto-instrumentor to check for modules defined in the code and
|
128
|
+
instrument them if available:
|
44
129
|
|
45
130
|
```ruby
|
46
|
-
|
47
|
-
```
|
48
|
-
|
49
|
-
Then execute the following (or use your desired installation method for your application).
|
131
|
+
require 'signalfx/tracing'
|
50
132
|
|
51
|
-
|
52
|
-
$ bundle install
|
133
|
+
SignalFx::Tracing::Instrumenter.configure(auto_instrument:true)
|
53
134
|
```
|
54
135
|
|
55
|
-
|
56
|
-
|
57
|
-
Configure the instrumentation anywhere in the setup portion of your code or before doing anything
|
58
|
-
that needs to be traced.
|
136
|
+
### Manually specify which libraries to instrument
|
59
137
|
|
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:
|
138
|
+
Specify which libraries to instrument:
|
64
139
|
|
65
140
|
```ruby
|
66
141
|
require 'signalfx/tracing'
|
67
142
|
|
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)
|
143
|
+
SignalFx::Tracing::Instrumenter.configure do |p|
|
144
|
+
p.instrument(<:myLibName>)
|
77
145
|
...
|
78
146
|
end
|
79
147
|
```
|
80
148
|
|
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.
|
149
|
+
## Usage information for each library
|
96
150
|
|
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
|
151
|
+
Here's information about instrumenting each supported library.
|
118
152
|
|
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
|
153
|
+
### Active Record
|
148
154
|
|
149
155
|
This instrumentation creates spans for each Active Record query using the Active
|
150
|
-
Support notifications framework.
|
156
|
+
Support notifications framework. If you configure Rails instrumentation, it also configures Active Record instrumentation, so you don't need to instrument both.
|
151
157
|
|
152
|
-
The source for this instrumentation is located
|
158
|
+
The source for this instrumentation is located
|
159
|
+
[here](https://github.com/salemove/ruby-activerecord-opentracing).
|
153
160
|
|
154
|
-
|
161
|
+
#### Usage
|
155
162
|
|
156
163
|
```bash
|
157
164
|
$ # install the instrumentation if not done previously
|
@@ -164,14 +171,15 @@ SignalFx::Tracing::Instrumenter.configure do |p|
|
|
164
171
|
end
|
165
172
|
```
|
166
173
|
|
167
|
-
|
174
|
+
### Elasticsearch
|
168
175
|
|
169
176
|
Elasticsearch queries through the Ruby client are traced using a wrapper around
|
170
177
|
the transport.
|
171
178
|
|
172
|
-
The forked source for the instrumentation is located
|
179
|
+
The forked source for the instrumentation is located
|
180
|
+
[here](https://github.com/signalfx/ruby-elasticsearch-tracer).
|
173
181
|
|
174
|
-
|
182
|
+
#### Usage
|
175
183
|
|
176
184
|
```bash
|
177
185
|
$ # install the instrumentation if not done previously
|
@@ -201,15 +209,16 @@ client.transport = Elasticsearch::Tracer::Transport.new(tracer: OpenTracing.glob
|
|
201
209
|
transport: client.transport)
|
202
210
|
```
|
203
211
|
|
204
|
-
|
212
|
+
### Faraday
|
205
213
|
|
206
214
|
Faraday HTTP client instrumentation automatically creates spans for outgoing
|
207
215
|
requests. If the remote service has instrumentation that is aware of Rack,
|
208
216
|
those spans will be automatically nested with Faraday's spans.
|
209
217
|
|
210
|
-
The source for this instrumentation is located
|
218
|
+
The source for this instrumentation is located
|
219
|
+
[here](https://github.com/opentracing-contrib/ruby-faraday-tracer).
|
211
220
|
|
212
|
-
|
221
|
+
#### Usage
|
213
222
|
|
214
223
|
```bash
|
215
224
|
$ # install the instrumentation if not done previously
|
@@ -232,15 +241,16 @@ end
|
|
232
241
|
|
233
242
|
For more detailed usage, please check the instrumentation's page.
|
234
243
|
|
235
|
-
|
244
|
+
### Grape
|
236
245
|
|
237
246
|
This instrumentation subscribes to ActiveSupport notifications emitted by the
|
238
247
|
Grape API. It patches `Grape::API` to automatically insert the `Rack::Tracer`
|
239
248
|
middleware and trace requests.
|
240
249
|
|
241
|
-
The source for this instrumentation is located
|
250
|
+
The source for this instrumentation is located
|
251
|
+
[here](https://github.com/signalfx/ruby-grape-instrumentation)
|
242
252
|
|
243
|
-
|
253
|
+
#### Usage
|
244
254
|
|
245
255
|
```bash
|
246
256
|
$ # install the instrumentation if not done previously
|
@@ -255,8 +265,10 @@ end
|
|
255
265
|
|
256
266
|
`instrument` takes these optional arguments:
|
257
267
|
- `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
|
-
|
268
|
+
- `parent_span`: parent span to group spans or block that returns a span.
|
269
|
+
Default: `nil`
|
270
|
+
- `disable_patching`: disable patching if managing the middleware stack
|
271
|
+
manually. Default: `false`
|
260
272
|
|
261
273
|
If patching is disabled, but spans nested by request are still desired, then the
|
262
274
|
Rack middleware must be manually added to the API class.
|
@@ -277,13 +289,15 @@ end
|
|
277
289
|
|
278
290
|
Please see the instrumentation's page for more details.
|
279
291
|
|
280
|
-
|
292
|
+
### Mongo
|
281
293
|
|
282
|
-
Mongo driver instrumentation traces queries performed through the Ruby Mongodb
|
294
|
+
Mongo driver instrumentation traces queries performed through the Ruby Mongodb
|
295
|
+
driver.
|
283
296
|
|
284
|
-
The source for this instrumentation is located
|
297
|
+
The source for this instrumentation is located
|
298
|
+
[here](https://github.com/signalfx/ruby-mongodb-instrumentation)
|
285
299
|
|
286
|
-
|
300
|
+
#### Usage
|
287
301
|
|
288
302
|
```bash
|
289
303
|
$ # install the instrumentation if not done previously
|
@@ -296,13 +310,14 @@ SignalFx::Tracing::Instrumenter.configure do |p|
|
|
296
310
|
end
|
297
311
|
```
|
298
312
|
|
299
|
-
|
313
|
+
### Mysql2
|
300
314
|
|
301
315
|
Mysql2 instrumentation traces all queries performed with the Mysql2 client.
|
302
316
|
|
303
|
-
The source for this instrumentation is located
|
317
|
+
The source for this instrumentation is located
|
318
|
+
[here](https://github.com/signalfx/ruby-mysql2-instrumentation)
|
304
319
|
|
305
|
-
|
320
|
+
#### Usage
|
306
321
|
|
307
322
|
```bash
|
308
323
|
$ # install the instrumentation if not done previously
|
@@ -315,13 +330,14 @@ SignalFx::Tracing::Instrumenter.configure do |p|
|
|
315
330
|
end
|
316
331
|
```
|
317
332
|
|
318
|
-
|
333
|
+
### Net::HTTP
|
319
334
|
|
320
335
|
This automatically traces all requests using Net::HTTP.
|
321
336
|
|
322
|
-
The source for this instrumentation is located
|
337
|
+
The source for this instrumentation is located
|
338
|
+
[here](https://github.com/signalfx/ruby-net-http-instrumentation).
|
323
339
|
|
324
|
-
|
340
|
+
#### Usage
|
325
341
|
|
326
342
|
```ruby
|
327
343
|
SignalFx::Tracing::Instrumenter.configure do |p|
|
@@ -329,15 +345,17 @@ SignalFx::Tracing::Instrumenter.configure do |p|
|
|
329
345
|
end
|
330
346
|
```
|
331
347
|
|
332
|
-
An optional `tracer` named argument can be provided to use a custom tracer.
|
348
|
+
An optional `tracer` named argument can be provided to use a custom tracer.
|
349
|
+
It will default to `OpenTracing.global_tracer` if not provided.
|
333
350
|
|
334
|
-
|
351
|
+
### Pg
|
335
352
|
|
336
353
|
Pg instrumentation traces all queries performed with the pg client.
|
337
354
|
|
338
|
-
The source for this instrumentation is located
|
355
|
+
The source for this instrumentation is located
|
356
|
+
[here](https://github.com/signalfx/ruby-pg-instrumentation)
|
339
357
|
|
340
|
-
|
358
|
+
#### Usage
|
341
359
|
|
342
360
|
```bash
|
343
361
|
$ # install the instrumentation if not done previously
|
@@ -349,15 +367,16 @@ SignalFx::Tracing::Instrumenter.configure do |p|
|
|
349
367
|
p.instrument(:pg)
|
350
368
|
end
|
351
369
|
```
|
352
|
-
|
370
|
+
### Rack
|
353
371
|
|
354
372
|
Rack spans are created using the `rack-tracer` gem. This is enabled
|
355
373
|
automatically for other frameworks that are built on top of Rack, but it can
|
356
374
|
also be separately enabled.
|
357
375
|
|
358
|
-
The source for this instrumentation is located
|
376
|
+
The source for this instrumentation is located
|
377
|
+
[here](https://github.com/opentracing-contrib/ruby-rack-tracer).
|
359
378
|
|
360
|
-
|
379
|
+
#### Usage
|
361
380
|
|
362
381
|
```bash
|
363
382
|
$ # install the instrumentation if not done previously
|
@@ -372,14 +391,15 @@ end
|
|
372
391
|
use Rack::Tracer
|
373
392
|
```
|
374
393
|
|
375
|
-
|
394
|
+
### Rails
|
376
395
|
|
377
396
|
Rails applications can be traced using the notifications provided by ActiveSupport.
|
378
397
|
It will use `rack-tracer` to trace by requests.
|
379
398
|
|
380
|
-
The forked source for this instrumentation is located
|
399
|
+
The forked source for this instrumentation is located
|
400
|
+
[here](https://github.com/signalfx/ruby-rails-instrumentation).
|
381
401
|
|
382
|
-
|
402
|
+
#### Usage
|
383
403
|
|
384
404
|
```bash
|
385
405
|
$ # install the instrumentation if not done previously
|
@@ -408,13 +428,15 @@ Note that if `rack_tracer` is set to `false`, requests propagated to the Rails
|
|
408
428
|
app will not be extracted. For example, if a traced service makes a request to
|
409
429
|
an endpoint served by the Rails app, it will not be automatically nested.
|
410
430
|
|
411
|
-
|
431
|
+
### Redis
|
412
432
|
|
413
|
-
This instrumentation traces commands performed using the
|
433
|
+
This instrumentation traces commands performed using the
|
434
|
+
[Redis client](https://github.com/redis/redis-rb).
|
414
435
|
|
415
|
-
The source for this instrumentation is located
|
436
|
+
The source for this instrumentation is located
|
437
|
+
[here](https://github.com/signalfx/ruby-redis-instrumentation).
|
416
438
|
|
417
|
-
|
439
|
+
#### Usage
|
418
440
|
|
419
441
|
```bash
|
420
442
|
$ # install the instrumentation if not done previously
|
@@ -431,14 +453,15 @@ Arguments:
|
|
431
453
|
- `tracer`: Optional custom tracer to use for this instrumentation
|
432
454
|
- Default: `OpenTracing.global_tracer`
|
433
455
|
|
434
|
-
|
456
|
+
### RestClient
|
435
457
|
|
436
458
|
RestClient requests can be patched to automatically be wrapped in a span. It
|
437
459
|
will also inject the span context so remote services can extract it.
|
438
460
|
|
439
|
-
The source for this instrumentation is located
|
461
|
+
The source for this instrumentation is located
|
462
|
+
[here](https://github.com/signalfx/ruby-restclient-instrumentation).
|
440
463
|
|
441
|
-
|
464
|
+
#### Usage
|
442
465
|
|
443
466
|
```bash
|
444
467
|
$ # install the instrumentation if not done previously
|
@@ -457,13 +480,15 @@ Arguments:
|
|
457
480
|
- `propagate`: Propagate spans to the request endpoint.
|
458
481
|
- Default: `false`
|
459
482
|
|
460
|
-
|
483
|
+
### Sequel
|
461
484
|
|
462
|
-
Sequel instrumentation adds extensions to the Database and Dataset to trace
|
485
|
+
Sequel instrumentation adds extensions to the Database and Dataset to trace
|
486
|
+
queries.
|
463
487
|
|
464
|
-
The source for this instrumentation is located
|
488
|
+
The source for this instrumentation is located
|
489
|
+
[here](https://github.com/signalfx/ruby-sequel-instrumentation).
|
465
490
|
|
466
|
-
|
491
|
+
#### Usage
|
467
492
|
|
468
493
|
```bash
|
469
494
|
$ # install the instrumentation if not done previously
|
@@ -480,16 +505,19 @@ Arguments:
|
|
480
505
|
- `tracer`: Optional custom tracer for this instrumentation
|
481
506
|
- Default: `OpenTracing.global_tracer`
|
482
507
|
|
483
|
-
|
508
|
+
### Sidekiq
|
484
509
|
|
485
|
-
Sidekiq instrumentation traces worker job submissions and execution via
|
486
|
-
|
487
|
-
|
488
|
-
|
510
|
+
Sidekiq instrumentation traces worker job submissions and execution via
|
511
|
+
[Sidekiq middleware](https://github.com/mperham/sidekiq/wiki/Middleware).
|
512
|
+
The instrumenter registers both client and server middleware that use job
|
513
|
+
metadata to represent all job submissions and their invocations. Trace
|
514
|
+
context propagation adds to this job metadata to unifiy distributed client
|
515
|
+
and server requests and processing.
|
489
516
|
|
490
|
-
The source for this instrumentation is located
|
517
|
+
The source for this instrumentation is located
|
518
|
+
[here](https://github.com/signalfx/ruby-sidekiq-tracer).
|
491
519
|
|
492
|
-
|
520
|
+
#### Usage
|
493
521
|
|
494
522
|
```bash
|
495
523
|
$ # install the instrumentation if not done previously
|
@@ -505,20 +533,22 @@ end
|
|
505
533
|
Arguments:
|
506
534
|
- `tracer`: Optional custom tracer for this instrumentation
|
507
535
|
- Default: `OpenTracing.global_tracer`
|
508
|
-
- `propagate`: Optional boolean to enable/disable trace context injection via
|
536
|
+
- `propagate`: Optional boolean to enable/disable trace context injection via
|
537
|
+
job metadata
|
509
538
|
- Default: `true`
|
510
539
|
|
511
540
|
|
512
|
-
|
541
|
+
### Sinatra
|
513
542
|
|
514
543
|
Sinatra instrumentation traces requests and template rendering. The instrumenter
|
515
544
|
registers a Sinatra extension that uses `rack-tracer` to trace requests and
|
516
545
|
monkey-patches to trace view rendering. Rack instrumentation is automatically
|
517
546
|
enabled when using Sinatra instrumentation.
|
518
547
|
|
519
|
-
The source for this instrumentation is located
|
548
|
+
The source for this instrumentation is located
|
549
|
+
[here](https://github.com/signalfx/ruby-sinatra-instrumentation).
|
520
550
|
|
521
|
-
|
551
|
+
#### Usage
|
522
552
|
|
523
553
|
```bash
|
524
554
|
$ # install the instrumentation if not done previously
|
@@ -531,9 +561,10 @@ SignalFx::Tracing::Instrumenter.configure do |p|
|
|
531
561
|
end
|
532
562
|
```
|
533
563
|
|
534
|
-
##
|
564
|
+
## Configure the logger
|
535
565
|
|
536
|
-
The logger, based on the [Ruby Logger](https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html),
|
566
|
+
The logger, based on the [Ruby Logger](https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html),
|
567
|
+
can be configured by setting the following environment variables:
|
537
568
|
|
538
569
|
| Environmental Variable Name | Description | Default |
|
539
570
|
|:------------------------------|:----------------------|:-------------------- |
|
@@ -542,8 +573,13 @@ The logger, based on the [Ruby Logger](https://ruby-doc.org/stdlib-2.4.0/libdoc/
|
|
542
573
|
| `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
574
|
| `SIGNALFX_LOG_LEVEL` | The severity criteria for recording logs (from least to most severe). Options: `debug`, `info`, `warn`, `error`, `fatal`, `unknown` | `warn` |
|
544
575
|
|
545
|
-
More information regarding the logging configuration may be found
|
576
|
+
More information regarding the logging configuration may be found
|
577
|
+
[here](https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html).
|
546
578
|
|
547
579
|
**NB**:
|
548
|
-
- If the default path for `SIGNALFX_LOG_PATH` (that is, `/var/log/signalfx/signalfx-ruby-tracing.log`)
|
549
|
-
|
580
|
+
- If the default path for `SIGNALFX_LOG_PATH` (that is, `/var/log/signalfx/signalfx-ruby-tracing.log`)
|
581
|
+
is to be used, then please create the directory and or file (if necessary)
|
582
|
+
and grant the relevant access permissions to the instrumentation user process.
|
583
|
+
If there are permission issues, the instrumentation will default to logging to
|
584
|
+
the standard error (STDERR) handle, until the path is provided to which logs
|
585
|
+
can be written without any access issues.
|
data/Rakefile
CHANGED
data/bin/sfx-rb-trace-bootstrap
CHANGED
@@ -13,7 +13,7 @@ instrumentations = {
|
|
13
13
|
"nethttp" => ["nethttp-instrumentation", "~> 0.1.2"],
|
14
14
|
"pg" => ["pg-instrumentation", "~> 0.1.0"],
|
15
15
|
"rack" => ["rack-tracer", { git: 'git://github.com/signalfx/ruby-rack-tracer.git', branch: 'sfx_release' }],
|
16
|
-
"rails" => ["rails-instrumentation", "~> 0.1.
|
16
|
+
"rails" => ["rails-instrumentation", "~> 0.1.5"],
|
17
17
|
"redis" => ["redis-instrumentation", "~> 0.2.0"],
|
18
18
|
"restclient" => ["restclient-instrumentation", "~> 0.1.1"],
|
19
19
|
"sequel" => ["sequel-instrumentation", "~> 0.1.0"],
|
data/lib/signalfx/tracing.rb
CHANGED
@@ -2,6 +2,8 @@ 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'
|
6
|
+
require 'signalfx/tracing/tags'
|
5
7
|
require 'thread'
|
6
8
|
|
7
9
|
module SignalFx
|
@@ -25,7 +27,12 @@ module SignalFx
|
|
25
27
|
|
26
28
|
if auto_instrument
|
27
29
|
Register.available_libs.each_pair do |key, value|
|
28
|
-
|
30
|
+
begin
|
31
|
+
value.instrument
|
32
|
+
rescue Exception => e
|
33
|
+
logger.error { "failed to initialize instrumentation '#{key}': #{e.inspect}" }
|
34
|
+
logger.error { e.backtrace }
|
35
|
+
end
|
29
36
|
end
|
30
37
|
else
|
31
38
|
yield self
|
@@ -36,9 +43,14 @@ module SignalFx
|
|
36
43
|
|
37
44
|
def instrument(to_patch, **args)
|
38
45
|
if Register.available_libs[to_patch].nil?
|
39
|
-
|
46
|
+
logger.error { "instrumentation not found: #{to_patch}" }
|
40
47
|
else
|
41
|
-
|
48
|
+
begin
|
49
|
+
Register.available_libs[to_patch].instrument(**args)
|
50
|
+
rescue Exception => e
|
51
|
+
logger.error { "failed to initialize instrumentation '#{to_patch}': #{e.inspect}" }
|
52
|
+
logger.error { e.backtrace }
|
53
|
+
end
|
42
54
|
end
|
43
55
|
end
|
44
56
|
|
@@ -78,6 +90,13 @@ module SignalFx
|
|
78
90
|
def revive
|
79
91
|
set_tracer(service_name: @service_name, access_token: @access_token)
|
80
92
|
end
|
93
|
+
|
94
|
+
def logger()
|
95
|
+
if @_logger == nil
|
96
|
+
@_logger = Logging.logger
|
97
|
+
end
|
98
|
+
return @_logger
|
99
|
+
end
|
81
100
|
end
|
82
101
|
end
|
83
102
|
|
@@ -31,9 +31,9 @@ module SignalFx
|
|
31
31
|
::Faraday::Connection.module_eval do
|
32
32
|
alias_method :initialize_original, :initialize
|
33
33
|
|
34
|
-
def initialize(url = nil, options = nil)
|
34
|
+
def initialize(url = nil, options = nil, &block)
|
35
35
|
# initialize the connection as usual
|
36
|
-
initialize_original(url, options)
|
36
|
+
initialize_original(url, options, &block)
|
37
37
|
|
38
38
|
# before we let go, add the Faraday tracer to the beginning of the stack
|
39
39
|
@builder.insert(0, ::Faraday::Tracer)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'jaeger/span'
|
2
|
+
|
3
|
+
module SignalFx
|
4
|
+
module Tracing
|
5
|
+
module TagBuilder
|
6
|
+
def self.prepended(base)
|
7
|
+
base.singleton_class.prepend(ClassMethods)
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
@@max_attr_length = (ENV['SIGNALFX_RECORDED_VALUE_MAX_LENGTH'] || '1200').to_i
|
12
|
+
|
13
|
+
def self.max_attr_length
|
14
|
+
@@max_attr_length
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.max_attr_length=(v)
|
18
|
+
@@max_attr_length = v
|
19
|
+
end
|
20
|
+
|
21
|
+
def _truncate_value_if_needed(value)
|
22
|
+
if value.is_a? String
|
23
|
+
if @@max_attr_length > 0
|
24
|
+
value = value[0..@@max_attr_length-1]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
return value
|
28
|
+
end
|
29
|
+
|
30
|
+
def build(key, value)
|
31
|
+
tag = super(key, value)
|
32
|
+
if tag.vStr != nil
|
33
|
+
tag.vStr = _truncate_value_if_needed(tag.vStr)
|
34
|
+
end
|
35
|
+
tag
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
module Jaeger
|
44
|
+
class ThriftTagBuilder
|
45
|
+
prepend SignalFx::Tracing::TagBuilder
|
46
|
+
end
|
47
|
+
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.3
|
4
|
+
version: 1.4.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-11-11 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:
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/signalfx/tracing/register.rb
|
119
119
|
- lib/signalfx/tracing/reporter/auto_reviving_async_reporter.rb
|
120
120
|
- lib/signalfx/tracing/sfx_logger.rb
|
121
|
+
- lib/signalfx/tracing/tags.rb
|
121
122
|
- lib/signalfx/tracing/tracer.rb
|
122
123
|
- lib/signalfx/tracing/version.rb
|
123
124
|
- signalfx-tracing.gemspec
|
@@ -125,7 +126,7 @@ homepage: https://github.com/signalfx/signalfx-ruby-tracing
|
|
125
126
|
licenses:
|
126
127
|
- Apache-2.0
|
127
128
|
metadata: {}
|
128
|
-
post_install_message:
|
129
|
+
post_install_message:
|
129
130
|
rdoc_options: []
|
130
131
|
require_paths:
|
131
132
|
- lib
|
@@ -140,8 +141,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
141
|
- !ruby/object:Gem::Version
|
141
142
|
version: '0'
|
142
143
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
144
|
-
signing_key:
|
144
|
+
rubygems_version: 3.1.2
|
145
|
+
signing_key:
|
145
146
|
specification_version: 4
|
146
147
|
summary: Auto-instrumentation framework for Ruby
|
147
148
|
test_files: []
|