diff --git a/lib/appsignal/transaction.rb b/lib/appsignal/transaction.rb
index <HASH>..<HASH> 100644
--- a/lib/appsignal/transaction.rb
+++ b/lib/appsignal/transaction.rb
@@ -128,6 +128,7 @@ module Appsignal
 
     def set_error(error)
       return unless error
+      return unless Appsignal.active?
       return if Appsignal.is_ignored_error?(error)
 
       Appsignal.logger.debug("Adding #{error.class.name} to transaction: #{transaction_id}")
diff --git a/spec/lib/appsignal/transaction_spec.rb b/spec/lib/appsignal/transaction_spec.rb
index <HASH>..<HASH> 100644
--- a/spec/lib/appsignal/transaction_spec.rb
+++ b/spec/lib/appsignal/transaction_spec.rb
@@ -332,6 +332,13 @@ describe Appsignal::Transaction do
         transaction.set_error(error)
       end
 
+      it "should not add the error if appsignal is not active" do
+        Appsignal.stub(:active? => false)
+        Appsignal::Extension.should_not_receive(:set_transaction_error)
+
+        transaction.set_error(error)
+      end
+
       context "for a http request" do
         it "should set an error in the extension" do
           Appsignal::Extension.should_receive(:set_transaction_error).with(
Do not attempt to set an error when appsignal is not active