diff --git a/lib/appsignal_phoenix/event_handler.ex b/lib/appsignal_phoenix/event_handler.ex index e3b0653..0252cfc 100644 --- a/lib/appsignal_phoenix/event_handler.ex +++ b/lib/appsignal_phoenix/event_handler.ex @@ -106,6 +106,12 @@ defmodule Appsignal.Phoenix.EventHandler do def phoenix_template_render_start(_event, _measurements, metadata, _config) do parent = @tracer.current_span() + _ = @span.set_sample_data_if_nil(@tracer.root_span(), "tags", %{ + "phoenix_template" => metadata.template, + "phoenix_format" => metadata.format, + "phoenix_view" => module_name(metadata.view) + }) + "http_request" |> @tracer.create_span(parent) |> @span.set_name( diff --git a/test/appsignal_phoenix/event_handler_test.exs b/test/appsignal_phoenix/event_handler_test.exs index 13cc153..c452820 100644 --- a/test/appsignal_phoenix/event_handler_test.exs +++ b/test/appsignal_phoenix/event_handler_test.exs @@ -254,6 +254,18 @@ defmodule Appsignal.Phoenix.EventHandlerTest do assert {:ok, [{%Span{}, "appsignal:category", "render.phoenix_template"}]} = Test.Span.get(:set_attribute) end + + test "sets the root span's tags" do + assert {:ok, + [ + {%Span{}, "tags", + %{ + "phoenix_template" => "template", + "phoenix_format" => "html", + "phoenix_view" => "PhoenixWeb.View" + }} + ]} = Test.Span.get(:set_sample_data_if_nil) + end end describe "after receiving an render-start and an render-stop event" do