Skip to content
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

Add more granularity for OpenTelemetry metrics (per-database metrics) #33634

Open
cincuranet opened this issue Apr 29, 2024 · 1 comment
Open

Comments

@cincuranet
Copy link
Contributor

With/After #25880 and #33633, it would be nice to have option for more granularity - i.e. metrics per "database" (connection string, some user provided name, DbDataSource, etc.).

@roji
Copy link
Member

roji commented May 22, 2024

From our design discussion on this... What's needed is a metric "dimension" for which database is being accessed, so that accesses to e.g. the "customers" and "products" databases can be tracked separately (this is well-supported by the new metrics API).

The main problem here is what value that dimension would have... The only natural and universal identifier currently available is the connection string, which isn't a great value to use, but is probably OK. We should then expose some sort of hook for the user to configure this info in the context options config (e.g. UseSqlServer(..., o => o.UseMetricsIdentifier("Customers"))). We could also consider a provider hook so that the provider can take care of this; for example, NpgsqlDataSource has the concept of a "name" (for exactly the same purpose, metrics reporting at the ADO.NET level); a hook would allow EFCore.PG to extract this and use it for the EF metrics as well.

This will likely be incompatible with multi-tenant and related scenarios where the same service provider is being used with different connection string databases (since the metrics identifier would presumably be a singleton). This is yet another example of the difficulties created by OnConfiguring and varying configuration inside the same provider; users would be able to simply have different factories/service providers for their different databases to properly deal with this.

In any case, putting this in the backlog for now.

@roji roji added this to the Backlog milestone May 22, 2024
@roji roji changed the title Add more granularity for OpenTelemetry metrics Add more granularity for OpenTelemetry metrics (per-database metrics) May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants