Sha256: 5c50879e0fadd1993630ae0587bd6eda6baf51a6acf93f58fe78ff707f243ed9

Contents?: true

Size: 1.41 KB

Versions: 29

Compression:

Stored size: 1.41 KB

Contents

# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

module NewRelic::Agent
  module InfiniteTracing
    class Channel
      SETTINGS_BASE = {'grpc.enable_deadline_checking' => 0}.freeze
      SETTINGS_COMPRESSION_DISABLED = SETTINGS_BASE.merge({'grpc.minimal_stack' => 1}).freeze

      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

      def host_and_port
        Config.trace_observer_host_and_port
      end

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

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

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

        channel_args.merge(SETTINGS_BASE).freeze
      end

      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
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
newrelic-infinite_tracing-9.17.0 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.16.1 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.16.0 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.15.0 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.14.0 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.13.0 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.12.0 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.11.0 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.10.2 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.10.1 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.10.0 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.9.0 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.8.0 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.7.1 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.7.0 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.6.0 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.5.0 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.4.2 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.4.1 lib/infinite_tracing/channel.rb
newrelic-infinite_tracing-9.4.0 lib/infinite_tracing/channel.rb