From d4ced54a3ce47c32b48185003eebf0b411dfe8fb Mon Sep 17 00:00:00 2001 From: Andrea Leopardi Date: Sat, 30 Dec 2023 22:50:03 +0100 Subject: [PATCH 1/3] Add Sentry.Interfaces.Span --- lib/sentry/interfaces.ex | 58 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/lib/sentry/interfaces.ex b/lib/sentry/interfaces.ex index 0855ad2c..6f131bb6 100644 --- a/lib/sentry/interfaces.ex +++ b/lib/sentry/interfaces.ex @@ -267,4 +267,62 @@ defmodule Sentry.Interfaces do :stacktrace ] end + + defmodule Span do + @moduledoc """ + The struct for a tracing **span**. + + See . + """ + + @moduledoc since: "11.0.0" + + alias Sentry.Interfaces + + @typedoc since: "11.0.0" + @type t() :: %__MODULE__{ + start_timestamp: String.t() | number(), + timestamp: String.t() | number(), + span_id: String.t(), + parent_span_id: String.t() | nil, + description: String.t(), + tags: map(), + trace_id: String.t() | nil, + op: String.t(), + contexts: Interfaces.contexts(), + spans: [t()], + status: String.t(), + data: map(), + fingerprint: [String.t()], + origin: String.t(), + measurements: %{ + optional(String.t()) => %{required(:value) => term(), optional(:unit) => String.t()} + }, + + # Attributes that are only for "transactions", which are basically the root + # span of a trace. https://develop.sentry.dev/sdk/event-payloads/transaction/ + event_id: String.t() | nil, + transaction_info: %{source: :custom | :url | :route | :view | :component | :task} + } + + defstruct [ + :event_id, + :description, + :tags, + :parent_span_id, + :trace_id, + :op, + :span_id, + :start_timestamp, + :timestamp, + :contexts, + :spans, + :measurements, + :transaction_info, + :status, + :data, + :fingerprint, + :origin + ] + end end From 7f813cb75f4a907354b5bc6244df26541839deb7 Mon Sep 17 00:00:00 2001 From: Andrea Leopardi Date: Sat, 30 Dec 2023 23:00:12 +0100 Subject: [PATCH 2/3] Fix Dialyzer --- lib/sentry/interfaces.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sentry/interfaces.ex b/lib/sentry/interfaces.ex index 6f131bb6..af62e1bf 100644 --- a/lib/sentry/interfaces.ex +++ b/lib/sentry/interfaces.ex @@ -289,7 +289,7 @@ defmodule Sentry.Interfaces do tags: map(), trace_id: String.t() | nil, op: String.t(), - contexts: Interfaces.contexts(), + contexts: Interfaces.context(), spans: [t()], status: String.t(), data: map(), From c3559c5411fb43e4c8a93426b307d00e744ddb97 Mon Sep 17 00:00:00 2001 From: Andrea Leopardi Date: Tue, 2 Jan 2024 17:38:10 +0100 Subject: [PATCH 3/3] Address review comments --- lib/sentry/interfaces.ex | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/sentry/interfaces.ex b/lib/sentry/interfaces.ex index af62e1bf..3f406ee0 100644 --- a/lib/sentry/interfaces.ex +++ b/lib/sentry/interfaces.ex @@ -277,8 +277,6 @@ defmodule Sentry.Interfaces do @moduledoc since: "11.0.0" - alias Sentry.Interfaces - @typedoc since: "11.0.0" @type t() :: %__MODULE__{ start_timestamp: String.t() | number(), @@ -289,11 +287,9 @@ defmodule Sentry.Interfaces do tags: map(), trace_id: String.t() | nil, op: String.t(), - contexts: Interfaces.context(), spans: [t()], status: String.t(), data: map(), - fingerprint: [String.t()], origin: String.t(), measurements: %{ optional(String.t()) => %{required(:value) => term(), optional(:unit) => String.t()} @@ -315,13 +311,11 @@ defmodule Sentry.Interfaces do :span_id, :start_timestamp, :timestamp, - :contexts, :spans, :measurements, :transaction_info, :status, :data, - :fingerprint, :origin ] end