-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to record multi-operation/table/dbs operations on DB metrics #805
Comments
I wonder if we are over-engineering here. Taking SQL statements as an example, they can be parsed into an AST which has a top-level statement, which tells you whether you I'm not sure about |
Another thought I have is that what we actually want is to capture duration per query template. Operation/collection/db names on the measurement is a proxy to identify a subset of queries. So we want to have a metric for a thing that has high-cardinality in general case (query template) which seems to be impossible. Ways to limit the cardinality explored above:
What if we give up on a general case support in default experience? Option 4:
Pros: explicit choice for users who don't expect high cardinality Option 5:
Pros:
Cons:
|
so the proposal (Options 3, 4, and 5 combined):
Assuming we could collect operation/collection/namespace by default, we could consider |
It seems the dynamodb (which btw don't live under the |
I agree. What's the rational is for considering
I agree with this proposal, but think that we should best effort populate |
@lmolkova is this resolved now that |
Reopening based on the community feedback (thanks a lot @pellared for bringing it up). Discussed and tentatively agreed on the following approach Non-query operations:
Query-based operations:
|
For a simple database queries (such as
SELECT * from foo where bar="baz"
), we'd like to capture the following attributes when possible (on spans):db.operation.name = SELECT
db.collection.name = foo
(akadb.sql.table
and other similar system-specific attributes)db.collection.namespace = mydb
(akadb.name
along withdb.instance.id
and similar)db.query.text = SELECT * from foo where bar=?
(akadb.statement
)db.query.parameter.bar=baz
(attribute names are being discussed and are not final).
This simple case is supported by current version of DB semantic conventions. It's also a common one in the NoSQL world if we exclude bulk operations (or non-homogeneous batch operations).
Attributes (except
db.query.*
ones) have reasonable cardinality and can be used on traces and metrics.More complicated queries involve multiple operations, tables, or even databases. E.g. in
SELECT * from foo JOIN bar ON baz
we have two operations (
SELECT
andJOIN
), two tables (foo
and ``bar`), and just one database.db.query.text
anddb.query.parameter.*
for such queries are still relevant and make sense on spans (still cardinality is a problem for metrics)DB WG is considering multiple options:
Option 1: always capture
db.operation.names
,db.collection.names
,db.collection.namespaces
as arraysPros: consistent understandable model
Cons:
db.query.text
Option 2: capture both
db.operation.name
anddb.operation.names
(same for collections and namespaces).The array attributes are only captured when more than one operation is performed.
In this case we can entertain different options for
db.operation.name
- it may contain the first operation, operations joined as string, or shouldn't be reported at all.Pros:
db.operation.name
contains joined listSELECT JOIN
)Cons:
db.query.text
Option 3: don't capture multiple operation names, collection names, namespaces
Pros: simple case is easy
Cons: nothing distinguishes different operations in the complex case
There could be other options including opting into collecting templatized query string on metrics, but none of those is perfect.
Still, we'd like to provide a default experience which could be improved with users providing query nick-names (see #521 for the context).
Additional context
{[\"SELECT\", \"JOIN\"]}
making them even harder to use. Space (or comma) delimited list would be nicer ([SELECT, JOIN]
)The text was updated successfully, but these errors were encountered: