From 9fca9d6f605272995c471bd50f605e9eda2484c9 Mon Sep 17 00:00:00 2001 From: Noemi <45180344+unflxw@users.noreply.github.com> Date: Thu, 10 Oct 2024 17:11:43 +0200 Subject: [PATCH] Add `reported_by` tag to error backend errors We get support tickets about incomplete error reporting, which we assume is due to the use of the error backend. Often customers do not know whether the error was raised from an uninstrumented context, or whether they're using a version of the integration where the error backend is enabled by default. This should simplify the support workflow for it going forward, by giving us that information in the error sample itself. We can also ask customers to update to the latest version and see if the affected samples have this tag. This follows the format that we use in [the Ruby integration][ruby] [ruby]: https://github.com/appsignal/appsignal-ruby/blob/6201f5dbe662e22e682a8a324b7e996e979ef09f/lib/appsignal/integrations/puma.rb#L21 --- lib/appsignal/error/backend.ex | 1 + test/appsignal/error/backend_test.exs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/appsignal/error/backend.ex b/lib/appsignal/error/backend.ex index 69e5e61a5..c6b0aef23 100644 --- a/lib/appsignal/error/backend.ex +++ b/lib/appsignal/error/backend.ex @@ -90,6 +90,7 @@ defmodule Appsignal.Error.Backend do defp set_error_data(span, reason, stacktrace) do span |> @span.add_error(:error, reason, stacktrace) + |> @span.set_sample_data("tags", %{"reported_by" => "error_backend"}) |> @tracer.close_span() end end diff --git a/test/appsignal/error/backend_test.exs b/test/appsignal/error/backend_test.exs index bf18f0ba9..cc6d76ae4 100644 --- a/test/appsignal/error/backend_test.exs +++ b/test/appsignal/error/backend_test.exs @@ -225,6 +225,11 @@ defmodule Appsignal.Error.BackendTest do assert is_list(stack) end + test "adds a `reported_by` tag to the created span", %{pid: pid} do + assert {:ok, [{%Span{pid: ^pid}, "tags", %{"reported_by" => "error_backend"}} | _]} = + Test.Span.get(:set_sample_data) + end + test "closes the created span", %{pid: pid} do assert {:ok, [{%Span{pid: ^pid}} | _]} = Test.Tracer.get(:close_span) end