2525import com .uid2 .shared .secure .nitro .InMemoryAWSCertificateStore ;
2626import com .uid2 .shared .store .CloudPath ;
2727import com .uid2 .shared .store .scope .GlobalScope ;
28+ import com .uid2 .shared .util .HTTPPathMetricFilter ;
2829import com .uid2 .shared .vertx .RotatingStoreVerticle ;
2930import com .uid2 .shared .vertx .VertxUtils ;
3031import io .micrometer .core .instrument .Gauge ;
3132import io .micrometer .core .instrument .Metrics ;
3233import io .micrometer .core .instrument .config .MeterFilter ;
3334import io .micrometer .prometheus .PrometheusMeterRegistry ;
3435import io .micrometer .prometheus .PrometheusRenameFilter ;
36+ import io .vertx .core .DeploymentOptions ;
3537import io .vertx .core .Vertx ;
3638import io .vertx .core .VertxOptions ;
3739import io .vertx .core .http .HttpServerOptions ;
4951
5052public class Main {
5153
54+ private static final int vertxServiceInstances = 1 ;
55+
5256 public static void main (String [] args ) {
5357 final String vertxConfigPath = System .getProperty (Const .Config .VERTX_CONFIG_PATH_PROP );
5458 if (vertxConfigPath != null ) {
@@ -157,17 +161,19 @@ public static void main(String[] args) {
157161 );
158162
159163 JwtService jwtService = new JwtService (config );
160-
161164 coreVerticle = new CoreVerticle (cloudStorage , operatorKeyProvider , attestationService , attestationTokenService , enclaveIdProvider , operatorJWTTokenProvider , jwtService , cloudEncryptionKeyProvider );
162165 } catch (Exception e ) {
163166 System .out .println ("failed to initialize core verticle: " + e .getMessage ());
164167 System .exit (-1 );
165168 }
166169
170+ createVertxInstancesMetric ();
171+ createVertxEventLoopsMetric ();
172+
167173 vertx .deployVerticle (enclaveRotatingVerticle );
168174 vertx .deployVerticle (operatorRotatingVerticle );
169175 vertx .deployVerticle (cloudEncryptionKeyRotatingVerticle );
170- vertx .deployVerticle (coreVerticle );
176+ vertx .deployVerticle (coreVerticle , new DeploymentOptions (). setInstances ( vertxServiceInstances ) );
171177 });
172178 }
173179
@@ -182,14 +188,8 @@ private static void setupMetrics(MicrometerMetricsOptions metricOptions) {
182188 prometheusRegistry .config ()
183189 // providing common renaming for prometheus metric, e.g. "hello.world" to "hello_world"
184190 .meterFilter (new PrometheusRenameFilter ())
185- .meterFilter (MeterFilter .replaceTagValues (Label .HTTP_PATH .toString (), actualPath -> {
186- try {
187- String normalized = HttpUtils .normalizePath (actualPath ).split ("\\ ?" )[0 ];
188- return Endpoints .pathSet ().contains (normalized ) ? normalized : "/unknown" ;
189- } catch (IllegalArgumentException e ) {
190- return actualPath ;
191- }
192- }))
191+ .meterFilter (MeterFilter .replaceTagValues (Label .HTTP_PATH .toString (),
192+ actualPath -> HTTPPathMetricFilter .filterPath (actualPath , Endpoints .pathSet ())))
193193 // Don't record metrics for 404s.
194194 .meterFilter (MeterFilter .deny (id ->
195195 id .getName ().startsWith (MetricsDomain .HTTP_SERVER .getPrefix ()) &&
@@ -210,6 +210,19 @@ private static void setupMetrics(MicrometerMetricsOptions metricOptions) {
210210 .register (Metrics .globalRegistry );
211211 }
212212
213+ private static void createVertxInstancesMetric () {
214+ Gauge .builder ("uid2.vertx_service_instances" , () -> vertxServiceInstances )
215+ .description ("gauge for number of vertx service instances requested" )
216+ .register (Metrics .globalRegistry );
217+ }
218+
219+ private static void createVertxEventLoopsMetric () {
220+ Gauge .builder ("uid2.vertx_event_loop_threads" , () -> VertxOptions .DEFAULT_EVENT_LOOP_POOL_SIZE )
221+ .description ("gauge for number of vertx event loop threads" )
222+ .register (Metrics .globalRegistry );
223+ }
224+
225+
213226 /*
214227 private static CommandLine parseArgs(String[] args) {
215228 final CLI cli = CLI.create("uid2-core")
0 commit comments