Skip to content

Provide connection pool metrics #1400

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
fabianfett opened this issue May 5, 2022 · 3 comments · Fixed by #1515
Closed

Provide connection pool metrics #1400

fabianfett opened this issue May 5, 2022 · 3 comments · Fixed by #1515
Labels
kind/enhancement Improvements to existing feature.

Comments

@fabianfett
Copy link
Collaborator

fabianfett commented May 5, 2022

As a developer using grpc-swift, I would love to instrument my outgoing grpc connections with swift-metrics. Since connections are mostly handled by grpc-swift, grpc-swift should expose those metrics.

Metrics I would like to export:

  1. How many open connections in a given pool
  2. How many streams on a given connection
  3. Connect failures and types for a pool
  4. Connect latency for a pool

Describe the solution you'd like

grpc-swift should accept a MetricsDelegate on grpc connection pool creation. If the pool state changes the delegate should be informed. The protocol could look something like this. First raw draft.

protocol GRPCChannelPoolMetricsDelegate {
  func connectionCreated(connectionID: Int, latency: Int)

  func connectionUtilizationChanged(connectionID: Int, available: Int, used: Int)

  func connectionClosed(connectionID: Int, error: Error?)

  func connectFailure(error: Error)
}

Describe alternatives you've considered

GRPC could export metrics directly to swift-metrics. However this would add a new dependency, that some adopters might not want. Further adopters may want to report the metrics differently and we want to give them options. Offering the connection metrics through a protocol should give adopters the most flexibility.

@fabianfett fabianfett added the kind/enhancement Improvements to existing feature. label May 5, 2022
@PeterAdams-A
Copy link
Contributor

Wondering if there are any other purposes these delegates could be used for - nothing springs immediately to mind but I could imagine there might be something else which users try and trigger off connection creation.

I guess this is more flexible than direct call to metrics but a bit harder for users to use.

@Lukasa
Copy link
Collaborator

Lukasa commented May 5, 2022

I think we could probably offer a default solution in a separate target. That doesn't prevent us having the dependency but users who don't want it can at least avoid linking it in.

@glbrntt
Copy link
Collaborator

glbrntt commented May 5, 2022

I guess this is more flexible than direct call to metrics but a bit harder for users to use.

Flexibility is a good thing here, no doubt people will want to label metrics in their own way.

I think we could probably offer a default solution in a separate target. That doesn't prevent us having the dependency but users who don't want it can at least avoid linking it in.

A "GRPCExtras" module is something I've thought about for a while. There are other general purpose things like interceptors which could be included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements to existing feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants