theigl commented on issue #2543:
URL: https://github.com/apache/fory/issues/2543#issuecomment-3269465380
I'm not planning on working on this at the moment. What I'm currently doing
is reflecting into `ThreadPoolFory` and creating the following metrics:
```java
final ForyPooledObjectFactory objectFactory = (ForyPooledObjectFactory)
ReflectionUtil.readField(fory, "foryPooledObjectFactory");
Metrics.gauge("fory.cache.numIdle", Tags.of("name", name), objectFactory,
value -> {
final ClassLoaderForyPooled c = value.getPooledCache();
return ((BlockingQueue<?>) ReflectionUtil.readField(c,
"idleCacheQueue")).size();
});
Metrics.gauge("fory.cache.numActive", Tags.of("name", name), objectFactory,
value -> {
final ClassLoaderForyPooled c = value.getPooledCache();
return ((AtomicInteger) ReflectionUtil.readField(c,
"activeCacheNumber")).get();
});
Metrics.gauge("fory.cache.numAll", Tags.of("name", name), objectFactory,
value -> {
final ClassLoaderForyPooled c = value.getPooledCache();
return ((Map<?, ?>) ReflectionUtil.readField(c, "allFory")).size();
});
```
Since `numAll` is always the same as `numActive` it should be enough to
expose metrics for `numIdle` and `numActive`. Ideally, `ThreadPoolFory` would
expose a method like `getPoolStats()` that gives the user access to these
metrics.
@chaokunyang What do you think?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]