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

Flesh out synchronization of EmbraceSpan functionality #938

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

bidetofevil
Copy link
Collaborator

@bidetofevil bidetofevil commented Jun 9, 2024

Goal

Flesh out synchronization of the wrapper EmbraceSpan given that we know the operations in the SdkSpan are synchronized already.


synchronized(startedSpan) {
val newSpan = spanBuilder.startSpan(attemptedStartTimeMs)
if (newSpan.isRecording) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the main change - If a newly started span is not actually recording, it means the underlying span is a non-recording one or has already been stopped (i.e. the wrapping span builder has already created the span and stopped it on another thread), so we fail the invocation of this wrapper call, first-writer-wins style. We do the same for stop()


@Before
fun setup() {
val initModule = FakeInitModule(clock)
spanRepository = initModule.openTelemetryModule.spanRepository
tracer = initModule.openTelemetryModule.tracer
tracer = FakeTracer()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changing the code to check whether the associated span is recording before returning that a start call has succeeded means that if I used a real Tracer, it would find that the parent I had set is fake (and therefore the Context object isn't populated), so it'll fail.

Since the goal for this is testing the unit, I'm going to use a fake in here instead so the implementation detail of another object doesn't affect the results of this test.

@bidetofevil bidetofevil marked this pull request as ready for review June 10, 2024 15:28
@bidetofevil bidetofevil requested a review from a team as a code owner June 10, 2024 15:28
Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

codecov bot commented Jun 11, 2024

Codecov Report

Attention: Patch coverage is 84.44444% with 7 lines in your changes missing coverage. Please review.

Project coverage is 80.91%. Comparing base (269801f) to head (1f179b3).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #938      +/-   ##
==========================================
- Coverage   80.94%   80.91%   -0.03%     
==========================================
  Files         444      444              
  Lines       11800    11802       +2     
  Branches     1802     1802              
==========================================
- Hits         9551     9550       -1     
- Misses       1456     1458       +2     
- Partials      793      794       +1     
Files Coverage Δ
...droid/embracesdk/internal/spans/EmbraceSpanImpl.kt 86.71% <84.44%> (-1.38%) ⬇️

... and 1 file with indirect coverage changes

Base automatically changed from hho/embspan-sync to master June 11, 2024 17:04
@bidetofevil bidetofevil merged commit 4a7a61e into master Jun 11, 2024
4 checks passed
@bidetofevil bidetofevil deleted the hho/embrace-span-synch branch June 11, 2024 17:31
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