Under the Hood

Metis provides an end-to-end solution to easily detect db-related problems before they hit production. For that Metis needs to collect the SQL commands and relevant data. Then it processes the raw data into clear insights which explain the users what went wrong and how to fix that.

Metis SDK Instrumentation

Metis provides an SDK for popular ORM and Middlewares, such as Python SQL Alchemy or JS Pg based ORM's. The SDK provides simple installation and instrumentation with almost no impact on performance. The SDK uses only metadata about the db schema and query activity is needed.
The SDK generates Traces that link the caller REST or GraphQL with the SQL command(s) it generated. The SDK uses OpenTelemetry to generate the traces. That allows Metis easy integration with existing Open Telemetry instrumentation and other Application Performance Monitoring (APM) tools.
On top of the traces, the SDK also sends Metis the execution plan of the SQL commands, the schema of the relevant tables and indexes, tables size, and index usage.

Generating the Insights

The Backend processes the stream of traces. It runs automatic checks for rule violations and misconfiguration of the database. When rule violations are found, Metis produces an insight which guides the developer to fix the issue while explaining the reason behind the rule.

Viewing the Insights

The web app shows the traces sent from the users' app servers via the SDK. The users can see an overview of the recent QA tests, and quickly identify the REST commands which generated bad SQL. The web app provides deep SQL command analysis, showing all the insights related to the SQL. The insights are easy to understand and contain a remediation plan for the problem.

OpenTelemetry

The SDK generates a Trace, the REST command caller and every SQL command generated in the code. The technical implementation is a Span (part of a Trace) for the REST command and more Spans for each SQL command, all using the same Trace ID, to allow the backend to show all the spans in the same context. Generating Traces in the code is now a simple task using OpenTelemetry. OpenTelemetry is an open source, vendor agnostic, collection of tools, APIs, and SDKs. It is used to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) to help you analyze your software’s performance and behavior. OpenTelemetry provides SDKs for all major Frameworks and ORMs.
Another interesting feature in OpenTelemetry is SQLCommenter. SQLCommenter is a suite of middleware / plugins that enable your ORMs to augment SQL statements before execution, with comments containing information about the code that caused its execution. This helps in easily correlating slow performance with source code and giving insights into backend database performance. In short, it provides some observability into the state of your client-side applications and their impact on the database’s server-side.
SELECT
booking.title AS booking_title
FROM
booking
/*traceparent='00-59888198e0d98e0d9c1e72d4def4387019030-5fd1362f8aa2affe-1'*/