newrelic-infinite_tracing 8.9.0 → 8.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/Rakefile +5 -1
- data/lib/infinite_tracing/agent_integrations/agent.rb +6 -6
- data/lib/infinite_tracing/agent_integrations/datastore_segment.rb +1 -2
- data/lib/infinite_tracing/agent_integrations/external_request_segment.rb +1 -2
- data/lib/infinite_tracing/agent_integrations/segment.rb +1 -2
- data/lib/infinite_tracing/agent_integrations.rb +2 -3
- data/lib/infinite_tracing/channel.rb +23 -14
- data/lib/infinite_tracing/client.rb +38 -27
- data/lib/infinite_tracing/config.rb +31 -6
- data/lib/infinite_tracing/connection.rb +30 -15
- data/lib/infinite_tracing/constants.rb +0 -1
- data/lib/infinite_tracing/proto/infinite_tracing_pb.rb +0 -1
- data/lib/infinite_tracing/proto/infinite_tracing_services_pb.rb +0 -2
- data/lib/infinite_tracing/proto.rb +0 -1
- data/lib/infinite_tracing/record_status_handler.rb +28 -23
- data/lib/infinite_tracing/streaming_buffer.rb +31 -20
- data/lib/infinite_tracing/suspended_streaming_buffer.rb +4 -5
- data/lib/infinite_tracing/transformer.rb +3 -4
- data/lib/infinite_tracing/version.rb +0 -1
- data/lib/infinite_tracing/worker.rb +12 -9
- data/lib/newrelic/infinite_tracing.rb +36 -3
- data/lib/proto/infinite_tracing.proto +1 -2
- data/newrelic-infinite_tracing.gemspec +8 -8
- data/tasks/all.rb +1 -1
- data/tasks/helpers/license.rb +25 -0
- data/tasks/proto.rake +10 -30
- metadata +21 -8
- data/lib/infinite_tracing.rb +0 -40
- data/lib/new_relic/infinite_tracing.rb +0 -40
@@ -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
|
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
|
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
|
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
|
36
|
+
def transfer(new_buffer)
|
34
37
|
@lock.synchronize do
|
35
|
-
until @queue.empty? do new_buffer.push
|
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 <<
|
51
|
+
def <<(segment)
|
49
52
|
@lock.synchronize do
|
50
53
|
clear_queue if @queue.size >= @max_size
|
51
|
-
NewRelic::Agent.increment_metric
|
52
|
-
@queue.push
|
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
|
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
|
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
|
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
|
98
|
-
yield
|
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(:
|
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
|
129
|
+
NewRelic::Agent.increment_metric(SPANS_SENT_METRIC)
|
124
130
|
@batch << transform(proc_or_segment)
|
125
|
-
if
|
126
|
-
yield
|
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
|
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
|
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
|
148
|
-
Span.new
|
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
|
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 <<
|
22
|
-
NewRelic::Agent.increment_metric
|
20
|
+
def <<(segment)
|
21
|
+
NewRelic::Agent.increment_metric(SPANS_SEEN_METRIC)
|
23
22
|
end
|
24
23
|
|
25
|
-
def transfer
|
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
|
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
|
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
|
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
|
@@ -12,7 +11,7 @@ module NewRelic::Agent
|
|
12
11
|
class Worker
|
13
12
|
attr_reader :name, :error
|
14
13
|
|
15
|
-
def initialize
|
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
|
37
|
+
def join(timeout = nil)
|
37
38
|
return unless @worker_thread
|
38
|
-
|
39
|
-
|
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
|
-
|
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
|
55
|
-
@worker_thread =
|
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?
|
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,8 +1,41 @@
|
|
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
|
-
|
7
|
-
|
5
|
+
# Entry point for New Relic Infinite Tracing.
|
6
|
+
|
7
|
+
require 'uri'
|
8
|
+
|
9
|
+
require 'newrelic_rpm'
|
10
|
+
|
11
|
+
NewRelic::Agent.logger.debug("Detected New Relic Infinite Tracing Gem")
|
12
|
+
|
13
|
+
require 'infinite_tracing/version'
|
14
|
+
require 'infinite_tracing/config'
|
15
|
+
|
16
|
+
DependencyDetection.defer do
|
17
|
+
named :infinite_tracing
|
18
|
+
|
19
|
+
depends_on do
|
20
|
+
NewRelic::Agent::InfiniteTracing::Config.should_load?
|
21
|
+
end
|
22
|
+
|
23
|
+
executes do
|
24
|
+
NewRelic::Agent.logger.debug("Loading New Relic Infinite Tracing Library")
|
25
|
+
|
26
|
+
require 'infinite_tracing/proto'
|
27
|
+
|
28
|
+
require 'infinite_tracing/constants'
|
29
|
+
require 'infinite_tracing/worker'
|
30
|
+
require 'infinite_tracing/record_status_handler'
|
31
|
+
|
32
|
+
require 'infinite_tracing/transformer'
|
33
|
+
require 'infinite_tracing/streaming_buffer'
|
34
|
+
require 'infinite_tracing/suspended_streaming_buffer'
|
35
|
+
require 'infinite_tracing/channel'
|
36
|
+
require 'infinite_tracing/connection'
|
37
|
+
require 'infinite_tracing/client'
|
38
|
+
|
39
|
+
require 'infinite_tracing/agent_integrations'
|
40
|
+
end
|
8
41
|
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
|
|
@@ -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
|
16
|
-
subfolder = File.expand_path
|
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
|
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
|
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?
|
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 = [
|
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.
|
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
|
-
|
10
|
-
|
11
|
-
|
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
|
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
|
23
|
+
if system(cmd)
|
44
24
|
puts "Proto file generated!"
|
45
|
-
add_license_preamble_and_remove_requires
|
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.
|
4
|
+
version: 8.15.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:
|
14
|
+
date: 2023-01-09 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.
|
22
|
+
version: 8.15.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.
|
29
|
+
version: 8.15.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.
|
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.
|
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
|
@@ -234,7 +248,6 @@ files:
|
|
234
248
|
- Gemfile
|
235
249
|
- LICENSE
|
236
250
|
- Rakefile
|
237
|
-
- lib/infinite_tracing.rb
|
238
251
|
- lib/infinite_tracing/agent_integrations.rb
|
239
252
|
- lib/infinite_tracing/agent_integrations/agent.rb
|
240
253
|
- lib/infinite_tracing/agent_integrations/datastore_segment.rb
|
@@ -254,11 +267,11 @@ files:
|
|
254
267
|
- lib/infinite_tracing/transformer.rb
|
255
268
|
- lib/infinite_tracing/version.rb
|
256
269
|
- lib/infinite_tracing/worker.rb
|
257
|
-
- lib/new_relic/infinite_tracing.rb
|
258
270
|
- lib/newrelic/infinite_tracing.rb
|
259
271
|
- lib/proto/infinite_tracing.proto
|
260
272
|
- newrelic-infinite_tracing.gemspec
|
261
273
|
- tasks/all.rb
|
274
|
+
- tasks/helpers/license.rb
|
262
275
|
- tasks/proto.rake
|
263
276
|
homepage: https://github.com/newrelic/newrelic-ruby-agent/tree/main/infinite_tracing
|
264
277
|
licenses:
|
data/lib/infinite_tracing.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
|
-
# frozen_string_literal: true
|
5
|
-
|
6
|
-
require 'uri'
|
7
|
-
|
8
|
-
require 'newrelic_rpm'
|
9
|
-
|
10
|
-
NewRelic::Agent.logger.debug "Detected New Relic Infinite Tracing Gem"
|
11
|
-
|
12
|
-
require 'infinite_tracing/version'
|
13
|
-
require 'infinite_tracing/config'
|
14
|
-
|
15
|
-
DependencyDetection.defer do
|
16
|
-
named :infinite_tracing
|
17
|
-
|
18
|
-
depends_on do
|
19
|
-
NewRelic::Agent::InfiniteTracing::Config.should_load?
|
20
|
-
end
|
21
|
-
|
22
|
-
executes do
|
23
|
-
NewRelic::Agent.logger.debug "Loading New Relic Infinite Tracing Library"
|
24
|
-
|
25
|
-
require 'infinite_tracing/proto'
|
26
|
-
|
27
|
-
require 'infinite_tracing/constants'
|
28
|
-
require 'infinite_tracing/worker'
|
29
|
-
require 'infinite_tracing/record_status_handler'
|
30
|
-
|
31
|
-
require 'infinite_tracing/transformer'
|
32
|
-
require 'infinite_tracing/streaming_buffer'
|
33
|
-
require 'infinite_tracing/suspended_streaming_buffer'
|
34
|
-
require 'infinite_tracing/channel'
|
35
|
-
require 'infinite_tracing/connection'
|
36
|
-
require 'infinite_tracing/client'
|
37
|
-
|
38
|
-
require 'infinite_tracing/agent_integrations'
|
39
|
-
end
|
40
|
-
end
|