gRPC is an open-source Remote Procedure Call (RPC) framework developed by Google and released in 2016. Although gRPC is still relatively new, large organizations are adopting it in increasing numbers to build APIs that connect complex microservice meshes that use disparate languages and frameworks. gRPC-based APIs can perform requests up to seven times faster than REST APIs and enable customers to easily implement SSL authentication, load balancing, and tracing via plug-in libraries.
We’re pleased to announce that Datadog Synthetic Monitoring now enables you to test your gRPC endpoints, so you can continually monitor the availability of your gRPC services to ensure that your APIs respond to requests correctly. Like other Datadog Synthetic tests, gRPC tests include a wide range of configuration options, so you can customize them to fit your team’s needs. In this post, we’ll discuss how you can perform gRPC unary calls and gRPC health checks within the Datadog platform and monitor their results from the Synthetic Monitoring view.
How does gRPC work?
In an RPC architecture, the client application can call a method on a networked service as if it were a local object in the same address space. This function invocation is known as the Remote Procedure Call, or RPC. gRPC implements an RPC architecture in which RPCs contain data payloads serialized in protocol buffers, rather than in JSON files, as is the case in the REST API framework. Whereas JSON files are human-readable, protocol buffer serialization encodes the data in binary, facilitating faster processing and a broader range of compatible data types. By defining your RPC services in serialized proto files, you can perform gRPC calls that are either unary (that is, a discrete request is invoked once to fetch a response) or continuous streams.
Configure gRPC tests
Datadog Synthetic Monitoring enables you to perform synthetic gRPC unary calls to test the health and response time of your request functions. Once you’ve selected “gRPC” on the test creation view, you can specify the host and port and then import the service definition for a unary call by uploading the proto file and specifying which method to test. Next, set the request message you want to send. You can enter the message manually or generate a boilerplate message automatically using the Generate Example button. Then, you can add assertions to define a successful test result—such as the minimum response time and desired output—and set the managed and private locations where you’d like the test to run.
In addition to simulating gRPC unary calls, you can also create health checks that can proactively validate whether or not a service is available to receive RPCs. As with unary call tests, you can add assertions to your health checks to define the maximum response time and expected output.
Like other Synthetic tests, gRPC tests can be run on demand, on a regular schedule, or from within your CI/CD pipelines via Synthetic Monitoring’s integrations with services such as Jenkins and Github Actions. If a test fails in the pipeline, you can optionally block the deployment and automatically trigger a rollback, enabling you to keep problematic code changes from reaching production.
Finally, you can use Datadog’s robust alerting capabilities to notify your teams when a gRPC test is failing for a certain period of time or in a certain number of locations. You can also include additional context in the alert message in order to ensure on-call engineers have enough information to begin their investigation.
Monitor your gRPC tests in Datadog
The Synthetic Monitoring main view includes a list of all the Synthetic tests shared by your organization, including gRPC tests. You can query, sort, and filter this list by test type, as well as keywords and tags, to quickly find the ones you care about. For example, you can filter by error status to surface failed tests for troubleshooting, or sort by uptime to view which tests are failing the most often.
You can click on any test to access more granular details that can help you spot performance trends and begin to investigate why the test is failing. For instance, uptime graphs allow you to see at a glance how a test’s status differs between locations, which enables you to determine if any regional server outages are at play. You can also drill into individual test runs to view a breakdown of network timings and verify that the response message and headers are consistent with your expectations.
For additional context around a test result, you can leverage Synthetics’ integration with Datadog APM to view the full trace of the inter-service function calls leading up to the RPC request. Errorful spans are highlighted in red, so you can examine any errors that may have contributed to the failure. Relevant stacktraces, infrastructure metrics, and logs are included in the same view, enabling you to easily access all the information you need to begin troubleshooting.
Get started with Synthetic gRPC testing
Datadog’s Synthetic gRPC tests, which are now available for all Synthetic Monitoring customers, enable teams to continually monitor the availability and performance of their gRPC endpoints in order to detect and resolve issues as quickly as possible. See our documentation for more information on how to start creating these tests today. If you’re not yet using Datadog to monitor your applications and infrastructure, get started with a 14-day free trial.