Skip to content

Commit 3fa5b9a

Browse files
committed
Add documentation
1 parent dde3152 commit 3fa5b9a

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

plume-web-jersey-monitoring/README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ to provide some basic functionality for monitoring your application's metrics (C
6565
Exposed API :
6666
- `registerMetric`: Register metrics to monitor
6767
- `registerJvmMetrics`: Register the basic JVM metrics to monitor
68+
- `registerGrizzlyMetrics`: Register metrics for Grizzly HTTP threads pool, see [Jersey module](../plume-web-jersey) for usage documentation on `GrizzlyThreadPoolProbe`
69+
- `registerHikariMetrics`: Register metrics for HikariCP SQL connections pool
6870
- `build`: create a metrics provider that provides the status of the metrics that are monitored.
6971

7072

@@ -87,7 +89,13 @@ public class MonitoringWs {
8789
private final BasicAuthenticator<String> basicAuthenticator;
8890

8991
@Inject
90-
public MonitoringWs(ApplicationInfoProvider applicationInfoProvider, TransactionManager transactionManager) {
92+
public MonitoringWs(
93+
ApplicationInfoProvider applicationInfoProvider,
94+
TransactionManager transactionManager,
95+
GrizzlyThreadPoolProbe grizzlyThreadPoolProbe,
96+
HikariDataSource hikariDataSource,
97+
InternalApiAuthenticator apiAuthenticator
98+
) {
9199
this.applicationInfo = applicationInfoProvider.get();
92100
// Registering health checks
93101
this.healthStatusProvider = new HealthCheckBuilder()
@@ -97,14 +105,12 @@ public class MonitoringWs {
97105
// Registering metrics to monitor
98106
this.metricsStatusProvider = new MetricsCheckBuilder()
99107
.registerJvmMetrics()
108+
.registerGrizzlyMetrics(grizzlyThreadPoolProbe)
109+
.registerHikariMetrics(hikariDataSource)
100110
.build();
101111

102112
// Require authentication to access monitoring endpoints
103-
this.basicAuthenticator = BasicAuthenticator.fromSingleCredentials(
104-
"plume",
105-
"rocks",
106-
"Plume showcase"
107-
);
113+
this.basicAuthenticator = apiAuthenticator.get();
108114
}
109115

110116
@GET

plume-web-jersey/README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ One sample valid request: `curl -H 'Authorization: Bearer my-bearer-token' 'http
213213

214214
### Resource authorization based on annotation
215215
This feature is provided `AuthorizationSecurityFeature` and works with any authentication system.
216-
For example using bearer auth:
216+
For example, using bearer auth:
217217
- In the `JerseyConfigProvider` file, declare the feature with the annotation used for resource identification: `config.register(new BearerAuthenticator("my-bearer-token").toAuthorizationFeature(BearerRestricted.class));`
218218
- In the `JerseyConfigProvider` file, register if needed the annotation used in the `RequireExplicitAccessControlFeature`: `config.register(RequireExplicitAccessControlFeature.accessControlAnnotations(PublicApi.class, BearerRestricted.class));`
219219
- Use the annotation in a resource definition:
@@ -237,3 +237,14 @@ public class ExampleWs {
237237

238238
### Permissions based authorization
239239
TODO to details
240+
241+
Grizzly HTTP Thread pool monitoring
242+
-----------------------------------
243+
Grizzly worker threads pool can be monitored using `GrizzlyThreadPoolProbe`.
244+
245+
Usage:
246+
1. Declare an instance of `GrizzlyThreadPoolProbe`
247+
2. Use this instance in Grizzly configuration: `httpServer.getServerConfiguration().getMonitoringConfig().getThreadPoolConfig().addProbes(grizzlyThreadPoolProbe)`
248+
3. Access metrics in the `GrizzlyThreadPoolProbe` instance, e.g. `grizzlyThreadPoolProbe.getPoolUsageSize()`
249+
250+
This can be used in the `MonitoringWs` class defined in the [Jersey monitoring module](../plume-web-jersey-monitoring)

plume-web-jersey/src/main/java/com/coreoz/plume/jersey/grizzly/GrizzlyThreadPoolProbe.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
import jakarta.inject.Singleton;
99
import java.util.concurrent.atomic.AtomicInteger;
1010

11+
/**
12+
* A Grizzly thread pool probe to monitor Grizzly thread pool.<br>
13+
* <br>
14+
* Usage:<br>
15+
* - Usage with Grizzly: <code>httpServer.getServerConfiguration().getMonitoringConfig().getThreadPoolConfig().addProbes(grizzlyThreadPoolProbe);</code><br>
16+
* - Metrics can be fetched using: {@link #getPoolUsageSize()} and {@link #getPoolMaxSize()} and {@link #getPoolCurrentSize()} and {@link #getTasksWaitingSize()}
17+
*/
1118
@Singleton
1219
public class GrizzlyThreadPoolProbe implements ThreadPoolProbe {
1320
private static final Logger logger = LoggerFactory.getLogger(GrizzlyThreadPoolProbe.class);
@@ -20,18 +27,30 @@ public class GrizzlyThreadPoolProbe implements ThreadPoolProbe {
2027

2128
/* Stats accessors */
2229

30+
/**
31+
* The maximum number of worker threads in the HTTP threads pool
32+
*/
2333
public int getPoolMaxSize() {
2434
return poolMaxSize;
2535
}
2636

37+
/**
38+
* The current number of worker threads in the HTTP threads pool
39+
*/
2740
public int getPoolCurrentSize() {
2841
return poolCurrentSize;
2942
}
3043

44+
/**
45+
* The number of worker threads currently in use
46+
*/
3147
public int getPoolUsageSize() {
3248
return poolUsageSize.get();
3349
}
3450

51+
/**
52+
* The number of tasks that are waiting because all the worker threads are in use
53+
*/
3554
public int getTasksWaitingSize() {
3655
return tasksWaitingSize.get();
3756
}

0 commit comments

Comments
 (0)