High inflation and rising interest rates have dragged the stock market down this year. In the second quarter, the S&P 500 slipped into its seventh bear market in the last 50 years. Each of these events has varied in terms of duration and severity, but all but the latest one ended the exact same way: A bull market came along and sent the index soaring to new highs.

Right now, some investors are obsessing over the short-term fate of the economy and what a recession might mean for the stock market. But smart investors see the situation as an opportunity. Sharp downturns have historically been the best time to buy stocks, simply because bear markets have always been followed by bull markets. And there is no reason to believe this latest one will be any different.

With that in mind, Block (SQ -0.93%) and Datadog (DDOG 0.03%) look like smart long-term investments. Here's why.

Block: A fintech with a disruptive approach to commerce and consumer finance

Block breaks its business into two parts: Square and Cash App. Its Square ecosystem is an integrated suite of hardware, software, and financial services that helps merchants operate across physical and digital sales channels. Block's ability to bundle payment processing and banking services with a broad range of business software (e.g., payroll, marketing, scheduling) gives it an edge over traditional payment processors.

The Cash App ecosystem has been a similarly disruptive force in consumer finance. It allows users to deposit funds, spend and borrow money, and invest in stocks and cryptocurrency though a single platform. And the convenience of accessing all those services in one place has driven strong adoption. In fact, Cash App was the most downloaded digital wallet in the U.S. in the first half of 2022, according to Apptopia.

Collectively, the Square and Cash App ecosystems fueled solid financial results over the past year, in spite of the choppy macroeconomic environment. Gross profit jumped 37% to $5.1 billion, and free cash flow soared 178% to $563 million. But Block has captured just 3% of its $190 billion (in gross profit) market opportunity, and several catalysts could accelerate growth in the future.

In the Square ecosystem, premium point-of-sale software for retail and restaurants has been instrumental in driving adoption by larger businesses. In fact, mid-market merchants (i.e., greater than $500,000 in annual gross payment volume, or GPV) accounted for 39% of annualized GPV in the second quarter, up from 27% in the same quarter of 2020. That trend is particularly exciting because larger businesses use more adjacent software products than smaller businesses, and that translates into more revenue and great retention rates for Block.

Additionally, new shopping capabilities in Cash App could turbocharge its popularity. It now features a discovery tab that allows consumers to browse products and make purchases from Afterpay merchants, creating synergies between the ecosystems. And as Cash App evolves into a commerce engine, Block will reinforce those synergies by expanding into digital advertising. Specifically, Afterpay merchants will be able to engage Cash App consumers with relevant product suggestions delivered through the digital wallet.

On that note, with shares currently trading at 2.1 times sales -- an absolute bargain compared to its five-year average of eight times sales -- now is a great time to buy this growth stock.

Datadog: Ensuring the security and performance of business-critical applications

Datadog specializes in monitoring and security. Its platform gathers and analyzes data from applications, networks, and infrastructure, and it leans on artificial intelligence (AI) to predict and identify performance issues. In doing so, Datadog helps businesses secure sensitive data, avoid system downtime, and ensure a positive user experience for its customers.

In 2018, Datadog became the first vendor to unify the "three pillars of observability" on a single platform: metrics, traces, and logs. The company has since continued to innovate like clockwork, turning its platform into a comprehensive suite of monitoring and analytics software. In June, research company Gartner once again recognized Datadog as a leader in application performance monitoring (APM) and observability, citing its broad portfolio and AI engine as key differentiators.

Not surprisingly, Datadog has churned out impressive growth metrics. Its customer base increased approximately 29% over the past year, and the company has maintained a dollar-based net retention rate of more than 130% for 20 consecutive quarters. In other words, existing customers spend at least 30% more with the company from year to year. In turn, revenue has soared 79% to $1.4 billion and free cash flow skyrocketed 168% to $354 million over the past year.

Investors have good reason to be optimistic about the future too. Datadog puts its market opportunity at $53 billion by 2025, and its capacity for innovation has already carried it to the forefront of the APM industry.

On that note, the company recently announced the availability of two new products: Observability Pipelines and Audit Trails. The former is used to collect, transform, and route observability data from any source to any destination, helping businesses control costs and protect sensitive data. And the latter is used to audit changes made to the Datadog platform, helping businesses meet compliance requirements.

Currently, shares trade at 21.7 times sales. That is far from cheap, but it's still a bargain compared to the historical average of 38.5. In light of Datadog's potential for future growth, it seems like a reasonable price to pay. That's why investors should start with a small position in this monster growth stock right now.