newrelic-infinite_tracing 8.9.0 → 8.12.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: e6712a9c3ffb94789cc17ccdcce33735ba3afdfd6bab87b2e03e98f54eba7f1c
4
- data.tar.gz: b9e852c742440d75b8c89ba20cd49a92164ead327ddedbeedeefdff674970282
3
+ metadata.gz: 3d82f3d8556283da9e25f2789f9e83fac58f65b3df011af7d2adf2fd32894917
4
+ data.tar.gz: '0995598d2923cafdbc3eb38a663500ea48e37ba207cb6c58a1e8a15dbcb25d58'
5
5
  SHA512:
6
- metadata.gz: a9cca5b997416ec8b89e45c7833b185429343ce89e899eddcf1620316aaa09a51258c2b505c49cf4b6f69f8ee7daab596edb5dcdb3965bc9a0ee7efc0fce944a
7
- data.tar.gz: 3197dc1c5cf9c01631b7a7499fa70b74e218b52c70302f85a03dbc39317feb47122e79331c6575df22ac181b5a84a38aee01374b39ed176e4e876bbbe0b3715a
6
+ metadata.gz: 2aeb0110716ff65afcc46ef898690cdd951d8318273709840ed303657679dd4fa8110f7dd229fcce0b0a36806d8ced9e16e20297dae1d19f1a4d88093c48f7a2
7
+ data.tar.gz: d41478145f1891e1f02d5df82bbca1fe711c5d5a99fd352c118e6441635f86cbbf0255b963e791e2d87c1aefb3085a65786306491e89a18032c9907462e6cd0b
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
data/Rakefile CHANGED
@@ -1,3 +1,7 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
1
5
  require 'rubygems'
2
6
  require 'rake/testtask'
3
7
  require "#{File.dirname(__FILE__)}/tasks/all.rb"
@@ -12,7 +16,7 @@ task :console do
12
16
  end
13
17
 
14
18
  Rake::TestTask.new do |t|
15
- ROOT = File.join File.dirname(__FILE__)
19
+ ROOT = File.join(File.dirname(__FILE__))
16
20
  $LOAD_PATH << ROOT
17
21
 
18
22
  file_pattern = "#{ROOT}/**/*_test.rb"
@@ -1,10 +1,9 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
5
4
 
6
5
  module NewRelic::Agent
7
- NewRelic::Agent.logger.debug "Installing Infinite Tracer in Agent"
6
+ NewRelic::Agent.logger.debug("Installing Infinite Tracer in Agent")
8
7
 
9
8
  Agent.class_eval do
10
9
  def new_infinite_tracer
@@ -12,7 +11,7 @@ module NewRelic::Agent
12
11
  # entire start up process for the Agent.
13
12
  InfiniteTracing::Client.new.tap do |client|
14
13
  @infinite_tracer_thread = InfiniteTracing::Worker.new(:infinite_tracer) do
15
- NewRelic::Agent.logger.debug "Opening Infinite Tracer Stream with gRPC server"
14
+ NewRelic::Agent.logger.debug("Opening Infinite Tracer Stream with gRPC server")
16
15
  client.start_streaming
17
16
  end
18
17
  end
@@ -22,18 +21,19 @@ module NewRelic::Agent
22
21
  # this clears the data, clears connection attempts, and
23
22
  # waits a while to reconnect.
24
23
  def handle_force_restart(error)
25
- ::NewRelic::Agent.logger.debug error.message
24
+ ::NewRelic::Agent.logger.debug(error.message)
26
25
  drop_buffered_data
27
26
  @service.force_restart if @service
28
27
  @connect_state = :pending
29
28
  close_infinite_tracer
30
- sleep 30
29
+ sleep(30)
31
30
  end
32
31
 
33
32
  # Whenever we reconnect, close and restart
34
33
  def close_infinite_tracer
35
- NewRelic::Agent.logger.debug "Closing infinite tracer threads"
34
+ NewRelic::Agent.logger.debug("Closing infinite tracer threads")
36
35
  return unless @infinite_tracer_thread
36
+
37
37
  @infinite_tracer_thread.join
38
38
  @infinite_tracer_thread.stop
39
39
  @infinite_tracer_thread = nil
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -12,7 +11,7 @@ module NewRelic
12
11
  return if transaction.ignore?
13
12
 
14
13
  tracer = ::NewRelic::Agent.agent.infinite_tracer
15
- tracer << Proc.new { SpanEventPrimitive.for_datastore_segment self }
14
+ tracer << proc { SpanEventPrimitive.for_datastore_segment(self) }
16
15
  end
17
16
  end
18
17
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -12,7 +11,7 @@ module NewRelic
12
11
  return if transaction.ignore?
13
12
 
14
13
  tracer = ::NewRelic::Agent.agent.infinite_tracer
15
- tracer << Proc.new { SpanEventPrimitive.for_external_request_segment self }
14
+ tracer << proc { SpanEventPrimitive.for_external_request_segment(self) }
16
15
  end
17
16
  end
18
17
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -16,7 +15,7 @@ module NewRelic
16
15
  return if transaction.ignore?
17
16
 
18
17
  tracer = ::NewRelic::Agent.agent.infinite_tracer
19
- tracer << Proc.new { SpanEventPrimitive.for_segment self }
18
+ tracer << proc { SpanEventPrimitive.for_segment(self) }
20
19
  end
21
20
  end
22
21
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -6,7 +5,7 @@
6
5
  module NewRelic::Agent
7
6
  module InfiniteTracing
8
7
  if Config.enabled? || Config.test_framework?
9
- NewRelic::Agent.logger.debug "Integrating Infinite Tracer with Agent"
8
+ NewRelic::Agent.logger.debug("Integrating Infinite Tracer with Agent")
10
9
 
11
10
  require_relative 'agent_integrations/agent'
12
11
  require_relative 'agent_integrations/segment'
@@ -14,7 +13,7 @@ module NewRelic::Agent
14
13
  require_relative 'agent_integrations/external_request_segment'
15
14
 
16
15
  else
17
- NewRelic::Agent.logger.debug "Skipped Integrating Infinite Tracer with Agent"
16
+ NewRelic::Agent.logger.debug("Skipped Integrating Infinite Tracer with Agent")
18
17
  end
19
18
  end
20
19
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -6,19 +5,55 @@
6
5
  module NewRelic::Agent
7
6
  module InfiniteTracing
8
7
  class Channel
8
+ COMPRESSION_LEVELS = %i[none low medium high].freeze
9
+ DEFAULT_COMPRESSION_LEVEL = :none
10
+
9
11
  def stub
10
- NewRelic::Agent.logger.debug "Infinite Tracer Opening Channel to #{host_and_port}"
12
+ NewRelic::Agent.logger.debug("Infinite Tracer Opening Channel to #{host_and_port}")
11
13
 
12
- Com::Newrelic::Trace::V1::IngestService::Stub.new \
14
+ Com::Newrelic::Trace::V1::IngestService::Stub.new( \
13
15
  host_and_port,
14
16
  credentials,
15
- channel_override: channel
17
+ channel_override: channel,
18
+ channel_args: channel_args
19
+ )
16
20
  end
17
21
 
18
22
  def channel
19
23
  GRPC::Core::Channel.new(host_and_port, settings, credentials)
20
24
  end
21
25
 
26
+ def channel_args
27
+ return NewRelic::EMPTY_HASH unless compression_enabled?
28
+
29
+ GRPC::Core::CompressionOptions.new(compression_options).to_channel_arg_hash
30
+ end
31
+
32
+ def compression_enabled?
33
+ compression_level != :none
34
+ end
35
+
36
+ def compression_level
37
+ @compression_level ||= begin
38
+ level = if valid_compression_level?(configured_compression_level)
39
+ configured_compression_level
40
+ else
41
+ DEFAULT_COMPRESSION_LEVEL
42
+ end
43
+ NewRelic::Agent.logger.debug("Infinite Tracer compression level set to #{level}")
44
+ level
45
+ end
46
+ end
47
+
48
+ def compression_options
49
+ {default_algorithm: :gzip,
50
+ default_level: compression_level}
51
+ end
52
+
53
+ def configured_compression_level
54
+ NewRelic::Agent.config[:'infinite_tracing.compression_level']
55
+ end
56
+
22
57
  def credentials
23
58
  # Uses system configured certificates by default
24
59
  GRPC::Core::ChannelCredentials.new
@@ -34,6 +69,15 @@ module NewRelic::Agent
34
69
  'grpc.enable_deadline_checking' => 0
35
70
  }
36
71
  end
72
+
73
+ def valid_compression_level?(level)
74
+ return true if COMPRESSION_LEVELS.include?(level)
75
+
76
+ NewRelic::Agent.logger.error("Invalid compression level '#{level}' specified! Must be one of " \
77
+ "#{COMPRESSION_LEVELS.join('|')}. Using default level of '#{DEFAULT_COMPRESSION_LEVEL}'")
78
+
79
+ false
80
+ end
37
81
  end
38
82
  end
39
83
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -22,15 +21,20 @@ module NewRelic::Agent
22
21
  @lock = Mutex.new
23
22
  end
24
23
 
25
- def << segment
24
+ def <<(segment)
26
25
  buffer << segment
27
26
  end
28
27
 
28
+ def batching_enabled?
29
+ NewRelic::Agent.config[:'infinite_tracing.batching']
30
+ end
31
+
29
32
  # Transfers spans in streaming buffer from previous
30
33
  # client (if any) and returns self (so we chain the call)
31
- def transfer previous_client
34
+ def transfer(previous_client)
32
35
  return self unless previous_client
33
- previous_client.buffer.transfer buffer
36
+
37
+ previous_client.buffer.transfer(buffer)
34
38
  self
35
39
  end
36
40
 
@@ -38,7 +42,7 @@ module NewRelic::Agent
38
42
  # client is currently suspended.
39
43
  def new_streaming_buffer
40
44
  buffer_class = suspended? ? SuspendedStreamingBuffer : StreamingBuffer
41
- buffer_class.new Config.span_events_queue_size
45
+ buffer_class.new(Config.span_events_queue_size)
42
46
  end
43
47
 
44
48
  def buffer
@@ -50,30 +54,30 @@ module NewRelic::Agent
50
54
  end
51
55
 
52
56
  # Turns camelcase base class name into upper snake case version of the name.
53
- def formatted_class_name class_name
57
+ def formatted_class_name(class_name)
54
58
  class_name = class_name.split(":")[-1]
55
59
  (class_name.gsub!(/(.)([A-Z])/, '\1_\2') || class_name).upcase
56
60
  end
57
61
 
58
62
  # Literal codes are all mapped to unique class names, so we can deduce the
59
63
  # name of the error to report in the metric from the error's class name.
60
- def grpc_error_metric_name error
64
+ def grpc_error_metric_name(error)
61
65
  GRPC_ERROR_NAME_METRIC % formatted_class_name(error.class.name)
62
66
  end
63
67
 
64
68
  # Reports AND logs general response metric along with a more specific error metric
65
- def record_error_metrics_and_log error
66
- NewRelic::Agent.record_metric RESPONSE_ERROR_METRIC, 0.0
67
- if error.is_a? GRPC::BadStatus
68
- NewRelic::Agent.record_metric grpc_error_metric_name(error), 0.0
69
+ def record_error_metrics_and_log(error)
70
+ NewRelic::Agent.record_metric(RESPONSE_ERROR_METRIC, 0.0)
71
+ if error.is_a?(GRPC::BadStatus)
72
+ NewRelic::Agent.record_metric(grpc_error_metric_name(error), 0.0)
69
73
  else
70
- NewRelic::Agent.record_metric GRPC_OTHER_ERROR_METRIC, 0.0
74
+ NewRelic::Agent.record_metric(GRPC_OTHER_ERROR_METRIC, 0.0)
71
75
  end
72
- NewRelic::Agent.logger.warn "gRPC response error received.", error
76
+ NewRelic::Agent.logger.warn("gRPC response error received.", error)
73
77
  end
74
78
 
75
- def handle_error error
76
- record_error_metrics_and_log error
79
+ def handle_error(error)
80
+ record_error_metrics_and_log(error)
77
81
 
78
82
  case error
79
83
  when GRPC::Unavailable then restart
@@ -81,7 +85,7 @@ module NewRelic::Agent
81
85
  when GRPC::Unimplemented then suspend
82
86
  else
83
87
  # Set exponential backoff to false so we'll reconnect at periodic (15 second) intervals instead
84
- start_streaming false
88
+ start_streaming(false)
85
89
  end
86
90
  end
87
91
 
@@ -95,8 +99,8 @@ module NewRelic::Agent
95
99
  # server and re-establish the gRPC bi-directional stream. Useful for the server
96
100
  # to initiate a load-balancing scheme.
97
101
  def handle_close
98
- NewRelic::Agent.logger.debug "The gRPC Trace Observer closed the stream with OK response. " \
99
- "Restarting the stream."
102
+ NewRelic::Agent.logger.debug("The gRPC Trace Observer closed the stream with OK response. " \
103
+ "Restarting the stream.")
100
104
  start_streaming
101
105
  end
102
106
 
@@ -105,11 +109,12 @@ module NewRelic::Agent
105
109
  # The Suspended Streaming Buffer will be installed in this state.
106
110
  def suspend
107
111
  return if suspended?
112
+
108
113
  @lock.synchronize do
109
114
  @suspended = true
110
115
  @buffer = new_streaming_buffer
111
- NewRelic::Agent.logger.warn "The Trace Observer host signaled to suspend streaming span events. " \
112
- "No more span events will be sent during this session."
116
+ NewRelic::Agent.logger.warn("The Trace Observer host signaled to suspend streaming span events. " \
117
+ "No more span events will be sent during this session.")
113
118
  end
114
119
  end
115
120
 
@@ -123,7 +128,7 @@ module NewRelic::Agent
123
128
  @lock.synchronize do
124
129
  old_buffer = @buffer
125
130
  @buffer = new_streaming_buffer
126
- old_buffer.transfer @buffer
131
+ old_buffer.transfer(@buffer)
127
132
  end
128
133
  end
129
134
 
@@ -135,24 +140,30 @@ module NewRelic::Agent
135
140
 
136
141
  def stop
137
142
  return unless @response_handler
143
+
138
144
  @lock.synchronize do
139
145
  @response_handler.stop
140
146
  @response_handler = nil
141
147
  end
142
148
  end
143
149
 
144
- def start_streaming exponential_backoff = true
150
+ def start_streaming(exponential_backoff = true)
145
151
  return if suspended?
152
+
146
153
  Connection.instance.wait_for_agent_connect
147
- @lock.synchronize { @response_handler = record_spans exponential_backoff }
154
+ @lock.synchronize { response_handler(exponential_backoff) }
155
+ end
156
+
157
+ def record_spans(exponential_backoff)
158
+ RecordStatusHandler.new(self, Connection.record_spans(self, buffer.enumerator, exponential_backoff))
148
159
  end
149
160
 
150
- def record_spans exponential_backoff
151
- RecordStatusHandler.new self, Connection.record_spans(self, buffer.enumerator, exponential_backoff)
161
+ def record_span_batches(exponential_backoff)
162
+ RecordStatusHandler.new(self, Connection.record_span_batches(self, buffer.batch_enumerator, exponential_backoff))
152
163
  end
153
164
 
154
- def record_span_batches exponential_backoff
155
- RecordStatusHandler.new self, Connection.record_span_batches(self, buffer.batch_enumerator, exponential_backoff)
165
+ def response_handler(backoff)
166
+ @response_handler = batching_enabled? ? record_span_batches(backoff) : record_spans(backoff)
156
167
  end
157
168
  end
158
169
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -48,18 +47,18 @@ module NewRelic::Agent
48
47
  end
49
48
 
50
49
  # removes the scheme and port from a host entry.
51
- def without_scheme_or_port url
50
+ def without_scheme_or_port(url)
52
51
  url.gsub(%r{^https?://|:\d+$}, '')
53
52
  end
54
53
 
55
54
  def trace_observer_host
56
- without_scheme_or_port NewRelic::Agent.config[:'infinite_tracing.trace_observer.host']
55
+ without_scheme_or_port(NewRelic::Agent.config[:'infinite_tracing.trace_observer.host'])
57
56
  end
58
57
 
59
58
  # If the port is declared on the host entry, it overrides the port entry because otherwise
60
59
  # we'd need to figure out if user supplied the port or if the default source config set
61
60
  # the port. To help with debugging configuration issues, we log whenever the port entry
62
- # is overriden by the presence of the port on the host entry.
61
+ # is overridden by the presence of the port on the host entry.
63
62
  def port_from_host_entry
64
63
  port_str = NewRelic::Agent.config[:'infinite_tracing.trace_observer.host'].scan(%r{:(\d+)$}).flatten
65
64
  if port = (port_str[0] and port_str[0].to_i)
@@ -75,7 +74,7 @@ module NewRelic::Agent
75
74
  end
76
75
 
77
76
  # The scheme is based on whether the Trace Observer is running locally or remotely.
78
- # Remote unsecure (unencypted) streaming is disallowed!
77
+ # Remote unsecure (unencrypted) streaming is disallowed!
79
78
  def trace_observer_scheme
80
79
  local? ? NewRelic::HTTP : NewRelic::HTTPS
81
80
  end
@@ -85,7 +84,7 @@ module NewRelic::Agent
85
84
  if trace_observer_configured?
86
85
  URI("#{trace_observer_scheme}://#{trace_observer_host_and_port}")
87
86
  else
88
- NewRelic::Agent.logger.error TRACE_OBSERVER_NOT_CONFIGURED_ERROR
87
+ NewRelic::Agent.logger.error(TRACE_OBSERVER_NOT_CONFIGURED_ERROR)
89
88
  raise TRACE_OBSERVER_NOT_CONFIGURED_ERROR
90
89
  end
91
90
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -25,9 +24,10 @@ module NewRelic::Agent
25
24
  begin
26
25
  Connection.instance.notify_agent_started
27
26
  rescue => error
28
- NewRelic::Agent.logger.error \
27
+ NewRelic::Agent.logger.error( \
29
28
  "Error during notify :server_source_configuration_added event",
30
29
  error
30
+ )
31
31
  end
32
32
  end
33
33
 
@@ -43,15 +43,15 @@ module NewRelic::Agent
43
43
  # RPC calls will pass the calling client instance in. We track this
44
44
  # so we're able to signal the client to restart when connectivity to the
45
45
  # server is disrupted.
46
- def record_spans client, enumerator, exponential_backoff
47
- instance.record_spans client, enumerator, exponential_backoff
46
+ def record_spans(client, enumerator, exponential_backoff)
47
+ instance.record_spans(client, enumerator, exponential_backoff)
48
48
  end
49
49
 
50
50
  # RPC calls will pass the calling client instance in. We track this
51
51
  # so we're able to signal the client to restart when connectivity to the
52
52
  # server is disrupted.
53
- def record_span_batches client, enumerator, exponential_backoff
54
- instance.record_span_batch client, enumerator, exponential_backoff
53
+ def record_span_batches(client, enumerator, exponential_backoff)
54
+ instance.record_span_batches(client, enumerator, exponential_backoff)
55
55
  end
56
56
 
57
57
  def metadata
@@ -61,17 +61,17 @@ module NewRelic::Agent
61
61
 
62
62
  # We attempt to connect and record spans with reconnection backoff in order to deal with
63
63
  # unavailable errors coming from the stub being created and record_span call
64
- def record_spans client, enumerator, exponential_backoff
64
+ def record_spans(client, enumerator, exponential_backoff)
65
65
  @active_clients[client] = client
66
- with_reconnection_backoff(exponential_backoff) { rpc.record_span enumerator, metadata: metadata }
66
+ with_reconnection_backoff(exponential_backoff) { rpc.record_span(enumerator, metadata: metadata) }
67
67
  end
68
68
 
69
69
  # RPC calls will pass the calling client instance in. We track this
70
70
  # so we're able to signal the client to restart when connectivity to the
71
71
  # server is disrupted.
72
- def record_span_batches client, enumerator, exponential_backoff
72
+ def record_span_batches(client, enumerator, exponential_backoff)
73
73
  @active_clients[client] = client
74
- with_reconnection_backoff(exponential_backoff) { rpc.record_span_batch enumerator, metadata: metadata }
74
+ with_reconnection_backoff(exponential_backoff) { rpc.record_span_batch(enumerator, metadata: metadata) }
75
75
  end
76
76
 
77
77
  # Acquires the new channel stub for the RPC calls.
@@ -147,21 +147,21 @@ module NewRelic::Agent
147
147
  end
148
148
 
149
149
  # Continues retrying the connection at backoff intervals until a successful connection is made
150
- def with_reconnection_backoff exponential_backoff = true, &block
150
+ def with_reconnection_backoff(exponential_backoff = true, &block)
151
151
  @connection_attempts = 0
152
152
  begin
153
153
  yield
154
154
  rescue => exception
155
155
  retry_connection_period = retry_connection_period(exponential_backoff)
156
- ::NewRelic::Agent.logger.error "Error establishing connection with infinite tracing service:", exception
157
- ::NewRelic::Agent.logger.info "Will re-attempt infinte tracing connection in #{retry_connection_period} seconds"
158
- sleep retry_connection_period
156
+ ::NewRelic::Agent.logger.error("Error establishing connection with infinite tracing service:", exception)
157
+ ::NewRelic::Agent.logger.info("Will re-attempt infinite tracing connection in #{retry_connection_period} seconds")
158
+ sleep(retry_connection_period)
159
159
  note_connect_failure
160
160
  retry
161
161
  end
162
162
  end
163
163
 
164
- def retry_connection_period exponential_backoff = true
164
+ def retry_connection_period(exponential_backoff = true)
165
165
  if exponential_backoff
166
166
  NewRelic::CONNECT_RETRY_PERIODS[@connection_attempts] || NewRelic::MAX_RETRY_PERIOD
167
167
  else
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -6,7 +5,6 @@
6
5
  # Generated by the protocol buffer compiler. DO NOT EDIT!
7
6
  # Source: infinite_tracing.proto for package 'com.newrelic.trace.v1'
8
7
  # Original file comments:
9
- # encoding: utf-8
10
8
  # This file is distributed under New Relic's license terms.
11
9
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
12
10
  #
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -6,7 +5,7 @@
6
5
  module NewRelic::Agent
7
6
  module InfiniteTracing
8
7
  class RecordStatusHandler
9
- def initialize client, enumerator
8
+ def initialize(client, enumerator)
10
9
  @client = client
11
10
  @enumerator = enumerator
12
11
  @messages_seen = nil
@@ -18,34 +17,40 @@ module NewRelic::Agent
18
17
  @messages_seen ? @messages_seen.messages_seen : 0
19
18
  end
20
19
 
21
- def start_handler
22
- Worker.new self.class.name do
23
- begin
24
- @enumerator.each do |response|
25
- break if response.nil? || response.is_a?(Exception)
26
- @lock.synchronize do
27
- @messages_seen = response
28
- NewRelic::Agent.logger.debug "gRPC Infinite Tracer Observer saw #{messages_seen} messages"
29
- end
30
- end
31
- NewRelic::Agent.logger.debug "gRPC Infinite Tracer Observer closed the stream"
32
- @client.handle_close
33
- rescue => error
34
- @client.handle_error error
35
- end
36
- end
37
- rescue => error
38
- NewRelic::Agent.logger.error "gRPC Worker Error", error
39
- end
40
-
41
20
  def stop
42
21
  return if @worker.nil?
22
+
43
23
  @lock.synchronize do
44
- NewRelic::Agent.logger.debug "gRPC Stopping Response Handler"
24
+ NewRelic::Agent.logger.debug("gRPC Stopping Response Handler")
45
25
  @worker.stop
46
26
  @worker = nil
47
27
  end
48
28
  end
29
+
30
+ private
31
+
32
+ def handle_response
33
+ @enumerator.each do |response|
34
+ break if response.nil? || response.is_a?(Exception)
35
+
36
+ @lock.synchronize do
37
+ @messages_seen = response
38
+ NewRelic::Agent.logger.debug("gRPC Infinite Tracer Observer saw #{messages_seen} messages")
39
+ end
40
+ end
41
+ end
42
+
43
+ def start_handler
44
+ Worker.new(self.class.name) do
45
+ handle_response
46
+ NewRelic::Agent.logger.debug("gRPC Infinite Tracer Observer closed the stream")
47
+ @client.handle_close
48
+ rescue => error
49
+ @client.handle_error(error)
50
+ end
51
+ rescue => error
52
+ NewRelic::Agent.logger.error("gRPC Worker Error", error)
53
+ end
49
54
  end
50
55
  end
51
56
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -18,10 +17,14 @@ module NewRelic::Agent
18
17
  DEFAULT_QUEUE_SIZE = 10_000
19
18
  FLUSH_DELAY = 0.005
20
19
  MAX_FLUSH_WAIT = 3 # three seconds
20
+ # To ensure that two bits of info for the same transaction
21
+ # are recognized as belonging together, set a maximum time
22
+ # in seconds to elapse between batch submissions.
23
+ MAX_BATCH_HOLD = 5
21
24
 
22
25
  attr_reader :queue
23
26
 
24
- def initialize max_size = DEFAULT_QUEUE_SIZE
27
+ def initialize(max_size = DEFAULT_QUEUE_SIZE)
25
28
  @max_size = max_size
26
29
  @lock = Mutex.new
27
30
  @queue = Queue.new
@@ -30,9 +33,9 @@ module NewRelic::Agent
30
33
 
31
34
  # Dumps the contents of this streaming buffer onto
32
35
  # the given buffer and closes the queue
33
- def transfer new_buffer
36
+ def transfer(new_buffer)
34
37
  @lock.synchronize do
35
- until @queue.empty? do new_buffer.push @queue.pop end
38
+ until @queue.empty? do new_buffer.push(@queue.pop) end
36
39
  @queue.close
37
40
  end
38
41
  end
@@ -45,11 +48,11 @@ module NewRelic::Agent
45
48
  # When a restart signal is received, the queue is
46
49
  # locked with a mutex, blocking the push until
47
50
  # the queue has restarted.
48
- def << segment
51
+ def <<(segment)
49
52
  @lock.synchronize do
50
53
  clear_queue if @queue.size >= @max_size
51
- NewRelic::Agent.increment_metric SPANS_SEEN_METRIC
52
- @queue.push segment
54
+ NewRelic::Agent.increment_metric(SPANS_SEEN_METRIC)
55
+ @queue.push(segment)
53
56
  end
54
57
  end
55
58
 
@@ -57,19 +60,19 @@ module NewRelic::Agent
57
60
  # supportability metric for the event.
58
61
  def clear_queue
59
62
  @queue.clear
60
- NewRelic::Agent.increment_metric QUEUE_DUMPED_METRIC
63
+ NewRelic::Agent.increment_metric(QUEUE_DUMPED_METRIC)
61
64
  end
62
65
 
63
66
  # Waits for the queue to be fully consumed or for the
64
67
  # waiting consumers to release.
65
68
  def flush_queue
66
- @queue.num_waiting.times { @queue.push nil }
69
+ @queue.num_waiting.times { @queue.push(nil) }
67
70
  close_queue
68
71
 
69
72
  # Logs if we're throwing away spans because nothing's
70
73
  # waiting to take them off the queue.
71
74
  if @queue.num_waiting == 0 && !@queue.empty?
72
- NewRelic::Agent.logger.warn "Discarding #{@queue.size} segments on Streaming Buffer"
75
+ NewRelic::Agent.logger.warn("Discarding #{@queue.size} segments on Streaming Buffer")
73
76
  return
74
77
  end
75
78
 
@@ -92,10 +95,11 @@ module NewRelic::Agent
92
95
  # application thread.
93
96
  def enumerator
94
97
  return enum_for(:enumerator) unless block_given?
98
+
95
99
  loop do
96
100
  if segment = @queue.pop(false)
97
- NewRelic::Agent.increment_metric SPANS_SENT_METRIC
98
- yield transform(segment)
101
+ NewRelic::Agent.increment_metric(SPANS_SENT_METRIC)
102
+ yield(transform(segment))
99
103
 
100
104
  else
101
105
  raise ClosedQueueError
@@ -117,18 +121,21 @@ module NewRelic::Agent
117
121
  # the gRPC call's thread rather than in the main
118
122
  # application thread.
119
123
  def batch_enumerator
120
- return enum_for(:enumerator) unless block_given?
124
+ return enum_for(:batch_enumerator) unless block_given?
125
+
126
+ last_time = Process.clock_gettime(Process::CLOCK_REALTIME)
121
127
  loop do
122
128
  if proc_or_segment = @queue.pop(false)
123
- NewRelic::Agent.increment_metric SPANS_SENT_METRIC
129
+ NewRelic::Agent.increment_metric(SPANS_SENT_METRIC)
124
130
  @batch << transform(proc_or_segment)
125
- if @batch.size >= BATCH_SIZE
126
- yield SpanBatch.new(spans: @batch)
131
+ if batch_ready?(last_time)
132
+ yield(SpanBatch.new(spans: @batch))
133
+ last_time = Process.clock_gettime(Process::CLOCK_REALTIME)
127
134
  @batch.clear
128
135
  end
129
136
 
130
137
  else
131
- yield SpanBatch.new(spans: @batch) unless @batch.empty?
138
+ yield(SpanBatch.new(spans: @batch)) unless @batch.empty?
132
139
  raise ClosedQueueError
133
140
  end
134
141
  end
@@ -136,7 +143,11 @@ module NewRelic::Agent
136
143
 
137
144
  private
138
145
 
139
- def span_event proc_or_segment
146
+ def batch_ready?(last_time)
147
+ @batch.size >= BATCH_SIZE || Process.clock_gettime(Process::CLOCK_REALTIME) - last_time >= MAX_BATCH_HOLD
148
+ end
149
+
150
+ def span_event(proc_or_segment)
140
151
  if proc_or_segment.is_a?(Proc)
141
152
  proc_or_segment.call
142
153
  else
@@ -144,8 +155,8 @@ module NewRelic::Agent
144
155
  end
145
156
  end
146
157
 
147
- def transform proc_or_segment
148
- Span.new Transformer.transform(span_event proc_or_segment)
158
+ def transform(proc_or_segment)
159
+ Span.new(Transformer.transform(span_event(proc_or_segment)))
149
160
  end
150
161
  end
151
162
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -13,16 +12,16 @@ module NewRelic::Agent
13
12
  extend Forwardable
14
13
  def_delegators :@empty_buffer, :empty?, :push
15
14
 
16
- def initialize max_size = DEFAULT_QUEUE_SIZE
15
+ def initialize(max_size = DEFAULT_QUEUE_SIZE)
17
16
  @empty_buffer = NewRelic::EMPTY_ARRAY
18
17
  end
19
18
 
20
19
  # updates the seen metric and discards the segment
21
- def << segment
22
- NewRelic::Agent.increment_metric SPANS_SEEN_METRIC
20
+ def <<(segment)
21
+ NewRelic::Agent.increment_metric(SPANS_SEEN_METRIC)
23
22
  end
24
23
 
25
- def transfer new_buffer
24
+ def transfer(new_buffer)
26
25
  # NOOP
27
26
  end
28
27
 
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -8,7 +7,7 @@ module NewRelic::Agent
8
7
  module Transformer
9
8
  extend self
10
9
 
11
- def transform span_event
10
+ def transform(span_event)
12
11
  intrinsics, user_attributes, agent_attributes = span_event
13
12
  {
14
13
  "trace_id" => intrinsics[NewRelic::Agent::SpanEventPrimitive::TRACE_ID_KEY],
@@ -34,11 +33,11 @@ module NewRelic::Agent
34
33
  KLASS_TO_ARG[BigDecimal] = :double_value
35
34
  end
36
35
 
37
- def safe_param_name value
36
+ def safe_param_name(value)
38
37
  KLASS_TO_ARG[value.class] || raise("Unhandled class #{value.class.name}")
39
38
  end
40
39
 
41
- def hash_to_attributes values
40
+ def hash_to_attributes(values)
42
41
  values.map do |key, value|
43
42
  begin
44
43
  [key, AttributeValue.new(safe_param_name(value) => value)]
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -12,7 +11,7 @@ module NewRelic::Agent
12
11
  class Worker
13
12
  attr_reader :name, :error
14
13
 
15
- def initialize name, &job
14
+ def initialize(name, &job)
16
15
  @name = name
17
16
  @job = job
18
17
  @error = nil
@@ -23,8 +22,10 @@ module NewRelic::Agent
23
22
 
24
23
  def status
25
24
  return "error" if error?
25
+
26
26
  @lock.synchronize do
27
27
  return "stopped" if @worker_thread.nil?
28
+
28
29
  @worker_thread.status || "idle"
29
30
  end
30
31
  end
@@ -33,16 +34,18 @@ module NewRelic::Agent
33
34
  !!@error
34
35
  end
35
36
 
36
- def join timeout = nil
37
+ def join(timeout = nil)
37
38
  return unless @worker_thread
38
- NewRelic::Agent.logger.debug "joining worker #{@name} thread..."
39
- @worker_thread.join timeout
39
+
40
+ NewRelic::Agent.logger.debug("joining worker #{@name} thread...")
41
+ @worker_thread.join(timeout)
40
42
  end
41
43
 
42
44
  def stop
43
45
  @lock.synchronize do
44
46
  return unless @worker_thread
45
- NewRelic::Agent.logger.debug "stopping worker #{@name} thread..."
47
+
48
+ NewRelic::Agent.logger.debug("stopping worker #{@name} thread...")
46
49
  @worker_thread.kill
47
50
  @worker_thread = nil
48
51
  end
@@ -51,8 +54,8 @@ module NewRelic::Agent
51
54
  private
52
55
 
53
56
  def start_thread
54
- NewRelic::Agent.logger.debug "starting worker #{@name} thread..."
55
- @worker_thread = Thread.new do
57
+ NewRelic::Agent.logger.debug("starting worker #{@name} thread...")
58
+ @worker_thread = NewRelic::Agent::Threading::AgentThread.create("infinite_tracing_worker") do
56
59
  catch(:exit) do
57
60
  begin
58
61
  @job.call
@@ -63,7 +66,7 @@ module NewRelic::Agent
63
66
  end
64
67
  end
65
68
  @worker_thread.abort_on_exception = true
66
- if @worker_thread.respond_to? :report_on_exception
69
+ if @worker_thread.respond_to?(:report_on_exception)
67
70
  @worker_thread.report_on_exception = NewRelic::Agent.config[:log_level] == "debug"
68
71
  end
69
72
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -7,7 +6,7 @@ require 'uri'
7
6
 
8
7
  require 'newrelic_rpm'
9
8
 
10
- NewRelic::Agent.logger.debug "Detected New Relic Infinite Tracing Gem"
9
+ NewRelic::Agent.logger.debug("Detected New Relic Infinite Tracing Gem")
11
10
 
12
11
  require 'infinite_tracing/version'
13
12
  require 'infinite_tracing/config'
@@ -20,7 +19,7 @@ DependencyDetection.defer do
20
19
  end
21
20
 
22
21
  executes do
23
- NewRelic::Agent.logger.debug "Loading New Relic Infinite Tracing Library"
22
+ NewRelic::Agent.logger.debug("Loading New Relic Infinite Tracing Library")
24
23
 
25
24
  require 'infinite_tracing/proto'
26
25
 
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -7,7 +6,7 @@ require 'uri'
7
6
 
8
7
  require 'newrelic_rpm'
9
8
 
10
- NewRelic::Agent.logger.debug "Detected New Relic Infinite Tracing Gem"
9
+ NewRelic::Agent.logger.debug("Detected New Relic Infinite Tracing Gem")
11
10
 
12
11
  require 'new_relic/infinite_tracing/version'
13
12
  require 'new_relic/infinite_tracing/config'
@@ -20,7 +19,7 @@ DependencyDetection.defer do
20
19
  end
21
20
 
22
21
  executes do
23
- NewRelic::Agent.logger.debug "Loading New Relic Infinite Tracing Library"
22
+ NewRelic::Agent.logger.debug("Loading New Relic Infinite Tracing Library")
24
23
 
25
24
  require 'new_relic/infinite_tracing/proto'
26
25
 
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
  # frozen_string_literal: true
@@ -1,4 +1,3 @@
1
- // encoding: utf-8
2
1
  // This file is distributed under New Relic's license terms.
3
2
  // See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
4
3
 
@@ -39,4 +38,4 @@ message AttributeValue {
39
38
 
40
39
  message RecordStatus {
41
40
  uint64 messages_seen = 1;
42
- }
41
+ }
@@ -1,4 +1,3 @@
1
- #-*- coding: utf-8 -*-
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'fileutils'
@@ -12,13 +11,13 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
12
11
  require 'new_relic/version'
13
12
 
14
13
  Gem::Specification.new do |s|
15
- def self.copy_files filelist
16
- subfolder = File.expand_path File.dirname(__FILE__)
14
+ def self.copy_files(filelist)
15
+ subfolder = File.expand_path(File.dirname(__FILE__))
17
16
 
18
17
  filelist.each do |filename|
19
18
  source_full_filename = File.expand_path(filename)
20
19
  dest_full_filename = File.join(subfolder, File.basename(filename))
21
- FileUtils.cp source_full_filename, dest_full_filename
20
+ FileUtils.cp(source_full_filename, dest_full_filename)
22
21
  end
23
22
  end
24
23
 
@@ -27,12 +26,12 @@ Gem::Specification.new do |s|
27
26
  "../CONTRIBUTING.md"
28
27
  ]
29
28
 
30
- self.copy_files shared_files
29
+ self.copy_files(shared_files)
31
30
 
32
31
  s.name = "newrelic-infinite_tracing"
33
32
  s.version = NewRelic::VERSION::STRING
34
33
  s.required_ruby_version = '>= 2.5.0'
35
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
34
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to?(:required_rubygems_version=)
36
35
  s.authors = ["Tanna McClure", "Kayla Reopelle", "James Bunch", "Hannah Ramadan"]
37
36
  s.licenses = ['Apache-2.0']
38
37
  s.description = <<-EOS
@@ -69,7 +68,7 @@ Gem or plugin, hosted on https://github.com/newrelic/newrelic-ruby-agent/
69
68
  s.files = file_list
70
69
 
71
70
  s.homepage = "https://github.com/newrelic/newrelic-ruby-agent/tree/main/infinite_tracing"
72
- s.require_paths = ["lib", "infinite_tracing"]
71
+ s.require_paths = %w[lib infinite_tracing]
73
72
  s.summary = "New Relic Infinite Tracing for the Ruby agent"
74
73
 
75
74
  s.add_dependency 'newrelic_rpm', NewRelic::VERSION::STRING
@@ -78,7 +77,8 @@ Gem or plugin, hosted on https://github.com/newrelic/newrelic-ruby-agent/
78
77
  s.add_development_dependency 'rake', '12.3.3'
79
78
  s.add_development_dependency 'rb-inotify', '0.9.10' # locked to support < Ruby 2.3 (and listen 3.0.8)
80
79
  s.add_development_dependency 'listen', '3.0.8' # locked to support < Ruby 2.3
81
- s.add_development_dependency 'minitest', '~> 5.14.0'
80
+ s.add_development_dependency 'minitest', '~> 5.15'
81
+ s.add_development_dependency 'minitest-stub-const', '0.6'
82
82
  s.add_development_dependency 'mocha', '~> 1.9.0'
83
83
  s.add_development_dependency 'pry-nav', '~> 0.3.0'
84
84
  s.add_development_dependency 'pry-stack_explorer', '~> 0.4.9'
data/tasks/all.rb CHANGED
@@ -1,6 +1,6 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
4
 
5
5
  # This is required to load in task definitions
6
6
  Dir.glob(File.join(File.dirname(__FILE__), '*.rake')) do |file|
@@ -0,0 +1,25 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ module License
6
+ def extract_license_terms(file_contents)
7
+ text = []
8
+ text << file_contents.shift while !file_contents.empty? && file_contents[0] =~ /^#/
9
+ text << ""
10
+ text
11
+ end
12
+
13
+ def add_license_preamble_and_remove_requires(output_path)
14
+ gemspec_path = File.expand_path(File.join(output_path, '..', '..', '..', '..', '..'))
15
+ license_terms = extract_license_terms(File.readlines(File.join(gemspec_path, "Gemfile")))
16
+ Dir.glob(File.join(output_path, "*.rb")) do |filename|
17
+ contents = File.readlines(filename)
18
+ contents.reject! { |r| r =~ /^\s*require\s.*$/ }
19
+ File.open(filename, 'w') do |output|
20
+ output.puts license_terms
21
+ output.puts contents
22
+ end
23
+ end
24
+ end
25
+ end
data/tasks/proto.rake CHANGED
@@ -1,38 +1,18 @@
1
- # encoding: utf-8
2
1
  # This file is distributed under New Relic's license terms.
3
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ require_relative 'helpers/license'
6
+ include License
4
7
 
5
8
  namespace :proto do
6
9
  desc "Generate proto files"
7
-
8
10
  task :generate do
9
- def extract_license_terms file_contents
10
- text = []
11
- text << file_contents.shift while !file_contents.empty? && file_contents[0] =~ /^#/
12
- text << ""
13
- text
14
- end
15
-
16
- # adds the NewRelic License notice to the top of the generated files
17
- # Removes require lines since these are replicated in the proto.rb file.
18
- def add_license_preamble_and_remove_requires output_path
19
- gemspec_path = File.expand_path(File.join(output_path, '..', '..', '..', '..', '..'))
20
- license_terms = extract_license_terms File.readlines(File.join(gemspec_path, "Gemfile"))
21
- Dir.glob(File.join output_path, "*.rb") do |filename|
22
- contents = File.readlines filename
23
- contents.reject! { |r| r =~ /^\s*require\s.*$/ }
24
- File.open(filename, 'w') do |output|
25
- output.puts license_terms
26
- output.puts contents
27
- end
28
- end
29
- end
30
-
31
- gem_folder = File.expand_path File.join(File.dirname(__FILE__), "..")
32
- proto_filename = File.join gem_folder, "lib", "new_relic", "proto", "infinite_tracing.proto"
33
- output_path = File.join gem_folder, "lib", "new_relic", "infinite_tracing", "proto"
11
+ gem_folder = File.expand_path(File.join(File.dirname(__FILE__), ".."))
12
+ proto_filename = File.join(gem_folder, "lib", "new_relic", "proto", "infinite_tracing.proto")
13
+ output_path = File.join(gem_folder, "lib", "new_relic", "infinite_tracing", "proto")
34
14
 
35
- FileUtils.mkdir_p output_path
15
+ FileUtils.mkdir_p(output_path)
36
16
  cmd = [
37
17
  "grpc_tools_ruby_protoc",
38
18
  "-I#{gem_folder}/lib/new_relic/proto",
@@ -40,9 +20,9 @@ namespace :proto do
40
20
  "--grpc_out=#{output_path} #{proto_filename}"
41
21
  ].join(" ")
42
22
 
43
- if system cmd
23
+ if system(cmd)
44
24
  puts "Proto file generated!"
45
- add_license_preamble_and_remove_requires output_path
25
+ add_license_preamble_and_remove_requires(output_path)
46
26
  else
47
27
  puts "Failed to generate proto file."
48
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic-infinite_tracing
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.9.0
4
+ version: 8.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanna McClure
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2022-07-11 00:00:00.000000000 Z
14
+ date: 2022-10-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: newrelic_rpm
@@ -19,14 +19,14 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 8.9.0
22
+ version: 8.12.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 8.9.0
29
+ version: 8.12.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: grpc
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -89,14 +89,28 @@ dependencies:
89
89
  requirements:
90
90
  - - "~>"
91
91
  - !ruby/object:Gem::Version
92
- version: 5.14.0
92
+ version: '5.15'
93
93
  type: :development
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - "~>"
98
98
  - !ruby/object:Gem::Version
99
- version: 5.14.0
99
+ version: '5.15'
100
+ - !ruby/object:Gem::Dependency
101
+ name: minitest-stub-const
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '='
105
+ - !ruby/object:Gem::Version
106
+ version: '0.6'
107
+ type: :development
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - '='
112
+ - !ruby/object:Gem::Version
113
+ version: '0.6'
100
114
  - !ruby/object:Gem::Dependency
101
115
  name: mocha
102
116
  requirement: !ruby/object:Gem::Requirement
@@ -259,6 +273,7 @@ files:
259
273
  - lib/proto/infinite_tracing.proto
260
274
  - newrelic-infinite_tracing.gemspec
261
275
  - tasks/all.rb
276
+ - tasks/helpers/license.rb
262
277
  - tasks/proto.rake
263
278
  homepage: https://github.com/newrelic/newrelic-ruby-agent/tree/main/infinite_tracing
264
279
  licenses: