signalfx-tracing 1.5.1 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e746c7d7bd14f60dd0f45b263b38e05e4f4e591b221ad877d047c38aaf4ec8bf
4
- data.tar.gz: 7916da5154ead8d2cd37325bfa1bf9ed4f254704919d9802fb883a5783a0aeb9
3
+ metadata.gz: 2f20ce1d0998b95c507dd19b340537e51865387f1ab5022c45185746e0d03667
4
+ data.tar.gz: 0ada0dc7104f4dbaedd9194928117e7baf0aa23ae3ba66f69371bfc253582f0c
5
5
  SHA512:
6
- metadata.gz: 8e82266212716e99449a73c3d11a8bbee4229c213b95d3be3cea1e96e562ea97969f807f95ebfec0c5e12fae2155ad9b7b8a6960eee7a6a7675e51979d8554f9
7
- data.tar.gz: 26cd1d84fb7171603390a5f569122d7a91919e5c53b44041a358d651c685ae428d538e81afc6af780bec5024320dae394b0e8d2790e8ea4523077fdc8d8089c0
6
+ metadata.gz: baedb458a7cd326d523f53845cfc8157201de6d34811fde58c3643e8da2cb081e0a83186ee53e7815e86db11671659d87a33ab06ef56d496e74e3e0007fcfc34
7
+ data.tar.gz: b0ad72691b7a438b008d4748a4717cfc0f1a004b8cb939a1392f2fb88aa4cb7030807a23b8132829d80200443da11096fa21afad987b330b20e40fbaf230a7b9
data/README.md CHANGED
@@ -29,7 +29,7 @@ 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.13.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 |
@@ -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
@@ -156,7 +158,7 @@ This instrumentation creates spans for each Active Record query using the Active
156
158
  Support notifications framework. If you configure Rails instrumentation, it also configures Active Record instrumentation, so you don't need to instrument both.
157
159
 
158
160
  The source for this instrumentation is located
159
- [here](https://github.com/salemove/ruby-activerecord-opentracing).
161
+ [here](https://github.com/signalfx/ruby-activerecord-opentracing).
160
162
 
161
163
  #### Usage
162
164
 
@@ -216,7 +218,7 @@ requests. If the remote service has instrumentation that is aware of Rack,
216
218
  those spans will be automatically nested with Faraday's spans.
217
219
 
218
220
  The source for this instrumentation is located
219
- [here](https://github.com/opentracing-contrib/ruby-faraday-tracer).
221
+ [here](https://github.com/signalfx/ruby-faraday-tracer).
220
222
 
221
223
  #### Usage
222
224
 
@@ -374,7 +376,7 @@ 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/opentracing-contrib/ruby-rack-tracer).
379
+ [here](https://github.com/signalfx/ruby-rack-tracer).
378
380
 
379
381
  #### Usage
380
382
 
@@ -4,21 +4,21 @@ require 'ostruct'
4
4
  require 'pp'
5
5
 
6
6
  instrumentations = {
7
- "activerecord" => ["activerecord-opentracing", "~> 0.2.1"],
8
- "elasticsearch" => ["signalfx-elasticsearch-instrumentation", "~> 0.1.0"],
9
- "faraday" => ["signalfx-faraday-instrumentation", "~> 0.1.1"],
10
- "grape" => ["grape-instrumentation", "~> 0.1.0"],
11
- "mongodb" => ["mongodb-instrumentation", "~> 0.1.1"],
12
- "mysql2" => ["mysql2-instrumentation", "~> 0.2.1"],
13
- "nethttp" => ["nethttp-instrumentation", "~> 0.1.2"],
14
- "pg" => ["pg-instrumentation", "~> 0.1.0"],
15
- "rack" => ["sfx-rack-tracer", "~> 0.10.0"],
16
- "rails" => ["rails-instrumentation", "~> 0.1.5"],
17
- "redis" => ["redis-instrumentation", "~> 0.2.0"],
18
- "restclient" => ["restclient-instrumentation", "~> 0.1.1"],
19
- "sequel" => ["sequel-instrumentation", "~> 0.1.0"],
20
- "sidekiq" => ["sfx-sidekiq-opentracing", "~> 0.0.3"],
21
- "sinatra" => ["sinatra-instrumentation", "~> 0.1.2"]
7
+ "activerecord" => ["signalfx-activerecord-opentracing", "~> 0.1.0"],
8
+ "elasticsearch" => ["signalfx-elasticsearch-instrumentation", "~> 0.2.0"],
9
+ "faraday" => ["signalfx-faraday-instrumentation", "~> 0.2.0"],
10
+ "grape" => ["signalfx-grape-instrumentation", "~> 0.1.0"],
11
+ "mongodb" => ["signalfx-mongodb-instrumentation", "~> 0.1.1"],
12
+ "mysql2" => ["signalfx-mysql2-instrumentation", "~> 0.1.1"],
13
+ "nethttp" => ["signalfx-nethttp-instrumentation", "~> 0.2.0"],
14
+ "pg" => ["signalfx-pg-instrumentation", "~> 0.1.0"],
15
+ "rack" => ["signalfx-rack-tracer", "~> 0.1.0"],
16
+ "rails" => ["signalfx-rails-instrumentation", "~> 0.2.0"],
17
+ "redis" => ["signalfx-redis-instrumentation", "~> 0.1.0"],
18
+ "restclient" => ["signalfx-restclient-instrumentation", "~> 0.1.0"],
19
+ "sequel" => ["signalfx-sequel-instrumentation", "~> 0.1.0"],
20
+ "sidekiq" => ["signalfx-sidekiq-opentracing", "~> 0.1.0"],
21
+ "sinatra" => ["signalfx-sinatra-instrumentation", "~> 0.1.0"]
22
22
  }
23
23
 
24
24
  options = OpenStruct.new
@@ -1,17 +1,17 @@
1
1
  group :instrumentations do
2
- gem 'activerecord-opentracing', '~> 0.2.1'
3
- gem 'grape-instrumentation', "~> 0.1.0"
4
- gem 'mongodb-instrumentation', '~> 0.1.1'
5
- gem 'mysql2-instrumentation', '~> 0.2.1'
6
- gem 'nethttp-instrumentation', '~> 0.1.2'
7
- gem 'pg-instrumentation', '~> 0.1.0'
8
- gem 'sfx-rack-tracer', '0.10.0'
9
- gem 'rails-instrumentation', '0.1.3'
10
- gem 'redis-instrumentation', '~> 0.2.0'
11
- gem 'restclient-instrumentation', '~> 0.1.1'
12
- gem 'sequel-instrumentation', '~> 0.1.0'
13
- gem 'sfx-sidekiq-opentracing', '~> 0.0.3'
14
- gem 'signalfx-elasticsearch-instrumentation', '~> 0.1.0'
15
- gem 'signalfx-faraday-instrumentation', '~> 0.1.1'
16
- gem 'sinatra-instrumentation', '~> 0.1.2'
2
+ gem 'signalfx-activerecord-opentracing', '~> 0.1.0'
3
+ gem 'signalfx-grape-instrumentation', "~> 0.1.0"
4
+ gem 'signalfx-mongodb-instrumentation', '~> 0.1.1'
5
+ gem 'signalfx-mysql2-instrumentation', '~> 0.1.1'
6
+ gem 'signalfx-nethttp-instrumentation', '~> 0.2.0'
7
+ gem 'signalfx-pg-instrumentation', '~> 0.1.0'
8
+ gem 'signalfx-rack-tracer', '~> 0.1.0'
9
+ gem 'signalfx-rails-instrumentation', '~> 0.2.0'
10
+ gem 'signalfx-redis-instrumentation', '~> 0.1.0'
11
+ gem 'signalfx-restclient-instrumentation', '~> 0.1.0'
12
+ gem 'signalfx-sequel-instrumentation', '~> 0.1.0'
13
+ gem 'signalfx-sidekiq-opentracing', '~> 0.1.0'
14
+ gem 'signalfx-elasticsearch-instrumentation', '~> 0.2.0'
15
+ gem 'signalfx-faraday-instrumentation', '~> 0.2.0'
16
+ gem 'signalfx-sinatra-instrumentation', '~> 0.1.0'
17
17
  end
@@ -1,8 +1,10 @@
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
- require 'signalfx/tracing/client'
6
8
  require 'signalfx/tracing/sfx_logger'
7
9
  require 'signalfx/tracing/tags'
8
10
  require 'signalfx/tracing/tracer'
@@ -22,11 +24,14 @@ module SignalFx
22
24
  ingest_url: ENV['SIGNALFX_ENDPOINT_URL'] || ENV['SIGNALFX_INGEST_URL'] || 'http://localhost:9080/v1/trace',
23
25
  service_name: ENV['SIGNALFX_SERVICE_NAME'] || "signalfx-ruby-tracing",
24
26
  access_token: ENV['SIGNALFX_ACCESS_TOKEN'],
25
- auto_instrument: false)
27
+ auto_instrument: false,
28
+ span_tags: {})
26
29
  @ingest_url = ingest_url
27
30
  @service_name = service_name
28
31
  @access_token = access_token
29
- set_tracer(tracer: tracer, service_name: service_name, access_token: access_token) if @tracer.nil?
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?
30
35
 
31
36
  if auto_instrument
32
37
  Register.available_libs.each_pair do |key, value|
@@ -44,6 +49,17 @@ module SignalFx
44
49
  Compat.apply
45
50
  end
46
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
+
47
63
  def instrument(to_patch, **args)
48
64
  if Register.available_libs[to_patch].nil?
49
65
  logger.error { "instrumentation not found: #{to_patch}" }
@@ -57,33 +73,38 @@ module SignalFx
57
73
  end
58
74
  end
59
75
 
60
- def set_tracer(tracer: nil, service_name: nil, access_token: nil)
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: {})
61
105
  # build a new tracer if one wasn't provided
62
106
  if tracer.nil?
63
- headers = {}
64
-
65
- # don't set the header if no token was provided
66
- headers["X-SF-Token"] = access_token if access_token && !access_token.empty?
67
-
68
- encoder = Jaeger::Client::Encoders::ThriftEncoder.new(service_name: service_name)
69
- @http_sender = SignalFx::Tracing::HttpSenderWithFlag.new(url: @ingest_url, headers: headers, encoder: encoder)
70
- @reporter = Jaeger::Client::Reporters::RemoteReporter.new(sender: @http_sender, flush_interval: 1)
71
-
72
- injectors = {
73
- OpenTracing::FORMAT_RACK => [Jaeger::Client::Injectors::B3RackCodec],
74
- OpenTracing::FORMAT_TEXT_MAP => [Jaeger::Client::Injectors::B3RackCodec]
75
- }
76
- extractors = {
77
- OpenTracing::FORMAT_RACK => [Jaeger::Client::Extractors::B3RackCodec],
78
- OpenTracing::FORMAT_TEXT_MAP => [Jaeger::Client::Extractors::B3TextMapCodec]
79
- }
80
-
81
- @tracer = SignalFx::Tracing::Client.build(
82
- service_name: service_name,
83
- reporter: @reporter,
84
- injectors: injectors,
85
- extractors: extractors
86
- )
107
+ @tracer = new_tracer(service_name: service_name, access_token: access_token, span_tags: span_tags)
87
108
  OpenTracing.global_tracer = @tracer
88
109
  else
89
110
  @tracer = tracer
@@ -3,19 +3,16 @@ require 'jaeger/span'
3
3
  module SignalFx
4
4
  module Tracing
5
5
  module Span
6
- def set_error(error)
7
- set_tag('error', true)
8
- log_kv(
9
- event: 'error',
10
- :'error.kind' => error.class.to_s,
11
- :'error.object' => error,
12
- message: error.message,
13
- stack: error.backtrace.join("\n")
14
- )
6
+ def record_exception(exception, record_error=true)
7
+ set_tag(:error, true) if record_error
8
+ set_tag(:'sfx.error.kind', exception.class.to_s)
9
+ set_tag(:'sfx.error.message', exception.message)
10
+ if not exception.backtrace.nil?
11
+ set_tag(:'sfx.error.stack', exception.backtrace.join('\n'))
12
+ end
15
13
  end
16
14
  end
17
15
  end
18
16
  end
19
17
 
20
-
21
- Jaeger::Span.class_eval { include SignalFx::Tracing::Span }
18
+ Jaeger::Span.class_eval { prepend SignalFx::Tracing::Span }
@@ -13,9 +13,9 @@ module SignalFx
13
13
  @reporter = reporter
14
14
  end
15
15
 
16
- def set_error(error)
16
+ def record_exception(exception, record_error=true)
17
17
  span = active_span
18
- span.set_error(error) if span
18
+ span.record_exception(exception, record_error) if span
19
19
  end
20
20
  end
21
21
  end
@@ -1,5 +1,5 @@
1
1
  module Signalfx
2
2
  module Tracing
3
- VERSION = "1.5.1"
3
+ VERSION = "2.1.1"
4
4
  end
5
5
  end
@@ -35,4 +35,8 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  # stdlib instrumentations
37
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"
38
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.5.1
4
+ version: 2.1.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-13 00:00:00.000000000 Z
11
+ date: 2020-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,34 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.1.2
97
+ - !ruby/object:Gem::Dependency
98
+ name: faraday
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: signalfx-faraday-instrumentation
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  description:
98
126
  email:
99
127
  - info@signalfx.com
@@ -110,7 +138,6 @@ files:
110
138
  - bin/sfx-rb-trace-bootstrap
111
139
  - gem.deps.rb
112
140
  - lib/signalfx/tracing.rb
113
- - lib/signalfx/tracing/client.rb
114
141
  - lib/signalfx/tracing/compat.rb
115
142
  - lib/signalfx/tracing/compat/phusion_passenger.rb
116
143
  - lib/signalfx/tracing/http_sender.rb
@@ -1,38 +0,0 @@
1
- module SignalFx
2
- module Tracing
3
- module Client
4
- include ::Jaeger::Client
5
-
6
- def self.build(host: '127.0.0.1',
7
- port: 6831,
8
- service_name:,
9
- flush_interval: DEFAULT_FLUSH_INTERVAL,
10
- sampler: Samplers::Const.new(true),
11
- logger: Logger.new(STDOUT),
12
- sender: nil,
13
- reporter: nil,
14
- injectors: {},
15
- extractors: {},
16
- tags: {})
17
- encoder = Encoders::ThriftEncoder.new(service_name: service_name, tags: tags)
18
-
19
- if sender
20
- warn '[DEPRECATION] Passing `sender` directly to Jaeger::Client.build is deprecated.' \
21
- 'Please use `reporter` instead.'
22
- end
23
-
24
- reporter ||= Reporters::RemoteReporter.new(
25
- sender: sender || UdpSender.new(host: host, port: port, encoder: encoder, logger: logger),
26
- flush_interval: flush_interval
27
- )
28
-
29
- Tracer.new(
30
- reporter: reporter,
31
- sampler: sampler,
32
- injectors: Injectors.prepare(injectors),
33
- extractors: Extractors.prepare(extractors)
34
- )
35
- end
36
- end
37
- end
38
- end