Module: NewRelic::Agent::InfiniteTracing::Config
Constant Summary collapse
- COMPRESSION_LEVEL_DISABLED =
:none- COMPRESSION_LEVEL_DEFAULT =
:high- COMPRESSION_LEVEL_LIST =
i[none low medium high].freeze
- TRACE_OBSERVER_NOT_CONFIGURED_ERROR =
'Trace Observer host not configured!'
Instance Method Summary collapse
- #compression_enabled? ⇒ Boolean
- #compression_level ⇒ Object
- #configured_compression_level ⇒ Object
-
#distributed_tracing_enabled? ⇒ Boolean
Distributed Tracing must be enabled for Infinite Tracing.
-
#enabled? ⇒ Boolean
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.
-
#local? ⇒ Boolean
running locally is akin to communicating with the gRPC server with an unencrypted channel.
-
#port_from_host_entry ⇒ Object
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.
-
#should_load? ⇒ Boolean
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.
-
#span_events_enabled? ⇒ Boolean
Span Events must be enabled for Infinite Tracing.
-
#span_events_queue_size ⇒ Object
The maximum number of span events the Streaming Buffer can hold when buffering to stream across the gRPC channel.
-
#test_framework? ⇒ Boolean
Returns TRUE if we’re running in a test environment.
-
#trace_observer_configured? ⇒ Boolean
Infinite Tracing is configured when a non empty string is set as the host.
- #trace_observer_host ⇒ Object
-
#trace_observer_host_and_port ⇒ Object
returns host and port together expressed as
hostname:portstring. -
#trace_observer_port ⇒ Object
This is the port the trace observer is listening on.
-
#trace_observer_scheme ⇒ Object
The scheme is based on whether the Trace Observer is running locally or remotely.
-
#trace_observer_uri ⇒ Object
The uniform resource identifier of the Trace Observer host constructed from all the parts.
-
#without_scheme_or_port(url) ⇒ Object
removes the scheme and port from a host entry.
Instance Method Details
#compression_enabled? ⇒ Boolean
116 117 118 |
# File 'lib/infinite_tracing/config.rb', line 116 def compression_enabled? compression_level != COMPRESSION_LEVEL_DISABLED end |
#compression_level ⇒ Object
120 121 122 |
# File 'lib/infinite_tracing/config.rb', line 120 def compression_level @compression_level ||= configured_compression_level end |
#configured_compression_level ⇒ Object
124 125 126 |
# File 'lib/infinite_tracing/config.rb', line 124 def configured_compression_level NewRelic::Agent.config[:'infinite_tracing.compression_level'] end |
#distributed_tracing_enabled? ⇒ Boolean
Distributed Tracing must be enabled for Infinite Tracing
35 36 37 |
# File 'lib/infinite_tracing/config.rb', line 35 def distributed_tracing_enabled? NewRelic::Agent.config[:'distributed_tracing.enabled'] end |
#enabled? ⇒ Boolean
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.
28 29 30 31 32 |
# File 'lib/infinite_tracing/config.rb', line 28 def enabled? distributed_tracing_enabled? && span_events_enabled? && trace_observer_configured? end |
#local? ⇒ Boolean
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.
48 49 50 |
# File 'lib/infinite_tracing/config.rb', line 48 def local? test_framework? end |
#port_from_host_entry ⇒ Object
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 overridden by the presence of the port on the host entry.
65 66 67 68 69 70 71 |
# File 'lib/infinite_tracing/config.rb', line 65 def port_from_host_entry port_str = NewRelic::Agent.config[:'infinite_tracing.trace_observer.host'].scan(%r{:(\d+)$}).flatten if port = 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 |
#should_load? ⇒ Boolean
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
19 20 21 |
# File 'lib/infinite_tracing/config.rb', line 19 def should_load? test_framework? || trace_observer_configured? end |
#span_events_enabled? ⇒ Boolean
Span Events must be enabled for Infinite Tracing
40 41 42 |
# File 'lib/infinite_tracing/config.rb', line 40 def span_events_enabled? NewRelic::Agent.config[:'span_events.enabled'] end |
#span_events_queue_size ⇒ Object
The maximum number of span events the Streaming Buffer can hold when buffering to stream across the gRPC channel.
102 103 104 |
# File 'lib/infinite_tracing/config.rb', line 102 def span_events_queue_size NewRelic::Agent.config[:'span_events.queue_size'] end |
#test_framework? ⇒ Boolean
Returns TRUE if we’re running in a test environment
107 108 109 |
# File 'lib/infinite_tracing/config.rb', line 107 def test_framework? NewRelic::Agent.config[:framework] == :test end |
#trace_observer_configured? ⇒ Boolean
Infinite Tracing is configured when a non empty string is set as the host
112 113 114 |
# File 'lib/infinite_tracing/config.rb', line 112 def trace_observer_configured? trace_observer_host != NewRelic::EMPTY_STR end |
#trace_observer_host ⇒ Object
57 58 59 |
# File 'lib/infinite_tracing/config.rb', line 57 def trace_observer_host without_scheme_or_port(NewRelic::Agent.config[:'infinite_tracing.trace_observer.host']) end |
#trace_observer_host_and_port ⇒ Object
returns host and port together expressed as hostname:port string.
96 97 98 |
# File 'lib/infinite_tracing/config.rb', line 96 def trace_observer_host_and_port "#{trace_observer_host}:#{trace_observer_port}" end |
#trace_observer_port ⇒ Object
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.
75 76 77 |
# File 'lib/infinite_tracing/config.rb', line 75 def trace_observer_port port_from_host_entry || NewRelic::Agent.config[:'infinite_tracing.trace_observer.port'] end |
#trace_observer_scheme ⇒ Object
The scheme is based on whether the Trace Observer is running locally or remotely. Remote unsecure (unencrypted) streaming is disallowed!
81 82 83 |
# File 'lib/infinite_tracing/config.rb', line 81 def trace_observer_scheme local? ? NewRelic::HTTP : NewRelic::HTTPS end |
#trace_observer_uri ⇒ Object
The uniform resource identifier of the Trace Observer host constructed from all the parts.
86 87 88 89 90 91 92 93 |
# File 'lib/infinite_tracing/config.rb', line 86 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 |
#without_scheme_or_port(url) ⇒ Object
removes the scheme and port from a host entry.
53 54 55 |
# File 'lib/infinite_tracing/config.rb', line 53 def without_scheme_or_port(url) url.gsub(%r{^https?://|:\d+$}, '') end |