So, I largely agree with others that 4 Gate is fairly aggressive and susceptible to DTs, but let's pretend you "have" to 4 Gate, and your Zerg's build is something like Roach/Ling (ie. no lair tech).
First off, let me start by saying, these are very rational builds. They're fairly standard. You should not feel the need to dramatically change from these builds despite anything you encounter. Next, let me also say, there is no amount of scouting which will guarantee you detect DTs. While good scouting can alleviate this problem, it will not prevent it. There will always be some player who proxy's his Archives/Shrine and your many scouts just miss it. So while good scouting is always good advice, it is never a solution.
So What Can I Do?
Depending on the map, dealing with DTs usually means you'll have to protect both bases, so let's deal with the Zerg first. I routinely run a Roach/Ling or Ling/Baneling opening and I've run into enough DTs that I've made an Evolution Chamber a standard part of my build. Initially it was because you often see the DTs leaving the opponent's base (or scout them warping in at a proxy Pylon), and it turns out you have just enough time to get a Spore Crawler down at your mineral line.
The flipside to the very early Evo Chamber is a very early Melee upgrade (or Ranged). It turns out that +1 Zerglings are just terrors, and will eat through anything short of +1 Zealots in no time at all (including Roaches). In fact, that early Evo Chamber has become such a powerful move that I've taken to running it in all my match ups (P,T and even Z). So I highly recommend you work it into your Zerg builds.
Now for PvP it's much less standard that someone goes for a DT rush (or even DTs in general). Early Observers are just too common for DT play to become regular. However, that doesn't preclude you from running into DTs. There are a couple things you can start doing to prepare.
- Wall in -> wall ins aren't just for Zerg, they also shut down DTs and Korean 4 Gate openings by buying you more time to recover
- Early Forge -> an early Forge can be just as beneficial as an early Evo Chamber. +1 Zealots eat Zerglings/Marines, and that +1 carries over to Immortals/Colossus later (in fact, 3 Gate Expand into Double Forge is an amazingly powerful build).
- 3 Gate Robo -> while 4 Gate is the traditional agressive build, 3 Gate Robo was the original PvP build, and with the recent nerfs to Warp Gate tech, it's coming back into fashion (an Immortal really eats those Stalkers). Plus, quick observer!
- 2 Gate Play -> 2 Gate has fallen out of favor with the longer Zealot build time, but against an opponent who is rushing DTs, it is disastrous. Consider running 2 Gate while your partner FEs and then have him follow up at the 6 minute push timing.
The problem with DT rushes is that it's very much an all in build. While later DT pushes can be advantageous, anyone who's rushing DTs by the 7 minute mark has made HUGE sacrifices to get there. If you can just keep them out of your mineral line, you've pretty much won the game. Now in a 2v2 this means you'll have to fight a 2v1, but having been on the short side of a couple of those, I can tell you you're sitting pretty.