use of org.wildfly.extension.metrics.MetricRegistration in project wildfly by wildfly.
the class DeploymentMetricService method start.
@Override
public void start(StartContext startContext) {
final Runnable task = new Runnable() {
@Override
public void run() {
registration = new MetricRegistration(metricRegistry.get());
metricCollector.get().collectResourceMetrics(rootResource, managementResourceRegistration, // prepend the deployment address to the subsystem resource address
address -> deploymentAddress.append(address), exposeAnySubsystem, exposedSubsystems, prefix, registration);
startContext.complete();
}
};
try {
managementExecutor.get().execute(task);
} catch (RejectedExecutionException e) {
task.run();
} finally {
startContext.asynchronous();
}
}
use of org.wildfly.extension.metrics.MetricRegistration in project wildfly by wildfly.
the class MicroProfileMetricsSubsystemAdd method performBoottime.
@Override
protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
super.performBoottime(context, operation, model);
final List<String> exposedSubsystems = MicroProfileMetricsSubsystemDefinition.EXPOSED_SUBSYSTEMS.unwrap(context, model);
final boolean exposeAnySubsystem = exposedSubsystems.remove("*");
final String prefix = MicroProfileMetricsSubsystemDefinition.PREFIX.resolveModelAttribute(context, model).asStringOrNull();
final boolean securityEnabled = MicroProfileMetricsSubsystemDefinition.SECURITY_ENABLED.resolveModelAttribute(context, model).asBoolean();
context.addStep(new AbstractDeploymentChainStep() {
public void execute(DeploymentProcessorTarget processorTarget) {
processorTarget.addDeploymentProcessor(SUBSYSTEM_NAME, DEPENDENCIES, DEPENDENCIES_MICROPROFILE_METRICS, new DependencyProcessor());
processorTarget.addDeploymentProcessor(SUBSYSTEM_NAME, INSTALL, POST_MODULE_MICROPROFILE_METRICS, new DeploymentMetricProcessor(exposeAnySubsystem, exposedSubsystems, prefix));
}
}, RUNTIME);
MetricsHTTTPSecurityService.install(context, securityEnabled);
final MicroProfileVendorMetricRegistry vendorMetricRegistry = new MicroProfileVendorMetricRegistry();
MicroProfileMetricsContextService.install(context, vendorMetricRegistry);
// delay the registration of the metrics in the VERIFY stage so that all resources
// created during the RUNTIME phase will have been registered in the MRR.
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext operationContext, ModelNode modelNode) {
ServiceController<?> serviceController = context.getServiceRegistry(false).getService(WILDFLY_COLLECTOR);
MetricCollector metricCollector = MetricCollector.class.cast(serviceController.getValue());
ImmutableManagementResourceRegistration rootResourceRegistration = context.getRootResourceRegistration();
Resource rootResource = context.readResourceFromRoot(EMPTY_ADDRESS);
MetricRegistration registration = new MetricRegistration(vendorMetricRegistry);
metricCollector.collectResourceMetrics(rootResource, rootResourceRegistration, Function.identity(), exposeAnySubsystem, exposedSubsystems, prefix, registration);
JmxRegistrar jmxRegistrar = new JmxRegistrar();
try {
jmxRegistrar.init();
} catch (IOException e) {
throw LOGGER.failedInitializeJMXRegistrar(e);
}
}
}, VERIFY);
MicroProfileMetricsLogger.LOGGER.activatingSubsystem();
}
use of org.wildfly.extension.metrics.MetricRegistration in project wildfly by wildfly.
the class DeploymentMetricService method start.
@Override
public void start(StartContext startContext) {
final Runnable task = new Runnable() {
@Override
public void run() {
try {
registration = new MetricRegistration(new MicroProfileVendorMetricRegistry());
metricCollector.get().collectResourceMetrics(rootResource, managementResourceRegistration, // prepend the deployment address to the subsystem resource address
address -> deploymentAddress.append(address), exposeAnySubsystem, exposedSubsystems, prefix, registration);
} catch (Throwable t) {
t.printStackTrace();
throw t;
}
startContext.complete();
}
};
try {
managementExecutor.get().execute(task);
} catch (RejectedExecutionException e) {
task.run();
} finally {
startContext.asynchronous();
}
}
Aggregations