It's a tough time to be a technology investor, but the current share price drops that most stocks are experiencing won't last forever. 

And when the market eventually rebounds, there are some leading companies that investors will wish they had purchased and held onto. Here are two that are worth buying right now and holding onto for years: The Trade Desk (TTD 1.67%) and Datadog (DDOG 4.95%) are both gaining ground in their respective markets.

A person looking at a chart while sitting at a desk with two computer monitors on it.

Image source: Getty Images.

1. The Trade Desk

The advertising industry is undergoing some big changes at the moment, and The Trade Desk is trying to tap into them. The first trend it's tapping into is the shift from traditional advertising mediums to digital ones. The company's platform allows advertisers to buy ads and put them on internet-connected devices including laptops, cellphones, and connected TVs.

These markets offer fast-growing opportunities in the digital ad space that is expected to grow from a market size of $220 billion in 2022 to $278 billion just two years from now.  Research from eMarketer estimates that connected TV advertising will more than double from 2021 to 2024, reaching $30 billion. 

The Trade Desk is also helping companies move away from online trackers, called cookies, with its own anonymized identifier, called Unified ID 2.0, which also helps companies display relevant advertising. Already, some large companies have adopted Unified ID 2.0, including The Washington Post, fuboTV, and, most recently, Amazon's Amazon Web Services. 

If all of that weren't enough, The Trade Desk's second-quarter financial results were very impressive. The company's sales spiked 35% from the year-ago quarter to $377 million -- outpacing management's guidance and analysts' average estimate. 

The strong results in the quarter come as many companies in the digital ad space -- including Meta Platforms, Snap, and Roku -- all faced significant advertising headwinds.

The Trade Desk's recent quarterly results prove the company's resiliency during some tough times for the ad industry. And with the company's huge digital advertising market potential, now might be a good time to snatch up some shares as The Trade Desk continues to gain a foothold in the ad market. 

The Trade Desk's stock is currently trading at 21 times sales. That may seem a bit high, but unlike many other growth stocks, The Trade Desk has been profitable for years and has $1.2 billion in cash, which puts it in a better financial state than some other growth tech stocks. 

2. Datadog 

If advertising companies aren't your thing, then perhaps highly successful data monitoring and analytics company Datadog could be what you're looking for. Keeping track of web servers and company data is big business, and Datadog estimates that its total addressable market will reach $53 billion by 2025.  

But investors don't need to wait until then to understand just how great this company is. In the second quarter, Datadog's sales surged by 74% to $406 million, an impressive feat while many other tech stocks experienced a slowdown in sales. 

Even more impressive is the fact that its customers continue to increase their spending with the company, with Datadog's net revenue retention rate hovering around 130% for the 20th consecutive quarter. And the number of companies spending $100,000 or more with Datadog increased 54% in the quarter to 2,420.  

If all of that weren't enough to show Datadog's strong position in the monitoring and analytics space, consider that the company raised its full-year outlook following its second-quarter earnings results -- an unusual move for any company right now. 

Datadog now expects a 57% increase in sales for 2022, to $1.62 billion, up from the company's previous guidance of $1.61 billion.  

With the company's strong customer growth, skyrocketing sales, and ability to increase its number of lucrative customers, Datadog looks like a resilient tech leader that should continue growing its position for years to come. 

Datadog's current valuation is also making its stock look more enticing. The company's current price-to-sales ratio is 21.5,, the lowest it's been in more than two years.  And with the company recently posting a quarterly profit, it's clear Datadog's bottom line is moving in the right direction as well. 

Investors need to be patient right now 

The market is very volatile at the moment and many tech stocks have experienced significant declines over the past year. But for investors who take a buy-and-hold approach, putting some money into these two tech companies and holding onto them for years could be a great way to benefit from the recent tech stock sell-off.