flare 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of flare might be problematic. Click here for more details.

Files changed (70) hide show
  1. data/.document +5 -0
  2. data/.gitignore +22 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +18 -0
  5. data/Rakefile +55 -0
  6. data/VERSION +1 -0
  7. data/flare.gemspec +66 -0
  8. data/lib/flare/active_record.rb +102 -0
  9. data/lib/flare/collection.rb +47 -0
  10. data/lib/flare/configuration.rb +64 -123
  11. data/lib/flare/index_builder.rb +24 -0
  12. data/lib/flare/session.rb +142 -0
  13. data/lib/flare/tasks.rb +18 -0
  14. data/lib/flare.rb +19 -537
  15. data/test/helper.rb +10 -0
  16. data/test/test_flare.rb +7 -0
  17. metadata +89 -242
  18. checksums.yaml +0 -7
  19. data/CHANGELOG.md +0 -3
  20. data/LICENSE.txt +0 -21
  21. data/README.md +0 -148
  22. data/app/controllers/flare/application_controller.rb +0 -30
  23. data/app/controllers/flare/jobs_controller.rb +0 -55
  24. data/app/controllers/flare/requests_controller.rb +0 -73
  25. data/app/controllers/flare/spans_controller.rb +0 -101
  26. data/app/helpers/flare/application_helper.rb +0 -168
  27. data/app/views/flare/jobs/index.html.erb +0 -69
  28. data/app/views/flare/jobs/show.html.erb +0 -323
  29. data/app/views/flare/requests/index.html.erb +0 -120
  30. data/app/views/flare/requests/show.html.erb +0 -498
  31. data/app/views/flare/spans/index.html.erb +0 -112
  32. data/app/views/flare/spans/show.html.erb +0 -184
  33. data/app/views/layouts/flare/application.html.erb +0 -126
  34. data/config/routes.rb +0 -20
  35. data/exe/flare +0 -9
  36. data/lib/flare/backoff_policy.rb +0 -73
  37. data/lib/flare/cli/doctor_command.rb +0 -129
  38. data/lib/flare/cli/output.rb +0 -45
  39. data/lib/flare/cli/setup_command.rb +0 -404
  40. data/lib/flare/cli/status_command.rb +0 -47
  41. data/lib/flare/cli.rb +0 -50
  42. data/lib/flare/client_headers.rb +0 -39
  43. data/lib/flare/deadline.rb +0 -27
  44. data/lib/flare/engine.rb +0 -45
  45. data/lib/flare/filtering_span_processor.rb +0 -429
  46. data/lib/flare/http_metrics_config.rb +0 -101
  47. data/lib/flare/http_transport.rb +0 -76
  48. data/lib/flare/lifecycle.rb +0 -39
  49. data/lib/flare/marker.rb +0 -106
  50. data/lib/flare/metric_counter.rb +0 -51
  51. data/lib/flare/metric_flusher.rb +0 -279
  52. data/lib/flare/metric_key.rb +0 -42
  53. data/lib/flare/metric_span_processor.rb +0 -470
  54. data/lib/flare/metric_storage.rb +0 -67
  55. data/lib/flare/metric_submitter.rb +0 -239
  56. data/lib/flare/recording_batch_span_processor.rb +0 -238
  57. data/lib/flare/rule_manager.rb +0 -141
  58. data/lib/flare/sampler.rb +0 -130
  59. data/lib/flare/source_location.rb +0 -113
  60. data/lib/flare/sqlite_exporter.rb +0 -334
  61. data/lib/flare/storage/sqlite.rb +0 -794
  62. data/lib/flare/storage.rb +0 -54
  63. data/lib/flare/trace_blob.rb +0 -116
  64. data/lib/flare/trace_exporter.rb +0 -182
  65. data/lib/flare/trace_health_reporter.rb +0 -74
  66. data/lib/flare/upload_url_pool.rb +0 -108
  67. data/lib/flare/version.rb +0 -5
  68. data/lib/flare/web_marker_subscriber.rb +0 -76
  69. data/public/flare-assets/flare.css +0 -1245
  70. data/public/flare-assets/images/flipper.png +0 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ flare-solr.pid
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Michael Dwan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,18 @@
1
+ = flare
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but
13
+ bump version in a commit by itself I can ignore when I pull)
14
+ * Send me a pull request. Bonus points for topic branches.
15
+
16
+ == Copyright
17
+
18
+ Copyright (c) 2009 Michael Dwan. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,55 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "flare"
8
+ gem.summary = 'This needs to get updated'
9
+ gem.description = 'This needs to get updated'
10
+ gem.email = "mpdwan@gmail.com"
11
+ gem.homepage = "http://github.com/michaeldwan/flare"
12
+ gem.authors = ["Michael Dwan"]
13
+ gem.add_dependency('rsolr', '>= 0.9.6')
14
+ gem.add_dependency('escape', '>= 0.0.4')
15
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
21
+ end
22
+
23
+ require 'rake/testtask'
24
+ Rake::TestTask.new(:test) do |test|
25
+ test.libs << 'lib' << 'test'
26
+ test.pattern = 'test/**/test_*.rb'
27
+ test.verbose = true
28
+ end
29
+
30
+ begin
31
+ require 'rcov/rcovtask'
32
+ Rcov::RcovTask.new do |test|
33
+ test.libs << 'test'
34
+ test.pattern = 'test/**/test_*.rb'
35
+ test.verbose = true
36
+ end
37
+ rescue LoadError
38
+ task :rcov do
39
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
40
+ end
41
+ end
42
+
43
+ task :test => :check_dependencies
44
+
45
+ task :default => :test
46
+
47
+ require 'rake/rdoctask'
48
+ Rake::RDocTask.new do |rdoc|
49
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "flare #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/flare.gemspec ADDED
@@ -0,0 +1,66 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{flare}
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Michael Dwan"]
12
+ s.date = %q{2009-12-29}
13
+ s.description = %q{This needs to get updated}
14
+ s.email = %q{mpdwan@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "flare.gemspec",
27
+ "lib/flare.rb",
28
+ "lib/flare/active_record.rb",
29
+ "lib/flare/collection.rb",
30
+ "lib/flare/configuration.rb",
31
+ "lib/flare/index_builder.rb",
32
+ "lib/flare/session.rb",
33
+ "lib/flare/tasks.rb",
34
+ "test/helper.rb",
35
+ "test/test_flare.rb"
36
+ ]
37
+ s.homepage = %q{http://github.com/michaeldwan/flare}
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = %q{1.3.5}
41
+ s.summary = %q{This needs to get updated}
42
+ s.test_files = [
43
+ "test/helper.rb",
44
+ "test/test_flare.rb"
45
+ ]
46
+
47
+ if s.respond_to? :specification_version then
48
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
49
+ s.specification_version = 3
50
+
51
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
52
+ s.add_runtime_dependency(%q<rsolr>, [">= 0.9.6"])
53
+ s.add_runtime_dependency(%q<escape>, [">= 0.0.4"])
54
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
55
+ else
56
+ s.add_dependency(%q<rsolr>, [">= 0.9.6"])
57
+ s.add_dependency(%q<escape>, [">= 0.0.4"])
58
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
59
+ end
60
+ else
61
+ s.add_dependency(%q<rsolr>, [">= 0.9.6"])
62
+ s.add_dependency(%q<escape>, [">= 0.0.4"])
63
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
64
+ end
65
+ end
66
+
@@ -0,0 +1,102 @@
1
+ module Flare
2
+ module ActiveRecord
3
+ def self.included(base)
4
+ base.extend Hook
5
+ end
6
+
7
+ module Hook
8
+ def searchable(&block)
9
+ Flare.indexed_models << self unless Flare.indexed_models.include?(self)
10
+
11
+ builder = IndexBuilder.new(&block)
12
+ solr_index = builder.index
13
+
14
+ write_inheritable_attribute :solr_index, solr_index
15
+ class_inheritable_reader :solr_index
16
+
17
+ after_save :solr_save
18
+ after_destroy :solr_destroy
19
+
20
+ include InstanceMethods
21
+ extend ClassMethods
22
+ end
23
+
24
+ def searchable?
25
+ false
26
+ end
27
+ end
28
+
29
+ module ClassMethods
30
+ def search_for_ids(*args)
31
+ options = args.extract_options!
32
+ options[:types] ||= []
33
+ options[:types] << self
34
+ Flare.session.search_for_ids(*[args, options].flatten)
35
+ end
36
+
37
+ def search(*args)
38
+ options = args.extract_options!
39
+ options[:types] ||= []
40
+ options[:types] << self
41
+ Flare.session.search(*[args, options].flatten)
42
+ end
43
+
44
+ def search_count(*args)
45
+ options = args.extract_options!
46
+ options[:types] ||= []
47
+ options[:types] << self
48
+ Flare.session.count(*[args, options].flatten)
49
+ end
50
+
51
+ def searchable?
52
+ true
53
+ end
54
+
55
+ def rebuild_solr_index
56
+ total = self.count
57
+ count = 0
58
+ self.find_in_batches(:batch_size => 100) do |batch|
59
+ Flare.session.index(batch)
60
+ count += batch.length
61
+ printf "\r#{count}/#{total} complete"
62
+ STDOUT.flush
63
+ end
64
+ puts
65
+ Flare.session.commit
66
+ Flare.session.optimize
67
+ end
68
+
69
+ def clear_solr_index
70
+ Flare.session.remove_all!(self)
71
+ end
72
+ end
73
+
74
+ module InstanceMethods
75
+ def to_solr_doc
76
+ doc = { :id => solr_document_id, :type => self.class.name }
77
+ solr_index[:fields].each do |field|
78
+ value = send(field[:source])
79
+ # Need to convert dates to utc xmlschema.
80
+ #TODO: move this translation to rsolr gem
81
+ if value.respond_to?(:utc)
82
+ value = value.utc.xmlschema
83
+ end
84
+ doc[field[:name]] = value
85
+ end
86
+ doc
87
+ end
88
+
89
+ def solr_document_id
90
+ "#{self.class.name}:#{self.id}"
91
+ end
92
+
93
+ def solr_save
94
+ Flare.session.index!(self)
95
+ end
96
+
97
+ def solr_destroy
98
+ Flare.session.remove!(self)
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,47 @@
1
+ module Flare
2
+ class Collection < ::Array
3
+ attr_reader :total_entries, :total_pages, :current_page, :per_page
4
+ attr_accessor :response
5
+
6
+ def initialize(page, per_page, total)
7
+ @current_page, @per_page, @total_entries = page, per_page, total
8
+
9
+ @total_pages = (@total_entries / @per_page.to_f).ceil
10
+ end
11
+
12
+ def self.ids_from_response(response, page, per_page, options)
13
+ collection = self.new(page, per_page, response['response']['numFound'] || 0)
14
+ collection.response = response
15
+ collection.replace(response['response']['docs'].map {|doc| doc['id']})
16
+ return collection
17
+ end
18
+
19
+ def self.create_from_response(response, page, per_page, options)
20
+ # raise response.inspect
21
+ collection = self.new(page, per_page, response['response']['numFound'] || 0)
22
+ collection.response = response
23
+ collection.replace(instantiate_objects(response))
24
+ return collection
25
+ end
26
+
27
+ def previous_page
28
+ current_page > 1 ? (current_page - 1) : nil
29
+ end
30
+
31
+ def next_page
32
+ current_page < total_pages ? (current_page + 1): nil
33
+ end
34
+
35
+ def offset
36
+ (current_page - 1) * @per_page
37
+ end
38
+
39
+ private
40
+ def self.instantiate_objects(response)
41
+ response['response']['docs'].map do |doc|
42
+ type, id = doc['id'].split(':')
43
+ type.constantize.find(id)
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,135 +1,76 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "http_metrics_config"
1
+ require 'yaml'
4
2
 
5
3
  module Flare
6
4
  class Configuration
7
- attr_accessor :enabled
8
- attr_accessor :retention_hours
9
- attr_accessor :max_spans
10
- attr_accessor :ignore_request
11
- attr_writer :database_path
12
-
13
- # Spans: detailed trace data stored in SQLite (default: development only)
14
- # Metrics: aggregated counters in memory, flushed periodically (default: production only)
15
- # Tracing: server-controlled per-route trace sampling. Polls /api/rules
16
- # for which routes/jobs to capture, ships matched traces direct to R2
17
- # via presigned URLs, self-notifies POST /api/traces.
18
- attr_accessor :spans_enabled
19
- attr_accessor :metrics_enabled
20
- attr_accessor :metrics_flush_interval # seconds between flushes (default: 60)
21
- attr_accessor :tracing_enabled
22
- attr_accessor :tracing_poll_interval # seconds between /api/rules polls (default: 30)
23
- attr_accessor :tracing_max_queue # max traced spans buffered per process
24
-
25
- # Metrics HTTP submission settings
26
- attr_accessor :url # URL of the Flare metrics service
27
- attr_accessor :key # API key for authentication
28
- attr_accessor :metrics_timeout # HTTP timeout in seconds (default: 5)
29
- attr_accessor :metrics_gzip # Whether to gzip payloads (default: true)
30
-
31
- # Default patterns to auto-subscribe to for custom instrumentation
32
- # Use "app." prefix in your ActiveSupport::Notifications.instrument calls
33
- DEFAULT_SUBSCRIBE_PATTERNS = %w[app.].freeze
34
-
35
- attr_accessor :subscribe_patterns
36
-
37
- # HTTP metrics path tracking configuration.
38
- # Controls which outgoing HTTP paths are tracked with detail vs collapsed to "*".
39
- attr_reader :http_metrics_config
40
-
41
- # Enable debug logging to see what Flare is doing.
42
- # Set FLARE_DEBUG=1 or configure debug: true in your initializer.
43
- attr_accessor :debug
44
-
45
- def initialize
46
- @enabled = true
47
- @retention_hours = 24
48
- @max_spans = 10_000
49
- @database_path = nil
50
- @ignore_request = ->(request) { false }
51
- @subscribe_patterns = DEFAULT_SUBSCRIBE_PATTERNS.dup
52
- @debug = ENV["FLARE_DEBUG"] == "1"
53
- @http_metrics_config = HttpMetricsConfig::DEFAULT
54
-
55
- # Environment-based defaults:
56
- # - Development: spans ON (detailed debugging), metrics ON
57
- # - Production: spans OFF (too expensive), metrics ON
58
- # - Test: spans OFF, metrics OFF
59
- @spans_enabled = rails_development?
60
- @metrics_enabled = !rails_test?
61
- @metrics_flush_interval = 60 # seconds
62
- @tracing_enabled = !rails_test?
63
- @tracing_poll_interval = 30 # seconds
64
- @tracing_max_queue = 5_000
65
-
66
- # Metrics HTTP submission defaults
67
- @url = ENV.fetch("FLARE_URL", credentials_url || "https://flare.am")
68
- @key = ENV["FLARE_KEY"]
69
- @metrics_timeout = 5
70
- @metrics_gzip = true
71
- end
72
-
73
- # Check if metrics can be submitted (endpoint and API key configured)
74
- def metrics_submission_configured?
75
- !@url.nil? && !@url.empty? &&
76
- !@key.nil? && !@key.empty?
77
- end
78
-
79
- # Tracing reuses the same endpoint + key as metrics.
80
- def tracing_submission_configured?
81
- @tracing_enabled && metrics_submission_configured?
82
- end
83
-
84
- def database_path
85
- @database_path || default_database_path
86
- end
5
+ class << self
6
+ attr_reader :client, :server
7
+
8
+ def server(reload = false)
9
+ @server = nil if reload
10
+ @server ||= Server.new
11
+ end
87
12
 
88
- # Configure HTTP metrics path tracking.
89
- #
90
- # config.http_metrics do |http|
91
- # http.host "api.stripe.com" do |h|
92
- # h.allow %r{/v1/customers}
93
- # h.allow %r{/v1/charges}
94
- # h.map %r{/v1/connect/[\w-]+/transfers}, "/v1/connect/:account/transfers"
95
- # end
96
- # http.host "api.github.com", :all
97
- # end
98
- def http_metrics(&block)
99
- # Clone defaults on first customization so user additions merge with built-in defaults
100
- if @http_metrics_config.equal?(HttpMetricsConfig::DEFAULT)
101
- @http_metrics_config = @http_metrics_config.dup
13
+ def client(reload = false)
14
+ @client = nil if reload
15
+ @client = Client.new
102
16
  end
103
- yield @http_metrics_config
104
17
  end
105
18
 
106
19
  private
20
+ class Server
21
+ def initialize
22
+ @config = YAML::load_file(File.join(Rails.root, 'config', 'solr.yml'))[Rails.env]
23
+ end
24
+
25
+ def port
26
+ @port ||= (@config['port'] || 8983).to_i
27
+ end
28
+
29
+ def log_dir
30
+ @log_dir ||= File.expand_path(@config['log_dir'] || 'log')
31
+ end
32
+
33
+ def log_level
34
+ @log_level ||= @config['log_level'] || 'INFO'
35
+ end
36
+
37
+ def data_dir
38
+ @data_dir ||= File.expand_path(@config['data_dir'] || File.join('solr', 'data', Rails.env))
39
+ end
40
+
41
+ def solr_home
42
+ @solr_home ||= File.expand_path(@config['solr_home'] || File.join(File.dirname(__FILE__), '..', '..', 'solr', 'solr'))
43
+ end
44
+
45
+ def pid_dir
46
+ @pid_dir ||= File.expand_path(@config['pid_dir'] || 'tmp/pids')
47
+ end
48
+
49
+ def jvm_options
50
+ @jvm_options ||= @config['jvm_options']
51
+ end
52
+ end
107
53
 
108
- def rails_development?
109
- defined?(Rails) && Rails.env.development?
110
- rescue StandardError
111
- false # Default to false for safety - avoids enabling spans unexpectedly in production
112
- end
113
-
114
- def rails_test?
115
- defined?(Rails) && Rails.env.test?
116
- rescue StandardError
117
- false
118
- end
119
-
120
- def credentials_url
121
- return nil unless defined?(Rails) && Rails.application&.credentials
122
- Rails.application.credentials.dig(:flare, :url)
123
- rescue StandardError
124
- nil
125
- end
126
-
127
- def default_database_path
128
- if defined?(Rails) && Rails.respond_to?(:root) && Rails.root
129
- Rails.root.join("db", "flare.sqlite3").to_s
130
- else
131
- "flare.sqlite3"
54
+ class Client
55
+ def initialize
56
+ @config = YAML::load_file(File.join(Rails.root, 'config', 'flare.yml'))[Rails.env]
57
+ end
58
+
59
+ def port
60
+ @port ||= (@config['port'] || 8983).to_i
61
+ end
62
+
63
+ def host
64
+ @host ||= @config['host'] || '127.0.0.1'
65
+ end
66
+
67
+ def path
68
+ @path ||= @config['path'] || 'solr'
69
+ end
70
+
71
+ def url
72
+ @url ||= "http://#{host}:#{port}/#{path}"
73
+ end
132
74
  end
133
- end
134
75
  end
135
76
  end
@@ -0,0 +1,24 @@
1
+ module Flare
2
+ class IndexBuilder
3
+ attr_reader :fields
4
+
5
+ def initialize(&block)
6
+ @fields = []
7
+ self.instance_eval(&block) if block_given?
8
+ end
9
+
10
+ def index
11
+ { :fields => @fields }
12
+ end
13
+
14
+ protected
15
+ def field(*args)
16
+ field, options = args.first, args.extract_options!
17
+ @fields << {
18
+ :source => field,
19
+ :name => options[:as] || field,
20
+ :boost => options[:boost] || nil
21
+ }
22
+ end
23
+ end
24
+ end