Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
solnic committed Jan 7, 2025
1 parent abb15eb commit 55ec576
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/sentry/transaction.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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 ++
Expand All @@ -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 =
Expand All @@ -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))
Expand Down

0 comments on commit 55ec576

Please sign in to comment.