From 55ec57609e4bd273e0d58b0207a72caccd2fbc76 Mon Sep 17 00:00:00 2001 From: Peter Solnica Date: Tue, 7 Jan 2025 13:19:31 +0000 Subject: [PATCH] WIP --- lib/sentry/transaction.ex | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/sentry/transaction.ex b/lib/sentry/transaction.ex index 26e65d9f..c4d7a76f 100644 --- a/lib/sentry/transaction.ex +++ b/lib/sentry/transaction.ex @@ -9,8 +9,12 @@ defmodule Sentry.Transaction do @typedoc since: "11.0.0" + alias Sentry.{Config, UUID, Interfaces.Span} + @type t() :: %__MODULE__{ event_id: String.t(), + span_id: String.t(), + spans: [Span.t()], environment: String.t(), transaction: String.t(), transaction_info: map(), @@ -19,8 +23,6 @@ defmodule Sentry.Transaction do type: String.t() } - alias Sentry.{Config, UUID, Interfaces.Span} - @enforce_keys [:event_id, :span_id, :spans, :environment] defstruct @enforce_keys ++ @@ -42,6 +44,13 @@ defmodule Sentry.Transaction do ) end + # Common attributes between Transaction and Span: + # + # span_id - Used to identify spans in both structs + # type - Transaction has a default "transaction" type, Span has it in data + # data - Transaction has contexts/measurements, Span has data field + # timestamp - Transaction inherits from root span, Span has explicit timestamp + # @doc false def to_map(%__MODULE__{} = transaction) do transaction_attrs = @@ -57,6 +66,9 @@ defmodule Sentry.Transaction do {[root_span], child_spans} = Enum.split_with(transaction.spans, &is_nil(&1.parent_span_id)) + IO.inspect(root_span) + IO.inspect(child_spans) + root_span |> Span.to_map() |> Map.put(:spans, Enum.map(child_spans, &Span.to_map/1))