newrelic-infinite_tracing 8.14.0 → 8.15.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: dea7c3ce75b49f52316c4fb4623ce0308d76f408e3062d48b55c2111d5b05de1
4
- data.tar.gz: 7787146ae81457298650f724bfd98605a92ebab90795aefb464bfc7fd4e0f53f
3
+ metadata.gz: ef58ccd55c212b9f5de2fb32b7574ecbdfdb8d82794fccf628de4c76ae17cb5f
4
+ data.tar.gz: '0868bd0fc973b1a0562701b966a29e62636ed9558fe8710f0148be6239bd5433'
5
5
  SHA512:
6
- metadata.gz: 7bd69fe883e8747528f1be2d3a5ef615e178fd78afba6a0ec1a099066db1587686e01496676ffc756d8e3e8ddbb5e77faf4dd3cb1b44036967aa13f41be4e265
7
- data.tar.gz: f8cd73a605f526d9bd30d47f68326c56def716805691c566630e43108a918b84ffc39648dd81b9b8c607e0c1dcd2029162e5d11d8227691036802f94ed76ad17
6
+ metadata.gz: 2f5570f978e5a18bb7e7f6f9c9a06676ed4d3edc2fb874fbcfde6a19a8778806023af125a850e053479b6a2245a2d6d7da3a5718ba4a14a9eaa1a804954a158e
7
+ data.tar.gz: 6aead156960e0785cda78807c50e74dbf802b02a5e96e4b0073ad6593347dedfc3a53934d4345682a2de7f41bf5840c37f8b1a3300ac0df76cc6cb1a762541e9
@@ -5,8 +5,8 @@
5
5
  module NewRelic::Agent
6
6
  module InfiniteTracing
7
7
  class Channel
8
- COMPRESSION_LEVELS = %i[none low medium high].freeze
9
- DEFAULT_COMPRESSION_LEVEL = :none
8
+ SETTINGS_BASE = {'grpc.enable_deadline_checking' => 0}.freeze
9
+ SETTINGS_COMPRESSION_DISABLED = SETTINGS_BASE.merge({'grpc.minimal_stack' => 1}).freeze
10
10
 
11
11
  def stub
12
12
  NewRelic::Agent.logger.debug("Infinite Tracer Opening Channel to #{host_and_port}")
@@ -19,64 +19,29 @@ module NewRelic::Agent
19
19
  )
20
20
  end
21
21
 
22
- def channel
23
- GRPC::Core::Channel.new(host_and_port, settings, credentials)
24
- end
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']
22
+ def host_and_port
23
+ Config.trace_observer_host_and_port
55
24
  end
56
25
 
57
26
  def credentials
58
- # Uses system configured certificates by default
59
- GRPC::Core::ChannelCredentials.new
27
+ @credentials ||= GRPC::Core::ChannelCredentials.new
60
28
  end
61
29
 
62
- def host_and_port
63
- Config.trace_observer_host_and_port
30
+ def channel
31
+ GRPC::Core::Channel.new(host_and_port, settings, credentials)
64
32
  end
65
33
 
66
34
  def settings
67
- {
68
- 'grpc.minimal_stack' => 1,
69
- 'grpc.enable_deadline_checking' => 0
70
- }
71
- end
35
+ return channel_args.merge(SETTINGS_COMPRESSION_DISABLED).freeze unless Config.compression_enabled?
72
36
 
73
- def valid_compression_level?(level)
74
- return true if COMPRESSION_LEVELS.include?(level)
37
+ channel_args.merge(SETTINGS_BASE).freeze
38
+ end
75
39
 
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}'")
40
+ def channel_args
41
+ return NewRelic::EMPTY_HASH unless Config.compression_enabled?
78
42
 
79
- false
43
+ GRPC::Core::CompressionOptions.new(default_algorithm: :gzip,
44
+ default_level: Config.compression_level).to_channel_arg_hash
80
45
  end
81
46
  end
82
47
  end
@@ -7,6 +7,9 @@ module NewRelic::Agent
7
7
  module Config
8
8
  extend self
9
9
 
10
+ COMPRESSION_LEVEL_DISABLED = :none
11
+ COMPRESSION_LEVEL_DEFAULT = :high
12
+ COMPRESSION_LEVEL_LIST = %i[none low medium high].freeze
10
13
  TRACE_OBSERVER_NOT_CONFIGURED_ERROR = "Trace Observer host not configured!"
11
14
 
12
15
  # We only want to load the infinite tracing gem's files when
@@ -109,6 +112,29 @@ module NewRelic::Agent
109
112
  def trace_observer_configured?
110
113
  trace_observer_host != NewRelic::EMPTY_STR
111
114
  end
115
+
116
+ def compression_enabled?
117
+ compression_level != COMPRESSION_LEVEL_DISABLED
118
+ end
119
+
120
+ def compression_level
121
+ @compression_level ||= begin
122
+ level = if COMPRESSION_LEVEL_LIST.include?(configured_compression_level)
123
+ configured_compression_level
124
+ else
125
+ NewRelic::Agent.logger.error("Invalid compression level '#{configured_compression_level}' specified! " \
126
+ "Must be one of #{COMPRESSION_LEVEL_LIST.join('|')}. Using default level " \
127
+ "of '#{COMPRESSION_LEVEL_DEFAULT}'")
128
+ COMPRESSION_LEVEL_DEFAULT
129
+ end
130
+ NewRelic::Agent.logger.debug("Infinite Tracer compression level set to #{level}")
131
+ level
132
+ end
133
+ end
134
+
135
+ def configured_compression_level
136
+ NewRelic::Agent.config[:'infinite_tracing.compression_level']
137
+ end
112
138
  end
113
139
  end
114
140
  end
@@ -17,6 +17,12 @@
17
17
  module NewRelic::Agent
18
18
  module InfiniteTracing
19
19
  class Connection
20
+ GZIP_METADATA = {'grpc-internal-encoding-request' => 'gzip',
21
+ 'grpc-encoding' => 'gzip',
22
+ 'grpc-accept-encoding' => ['gzip'],
23
+ 'content-coding' => 'gzip',
24
+ 'content-encoding' => 'gzip'}.freeze
25
+
20
26
  # listens for server side configurations added to the agent. When a new config is
21
27
  # added, we have a new agent run token and need to restart the client's RPC stream
22
28
  # with the new metadata information.
@@ -100,9 +106,18 @@ module NewRelic::Agent
100
106
  "agent_run_token" => agent_id
101
107
  }
102
108
  @metadata.merge!(request_headers_map)
109
+ merge_gzip_metadata
103
110
  end
104
111
  end
105
112
 
113
+ # If (gzip based) compression is enabled, explicitly provide all
114
+ # relevant metadata
115
+ def merge_gzip_metadata
116
+ return @metadata unless Config.compression_enabled?
117
+
118
+ @metadata.merge!(GZIP_METADATA)
119
+ end
120
+
106
121
  # Initializes rpc so we can get a Channel and Stub (connect to gRPC server)
107
122
  # Initializes metadata so we use newest values in establishing channel
108
123
  # Sets the agent_connected flag and signals the agent started so any
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.14.0
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: 2022-12-14 00:00:00.000000000 Z
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.14.0
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.14.0
29
+ version: 8.15.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: grpc
32
32
  requirement: !ruby/object:Gem::Requirement