Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a threadsafe map to make getActiveSpans threadsafe #888

Merged
merged 1 commit into from
May 27, 2024

Conversation

bidetofevil
Copy link
Collaborator

@bidetofevil bidetofevil commented May 24, 2024

Goal

The underlying snapshot taking operation isn't thread safe, so we have to use a thread safe data structure to ensure we can snapshot the current active spans while is being modified. This leaves room for some race conditions as to which session a span is started or stopped in, which is probably fine given the asynchronous nature of tracking spans anyway.

What I don't want is to lock everything every time a span is started or stopped, which could potentially result in some pretty bad performance. I can take a look to see if we can have some greater guarantees to reduce the aforementioned race condition, but this will work fine for now as long as we don't mind a bit of timestamp misalignment between span and session boundaries.

Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @bidetofevil and the rest of your teammates on Graphite Graphite

Copy link

codecov bot commented May 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.91%. Comparing base (6e92cf7) to head (70ab85f).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #888   +/-   ##
=======================================
  Coverage   80.91%   80.91%           
=======================================
  Files         435      435           
  Lines       11613    11613           
  Branches     1764     1764           
=======================================
  Hits         9397     9397           
  Misses       1438     1438           
  Partials      778      778           
Files Coverage Δ
...ndroid/embracesdk/internal/spans/SpanRepository.kt 86.95% <100.00%> (ø)

... and 2 files with indirect coverage changes

@bidetofevil bidetofevil marked this pull request as ready for review May 25, 2024 00:01
@bidetofevil bidetofevil requested a review from a team as a code owner May 25, 2024 00:01
@bidetofevil bidetofevil requested review from fractalwrench and priettt and removed request for fractalwrench May 25, 2024 00:02
Copy link
Contributor

@priettt priettt left a comment

Choose a reason for hiding this comment

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

LGTM!

@bidetofevil bidetofevil merged commit af40d9a into master May 27, 2024
4 checks passed
@bidetofevil bidetofevil deleted the hho/get-active-span-threadsafe branch May 27, 2024 15:48
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.

2 participants