                     )}
 
     assert span_ctx() = Span.end_span(parent)
+    Ctx.detach(prev_ctx)
+    assert :undefined = Tracer.current_span_ctx()
 
     assert_receive {:span,
                     span(

                    )}

    assert span_ctx() = Span.end_span(parent)

    assert_receive {:span,
                    span(

    # make a new context with it as the active span
    ctx = Tracer.set_current_span(parent_ctx, parent)
    # attach this context (put it in the process dictionary)
    prev_ctx = Ctx.attach(ctx)

    task =
      Task.async(fn ->
        # new process has a new context so this span will have no parent
        parent_link = OpenTelemetry.link(parent)
        assert parent_link != :undefined

        Tracer.with_span "child", %{links: [parent_link]} do
          :hello
        end
