Skip to content

Commit 7d31819

Browse files
feat(develop): Add SDK spec for database transactions (#15194)
Specify requirements for adding instrumentation of database transactions. These include individual spans for statements and the priorities for adding instrumentation for different transaction-level statements to support features in Sentry.
1 parent 5d9688a commit 7d31819

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: SQL Transactions
3+
---
4+
5+
<Alert>
6+
This document uses key words such as "MUST", "SHOULD", and "MAY" as defined in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt) to indicate requirement levels.
7+
</Alert>
8+
9+
The SDK SHOULD auto-instrument all database transactions for SQL databases like PostgreSQL and MySQL.
10+
Each BEGIN, COMMIT, and ROLLBACK, or equivalent statement in the database system MUST result in an individual span.
11+
Spans for other transaction-level statements, such as SAVEPOINT, are RECOMMENDED and, when implemented, MUST also correspond to an individual SQL statement.
12+
Transaction statements SHOULD produce spans whether they are issued through a database driver or through an ORM.
13+
14+
### Span Data
15+
16+
Refer to <Link to="https://getsentry.github.io/sentry-conventions/generated/attributes/db.html">Database Span Data Conventions</Link> for a full list of attributes that database spans should have.
17+
The SDK SHOULD set the
18+
19+
- db.system.name
20+
- db.operation.name
21+
22+
attributes for transaction statement spans.
23+
Equivalent deprecated attributes MAY be used for backward compatibility, but they SHOULD be marked for deprecation.
24+
25+
The operation names for BEGIN, COMMIT and ROLLBACK statements MUST be "BEGIN", "COMMIT", and "ROLLBACK", respectively.
26+
For synonyms, like BEGIN TRANSACTION for BEGIN, the operation name MAY reflect the synonym. In this example, "BEGIN TRANSACTION" MAY be used.
27+
Some statements, like SAVEPOINT, ROLLBACK TO SAVEPOINT and RELEASE SAVEPOINT, take arguments.
28+
The operation name for statements that accept arguments MUST be the statement without the arguments. For the examples above, the operation names are "SAVEPOINT", "ROLLBACK TO SAVEPOINT", and "RELEASE SAVEPOINT", respectively.
29+
30+
For other transaction-level statements like MySQL's START TRANSACTION, the SDK SHOULD represent the literal statement as closely as possible, omitting control-flow characters like semicolons.
31+
SQLite's transaction statements can include modifiers. For instance, BEGIN DEFERRED is a modified BEGIN statement. In this case, the operation name MAY be either "BEGIN" or "BEGIN DEFERRED".
32+
The same rule applies to analogous modified statements.

0 commit comments

Comments
 (0)