signalfx-tracing 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 70e37568d76b69c20af72f6e4a439028e568da24
4
+ data.tar.gz: 0c88d1c7bc2f4c57b1a0f8dca466957015521e2d
5
+ SHA512:
6
+ metadata.gz: dc46b65b0ed79229223ea58013e2700d7f6b91d16f044812d3fcafb30699f60bc28751a308aa1ea39c4491b93766508a355c3b4b2cf31d777d9b7a1eb32cd951
7
+ data.tar.gz: 9abac060656963f07e8d6eb83022c429ba86410e7e743418057b967cab5f236f1a595f0e07eb92c66672a3ebfc2c2de5273487a0c58a6ba7e45c347cd711d984
data/README.md CHANGED
@@ -135,6 +135,7 @@ When interfacing with these web servers as a Rack application, please configure
135
135
  | [Mongo](#mongo) | >= 2.1.0 |
136
136
  | [Mysql2](#mysql2) | >= 0.4.0 |
137
137
  | [Net::HTTP](#nethttp) | Ruby >= 2.0 |
138
+ | [Pg](#pg) | >= 0.18.0 |
138
139
  | [Rack](#rack) | >= 0.1 |
139
140
  | [Rails](#rails) | >= 3.0.0 |
140
141
  | [Redis](#redis) | >= 4.0.0 |
@@ -330,6 +331,24 @@ end
330
331
 
331
332
  An optional `tracer` named argument can be provided to use a custom tracer. It will default to `OpenTracing.global_tracer` if not provided.
332
333
 
334
+ ## Pg
335
+
336
+ Pg instrumentation traces all queries performed with the pg client.
337
+
338
+ The source for this instrumentation is located [here](https://github.com/signalfx/ruby-pg-instrumentation)
339
+
340
+ ### Usage
341
+
342
+ ```bash
343
+ $ # install the instrumentation if not done previously
344
+ $ sfx-rb-trace-bootstrap -i pg
345
+ ```
346
+
347
+ ```ruby
348
+ SignalFx::Tracing::Instrumenter.configure do |p|
349
+ p.instrument(:pg)
350
+ end
351
+ ```
333
352
  ## Rack
334
353
 
335
354
  Rack spans are created using the `rack-tracer` gem. This is enabled
@@ -512,3 +531,19 @@ SignalFx::Tracing::Instrumenter.configure do |p|
512
531
  end
513
532
  ```
514
533
 
534
+ ## Configuring the Logger
535
+
536
+ The logger, based on the [Ruby Logger](https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html), can be configured by setting the following environment variables:
537
+
538
+ | Environmental Variable Name | Description | Default |
539
+ |:------------------------------|:----------------------|:-------------------- |
540
+ | `SIGNALFX_LOG_PATH` | The path to the desired file where the instrumentation logs will be written. Besides customized paths, output options also include `STDOUT` and `STDERR`.| `/var/log/signalfx/signalfx-ruby-tracing.log` |
541
+ | `SIGNALFX_LOG_SHIFT_AGE` | The desired number of old log files to keep, or frequency of rotation. Options include: `daily`, `weekly` or `monthly`) | `0` |
542
+ | `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
+ | `SIGNALFX_LOG_LEVEL` | The severity criteria for recording logs (from least to most severe). Options: `debug`, `info`, `warn`, `error`, `fatal`, `unknown` | `warn` |
544
+
545
+ More information regarding the logging configuration may be found [here](https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html).
546
+
547
+ **NB**:
548
+ - If the default path for `SIGNALFX_LOG_PATH` (that is, `/var/log/signalfx/signalfx-ruby-tracing.log`) is to be used, then please create the directory and or file (if necessary) and grant the relevant access permissions to the instrumentation user process.
549
+ If there are permission issues, the instrumentation will default to logging to the standard error (STDERR) handle, until the path is provided to which logs can be written without any access issues.
@@ -11,6 +11,7 @@ instrumentations = {
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
+ "pg" => ["pg-instrumentation", "~> 0.1.0"],
14
15
  "rack" => ["rack-tracer", { git: 'git://github.com/signalfx/ruby-rack-tracer.git', branch: 'sfx_release' }],
15
16
  "rails" => ["rails-instrumentation", "~> 0.1.3"],
16
17
  "redis" => ["redis-instrumentation", "~> 0.1.1"],
data/gem.deps.rb CHANGED
@@ -4,6 +4,7 @@ group :instrumentations do
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
+ gem 'pg-instrumentation', '~> 0.1.0'
7
8
  gem 'rack-tracer', git: 'git://github.com/signalfx/ruby-rack-tracer.git', branch: 'sfx_release'
8
9
  gem 'rails-instrumentation', '0.1.3'
9
10
  gem 'redis-instrumentation', '~> 0.1.1'
@@ -0,0 +1,41 @@
1
+ require_relative '../sfx_logger'
2
+
3
+ module SignalFx
4
+ module Tracing
5
+ module Instrumenter
6
+ module PG
7
+
8
+ @logger = Logging.logger
9
+ @logger.debug('SFx pg-instrumentation') { "Initializing instrumentation ..." }
10
+
11
+ Register.add_lib :PG, self
12
+
13
+ class << self
14
+
15
+ def instrument(opts = {})
16
+ return if @instrumented
17
+
18
+ # check for required gems
19
+ begin
20
+ require 'pg'
21
+ rescue LoadError
22
+ return
23
+ end
24
+
25
+ begin
26
+ require 'pg/instrumentation'
27
+ rescue LoadError => e
28
+ @logger.error { e.message }
29
+ return
30
+ end
31
+
32
+ tracer = opts.fetch(:tracer, OpenTracing.global_tracer)
33
+
34
+ ::PG::Instrumentation.instrument(tracer: tracer) if !@instrumented
35
+ @instrumented = true
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -43,3 +43,4 @@ require 'signalfx/tracing/instrumentation/redis'
43
43
  require 'signalfx/tracing/instrumentation/sequel'
44
44
  require 'signalfx/tracing/instrumentation/grape'
45
45
  require 'signalfx/tracing/instrumentation/sidekiq'
46
+ require 'signalfx/tracing/instrumentation/pg'
@@ -0,0 +1,57 @@
1
+ require 'logger'
2
+
3
+ module SignalFx
4
+ module Tracing
5
+ module Logging
6
+
7
+ LOG_LEVELS = {
8
+ 'unknown' => Logger::UNKNOWN,
9
+ 'fatal' => Logger::FATAL,
10
+ 'error' => Logger::ERROR,
11
+ 'warn' => Logger::WARN,
12
+ 'info' => Logger::INFO,
13
+ 'debug' => Logger::DEBUG
14
+ }.freeze
15
+
16
+ DEFAULT_LOG_PATH = '/var/log/signalfx/signalfx-ruby-tracing.log'
17
+ DEFAULT_SHIFT_AGE = 5
18
+ DEFAULT_SHIFT_SIZE = 1048576
19
+
20
+ def self.create (log_path = ENV['SIGNALFX_LOG_PATH'] || DEFAULT_LOG_PATH,
21
+ sfx_shift_age = ENV['SIGNALFX_LOG_SHIFT_AGE'] || DEFAULT_SHIFT_AGE,
22
+ sfx_shift_size = ENV['SIGNALFX_LOG_SHIFT_SIZE'] || DEFAULT_SHIFT_SIZE)
23
+
24
+ if log_path.upcase == 'STDOUT'
25
+ @logger = Logger.new(STDOUT)
26
+ elsif log_path.upcase == 'STDERR'
27
+ self.create_stderr_logger()
28
+ else
29
+ begin
30
+ @logger = Logger.new("#{log_path}", shift_age = sfx_shift_age, shift_size = sfx_shift_size)
31
+ rescue Errno::EACCES, Errno::ENOENT => e
32
+ self.create_stderr_logger(log_path, e)
33
+ end
34
+ end
35
+
36
+ log_level = ENV['SIGNALFX_LOG_LEVEL'].downcase if ENV['SIGNALFX_LOG_LEVEL']
37
+ @logger.level = LOG_LEVELS.fetch(log_level, Logger::WARN)
38
+ @logger.datetime_format = '%Y-%m-%d %H:%M:%S'
39
+ @logger.formatter = proc do | severity, datetime, progname, msg |
40
+ "#{datetime}, #{severity}: #{msg} --- #{progname} \n"
41
+ end
42
+ @logger
43
+ end
44
+
45
+ def self.logger
46
+ @logger ||= self.create
47
+ end
48
+
49
+ def self.create_stderr_logger(logpath=nil, error=nil)
50
+ @logger = Logger.new(STDERR)
51
+ if error
52
+ @logger.error { "LOG FILE ACCESS ERROR:\n*** Failed to write to '#{logpath}': #{error.message}\n--> Please manually create the required resources and/or grant relevant access permissions to this user process.\n*** Defaulting to sending log statements to the standard error (STDERR) handle.\n"}
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,5 +1,5 @@
1
1
  module Signalfx
2
2
  module Tracing
3
- VERSION = "1.2.0"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: signalfx-tracing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
5
- prerelease:
4
+ version: 1.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - SignalFx, Inc.
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2019-11-20 00:00:00.000000000 Z
11
+ date: 2020-02-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.16'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.16'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '10.0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: '10.0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: opentracing
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - '>'
45
+ - - ">"
52
46
  - !ruby/object:Gem::Version
53
47
  version: 0.3.0
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - '>'
52
+ - - ">"
60
53
  - !ruby/object:Gem::Version
61
54
  version: 0.3.0
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: jaeger-client
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: 1.0.0
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: 1.0.0
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: nethttp-instrumentation
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
75
  version: 0.1.2
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
82
  version: 0.1.2
94
83
  description:
@@ -99,7 +88,7 @@ executables:
99
88
  extensions: []
100
89
  extra_rdoc_files: []
101
90
  files:
102
- - .gitignore
91
+ - ".gitignore"
103
92
  - Gemfile
104
93
  - LICENSE
105
94
  - README.md
@@ -118,6 +107,7 @@ files:
118
107
  - lib/signalfx/tracing/instrumentation/mysql2.rb
119
108
  - lib/signalfx/tracing/instrumentation/net_http.rb
120
109
  - lib/signalfx/tracing/instrumentation/patching-test.rb
110
+ - lib/signalfx/tracing/instrumentation/pg.rb
121
111
  - lib/signalfx/tracing/instrumentation/rack.rb
122
112
  - lib/signalfx/tracing/instrumentation/rails.rb
123
113
  - lib/signalfx/tracing/instrumentation/redis.rb
@@ -127,32 +117,32 @@ files:
127
117
  - lib/signalfx/tracing/instrumentation/sinatra.rb
128
118
  - lib/signalfx/tracing/register.rb
129
119
  - lib/signalfx/tracing/reporter/auto_reviving_async_reporter.rb
120
+ - lib/signalfx/tracing/sfx_logger.rb
130
121
  - lib/signalfx/tracing/tracer.rb
131
122
  - lib/signalfx/tracing/version.rb
132
123
  - signalfx-tracing.gemspec
133
124
  homepage: https://github.com/signalfx/signalfx-ruby-tracing
134
125
  licenses:
135
126
  - Apache-2.0
127
+ metadata: {}
136
128
  post_install_message:
137
129
  rdoc_options: []
138
130
  require_paths:
139
131
  - lib
140
132
  required_ruby_version: !ruby/object:Gem::Requirement
141
- none: false
142
133
  requirements:
143
- - - '>='
134
+ - - ">="
144
135
  - !ruby/object:Gem::Version
145
136
  version: '0'
146
137
  required_rubygems_version: !ruby/object:Gem::Requirement
147
- none: false
148
138
  requirements:
149
- - - '>='
139
+ - - ">="
150
140
  - !ruby/object:Gem::Version
151
141
  version: '0'
152
142
  requirements: []
153
143
  rubyforge_project:
154
- rubygems_version: 1.8.25
144
+ rubygems_version: 2.5.2.3
155
145
  signing_key:
156
- specification_version: 3
146
+ specification_version: 4
157
147
  summary: Auto-instrumentation framework for Ruby
158
148
  test_files: []