Class: QueryGuard::Exporter

Inherits:
Object
  • Object
show all
Defined in:
lib/query_guard/exporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Exporter

Returns a new instance of Exporter.



11
12
13
# File 'lib/query_guard/exporter.rb', line 11

def initialize(config)
  @config = config
end

Instance Method Details

#enabled? ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/query_guard/exporter.rb', line 15

def enabled?
  @config.base_url && @config.api_key && @config.project
end

#export!(stats) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/query_guard/exporter.rb', line 19

def export!(stats)
  return unless enabled?

  payload = build_payload(stats)
  return if payload[:events].empty?

  if @config.export_mode.to_sym == :async
    Thread.new { post(payload) }
  else
    post(payload)
  end
end