8000 Extract metrics from a connection pool · Issue #491 · mysql-net/MySqlConnector · GitHub
[go: up one dir, main page]

Skip to content

Extract metrics from a connection pool #491

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

Closed
felipe-rochac opened this issue Apr 29, 2018 · 14 comments · Fixed by #1329
Closed

Extract metrics from a connection pool #491

felipe-rochac opened this issue Apr 29, 2018 · 14 comments · Fixed by #1329
Milestone

Comments

@felipe-rochac
Copy link
felipe-rochac commented Apr 29, 2018

Is there a way to extract some metrics from the pool like idle connections, connections in use, available connections... ?

@bgrainger
Copy link
Member

There is not currently any such method.

Do you know of another ADO.NET provider that exposes similar metrics? (Just curious if there's an existing example of exposing such an API.)

@felipe-rochac
Copy link
Author

We can gather it from the MySql Oracle driver through the reflection, however, I'm wondering if we can do it in this driver in a more elegant way

< 8000 svg aria-label="Loading..." style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" role="img" data-view-component="true" class="anim-rotate">

@daniel-munch-cko
Copy link

Interesting question indeed! Would a pull-request be accepted which introduces some metrics abstraction on the lines of the logging abstraction? I'm thinking about aIMySqlConnectorMetricsProvider kind of thing.

@bgrainger
Copy link
Member

I am looking for guidance (from the ADO.NET or ASP.NET Core team) about high-performance instrumentation with EventSource or DiagnosticSource (#471). One can also imagine exposing Prometheus-style metrics or integrating with OpenTracing, and I'd like to do it in a way that's standardised with other ADO.NET providers, not just implemented in an ad-hoc way.

It would also be extremely important to implement in a zero-overhead way when not activated, e.g., to not impact TFB performance benchmarks.

@daniel-munch-cko
Copy link

I see, thanks! I've stumbled over #471 after I wrote this comment and figured this would be the way to go anyway.

@bgrainger
Copy link
Member

#1137 provides a link to SQL Server Provider Statistics, which is an in-memory (?) Dictionary enabled via a connection-string setting. This could provide a template for a low-overhead approach, but also seems like it might be an historical method that would now be implemented instead with OpenTelemetry.

@spacentropy
Copy link

We can now use System.Diagnostics.Metrics for integration-agnostic metrics:
https://docs.microsoft.com/en-us/dotnet/core/diagnostics/metrics-instrumentation

@tarasevichvlad
Copy link

Hi, @bgrainger. Do you have any update for this topic?

@bgrainger
Copy link
Member

Based on Metric APIs comparison, System.Diagnostics.Metrics (.NET 6.0 and later) is the best approach to use for tracking metrics.

This namespace doesn't appear to be used by Npsql or Microsoft.Data.SqlClient, so there's no "prior art" to adapt for MySQL.

@tarasevichvlad
Copy link

@bgrainger https://www.npgsql.org/doc/diagnostics/metrics.html It is possible to create metrics view as maked in pgsql?

8000

@bgrainger
Copy link
Member

Using System.Diagnostics.Metrics in MySqlConnector would make it possible for dotnet-counters monitor MySqlConnector -p <PID> to produce similar output to that table, yes.

@tarasevichvlad
Copy link

@bgrainger
If I understand correctly, this is currently not implemented. I have searched the repository and have not found any evidence of the System.Diagnostics.Metrics namespace being used. Right?

@bgrainger
Copy link
Member

Correct; this issue is still open because the change has not been implemented.

@bgrainger
Copy link
Member

I opened a PR with a proposal for a specification for using System.Diagnostics.Metrics to implement the OpenTelemetry Semantic Conventions for Database Metrics: #1328.

This will provide a way to "extract some metrics from the pool like idle connections, connections in use, available connections" using the latest supported .NET APIs.

bgrainger added a commit that referenced this issue Jun 14, 2023
bgrainger added a commit that referenced this issue Jun 14, 2023
bgrainger added a commit that referenced this issue Sep 17, 2023
bgrainger added a commit that referenced this issue Oct 28, 2023
@bgrainger bgrainger added this to the 2.3 milestone Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

5 participants
0