skylight 5.2.0.beta → 5.2.0.beta2

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.
@@ -68,5 +68,8 @@ module Skylight
68
68
 
69
69
  # E0006
70
70
  register(6, "InvalidUtf8", "Invalid UTF-8")
71
+
72
+ # E0007
73
+ register(7, "GrpcConnect", "Failed to connect to gRPC server.")
71
74
  end
72
75
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "skylight/util/lru_cache"
4
- require "active_support/dependencies"
4
+ require "active_support/inflector"
5
5
 
6
6
  module Skylight
7
7
  module Extensions
@@ -163,7 +163,7 @@ module Skylight
163
163
 
164
164
  def instance_method_source_location(constant_name, method_name, source_name: :instance_method)
165
165
  @instance_method_source_location_cache.fetch([constant_name, method_name, source_name]) do
166
- if (constant = ::ActiveSupport::Dependencies.safe_constantize(constant_name))
166
+ if (constant = ::ActiveSupport::Inflector.safe_constantize(constant_name))
167
167
  if constant.instance_methods.include?(:"before_instrument_#{method_name}")
168
168
  method_name = :"before_instrument_#{method_name}"
169
169
  end
@@ -15,7 +15,7 @@ module Skylight
15
15
  .tap do |str|
16
16
  if str.match(DELIVERY_JOB)
17
17
  mailer_class, mailer_method, * = job_instance.arguments
18
- return "#{mailer_class}##{mailer_method}", str
18
+ return "#{mailer_class}##{mailer_method}", str if mailer_class && mailer_method
19
19
  end
20
20
  end
21
21
  end
@@ -33,9 +33,7 @@ module Skylight
33
33
  end
34
34
 
35
35
  def normalize_after(trace, _span, _name, payload)
36
- return unless config.enable_segments? && assign_endpoint?(trace, payload)
37
-
38
- trace.segment = payload[:job].queue_name
36
+ maybe_set_endpoint(trace, payload)
39
37
  end
40
38
 
41
39
  private
@@ -53,31 +51,30 @@ module Skylight
53
51
  end
54
52
 
55
53
  def maybe_set_endpoint(trace, payload)
56
- trace.endpoint = normalize_title(payload[:job]) if assign_endpoint?(trace, payload)
57
- end
54
+ endpoint = normalize_title(payload[:job])
58
55
 
59
- def assign_endpoint?(trace, payload)
60
56
  # Always assign the endpoint if it has not yet been assigned by the ActiveJob probe.
61
- return true unless trace.endpoint
62
- if defined?(Skylight::Probes::ActiveJob::TITLE) && trace.endpoint == Skylight::Probes::ActiveJob::TITLE
63
- return true
64
- end
65
- if defined?(SKylight::Probes::DelayedJob::Probe::UNKNOWN) &&
66
- trace.endpoint == Skylight::Probes::DelayedJob::Probe::UNKNOWN
67
- return true
57
+ if !trace.endpoint ||
58
+ (defined?(Skylight::Probes::ActiveJob::TITLE) && trace.endpoint == Skylight::Probes::ActiveJob::TITLE) ||
59
+ (
60
+ defined?(Skylight::Probes::DelayedJob::Probe::UNKNOWN) &&
61
+ trace.endpoint == Skylight::Probes::DelayedJob::Probe::UNKNOWN
62
+ ) ||
63
+ # If a job is called using #perform_now inside a controller action
64
+ # or within another job's #perform method, we do not want this to
65
+ # overwrite the existing endpoint name (unless it is the default from ActiveJob).
66
+ #
67
+ # If the current endpoint name matches this payload, return true to allow the
68
+ # segment to be assigned by normalize_after.
69
+ trace.endpoint =~ DELIVERY_JOB ||
70
+ # This adapter wrapper needs to be handled specifically due to interactions with the
71
+ # standalone Delayed::Job probe, as there is no consistent way to get the wrapped
72
+ # job name among all Delayed::Job backends.
73
+ trace.endpoint == DELAYED_JOB_WRAPPER
74
+ trace.endpoint = endpoint
68
75
  end
69
76
 
70
- # If a job is called using #perform_now inside a controller action
71
- # or within another job's #perform method, we do not want this to
72
- # overwrite the existing endpoint name (unless it is the default from ActiveJob).
73
- #
74
- # If the current endpoint name matches this payload, return true to allow the
75
- # segment to be assigned by normalize_after.
76
- trace.endpoint == DELIVERY_JOB || trace.endpoint == normalize_title(payload[:job]) ||
77
- # This adapter wrapper needs to be handled specifically due to interactions with the
78
- # standalone Delayed::Job probe, as there is no consistent way to get the wrapped
79
- # job name among all Delayed::Job backends.
80
- trace.endpoint == DELAYED_JOB_WRAPPER
77
+ trace.segment = payload[:job].queue_name if trace.endpoint == endpoint && config.enable_segments?
81
78
  end
82
79
 
83
80
  def normalize_title(job_instance)
@@ -13,7 +13,7 @@ module Skylight
13
13
  # rubocop:disable Lint/DuplicateMethods
14
14
  def tick
15
15
  now = Time.now
16
- now.to_i * 1_000_000_000 + now.usec * 1_000
16
+ (now.to_i * 1_000_000_000) + (now.usec * 1_000)
17
17
  end
18
18
 
19
19
  # rubocop:enable Lint/DuplicateMethods
@@ -3,5 +3,5 @@ module Skylight
3
3
  # for compatibility with semver when it is parsed by the rust agent.
4
4
  # This string will be transformed in the gemspec to "5.0.0.alpha"
5
5
  # to conform with rubygems.
6
- VERSION = "5.2.0-beta".freeze
6
+ VERSION = "5.2.0-beta2".freeze
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skylight
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0.beta
4
+ version: 5.2.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilde, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-10 00:00:00.000000000 Z
11
+ date: 2021-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.20.0
145
+ version: 1.21.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.20.0
152
+ version: 1.21.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: simplecov
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -383,7 +383,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
383
383
  - !ruby/object:Gem::Version
384
384
  version: 1.3.1
385
385
  requirements: []
386
- rubygems_version: 3.2.15
386
+ rubygems_version: 3.0.8
387
387
  signing_key:
388
388
  specification_version: 4
389
389
  summary: Skylight is a smart profiler for Rails, Sinatra, and other Ruby apps.