Class: NewRelic::Agent::InfiniteTracing::Channel
- Inherits:
-
Object
- Object
- NewRelic::Agent::InfiniteTracing::Channel
- Defined in:
- lib/infinite_tracing/channel.rb
Constant Summary collapse
- COMPRESSION_LEVELS =
%i[none low medium high].freeze
- DEFAULT_COMPRESSION_LEVEL =
:none
Instance Method Summary collapse
- #channel ⇒ Object
- #channel_args ⇒ Object
- #compression_enabled? ⇒ Boolean
- #compression_level ⇒ Object
- #compression_options ⇒ Object
- #configured_compression_level ⇒ Object
- #credentials ⇒ Object
- #host_and_port ⇒ Object
- #settings ⇒ Object
- #stub ⇒ Object
- #valid_compression_level?(level) ⇒ Boolean
Instance Method Details
#channel ⇒ Object
22 23 24 |
# File 'lib/infinite_tracing/channel.rb', line 22 def channel GRPC::Core::Channel.new(host_and_port, settings, credentials) end |
#channel_args ⇒ Object
26 27 28 29 30 |
# File 'lib/infinite_tracing/channel.rb', line 26 def channel_args return NewRelic::EMPTY_HASH unless compression_enabled? GRPC::Core::CompressionOptions.new().to_channel_arg_hash end |
#compression_enabled? ⇒ Boolean
32 33 34 |
# File 'lib/infinite_tracing/channel.rb', line 32 def compression_enabled? compression_level != :none end |
#compression_level ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/infinite_tracing/channel.rb', line 36 def compression_level @compression_level ||= begin level = if valid_compression_level?(configured_compression_level) configured_compression_level else DEFAULT_COMPRESSION_LEVEL end NewRelic::Agent.logger.debug("Infinite Tracer compression level set to #{level}") level end end |
#compression_options ⇒ Object
48 49 50 51 |
# File 'lib/infinite_tracing/channel.rb', line 48 def {default_algorithm: :gzip, default_level: compression_level} end |
#configured_compression_level ⇒ Object
53 54 55 |
# File 'lib/infinite_tracing/channel.rb', line 53 def configured_compression_level NewRelic::Agent.config[:'infinite_tracing.compression_level'] end |
#credentials ⇒ Object
57 58 59 60 |
# File 'lib/infinite_tracing/channel.rb', line 57 def credentials # Uses system configured certificates by default GRPC::Core::ChannelCredentials.new end |
#host_and_port ⇒ Object
62 63 64 |
# File 'lib/infinite_tracing/channel.rb', line 62 def host_and_port Config.trace_observer_host_and_port end |
#settings ⇒ Object
66 67 68 69 70 71 |
# File 'lib/infinite_tracing/channel.rb', line 66 def settings { 'grpc.minimal_stack' => 1, 'grpc.enable_deadline_checking' => 0 } end |
#stub ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/infinite_tracing/channel.rb', line 11 def stub NewRelic::Agent.logger.debug("Infinite Tracer Opening Channel to #{host_and_port}") Com::Newrelic::Trace::V1::IngestService::Stub.new( \ host_and_port, credentials, channel_override: channel, channel_args: channel_args ) end |
#valid_compression_level?(level) ⇒ Boolean
73 74 75 76 77 78 79 80 |
# File 'lib/infinite_tracing/channel.rb', line 73 def valid_compression_level?(level) return true if COMPRESSION_LEVELS.include?(level) NewRelic::Agent.logger.error("Invalid compression level '#{level}' specified! Must be one of " \ "#{COMPRESSION_LEVELS.join('|')}. Using default level of '#{DEFAULT_COMPRESSION_LEVEL}'") false end |