Is your feature request related to a problem? Please describe.
I would like to produce metrics for the underlying resource pool. However, crypto11.Context does not export its pool field or its StatsJSON() or related methods.
Describe the solution you'd like
A naive approach is to diectly access the pool stats through StatsJSON(), i.e. adding:
func (c *Context) PoolStatsJSON() string {
if c.pool != nil {
return c.pool.StatsJSON()
}
return "" // or introduce error into the method signature.
}
Callees can then parse the returned JSON.
A more concise approach could be to construct a:
type PoolStats struct {
Capacity int64
Available int64
// and so on for the metrics exposed by pool.ResourcePool through its accessor methods.
}
In the crypto11 package, a new ResourcePoolStats() method on crypto11.Context can be added:
func (c *Context) ResourcePoolStats() PoolStats {
if c.pool == nil {
return PoolStats{} // return empty
}
return PoolStats {
Capacity: c.pool.Capacity(),
Available: c.pool.Available(),
// And so on...
}
}
Note that I haven't explored any potential downsides to exposing pool statistics through crypto11.Context, for example if reading pool stats may cause (unnecessary) communication to happen with the underlying device.
Describe alternatives you've considered
No, not really. Since the stats are exposed on the pool.ResourcePool I believe it should be rather straightforward to expose them through crypto11.Context as well.
Additional context
I don't think exposing the full pool is necessary.
Is your feature request related to a problem? Please describe.
I would like to produce metrics for the underlying resource pool. However,
crypto11.Contextdoes not export itspoolfield or itsStatsJSON()or related methods.Describe the solution you'd like
A naive approach is to diectly access the pool stats through
StatsJSON(), i.e. adding:Callees can then parse the returned JSON.
A more concise approach could be to construct a:
In the crypto11 package, a new
ResourcePoolStats()method oncrypto11.Contextcan be added:Note that I haven't explored any potential downsides to exposing pool statistics through
crypto11.Context, for example if reading pool stats may cause (unnecessary) communication to happen with the underlying device.Describe alternatives you've considered
No, not really. Since the stats are exposed on the
pool.ResourcePoolI believe it should be rather straightforward to expose them throughcrypto11.Contextas well.Additional context
I don't think exposing the full
poolis necessary.