module NewRelic::Agent::InfiniteTracing::Config
Constants
- TRACE_OBSERVER_NOT_CONFIGURED_ERROR
Public Instance Methods
Distributed Tracing must be enabled for Infinite Tracing
# File lib/infinite_tracing/config.rb, line 33 def distributed_tracing_enabled? NewRelic::Agent.config[:'distributed_tracing.enabled'] end
Infinite Tracing support is enabled when the following conditions are true:
a) Distributed tracing is enabled in the agent, AND b) Span events are enabled in the agent, both by client side configuration AND the collect_span_events connect response field, AND c) A Trace Observer host is configured by setting infinite_tracing.trace_observer.host.
# File lib/infinite_tracing/config.rb, line 26 def enabled? distributed_tracing_enabled? && span_events_enabled? && trace_observer_configured? end
running locally is akin to communicating with the gRPC server with an unencrypted channel. Generally, this is not allowed by the agent in normal use-cases. The only known use-case for this is when streaming under TEST conditions.
# File lib/infinite_tracing/config.rb, line 46 def local? test_framework? end
If the port is declared on the host entry, it overrides the port entry because otherwise we'd need to figure out if user supplied the port or if the default source config set the port. To help with debugging configuration issues, we log whenever the port entry is overriden by the presence of the port on the host entry.
# File lib/infinite_tracing/config.rb, line 63 def port_from_host_entry port_str = NewRelic::Agent.config[:'infinite_tracing.trace_observer.host'].scan(%r{:(\d+)$}).flatten if port = (port_str[0] and port_str[0].to_i) NewRelic::Agent.logger.warn(":'infinite_tracing.trace_observer.port' is ignored if present because :'infinite_tracing.trace_observer.host' specifies the port") return port end end
We only want to load the infinite tracing gem's files when
a) we're inside test framework and running tests b) the trace observer host is configured
# File lib/infinite_tracing/config.rb, line 17 def should_load? test_framework? || trace_observer_configured? end
Span Events must be enabled for Infinite Tracing
# File lib/infinite_tracing/config.rb, line 38 def span_events_enabled? NewRelic::Agent.config[:'span_events.enabled'] end
The maximum number of span events the Streaming Buffer can hold when buffering to stream across the gRPC channel.
# File lib/infinite_tracing/config.rb, line 100 def span_events_queue_size NewRelic::Agent.config[:'span_events.queue_size'] end
Returns TRUE if we're running in a test environment
# File lib/infinite_tracing/config.rb, line 105 def test_framework? NewRelic::Agent.config[:framework] == :test end
Infinite Tracing is configured when a non empty string is set as the host
# File lib/infinite_tracing/config.rb, line 110 def trace_observer_configured? trace_observer_host != NewRelic::EMPTY_STR end
# File lib/infinite_tracing/config.rb, line 55 def trace_observer_host without_scheme_or_port NewRelic::Agent.config[:'infinite_tracing.trace_observer.host'] end
returns host and port together expressed as hostname:port
string.
# File lib/infinite_tracing/config.rb, line 94 def trace_observer_host_and_port "#{trace_observer_host}:#{trace_observer_port}" end
This is the port the trace observer is listening on. It can be supplied as a suffix on the host entry or via the separate port entry.
# File lib/infinite_tracing/config.rb, line 73 def trace_observer_port port_from_host_entry || NewRelic::Agent.config[:'infinite_tracing.trace_observer.port'] end
The scheme is based on whether the Trace Observer is running locally or remotely. Remote unsecure (unencypted) streaming is disallowed!
# File lib/infinite_tracing/config.rb, line 79 def trace_observer_scheme local? ? NewRelic::HTTP : NewRelic::HTTPS end
The uniform resource identifier of the Trace Observer host constructed from all the parts.
# File lib/infinite_tracing/config.rb, line 84 def trace_observer_uri if trace_observer_configured? URI("#{trace_observer_scheme}://#{trace_observer_host_and_port}") else NewRelic::Agent.logger.error TRACE_OBSERVER_NOT_CONFIGURED_ERROR raise TRACE_OBSERVER_NOT_CONFIGURED_ERROR end end
removes the scheme and port from a host entry.
# File lib/infinite_tracing/config.rb, line 51 def without_scheme_or_port url url.gsub(%r{^https?://|:\d+$}, '') end