Class: NewRelic::Agent::InfiniteTracing::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/infinite_tracing/channel.rb

Constant Summary collapse

SETTINGS_BASE =
{'grpc.enable_deadline_checking' => 0}.freeze
SETTINGS_COMPRESSION_DISABLED =
SETTINGS_BASE.merge({'grpc.minimal_stack' => 1}).freeze

Instance Method Summary collapse

Instance Method Details

#channelObject



30
31
32
# File 'lib/infinite_tracing/channel.rb', line 30

def channel
  GRPC::Core::Channel.new(host_and_port, settings, credentials)
end

#channel_argsObject



40
41
42
43
44
45
# File 'lib/infinite_tracing/channel.rb', line 40

def channel_args
  return NewRelic::EMPTY_HASH unless Config.compression_enabled?

  GRPC::Core::CompressionOptions.new(default_algorithm: :gzip,
    default_level: Config.compression_level).to_channel_arg_hash
end

#credentialsObject



26
27
28
# File 'lib/infinite_tracing/channel.rb', line 26

def credentials
  @credentials ||= GRPC::Core::ChannelCredentials.new
end

#host_and_portObject



22
23
24
# File 'lib/infinite_tracing/channel.rb', line 22

def host_and_port
  Config.trace_observer_host_and_port
end

#settingsObject



34
35
36
37
38
# File 'lib/infinite_tracing/channel.rb', line 34

def settings
  return channel_args.merge(SETTINGS_COMPRESSION_DISABLED).freeze unless Config.compression_enabled?

  channel_args.merge(SETTINGS_BASE).freeze
end

#stubObject



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