signalfx-tracing 1.5.2 → 1.6.0

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: 76f49e90a746e01bab86b3172c2ddd7f49aae975d70191f297a1e18e110e558d
4
- data.tar.gz: 677c15658a0d10c61c8defc270e1c9a4d84c8e838626dfc9fc63198927ba755f
3
+ metadata.gz: 49437c65e9bfc27abb4f181a5d313fb6a4c9bf50fd772c69740c0ac6b2b8f76e
4
+ data.tar.gz: 03302bdbd211243994211258d45d8d31bdb64f2937a5d761d96aabdead863048
5
5
  SHA512:
6
- metadata.gz: b934a8cdc290183f72306b772e1b4422171ad3c717fe97c9f9c697deb543c67d95ce25b7c7073dcc50e30a888a1ae5101477fb6260c611c82c985ee81d11b7bb
7
- data.tar.gz: 91a4a8d6817d3c28cb70672f315706a5c4153d279a956682650c0adf4d7ec69fa6ab305c38dce31220eca11932a924e6d63484427c18288057218cb13b69fa77
6
+ metadata.gz: 312b0aacb48ca54b5b27b5285d179216ca2e57b2ec22c88dff141a2859be907e3891be3e71b63aeccc18ff501051adf4faead0558be63b76413097e7db257197
7
+ data.tar.gz: 90bf8a6f27e8ca4b856b3c06ff9e09f4c20b5ac7deda0bcd300c099233e15b14c981291b926f6a90e6ac86f2109137f5ad6d5c422c584b7cdbb914ba2af4fe48
data/README.md CHANGED
@@ -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
@@ -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,14 +3,14 @@ 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)
6
+ def record_exception(exception, record_error=true)
7
+ set_tag('error', true) if record_error
8
8
  log_kv(
9
9
  event: 'error',
10
- :'error.kind' => error.class.to_s,
11
- :'error.object' => error,
12
- message: error.message,
13
- stack: error.backtrace.join("\n")
10
+ :'error.kind' => exception.class.to_s,
11
+ :'error.object' => exception,
12
+ message: exception.message,
13
+ stack: exception.backtrace.join("\n")
14
14
  )
15
15
  end
16
16
  end
@@ -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.2"
3
+ VERSION = "1.6.0"
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.2
4
+ version: 1.6.0
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-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -110,7 +110,6 @@ files:
110
110
  - bin/sfx-rb-trace-bootstrap
111
111
  - gem.deps.rb
112
112
  - lib/signalfx/tracing.rb
113
- - lib/signalfx/tracing/client.rb
114
113
  - lib/signalfx/tracing/compat.rb
115
114
  - lib/signalfx/tracing/compat/phusion_passenger.rb
116
115
  - 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