diff --git a/.changesets/remove-moped-support.md b/.changesets/remove-moped-support.md new file mode 100644 index 000000000..c39ffae3f --- /dev/null +++ b/.changesets/remove-moped-support.md @@ -0,0 +1,6 @@ +--- +bump: "patch" +type: "remove" +--- + +Remove Moped support as it is no longer the official Ruby Mongo driver and it's been unmaintained for 7 years. diff --git a/lib/appsignal/event_formatter/moped/query_formatter.rb b/lib/appsignal/event_formatter/moped/query_formatter.rb deleted file mode 100644 index 309bcc825..000000000 --- a/lib/appsignal/event_formatter/moped/query_formatter.rb +++ /dev/null @@ -1,86 +0,0 @@ -# frozen_string_literal: true - -module Appsignal - class EventFormatter - # @api private - module Moped - class QueryFormatter - def format(payload) - return unless payload[:ops] - return if payload[:ops].empty? - - op = payload[:ops].first - case op.class.to_s - when "Moped::Protocol::Command" - [ - "Command", { - :database => op.full_collection_name, - :selector => sanitize(op.selector, true, :mongodb) - }.inspect - ] - when "Moped::Protocol::Query" - [ - "Query", { - :database => op.full_collection_name, - :selector => sanitize(op.selector, false, :mongodb), - :flags => op.flags, - :limit => op.limit, - :skip => op.skip, - :fields => op.fields - }.inspect - ] - when "Moped::Protocol::Delete" - [ - "Delete", { - :database => op.full_collection_name, - :selector => sanitize(op.selector, false, :mongodb), - :flags => op.flags - }.inspect - ] - when "Moped::Protocol::Insert" - [ - "Insert", { - :database => op.full_collection_name, - :documents => sanitize(op.documents, true, :mongodb), - :count => op.documents.count, - :flags => op.flags - }.inspect - ] - when "Moped::Protocol::Update" - [ - "Update", - { - :database => op.full_collection_name, - :selector => sanitize(op.selector, false, :mongodb), - :update => sanitize(op.update, true, :mongodb), - :flags => op.flags - }.inspect - ] - when "Moped::Protocol::KillCursors" - [ - "KillCursors", - { :number_of_cursor_ids => op.number_of_cursor_ids }.inspect - ] - else - [ - op.class.to_s.sub("Moped::Protocol::", ""), - { :database => op.full_collection_name }.inspect - ] - end - end - - private - - def sanitize(params, only_top_level, key_sanitizer) - Appsignal::Utils::QueryParamsSanitizer.sanitize \ - params, only_top_level, key_sanitizer - end - end - end - end -end - -Appsignal::EventFormatter.register( - "query.moped", - Appsignal::EventFormatter::Moped::QueryFormatter -) diff --git a/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb b/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb index b4a0522fe..0e6ba8369 100644 --- a/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +++ b/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb @@ -2,7 +2,7 @@ let(:klass) { Appsignal::EventFormatter::ElasticSearch::SearchFormatter } let(:formatter) { klass.new } - it "should register query.moped" do + it "should register search.elasticsearch" do expect( Appsignal::EventFormatter.registered?("search.elasticsearch", klass) ).to be_truthy diff --git a/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb b/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb deleted file mode 100644 index 87c7635b0..000000000 --- a/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +++ /dev/null @@ -1,118 +0,0 @@ -describe Appsignal::EventFormatter::Moped::QueryFormatter do - let(:klass) { Appsignal::EventFormatter::Moped::QueryFormatter } - let(:formatter) { klass.new } - - it "should register query.moped" do - expect(Appsignal::EventFormatter.registered?("query.moped", klass)).to be_truthy - end - - describe "#format" do - let(:payload) { { :ops => [op] } } - subject { formatter.format(payload) } - - context "without ops in the payload" do - let(:payload) { {} } - - it { is_expected.to be_nil } - end - - context "when ops is nil in the payload" do - let(:payload) { { :ops => nil } } - - it { is_expected.to be_nil } - end - - context "Moped::Protocol::Command" do - let(:op) do - double( - :full_collection_name => "database.collection", - :selector => { "query" => { "_id" => "abc" } }, - :class => double(:to_s => "Moped::Protocol::Command") - ) - end - - it { is_expected.to eq ["Command", '{:database=>"database.collection", :selector=>{"query"=>"?"}}'] } - end - - context "Moped::Protocol::Query" do - let(:op) do - double( - :full_collection_name => "database.collection", - :selector => { "_id" => "abc" }, - :flags => [], - :limit => 0, - :skip => 0, - :fields => nil, - :class => double(:to_s => "Moped::Protocol::Query") - ) - end - - it { is_expected.to eq ["Query", '{:database=>"database.collection", :selector=>{"_id"=>"?"}, :flags=>[], :limit=>0, :skip=>0, :fields=>nil}'] } - end - - context "Moped::Protocol::Delete" do - let(:op) do - double( - :full_collection_name => "database.collection", - :selector => { "_id" => "abc" }, - :flags => [], - :class => double(:to_s => "Moped::Protocol::Delete") - ) - end - - it { is_expected.to eq ["Delete", '{:database=>"database.collection", :selector=>{"_id"=>"?"}, :flags=>[]}'] } - end - - context "Moped::Protocol::Insert" do - let(:op) do - double( - :full_collection_name => "database.collection", - :flags => [], - :documents => [ - { "_id" => "abc", "events" => { "foo" => [{ "bar" => "baz" }] } }, - { "_id" => "def", "events" => { "foo" => [{ "baz" => "bar" }] } } - ], - :class => double(:to_s => "Moped::Protocol::Insert") - ) - end - - it { is_expected.to eq ["Insert", '{:database=>"database.collection", :documents=>[{"_id"=>"?", "events"=>"?"}], :count=>2, :flags=>[]}'] } - end - - context "Moped::Protocol::Update" do - let(:op) do - double( - :full_collection_name => "database.collection", - :selector => { "_id" => "abc" }, - :update => { "user.name" => "James Bond" }, - :flags => [], - :class => double(:to_s => "Moped::Protocol::Update") - ) - end - - it { is_expected.to eq ["Update", '{:database=>"database.collection", :selector=>{"_id"=>"?"}, :update=>{"user.?"=>"?"}, :flags=>[]}'] } - end - - context "Moped::Protocol::KillCursors" do - let(:op) do - double( - :number_of_cursor_ids => 2, - :class => double(:to_s => "Moped::Protocol::KillCursors") - ) - end - - it { is_expected.to eq ["KillCursors", "{:number_of_cursor_ids=>2}"] } - end - - context "Moped::Protocol::Other" do - let(:op) do - double( - :full_collection_name => "database.collection", - :class => double(:to_s => "Moped::Protocol::Other") - ) - end - - it { is_expected.to eq ["Other", '{:database=>"database.collection"}'] } - end - end -end