Skip to content

Conversation

@savhappy
Copy link
Collaborator

[ WIP] Needs test adjustment and specs
Considerations:
Should we store root spans and child spans in separate tables?
Storing key/values like this -> parent: {{:root_span, span_id}, span} child: {parent_span_id, span}
Should we implement some sort of sweep in case spans don't get removed on_end
Should we order the child spans in the table? Or have an inserted_at value?

@savhappy savhappy force-pushed the sav/add-ets-to-store-spans branch from 609deb2 to e32e392 Compare October 28, 2024 13:28
@savhappy savhappy marked this pull request as ready for review November 14, 2024 08:06
@savhappy
Copy link
Collaborator Author

savhappy commented Nov 14, 2024

@whatyouhide refactored with the genserver added. Left a comment wondering if we should sweep based on ttl or something else to avoid build up.

@solnic I have two failing test that I'm confused about..

  1) test sends captured spans as transactions with child spans (Sentry.Opentelemetry.SpanProcessorTest)
     test/sentry/opentelemetry/span_processor_test.exs:59
     ** (FunctionClauseError) no function clause matching in Calendar.ISO.parse_utc_datetime/2

     The following arguments were given to Calendar.ISO.parse_utc_datetime/2:

         # 1
         nil

         # 2
         :extended

     Attempted function clauses (showing 1 out of 1):

         def parse_utc_datetime(string, format) when is_binary(string) and (format === :basic or format === :extended)

     code: assert_valid_iso8601(transaction.timestamp)
     stacktrace:
       (elixir 1.17.2) lib/calendar/iso.ex:591: Calendar.ISO.parse_utc_datetime/2
       (elixir 1.17.2) lib/calendar/datetime.ex:1233: DateTime.from_iso8601/3
       test/sentry/opentelemetry/span_processor_test.exs:112: Sentry.Opentelemetry.SpanProcessorTest.assert_valid_iso8601/1
       test/sentry/opentelemetry/span_processor_test.exs:67: (test)
     

Thoughts?

@impl true
def init(nil) do
_table =
if :ets.whereis(@table) == :undefined do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the table is tied to this GenServer, where would we ever have the table running without it that we need this check?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When testing, an error is thrown because the table is already created. We do this in check_in_id_mappings.ex as well.


@root_spans_table :sentry_root_spans
@child_spans_table :sentry_child_spans
@table :span_storage
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope this to Sentry, as the ETS namespace is global. My suggestion is

Suggested change
@table :span_storage
@table __MODULE__

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In one of our pairing sessions for check_in_id_mappings.ex, we discussed this being bad practice to have both the GenServer and the table name the same. Thoughts?

@solnic
Copy link
Collaborator

solnic commented Nov 28, 2024

@solnic I have two failing test that I'm confused about..

  1) test sends captured spans as transactions with child spans (Sentry.Opentelemetry.SpanProcessorTest)
     test/sentry/opentelemetry/span_processor_test.exs:59
     ** (FunctionClauseError) no function clause matching in Calendar.ISO.parse_utc_datetime/2

     The following arguments were given to Calendar.ISO.parse_utc_datetime/2:

         # 1
         nil

         # 2
         :extended

     Attempted function clauses (showing 1 out of 1):

         def parse_utc_datetime(string, format) when is_binary(string) and (format === :basic or format === :extended)

     code: assert_valid_iso8601(transaction.timestamp)
     stacktrace:
       (elixir 1.17.2) lib/calendar/iso.ex:591: Calendar.ISO.parse_utc_datetime/2
       (elixir 1.17.2) lib/calendar/datetime.ex:1233: DateTime.from_iso8601/3
       test/sentry/opentelemetry/span_processor_test.exs:112: Sentry.Opentelemetry.SpanProcessorTest.assert_valid_iso8601/1
       test/sentry/opentelemetry/span_processor_test.exs:67: (test)
     

Thoughts?

I'm looking into this finally. Sorry for late reply!

@solnic
Copy link
Collaborator

solnic commented Dec 5, 2024

@savhappy fixed tests via 2053408

@whatyouhide could you take another look please? would be good to merge this into the main PR branch and continue working there and wrap this up :)

I'm sorry that it took me so long to follow-up here!

@solnic solnic requested a review from whatyouhide December 5, 2024 19:54
@savhappy savhappy merged commit 4d2837b into solnic/support-for-transactions-via-otel Dec 6, 2024
4 checks passed
@savhappy savhappy deleted the sav/add-ets-to-store-spans branch December 6, 2024 10:19
solnic added a commit that referenced this pull request Dec 9, 2024
* initial refactor with ETS for span storage

* add genserver back

* Fix updating root spans in ets

* remove comment

---------

Co-authored-by: Peter Solnica <[email protected]>
solnic added a commit that referenced this pull request Dec 12, 2024
* initial refactor with ETS for span storage

* add genserver back

* Fix updating root spans in ets

* remove comment

---------

Co-authored-by: Peter Solnica <[email protected]>
solnic added a commit that referenced this pull request Dec 27, 2024
* initial refactor with ETS for span storage

* add genserver back

* Fix updating root spans in ets

* remove comment

---------

Co-authored-by: Peter Solnica <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants