lib/instana/backend/serverless_agent.rb in instana-1.197.0 vs lib/instana/backend/serverless_agent.rb in instana-1.198.0.pre1
- old
+ new
@@ -37,16 +37,14 @@
true
end
# @return [Hash, NilClass] the backend friendly description of the current in process collector
def source
- return @source if @source
-
snapshot = @snapshots.detect { |s| s.respond_to?(:source) }
if snapshot
- @source = snapshot.source
+ snapshot.source
else
@logger.warn('Unable to find a snapshot which provides a source.')
{}
end
end
@@ -56,25 +54,14 @@
@headers.split(';')
end
# @return [Hash] values which are removed from urls sent to the backend
def secret_values
- # TODO: Parse from env
matcher, *keys = @secrets.split(/[:,]/)
{'matcher' => matcher, 'list' => keys}
end
- private
-
- def request_headers
- {
- 'X-Instana-Host' => host_name,
- 'X-Instana-Key' => ENV['INSTANA_AGENT_KEY'],
- 'X-Instana-Time' => (Time.now.to_i * 1000).to_s
- }
- end
-
def send_bundle
spans = @processor.queued_spans
bundle = {
spans: spans,
metrics: {
@@ -88,10 +75,20 @@
return if response.ok?
@logger.warn("Recived a `#{response.code}` when sending data.")
end
+ private
+
+ def request_headers
+ {
+ 'X-Instana-Host' => host_name,
+ 'X-Instana-Key' => ENV['INSTANA_AGENT_KEY'],
+ 'X-Instana-Time' => (Time.now.to_i * 1000).to_s
+ }
+ end
+
def agent_snapshots
@snapshots.map do |snapshot|
begin # rubocop:disable Style/RedundantBegin, Lint/RedundantCopDisableDirective
snapshot.snapshot
rescue StandardError => e
@@ -100,15 +97,13 @@
end
end.compact
end
def host_name
- return @host_name if @host_name
-
snapshot = @snapshots.detect { |s| s.respond_to?(:host_name) }
if snapshot
- @host_name = snapshot.host_name
+ snapshot.host_name
else
@logger.warn('Unable to find a snapshot which provides a host_name.')
''
end
end