[NEW] Expose resource pool statistics through crypto11.Context · Issue #119 · ThalesGroup/crypto11 · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
eriklupander
changed the title
[NEW] Expose resource pool statistics through crypto.Context
[NEW] Expose resource pool statistics through crypto11.Context
Mar 13, 2025
Uh oh!
There was an error while loading. Please reload this page.
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 itspool
field 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.Context
can 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.ResourcePool
I believe it should be rather straightforward to expose them throughcrypto11.Context
as well.Additional context
I don't think exposing the full
pool
is necessary.The text was updated successfully, but these errors were encountered: