Module: Datadog::Quantization::HTTP
- Defined in:
- lib/ddtrace/quantization/http.rb
Overview
Quantization for HTTP resources
Constant Summary collapse
- PLACEHOLDER =
'?'.freeze
Class Method Summary collapse
- .query(query, options = {}) ⇒ Object
- .query!(query, options = {}) ⇒ Object
- .url(url, options = {}) ⇒ Object
- .url!(url, options = {}) ⇒ Object
Class Method Details
.query(query, options = {}) ⇒ Object
33 34 35 36 37 |
# File 'lib/ddtrace/quantization/http.rb', line 33 def query(query, = {}) query!(query, ) rescue StandardError [:placeholder] || PLACEHOLDER end |
.query!(query, options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ddtrace/quantization/http.rb', line 39 def query!(query, = {}) ||= {} [:show] = [:show] || [] [:exclude] = [:exclude] || [] # Short circuit if query string is meant to exclude everything # or if the query string is meant to include everything return '' if [:exclude] == :all return query if [:show] == :all collect_query(query, uniq: true) do |key, value| if [:exclude].include?(key) [nil, nil] else value = [:show].include?(key) ? value : nil [key, value] end end end |
.url(url, options = {}) ⇒ Object
12 13 14 15 16 |
# File 'lib/ddtrace/quantization/http.rb', line 12 def url(url, = {}) url!(url, ) rescue StandardError [:placeholder] || PLACEHOLDER end |
.url!(url, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ddtrace/quantization/http.rb', line 18 def url!(url, = {}) ||= {} URI.parse(url).tap do |uri| # Format the query string if uri.query query = query(uri.query, [:query]) uri.query = (!query.nil? && query.empty? ? nil : query) end # Remove any URI framents uri.fragment = nil unless [:fragment] == :show end.to_s end |