Skip to content

Add in Surreal DB client spans #1107 #2571

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

thompson-tomo
Copy link
Contributor

@thompson-tomo thompson-tomo commented Jul 29, 2025

Progresses #1107

Changes

This adds SurrealDB as a db system, so that it can be used in telemetry and defines client spans.

Usage Example

Note: if the PR is touching an area that is not listed in the existing areas, or the area does not have sufficient domain experts coverage, the PR might be tagged as experts needed and move slowly until experts are identified.

Merge requirement checklist

  • CONTRIBUTING.md guidelines followed.
  • Change log entry added, according to the guidelines in When to add a changelog entry.
    • If your PR does not need a change log, start the PR title with [chore]
  • Links to the prototypes or existing instrumentations (when adding or changing conventions)

@lmolkova
Copy link
Contributor

Is there an instrumentation that needs it? Please also provide links to prototype(s)

@thompson-tomo thompson-tomo force-pushed the feature/#1107_AddSurrealDB branch from db5fa6e to edff90b Compare August 4, 2025 04:22
@thompson-tomo
Copy link
Contributor Author

yes, there is and the health check example was already linked. Have added client library example as well.

| [`db.operation.name`](/docs/registry/attributes/db.md) | string | The name of the operation or command being executed. [9] | `EXECUTE`; `INSERT` | `Recommended` [10] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`db.query.summary`](/docs/registry/attributes/db.md) | string | Low cardinality summary of a database query. [11] | `SELECT wuser_table`; `INSERT shipping_details SELECT orders`; `get user by id` | `Recommended` [12] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`db.query.text`](/docs/registry/attributes/db.md) | string | The database query being executed. [13] | `SELECT * FROM wuser_table where username = ?`; `SET mykey ?` | `Recommended` [14] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
| [`db.stored_procedure.name`](/docs/registry/attributes/db.md) | string | The name of a stored procedure within the database. [15] | `GetCustomer` | `Recommended` [16] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: SurrealDB does not provide a notion of Stored procedure but a similar one named Functions, see https://surrealdb.com/docs/surrealql/statements/define/function. Should we keep the name using Functions, or should we rename that attribute?

Copy link
Contributor Author

@thompson-tomo thompson-tomo Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update the description of the attribute to indicate that these are referred to as functions in surrealdb.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes have been made.


**[1] `db.namespace`:** If a database system has multiple namespace components (e.g. schema name and database name), they SHOULD be concatenated
from the most general to the most specific namespace component,
using `|` as a separator between the components.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: given that SurrealDB has a notion of both namespace & database for each client, shouldn't we add a small section around this specific feature, associated with a proper example? (e.g. Namespace|Database?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


**[8] `db.operation.batch.size`:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`.

**[9] `db.operation.name`:** The operation name SHOULD NOT be extracted from `db.query.text`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: A good idea would be to list all possible operation names, given we already have that here: https://github.com/surrealdb/surrealdb/blob/3540101309327da9f2f9336a3d0486f4ae41f455/crates/core/src/rpc/method.rs#L3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I will do is update the description to indicate that the operation name should be set based on the api method being called.

@thompson-tomo thompson-tomo force-pushed the feature/#1107_AddSurrealDB branch 4 times, most recently from 836c630 to 086d88e Compare August 5, 2025 02:54
@thompson-tomo
Copy link
Contributor Author

@Odonno it would be appreciated if you could give this another review from the surrealdb perspective. 🙂

@thompson-tomo thompson-tomo force-pushed the feature/#1107_AddSurrealDB branch from 086d88e to 865b839 Compare August 5, 2025 02:57

**[6] `db.operation.batch.size`:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`.

**[7] `db.operation.name`:** The operation name is to reflect the api method being called ie upsert.
Copy link

@Odonno Odonno Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I would have expect a list item or table for each operation name, so that every client uses the same name/convention. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have looked at other db provider docs and none of them except for cosmosdb provide table/lists of operation names.

Copy link

@Odonno Odonno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gonna add @kearfy as a second reviewer

@thompson-tomo thompson-tomo changed the title Add in Surreal DB #1107 Add in Surreal DB client spans #1107 Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:db enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

3 participants