August 09, 2022

Prisma Support for Tracing and Metrics Is Now in Preview

5 min read

We are excited to launch two new features in Preview: Tracing and Metrics. These two features will allow you to monitor and troubleshoot various performance issues effectively. Try them out and share your feedback!

Developers want to be able to answer the question, "Why is my application slow?" Modern software systems are distributed and complex, making it increasingly difficult to diagnose issues that impact customer experience.

We designed the new tracing and metrics features with these concerns in mind. These features make Prisma more observable as well as easier to monitor and debug.

Get detailed insights into every Prisma operation with tracing

The tracing feature in Prisma provides a detailed view of every query the Prisma Client carries out, including the time taken to execute each query. This is useful for debugging performance issues, identifying bottlenecks and understanding the behavior of your database operations.

Visualize traces as waterfall diagrams

Using a tracing tool such as Jaeger or Honeycomb, traces can be visualized as waterfall diagrams like this:

Visualization of a single trace. A single trace consists of multiple spans. Each span represents the time taken by a certain stage of the total operation.

Prisma tracing is OpenTelemetry compliant

Tracing is a powerful tool that can help you track requests as they flow through your application. This is especially useful for debugging distributed systems, where each request can span multiple services. To levarage the full power of tracing, it should be implemented end-to-end throughout your application.

The tracing feature in Prisma is fully compliant with OpenTelemetry, so you can integrate it seamlessly into your end-to-end application tracing setup. This also means that you can export your trace data to any OpenTelemetry-compatible tracing system, such as Jaeger, Zipkin, Honeycomb, Datadog, etc.

Prisma tracing can be used with any OpenTelemetry-compatible tracing system

To get started with tracing, check out the tracing docs.

Monitor the health and performance of your system with metrics

Metrics is a new feature that allows you to monitor how Prisma interacts with your database. Metrics expose a set of counters, gauges, and histograms that provide information about the state of Prisma and the database connection. The metrics we expose include:

  • total number of Prisma Client queries executed (prisma_client_queries_total)
  • total number of SQL or MongoDB queries executed (prisma_datasource_queries_total)
  • the number of active database connections (prisma_pool_connections_open)
  • histogram containing the duration of all executed Prisma Client queries (prisma_client_queries_duration_histogram_ms_bucket)
  • ... and much more!

Note: A full list of the exposed metrics is available in the metrics docs.

Prisma can often feel like a black box that magically interacts with the database on your behalf. This lack of transparency into Prisma's inner workings can be a problem when things go wrong. With metrics, we aim to give you better visibility into what Prisma is doing under the hood, so that you can diagnose and troubleshoot issues much more easily.

Metrics can be integrated with external monitoring systems

Metrics can be analyzed directly by your application and can also be sent to external monitoring systems and time series databases, like Prometheus or StatsD. Integration with these external systems can significantly improve your monitoring ability by providing the following features out of the box:

  • Real-time performance monitoring through visualizations and dashboards
  • Query and analysis of historical data
  • Precise and automated alerts for failures and performance degradations

For example, you can create detailed dashboards and graphs by integrating Grafana, a popular visualization tool, into your metrics pipeline: Prisma metrics visualization using Grafana

In summary, metrics can help you analyze and monitor the health of your application. It also helps identify performance issues and misconfigurations, so you can quickly take necessary action.

To get started with metrics, check out the metrics docs.

Tracing vs Metrics β€” When to use what?

Tracing is helpful for getting fine-grained information about the lifecycle of each operation. Tracing is especially valuable in distributed environments, where a single request can pass through multiple services.

If you want aggregated numerical data for monitoring the health and performance of your application, then consider using metrics.

It's also important to note that tracing and metrics are complementary features. They can be used together to improve the observability of your system.

Get started with tracing and metrics

To get started with tracing and metrics:

Share your feedback

We are eager to hear from you! Try out these features and let us know what you think.

πŸ“Š Share your feedback on tracing.

πŸ“ˆ Share your feedback on metrics.

πŸš€ If you plan to use these features for mission critical applications, please contact us to discuss your use case.

🌍 We also invite you to join our Slack where you can discuss all things Prisma, share general product feedback in the #product-feedback channel and get help from the community.

Don’t miss the next post!

Sign up for the Prisma Newsletter

Key takeaways from the Discover Data DX virtual event

December 13, 2023

Explore the insights from the Discover Data DX virtual event held on December 7th, 2023. The event brought together industry leaders to discuss the significance and principles of the emerging Data DX category.

Prisma Accelerate now in General Availability

October 26, 2023

Now in General Availability: Dive into Prisma Accelerate, enhancing global database connections with connection pooling and edge caching for fast data access.

Support for Serverless Database Drivers in Prisma ORM Is Now in Preview

October 06, 2023

Prisma is releasing Preview support for serverless database drivers from Neon and PlanetScale. This feature allows Prisma users to leverage the existing database drivers for communication with their database without long-lived TCP connections!