-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6552 from ChrisBr/influxdb-beta-new
Improve influxdb
- Loading branch information
Showing
9 changed files
with
114 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module Backend | ||
class Instrumentation | ||
def initialize(http_method, host, http_status_code, runtime) | ||
@http_method = http_method | ||
@host = host | ||
@http_status_code = http_status_code | ||
@runtime = runtime | ||
end | ||
|
||
def instrument | ||
return unless enabled? | ||
|
||
ActiveSupport::Notifications.instrument('obs.backend.process_response', data) | ||
end | ||
|
||
private | ||
|
||
attr_accessor :http_method, :host, :http_status_code, :runtime | ||
|
||
def enabled? | ||
CONFIG['influxdb_hosts'].present? | ||
end | ||
|
||
def data | ||
{ | ||
http_method: http_method, | ||
http_status_code: http_status_code, | ||
host: host, | ||
runtime: runtime, | ||
controller_location: controller_location, | ||
backend_location: backend_location | ||
} | ||
end | ||
|
||
def controller_location | ||
[ | ||
Thread.current[:_influxdb_rails_controller], | ||
Thread.current[:_influxdb_rails_action] | ||
].reject(&:blank?).join('#') | ||
end | ||
|
||
def backend_location | ||
[ | ||
Thread.current[:_influxdb_obs_backend_api_module], | ||
Thread.current[:_influxdb_obs_backend_api_method] | ||
].reject(&:blank?).join('#') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Backend | ||
module RememberLocation | ||
def singleton_method_added(method_name) | ||
return if filtering.include?(method_name) | ||
return if method_name == :singleton_method_added | ||
return if method_name == :initialize | ||
|
||
original_method = singleton_method(method_name) | ||
|
||
filtering << method_name | ||
|
||
define_singleton_method(method_name) do |*args, &block| | ||
Thread.current[:_influxdb_obs_backend_api_method] = method_name.to_s | ||
Thread.current[:_influxdb_obs_backend_api_module] = name | ||
original_method.call(*args, &block) | ||
end | ||
end | ||
|
||
private | ||
|
||
def filtering | ||
@filtering ||= [] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
src/api/lib/influxdb_obs/obs/normalizer/location_normalizer.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Backend::RememberLocation do | ||
let(:mod) { WithRememberLocation } | ||
|
||
class WithRememberLocation | ||
extend Backend::RememberLocation | ||
|
||
def self.run_after; end | ||
end | ||
|
||
describe 'it remembers the location' do | ||
before do | ||
mod.run_after | ||
end | ||
|
||
it { expect(Thread.current[:_influxdb_obs_backend_api_module]).to eq(mod.to_s) } | ||
it { expect(Thread.current[:_influxdb_obs_backend_api_method]).to eq('run_after') } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
src/api/spec/lib/influx_db/obs/normalizer/location_normalizer_spec.rb
This file was deleted.
Oops, something went wrong.