Sha256: eae963b739d0867455e80972e1b00f41f5f9c3cc4056957cc357ff8b789daeba
Contents?: true
Size: 1.97 KB
Versions: 2
Compression:
Stored size: 1.97 KB
Contents
require "#{File.dirname(__FILE__)}/../spec_helper" RSpec.describe "ActiveRecord instantiation metrics", type: :request do let(:tags_middleware) do lambda do |tags| tags.merge(tags_middleware: :tags_middleware) end end let(:metric) { Metric.create!(name: "name") } before do allow_any_instance_of(InfluxDB::Rails::Configuration).to receive(:ignored_environments).and_return(%w[development]) allow_any_instance_of(ActionDispatch::Request).to receive(:request_id).and_return(:request_id) allow_any_instance_of(InfluxDB::Rails::Configuration).to receive(:application_name).and_return(:app_name) allow_any_instance_of(InfluxDB::Rails::Configuration).to receive(:tags_middleware).and_return(tags_middleware) end it "writes metric" do get metric_path(metric) expect_metric( tags: a_hash_including( location: "MetricsController#show", hook: "instantiation", class_name: "Metric", additional_tag: :value, server: Socket.gethostname, app_name: :app_name, tags_middleware: :tags_middleware ), values: a_hash_including( additional_value: :value, request_id: :request_id, value: be_between(1, 500), record_count: 1 ) ) end it "includes correct timestamps" do travel_to Time.zone.local(2018, 1, 1, 9, 0, 0) get metric_path(metric) expect_metric( tags: a_hash_including( location: "MetricsController#show", hook: "instantiation" ), timestamp: 1_514_797_200 ) end it "does not write metric when hook is ignored" do allow_any_instance_of(InfluxDB::Rails::Configuration).to receive(:ignored_hooks).and_return(["instantiation.active_record"]) get metric_path(metric) expect_no_metric( tags: a_hash_including( location: "MetricsController#show", hook: "instantiation" ) ) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
influxdb-rails-1.0.1 | spec/requests/active_record_instantiation_metrics_spec.rb |
influxdb-rails-1.0.1.beta3 | spec/requests/active_record_instantiation_metrics_spec.rb |